// since javascript only has 53bit number,
// we need to operate it as big number by using string
function multiply(x, strNum)
{
	var carry = 0;
	var num = strNum.split('').map(Number).reverse();
	var result = [];

	for(var i = 0; i < num.length; i++)
	{
		var prod = x * num[i] + carry;
		result.push(prod % 10);
		carry = Math.floor(prod / 10);
	}

	// the possible biggest carry is
	// 99999 * 9 = 899991
	while(carry)
	{
		result.push(carry % 10);
		carry = Math.floor(carry / 10);
	}

	return result.reverse().join('');
}

function pow(x, pow)
{
	var result = '1';
	for(var i = 0; i < pow; i++)
		result = multiply(x, result);

	return result;
}

var input = readline();
var digits = input[0] + input[2] + input[4] + input[3] + input[1];

var result = pow(digits, 5);
print(result.substr(result.length - 5));


function multiply(x, strNum)
{
	var carry = 0;
	var num = strNum.split('').map(Number).reverse();
	var result = [];

	for(var i = 0; i < num.length; i++)
	{
		var prod = x * num[i] + carry;
		result.push(prod % 10);
		carry = Math.floor(prod / 10);
	}

	while(carry)
	{
		result.push(carry % 10);
		carry = Math.floor(carry / 10);
	}

	return result.reverse().join('');
}

function pow(x, pow)
{
	var result = '1';
	for(var i = 0; i < pow; i++)
		result = multiply(x, result);

	return result;
}

var input = readline();
var digits = input[0] + input[2] + input[4] + input[3] + input[1];

var result = pow(digits, 5);
print(result.substr(result.length - 5));


'use strict'

const B = '127'
const S = '32767'
const I = '2147483647'
const L = '9223372036854775807'

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  ipt = ipt.trim()
  console.log(
    fit(ipt, B) && 'byte'
    || fit (ipt, S) && 'short'
    || fit (ipt, I) && 'int'
    || fit (ipt, L) && 'long'
    || 'BigInteger'
  )

  function fit (a, b) {
    if (a.length < b.length) return true
    if (a.length > b.length) return false
    for (let i = 0; i < a.length; i += 5) {
      const ap = +a.slice(i, i + 5)
      const bp = +b.slice(i, i + 5)
      if (ap < bp) return true
      if (ap > bp) return false
    }
    return true
  }
})


var s = readline().trim()
var t = [];
var d = {}
var abc = 'abcdefghijklmnopqrstuvwxyz';
for (var i in s.split('')) {
    var c = s[i];
    if (!d[c]) {
        t.push(c);
        d[c] = true;
    }
}
//t.sort()
//print(t.join(''))
var len = t.length;
var abc2 = abc.slice(0, len)
print (t.join('') === abc2 ? 'YES' : 'NO')


function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn, init) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b, fn);
  if (b < a) return [];
  let arr = Array(b - a + 1).fill(0);
  if (init) init(arr);
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = a / b | 0, a -= t * b, u -= t * v, t = a, a = b, b = t, t = u, u = v);
  return (u + MOD) % MOD;
}
// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let [n, a1, a2, a3, b1, b2, b3] = $(7)
  let Max = min(a1, b2) + min(a2, b3) + min(a3, b1)

  let c = [], d = [], A1, A2, A3, B1, B2, B3, m, Min = 1e10;
  let gen = i => {
    if (i == 6) {
      [A1, A2, A3, B1, B2, B3] = [a1, a2, a3, b1, b2, b3]
      For(6, j => {
        if (c[j] == 0) (m = min(A1, B1), A1 -= m, B1 -= m);
        if (c[j] == 1) (m = min(A1, B3), A1 -= m, B3 -= m);
        if (c[j] == 2) (m = min(A2, B2), A2 -= m, B2 -= m);
        if (c[j] == 3) (m = min(A2, B1), A2 -= m, B1 -= m);
        if (c[j] == 4) (m = min(A3, B3), A3 -= m, B3 -= m);
        if (c[j] == 5) (m = min(A3, B2), A3 -= m, B2 -= m);
      })
      Min = min(Min, A1 + A2 + A3)
      return;
    }
    For(6, j => {
      if (d[j]) return;
      d[j] = 1; c[i] = j; gen(i + 1); d[j] = 0;
    });
  }
  gen(0)

  log(Min, Max)
}


var root = function(dsu, v) {
    if (dsu[v] === v) {
        return v;
    } else {
        dsu[v] = root(dsu, dsu[v]);
        return dsu[v];
    }
}

var main = function () {
    var n = parseInt(readline());
    var p = [], prev = [], next = [];
    readline().split(/\s+/).forEach(function (t, i) {
        p.push(parseFloat(t));
    });

    for (var i = -1; i <= n; ++i) {
        prev[i] = next[i] = i;
    }

    var s = [];
    p.forEach(function(e, i) {
        s.push({pos: i, val: e});
    });

    s.sort(function(a, b) {
        return (a.val !== b.val) ? (a.val - b.val) : (a.pos - b.pos);
    });

    var ans = 0;
    var dec = 0;
    var left = n - 2;
    s.forEach(function (e, i) {
        if (left <= 0) {
            return;
        }

        var i = e.pos;
        next[i] = i + 1;
        prev[i] = i - 1;
        var lf = root(prev, i);
        var rg = root(next, i);

        var cur = e.val - dec;
        dec = e.val;
        ans += left * cur;
        left--;

        if (0 <= lf && lf <= rg && rg < n) {
            ans += Math.min(p[lf] - dec, p[rg] - dec);
        }

        return left > 0;
    });

    print(ans);
};

main();


let _inputLines;
let _lineNumber = 0;
let inputReader = _inputReader ();

function _main() {

	_inputLines = _inputData.trim().split('\n').map((string) => {
		return string.trim();
	});;
	let str = inputReader.readLine();
	let n = inputReader.readNumber();
	let arr = [];

	let bool = false;
	for (let i = 0; i < n; i++) {
		arr[i] = inputReader.readLine();
		if (arr[i] === str) {
			bool = true;
		}
	}

	if (n === 1) {
		let str1 = "" + arr[0] + arr[0];
		if (str[0] == str1[1] && str[1] == str1[2]) {
			bool = true;
		}
		//console.log(str1,str1[1],str[0]);
	} else if (!bool) {
		for (let i = 0; i < n; i++) {
			for (let j = 0; j < n; j++) {
				let res = arr[i] + arr[j];
				if (str[0] == res[1] && str[1] == res[2]) {
					bool = true;
					break;
				}
			}
			if (bool) break;
		}
	}
	if (bool) {
		console.log("YES");
	} else {
		console.log("NO");
	}

}

var _inputData = '';
function cacheInput(data) {
	_inputData += data;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', cacheInput).on('end', _main);

function _inputReader () {
	function readNumber(){
		return Number(_inputLines[_lineNumber++]);
	}

	function readLine(){
		return _inputLines[_lineNumber++];
	}

	return {
		readNumber,
		readLine,
	}
}


T=readline().split(' ')
var n=Number(T[0]),pos=Number(T[1]),l=Number(T[2]),r=Number(T[3]);

function q1(l,r,pos) {
  var A=0;
  if (l>1) {
   A += Math.abs(l-pos) + 1
   pos = l
  }
  if (r<n) {
   A += Math.abs(pos-r) + 1
  }
  return A;
}

function q2(l,r,pos) {
  var A=0;
  if (r<n) {
   A += Math.abs(pos-r) + 1
   pos = r;
  }
  if (l>1) {
   A += Math.abs(l-pos) + 1
  }
  return A;
}

if (l==1 && r==n) {
 print(0)
} else {
 print(Math.min(q1(l,r,pos),q2(l,r,pos)))
}


var n = +readline();
var t = readline().split(' ').map(function(v){
	return +v;
}).sort(function(a,b){
	return a===b?0:a>b?1:-1;
});
var T = +readline();
var ret = 0;
for(var i=0; i<n; i++){
	var a = 1;
	for(var j=i+1; j<n; j++){
		if( t[j]-t[i]<=T ){
			a++;
		}
	}
	ret = Math.max(ret, a);
}
print(ret);


function isPrime(n) {
	if (n == 1)
		return false;
	if (n <= 3)
		return true;
	if (n % 2 == 0)
		return false;
	for (var i = 3; i*i <= n; i += 2)
		if (n % i == 0) return false;
	return true;
}

function main() {
	var n = +readline();
	// 3 <= n <= 10**9
	var a = [];
	if (n <= 7) {
		if (n == 3) a = [3];
		if (n == 4) a = [2,2];
		if (n == 5) a = [2,3];
		if (n == 6) a = [3,3];
		if (n == 7) a = [2,5];
	} else {
		n -= 3;
		a = [3];
		for (var i = 2; i < n; i++)
			if (isPrime(i) && isPrime(n-i))
			{
				a.push(i);
				a.push(n-i);
				break;
			}
	}
	write(a.length + "\n");
	for (var i = 0; i < a.length; i++)
		write(a[i] + " ");
}

main();


  var tmp = readline().split(' ').map(x => parseInt(x));
  var n = tmp[0];
  var x = tmp[1];
  var y = tmp[2];
  var finding = true;
  var res = -1;
  var sucs = Infinity;
  for(var i = 0; finding && i < 10000; i += 1) {
    var target = x + 50 * i;
    var found = false;
    var ii = ((target / 50) | 0) % 475;
    for(var j = 0; !found && j < 25; j += 1) {
      ii = (ii * 96 + 42) % 475;
      if(ii + 26 === n) {
        found = true;
        if(sucs > ((i + 1) / 2 | 0)) {
          res = i;
          sucs = (i + 1) / 2 | 0
        }
      }
    }
    if(finding && x - 50 * i >= y) {
      target = x - 50 * i;
      found = false;
      ii = ((target / 50) | 0) % 475;
      for(var j = 0; !found && j < 25; j += 1) {
        ii = (ii * 96 + 42) % 475;
        if(ii + 26 === n) {
          found = true;
          res = -i;
          sucs = 0;
        }
      }
    }
  }
  print(sucs);


function main(iPeb) {
    const getIdealRows = n => {
    	var best = 1;
    	for(var i = 1; i < n; i++) {
            best = i > best && n % i === 0 ? i : best;
    	}
    	return best;
    }

    const iterateRows = n => {
        var x = n;
    	while(n > 1) {
            n = getIdealRows(n);
    		x += n;
    	}
    	return x;
    }

    return (iPeb < 2 || iPeb > 1000000000) ? '' : iterateRows(parseInt(iPeb));
}

const input1 = readline();
const output = main(input1);

print(output);


function main() {
  var n = +next(), a = [+next(), +next()];
  var t = 0;
  if (a[0] > a[1]) t = 1;
  var ans = [Infinity, Infinity];
  for (var i = 1; i * i <= 6 * n; ++i) {
    var f = Math.ceil(6 * n / i);
    // console.error(i, f);
    var u = Math.max(a[t], i), v = Math.max(a[t ^ 1], f);
    if (u * v < 6 * n) continue;
    if (ans[0] * ans[1] > u * v) {
      ans[t] = u;
      ans[t ^ 1] = v;
    }
  }
  print(ans[0] * ans[1]);
  print(ans[0] + " " + ans[1]);
}

var line = null, linepos = 0;
function next() {
  if (!line || linepos === line.length) {
    line = readline().split(' ');
    linepos = 0;
  }
  return line[linepos++];
}

if (typeof readline == 'undefined') {
  process.stdin.resume();
  process.stdin.setEncoding('ascii');

  var input_stdin = "";
  process.stdin.on('data', function (data) { input_stdin += data; });
  process.stdin.on('end', function () {
    // input_stdin = input_stdin.split(/\s/);
    input_stdin = input_stdin.split('\n');
    var curline = 0;
    readline = () => input_stdin[curline++];
    if (typeof print === 'undefined') print = console.log;
    main();
  });
} else main();


const lines = [];

const helpers = {
  arrStringtoInt: (arr, splitter) => {
    return arr.split(splitter).map(num => parseInt(num));
  },
  insterAt: (arr, idx, item) => {
    const newArray = [...arr];
    newArray.splice(idx, 0, item);
    return newArray;
  },
  sortAscending: (arr) => {
    return arr.sort((a, b) => a - b);
  },
  sortDescending(arr) {
    return arr.sort((a, b) => b - a);
  }
}

const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

// multi line input
readline.on('line', line => {
  lines.push(line);
});

readline.on('close', line => {
  let eggs = parseInt(lines[0]);
  let colorsSequence = ['R', 'O', 'Y', 'G', 'B', 'I', 'V'];
  let extraColors = eggs % 7;
  let cycles = Math.floor(eggs / 7);

  // Repeate complete cycles
  if (cycles > 1) for (let jj = 1; jj < cycles; colorsSequence.push(...['R', 'O', 'Y', 'G', 'B', 'I', 'V']), jj++);

  // Add extra colors in the right position
  for (let ii = 0; ii < extraColors; ii++) colorsSequence = helpers.insterAt(colorsSequence, ii + 4, colorsSequence[ii]);

  console.log(colorsSequence.join(''))

});


var line = readline().split(' ');
	var n = Number(line[0]);
	var d = Number(line[1]);
	var numbers = readline().split(' ');
	numbers.sort(function(a, b) {
		return a-b;
	});

	var i=0;
	var j=n-1;
	var count=0;
	var ready=false;

	while(i<j) {
		if (numbers[j] - numbers[i] <= d) {
			break;
		}
		if (numbers[j] - numbers[i+1] <= d
		    || numbers[j-1] - numbers[i] <= d) {
			count++;
			break;
		}
		count+=2;
		i++;
		j--;
	}

	print(count);


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var text = trim(readline());
	var middle = text.substring(1, text.length-1);
	middle = middle.replace(/dot/g, ".");
	var address = text.charAt(0) +
			middle.replace(/at/, "@") +
			text.charAt(text.length-1);
	print(address);
}

main();


let globalStdin = '';
const {EOL} = require('os');
process.stdin.on('data', i => globalStdin += i);

process.stdin.on('end', async () => {
  const lines = globalStdin.split(EOL);
  let [n, k] = lines[0].split(' ').map((v) => parseInt(v));
  let dp = Array.from({length: n+1}, () => new Array(n+1).fill(0));
  dp[0][0] = 1;
  let prev = {};
  for (let i = 1; i <= n; i++) {
    dp[i][0] = 1;
    let c = lines[1][i-1];
    for (let j = 1; j <= n; j++) {
      dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
      if (prev[c]) dp[i][j] -= dp[prev[c] - 1][j - 1];
    }
    prev[c] = i;
  }
  let sum = 0;
  for (let i = n; i >= 0; i--) {
    if (dp[n][i] > k) {
      sum += (n - i) * k;
      k = 0;
      break;
    }
    k -= dp[n][i];
    sum += (n - i) * dp[n][i];
  }
  console.log(k ? -1 : sum);
});


function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var integers = tokenizeIntegers(readline());
	var rowNum = integers[0], colNum = integers[1], jumpSize = integers[2];

	function solve(distance, jump) {
		var count = Math.floor(distance/jump);
		if (distance%jump != 0) {
			count += 1;
		}
		var rightmost = (count-1)*jump;
		var moves = distance - rightmost;
		return count*moves;
	}

	print(solve(rowNum, jumpSize) * solve(colNum, jumpSize));
}

main();


var x = readline().split(" ").map( function (x) { return parseInt(x); } );
var n = 0, ans = -1;

for (var i = 0, str = readline(); i < str.length; i++)
    if (str.charAt(i) == '1') n++;

for (var i = 1; i <= n; i++) {
    var nm = parseInt(x[0] / i);
    var cost = (i - x[0] % i) * (x[1] + x[2] * Math.pow(nm - 1, 2)) +
        (x[0] % i) * (x[1] + x[2] * nm * nm);
    if (ans == -1 || cost < ans)
        ans = cost;
}

print(ans);