var arr = readline().split(' ');
var arrSpeedBuckets = readline().split(' ');

var amountBuckets = arr[0];
var lengthGarden = arr[1];

var result = Infinity;
for (let i = 0; i < arrSpeedBuckets.length; i++) {
    var hours = lengthGarden / arrSpeedBuckets[i];
    if (/*(hours ^ 0) === hours &&*/ 0 < hours && hours < result) {
        result = hours;
    }
}
print(result);


let initial_info = readline().split(" ")
console.log(initial_info)


var y = readline();
var sB = readline();

var a = y.split(' ');
var aB = a[0];
var lG = a[1];
var x = 0;
var x = cH(lG, sB);
print(x);

function cH(lG,sB) {
    var aSB = sB.split(' ');
    var res = 0;

    for (let i = 0 ; i<aSB.length; i++) {
        var hours = lG/aSB[i];
        if ((hours^0) === hours && 0 < hours && hours < result ) {
          res = hours;
        }
    }
    return res;
}


var data = readline();
var speedBuckets  =  readline();

var a = data.split(' ');
var amountBuckets = a[0];
var lengthGarden = a[1];

var x = calculateHours(lengthGarden, speedBuckets);
print(x);

function calculateHours(lengthGarden,speedBuckets) {
    var arrSpeedBuckets = speedBuckets.split(' ');
    var result = Infinity;

    for (let i = 0 ; i<arrSpeedBuckets.length; i++) {
        var hours = lengthGarden/arrSpeedBuckets[i];
        if ((hours^0) === hours && 0 < hours && hours < result ) {
          result = hours;
        }
    }
    return result;
}


var y = readline();
var sB = readline();

var a = y.split(' ');
var aB = a[0];
var lG = a[1];

var x = calcH(l, sB);
console.log(x);

function cH(lG,sB) {
    var aSB = sB.split(' ');
    var res = 0;

    for (let i = 0 ; i<aSB.length; i++) {
        var hours = lG/aSB[i];
        if ((hours^0) === hours && 0 < hours && hours < result ) {
          res = hours;
        }
    }
    return res;
}


var temp = readline().split(" ").map(Number)[0];
var i=0;
boolean check = false;
while(temp[0]*i<=temp[2]){
    if((temp[2]-temp[0]*i)%temp[1]==0){
        check=true;
    }
    i++;
}
print(check ==true?"Yes":"No")


function f(u, v) {
    var t = Math.trunc(u * n / (u + v));
    u /= t;
    v /= n - t;
    return Math.trunc(u < v ? u : v);
}

var [n, a, b] = readline().split(' ').map(Number);
var x = f(a, b), y = f(b, a);
print(x > y ? x : y);


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <script src="ex3.js"></script>
</body>
</html>


var firstLine = readline();
print('\n');

print(tort(+firstLine.split(' ')[0], +firstLine.split(' ')[1], +firstLine.split(' ')[2]))

function tort(k, x, y) {
  let maxMin = 0;

  for (let i = 1; i < k; i++) {
      const curr = Math.min(Math.floor(x / i), Math.floor(y / (k - i)));
      if (curr > maxMin) {
          maxMin = curr;
      }
  }

  return maxMin;
}


// @flow

  const n = readline()
  const r = readline()

  let x = 0
  let y = 0
  let max = 0;

  for (var i = 0; i < r.length; i++) {
    switch(r[i]){
      case 'U': y++; break;
      case 'D': y--; break;
      case 'L': x--; break;
      case 'R': x++; break;
    }

    if (x === 0 && y === 0) max = i + 1
  }

  print(max)


// @flow

  const n = parseInt(readline(), 10)
  const r = readline()

  let x = 0
  let y = 0
  let max = 0;

  for (var i = 0; i < r.length; i++) {
    switch(r[i]){
      case 'U': y++; break;
      case 'D': y--; break;
      case 'L': x--; break;
      case 'R': x++; break;
    }

    if (x === 0 && y === 0) max = i + 1
  }

  print(max)


var inp = readline().split(" ").map(function(x){return parseInt(x);});
inp = inp.sort(function(a,b){return a > b;})
var toAdd = 0;
var res = inp[0];
if (inp[1] - inp[0] != 0){
	inp[1] -= inp[0];
	inp[2] -= inp[0];

	while (inp[1] != 0 && inp[2] != 0 && inp[1]+inp[2]>2 ){
		var mini = Math.min(inp[1],inp[2]);
		var temp = Math.min(Math.min(inp[1],inp[2]), )

		if (inp[2]>inp[1]){
					var temp = Math.min(inp[1], Math.floor((inp[2]-inp[1])/2));
					  inp[2]-=2 * temp;
					  inp[1]-= temp;
					  toAdd+=temp;
		} else{
		var temp = Math.min(inp[2], Math.floor((inp[1]-inp[2])/2));
			  inp[1]-=2 * temp;
			  inp[2]-= temp;
			  toAdd+=temp;
		}
	}
}

print(res + toAdd);


const readline = require('readline');

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

let n, k;

const remove = (string, index) => {
  return string.split('').filter((el, i) => i != index).join('');
}

var get = (n, k) => {
  n += '';
  let div = Math.pow(10, k);

  let counter = 0;

  if(n % div === 0)
    return counter;

  for(let i = n.length - 1; i >= 0; i--) {
    if(n % div === 0)
      return counter;

    if(n[i] != 0) {
      n = remove(n, i);
      counter++;
    }
  }

  return counter;
}

rl.on('line', (input) => {
  const arr = input.split(' ');

  n = arr[0];
  k = arr[1];

  console.log(get(n, k));
});

//nu i govno


function  solveSplitsProblem(n) {
    let result =  Math.floor((n/2 + 1));
    print(result);
}

let n = readline();
solveSplitsProblem(n);


function  solveSplitsProblem(n) {
    let result =  Math.floor((n/2 + 1));
    console.log(result);
}

solveSplitsProblem(9);


function  solveSplitsProblem(n) {
    let result =  Math.floor((n/2 + 1));
    console.log(result);
}

solveSplitsProblem(7);


var inp = readline()

let count4 = inp.match(/4/g);
let count7 = inp.match(/7/g);

if (count4) {
    if (count7) {
        if (count4.length >= count7.length) {
            print(4);
        } else {
            print(7);
        }
    }
} else if(count7) {
    print(7);
} else {
    print(-1);
}


const SPLIT_BY_SPACE = function(line) {
    return line.split(' ');
};
const STRING_LINE = function(line) {
    return line;
}
function getInput(...parseLineFunc) {
    let line = readline();
    let iFunc = 0;
    let data = [];
    parseLineFunc = parseLineFunc || [];

    do{
        let func = parseLineFunc[iFunc] || SPLIT_BY_SPACE;
        data[iFunc] = func(line);
        line = readline();
        iFunc++;
    }
    while(line);
    return data;

};

function solution() {
    let data = getInput(SPLIT_BY_SPACE, STRING_LINE);
    let N = parseInt(data[0]);
    let S = data[1];
    let maps = {};
    for (let s of S) {
        if (maps[s]) {
            console.log('Yes');
            return;
        }
        maps[s] =  true;
    }
    console.log('No');
    return;
}

solution();


const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false,
});

let n;

const numCapitals = word => {
  let total = 0;
  for (let i = 0; i < word.length; i++) {
    if (/[A-Z]/.test(word[i])) {
      total++;
    }
  }
  return total;
};

rl.on('line', line => {
  if (!n) {
    n = line;
  } else {
    const words = line.split(' ');
    const max = words.reduce((max, curr) => {
      const count = numCapitals(curr);
      if (count > max) {
        return count;
      }
      return max;
    }, -1);
    rl.write(max);
    process.exit();
  }
});


function numCapitals(word) {
  let total = 0;
  for (let i = 0; i < word.length; i++) {
    if (/[A-Z]/.test(word[i])) {
      total++;
    }
  }
  return total;
}

function main() {
  const n = readline();
  const words = readline().split(' ');

  const max = words.reduce((max, curr) => {
    const count = numCapitals(curr);
    if (count > max) {
      return count;
    }
    return max;
  }, -1);

  print(max);
}

main();


<!DOCTYPE html>
<html>
<meta charset='utf-8'>
<script type="text/javascript">
  var str = prompt('', '').split(' ');
  var n = str[0];
  var k = str[1];
  var multiplier = n;
  for( var i = 1; i <= k; i++ ) {
  	if( multiplier % 5 ) break;
  	else multiplier /= 5;
  };
  for( var i = 1; i <= k; i++ ) {
  	if( multiplier % 2 ) break;
  	else multiplier /= 2;
  };
  multiplier *= Math.pow(10, k);
  alert( multiplier );
</script>
</html>


var t = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];

var inp = readline().split(' ');
var n = inp[0];
var type = inp[2];

if (type == "week") {
    var current = 5;
    var a = 0;
    for (var i = 0; i < 366; ++i) {
        if(current == n)
            ++a;
        ++current;
        if(current > 7)
            current = 1;
    }
    print(a);
} else {
    var a = 0;
    for (var i = 0; i < 12; ++i) {
        a += n <= t[i];

    }
    print(a);
}


var s = readline().split(' ');
var p =function () {var t= parseInt(s[0]); if (s[2]=='month') {if (t<=29) { return 12;} else if (t==30) {return 11;} else return 7;} else if (t<=4 || t==7) {return 52;} else return 53; };
print (p());


var week = function (n) {
    var baseweek = 52;
    if (n==5 || n==6){
        baseweek++;
    }
    return baseweek;
}
var month = function (n) {
    var res = 0;
    if (n<=29){
        res = 12;
    }else if (n==30){
        res = 11;
    }else{
        res = 7;
    }
    return res;
}
var inp = readline();

if (inp.includes("month")){
    write(month(inp.split(" ")[0]));
}else{
    write(week(inp.split(" ")[0]));

}


var cwDirections = ['^', '>', 'v', '<'];

function main() {
  var dirs = readline().split(' ');
  var start = dirs[0];
  var end = dirs[1];
  var n = Number(readline());

  if (n % 2 === 0) {
    return print('undefined');
  }

  var startIndex = cwDirections.indexOf(start); // ^ = 0
  var endIndex = cwDirections.indexOf(end); // > = 1

  if ((startIndex + n) % 4 === endIndex) {
    return 'cw';
  } else {
    return 'ccw';
  }

  print();
}

main();


var cwDirections = ['^', '>', 'v', '<'];

function main() {
  var dirs = readline().split(' ');
  var start = dirs[0];
  var end = dirs[1];
  var n = Number(readLine());

  if (n % 2 === 0) {
    return print('undefined');
  }

  var startIndex = cwDirections.indexOf(start); // ^ = 0
  var endIndex = cwDirections.indexOf(end); // > = 1

  if ((startIndex + n) % 4 === endIndex) {
    return 'cw';
  } else {
    return 'ccw';
  }

  print();
}

main();


var cwDirections = ['^', '>', 'v', '<'];

function main() {
  var dirs = readline().split(' ');
  var start = dirs[0];
  var end = dirs[1];
  var n = Number(readline());

  if (n % 2 === 0) {
    return print('undefined');
  }

  var startIndex = cwDirections.indexOf(start); // ^ = 0
  var endIndex = cwDirections.indexOf(end); // > = 1

  if ((startIndex + n) % 4 === endIndex) {
    print('cw');
  } else {
    print('ccw');
  }
}

main();


const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let count = 0;
let a, b, c;

const solve = () => {
  let ans = 0;
  let hasFruits = true;

  while (hasFruits) {
    a -= 1;
    b -= 2;
    c -= 4;

    if (a > -1 && b > -1 & c > -1) {
      ans += 7;
    }
    else {
      hasFruits = false;
    }
  }

  console.log(ans);
};

rl.on('line', (d) => {
  if (count === 0) {
    a = +d;
  }
  else if (count === 1) {
    b = +d;
  }
  else {
    c = +d;

    solve();
  }

  count++;
});


var a = readline();
var b = readline();
var c = readline();
var res = 0;
while(a*2>b || a*4>c){
a--;
}
res = a+a*2+a*4;
print(res);


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 sides = [];

	for (var i = 0; i < 4; i += 1) {
		var integers = tokenizeIntegers(readline());
		sides.push( { x0: integers[0], y0: integers[1],
					  x1: integers[2], y1: integers[3] } );
	}

	var used = new Array(4);

	var found = false;

	function go(attempt) {
		if (attempt.length == 4) {
			var a = attempt[0], b = attempt[1], c = attempt[2], d = attempt[3];
			if (a.x0 == a.x1 && b.y0 == b.y1 && c.x0 == c.x1 && d.y0 == d.y1 &&
					Math.max(a.y0, a.y1) == b.y0 &&
					Math.max(b.x0, b.x1) == c.x0 &&
					Math.min(c.y0, c.y1) == d.y0 &&
					Math.min(d.x0, d.x1) == a.x0) {
				found = true;
			}
		}
		else {
			for (var i = 0; i < 4; i += 1) {
				if (used[i] === undefined) {
						used[i] = true;
						attempt.push(sides[i]);
						go(attempt);
						attempt.pop();
						used[i] = undefined;
				}
			}
		}
	}

	go([]);

	print(found ? "YES" : "NO");
}

main();


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 sides = [];

	for (var i = 0; i < 4; i += 1) {
		var integers = tokenizeIntegers(readline());
		sides.push([ { x: integers[0], y: integers[1] },
					 { x: integers[2], y: integers[3] } ]);
	}

	function makeCorner(a, b) {
		for (var i = 0; i < 2; i += 1) {
			var p = a[i], q = a[(i+1)%2];
			for (var j = 0; j < 2; j += 1) {
				var r = b[j], s = b[(j+1)%2];
				if (p.y == q.y && p.x != q.x &&
						q.x == r.x && q.y == r.y &&
						r.x == s.x && r.y != s.y) {
					return true;
				}
				if (p.x == q.x && p.y != q.y &&
						q.x == r.x && q.y == r.y &&
						r.y == s.y && r.x != s.x) {
					return true;
				}
			}
		}
		//write("("+a[0].x+", "+a[0].y+") ("+a[1].x+", "+a[1].y+")");
		//print(" -> ("+b[0].x+", "+b[0].y+") ("+b[1].x+", "+b[1].y+")");
		return false;
	}

	var used = new Array(4);
	var okay = false;

	function go(attempt) {
		//print(attempt.length);
		if (attempt.length == 4) {
			if (makeCorner(attempt[3], attempt[0])) {
				okay = true;
			}
		}
		else {
			for (var i = 0; i < 4; i += 1) {
				if (used[i] === undefined) {
					if (attempt.length == 0 ||
							makeCorner(attempt[attempt.length-1], sides[i])) {
						used[i] = true;
						attempt.push(sides[i]);
						go(attempt);
						attempt.pop();
						used[i] = false;
					}
				}
			}
		}
	}

	go([]);
	print(okay ? "YES" : "NO");
}

main();


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 sides = [];

	for (var i = 0; i < 4; i += 1) {
		var integers = tokenizeIntegers(readline());
		sides.push( { x0: integers[0], y0: integers[1],
					  x1: integers[2], y1: integers[3] } );
	}

	var used = new Array(4);

	var found = false;

	function go(attempt) {
		if (attempt.length == 4) {
			var a = attempt[0], b = attempt[1], c = attempt[2], d = attempt[3];
			if (a.x0 == a.x1 && b.y0 == b.y1 && c.x0 == c.x1 && d.y0 == d.y1 &&
					a.y0 != a.y1 && b.x0 != b.x1 &&
					Math.max(a.y0, a.y1) == b.y0 &&
					Math.max(b.x0, b.x1) == c.x0 &&
					Math.min(c.y0, c.y1) == d.y0 &&
					Math.min(d.x0, d.x1) == a.x0) {
				found = true;
			}
		}
		else {
			for (var i = 0; i < 4; i += 1) {
				if (used[i] === undefined) {
						used[i] = true;
						attempt.push(sides[i]);
						go(attempt);
						attempt.pop();
						used[i] = undefined;
				}
			}
		}
	}

	go([]);

	print(found ? "YES" : "NO");
}

main();


const readline = require('readline');

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

var IsPrime = function (num) {
    if (num == 2)
        return true;
    if (num < 2 || num % 2 == 0)
        return false;
    var limit = parseInt(Math.sqrt(num));
    for (i = 3; i <= limit; i += 2) {
        if (num % i == 0)
            return false;
    }
    return true;
}

var prev = 2,
    n, k, counter = 0,
    helper;

rl.on('line', (input) => {
    var temp = input.split(' ').map(item => parseInt(item));
    n = temp[0];
    k = temp[1];

    for (let i = 3; i <= n; i++) {
        if (IsPrime(i)) {
            helper = prev + i + 1;
            if (IsPrime(helper) && helper <= n)
                counter++;
            prev = i;
        }
    }
    console.log((counter >= k) ? "YES" : "NO");
    rl.close();
});


'use strict'

let lll = readline().split(' ').map(v => parseInt(v))

const N = lll[0]
const K = lll[1]

const simples = getSimpleToN(N)

let sc = 0

simples.forEach((s, i, a) => {
  for (let j = 1; j < i; j++) {
    let ps = a[j] + a[j - 1] + 1
    if (s == a[j] + a[j - 1] + 1) sc++
    if (s <= ps) break
  }
})

print(sc >= K ? 'YES' : 'NO')

function getSimpleToN (N) {
  const ss = [2]
  next: for (let i = 3; i <= N; i++) {
    for (let j = 0; j < ss.length; j++) {
      if (!(i % ss[j])) continue next
    }
    ss.push(i)
  }
  return ss
}


const readline = require('readline');

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

var IsPrime = function (Num) {
    if (Num == 2)
        return true;
    if (Num < 2 || Num % 2 == 0)
        return false;
    let limit = parseInt(Math.sqrt(Num));
    for (let i = 3; i <= limit; i+=2){
        if (!(Num % i))
            return false;
    }
    return true;
}

rl.on('line', (input) => {
    let temp = input.split(' ').map(item => parseInt(item));
    let n = temp[0];
    let k = temp[1];
    let prev = 2, counter = 0;

    for (let i = 3; i < n; i++){
        if (IsPrime(i)){
          let helper = prev + i + 1;
          counter += (IsPrime(helper) && helper <= n);
          prev = i;
        }
    }
    console.log(counter >= k?"YES":"NO");
    rl.close();
});


var nk = readline().split(' ').map(Number);
var n = nk[0];
var k = nk[1];

var pros = [2, 3, 5, 7, 11];
for (var i=12; i<=n; i++){
	if (i%2 != 0 && i%3 != 0 && i%5 != 0 && i%7 != 0 && i%11 != 0) pros.push(i);
}

var prossum = [];
for (var i=0; i<(pros.length-1); i++){
	var sum = pros[i] + pros[i+1] + 1;
	if (sum%2 != 0 && sum%3 != 0 && sum%5 != 0 && sum%7 != 0 && sum%11 != 0 && sum<=n) prossum.push(sum);
}

if (prossum.length >= k) print ('YES');
else print ('NO');


'use strict'

let lll = readline().split(' ').map(v => parseInt(v))

const N = lll[0]
const K = lll[1]

const simples = getSimpleToN(N)

let sc = 0

simples.forEach((s, i, a) => {
  for (let j = 0; j < i; j++) {
    if (s == a[j] + a[j] + 1) sc++
  }
})

print(sc >= K ? 'YES' : 'NO')

function getSimpleToN (N) {
  const ss = [2]
  next: for (let i = 3; i < N; i++) {
    for (let j = 0; j < ss.length; j++) {
      if (!(i % ss[j])) continue next
    }
    ss.push(i)
  }
  return ss
}


var a = readline().split(' ');

var count = Number(a[0]);
var place = Number(a[1]);
var diff = place > count / 2 ? count - place : place - 1;

print(count*2 + 1 + count - 1 + diff)


const input = readline().split(" ").map(e => parseInt(e));
const n = input[0];
const k = input[1];

const moving = n - 1 + Math.min(n - k, k - 1);
const stones = n + 1;

print(moving + stones + n);


var arry=readline().split(' ');
var manhole = arry[0], position = arry[1], steps=manhole*3;

if (position != 1 && position != manhole) {
  steps += Math.min(position - 1, manhole - position);
}

print(steps)


var inp = readline().split(' ').map(x => parseInt(x));
var n = inp[0], k = inp[1];

var mn = Math.min(n - k, k - 1);
var mx = Math.max(n - k, k - 1);
var ans = 3 + 4 * mn + 3 * mx;
print(ans);


var nk = readline().split(' ').map(v=>(parseInt(v)))
var n = nk[0]
var k = nk[1]

print(3*n + Math.min( k>0 ? k-1:n-k, n-k) )


var stats = readline().split(' ').map(function (num) {
    return parseInt(num);
  });

// var stats = [4, 2];

function min(a, b) {
  return (a < b) ? a : b;
}

var distance = min(stats[0] - stats[1], stats[1] - 1);

write(distance + (3 * stats[0]));


var arry=readline().split(' ');

var manhole = arry[0], position = arry[1], steps=0;

if (position == manhole || position == 1) {
  steps = 3 + (manhole - 1)*3;
}
else if (1 < position && position < manhole) {
  steps = 4 + (manhole - 1)*3;
}

print(steps)


var arry=readline().split(' ');

var manhole = arry[0], position = arry[1], steps=0;

if (position == manhole || position == 1) {
  steps = manhole*3;
}
else if (1 < position && position < manhole) {
  steps = Math.min(position - 1, manhole - position) + manhole*3;
}

print(steps)


var input = readline().split(' ').map(Number), n = input[0], a = input[1], b = input[2], k = input[3];
var MOD = 1000000007;
var res = [];
a--;
b--;

for (var j = 0; j < 2; j++) {
    res[j] = [];
    for (var i = 0; i < n + 1; i++) res[j][i] = 0;
}

res[0][a] = 1;

for (var j = 0; j < k; j++) {
    var current = j & 1;
    var next = current ^ 1;

    for (var i = 0; i < n; i++) res[next][i] = 0;

    for (var i = 0; i < n; i++) {
        var currentValue = res[current][i];
        var diff = Math.abs(i - b);
        var bottomBorder = Math.max(i - diff + 1, 0);     // inclusively
        var topBorder = Math.min(i + diff, n);            // exclusively
        res[next][bottomBorder] = (res[next][bottomBorder] + currentValue) % MOD;
        res[next][topBorder] = (res[next][topBorder] - currentValue);
        if (res[next][topBorder] < 0) res[next][topBorder] += MOD;
    }

    for (var i = 1; i < n; i++)
        res[next][i] = (res[next][i] + res[next][i-1]) % MOD;

    for (var i = 0; i < n; i++) {
        res[next][i] = res[next][i] - res[current][i];
        if (res[next][i] < 0) res[next][i] += MOD;
    }
}

var sum = 0;
for (var i = 0; i < n; i++) {
    sum = (sum + res[k & 1][i]) % MOD;
}

write(sum);


function allEqual(arr) {
  for (var i = 1; i < arr.length; i++) {
    if (arr[i] != arr[i - 1]) {
      return false;
    }
  }

  return true;
}

var n = parseInt(readline(), 10);
var seq = readline().split(" ").map(function(x) { return parseInt(x); });

seq.sort(function(a, b) { return a - b; });
while (!allEqual(seq)) {
  seq[n - 1] = seq[n - 1] - seq[n - 2];
  seq.sort(function(a, b) { return a - b; });
}

var result = 0;
for (var i = 0; i < n; i++) {
  result += seq[i];
}

print(result);


function allEqual(arr) {
  for (var i = 1; i < arr.length; i++) {
    if (arr[i] != arr[i - 1]) {
      return false;
    }
  }

  return true;
}

var n = parseInt(readline(), 10);
var seq = readline().split(" ").map(function(x) { return parseInt(x); });

seq.sort(function(a, b) { return a - b; });
while (!allEqual(seq)) {
  for (var k = n - 2; k >= 0; k++) {
    if (seq[n - 1] > seq[k]) {
      seq[n - 1] = seq[n - 1] - seq[k];
      break;
    }
  }

  seq.sort(function(a, b) { return a - b; });
}

var result = 0;
for (var i = 0; i < n; i++) {
  result += seq[i];
}

print(result);


function allEqual(arr) {
  for (var i = 1; i < arr.length; i++) {
    if (arr[i] != arr[i - 1]) {
      return false;
    }
  }

  return true;
}

var n = parseInt(readline(), 10);
var seq = readline().split(" ").map(function(x) { return parseInt(x); });

seq.sort(function(a, b) { return a - b; });
while (!allEqual(seq)) {
  for (var k = n - 2; k >= 0; k--) {
    if (seq[n - 1] > seq[k]) {
      seq[n - 1] = seq[n - 1] - seq[k];
      break;
    }
  }

  seq.sort(function(a, b) { return a - b; });
}

var result = 0;
for (var i = 0; i < n; i++) {
  result += seq[i];
}

print(result);


function gcd(a,b){
    //print("a="+a+" b="+b+"\n");
    return a%b==0 ? b : gcd(b,a%b);
}

var num = parseInt(readline());
var arr = readline().split(" ").map(function(x) { return parseInt(x); });

//for(var i in arr) arr[i] = parseInt(arr[i]);

    var ans=arr[0];

    //print("arr[1]="+arr[1]+"\n")
    var i;
    for(i=1;i<=num-1;i++)
    {
        ans=gcd(ans,arr[i]);
    }
    //print(ans);
    //print(num);
    print(ans*num);


(function (){
    var i, n = parseInt(readline());
    var a = readline().split(' ');
    function gcd(a,b){
        if ( a % b == 0 ){
            return b;
        }else{
            return gcd(b,a%b);
        }
    }
    var g = parseInt(a[0]);
    for ( i = 1 ; i < n ; ++i){
        g = gcd(g,parseInt(a[i]));
    }
    print(g*n);
})();


var n=+readline();
var x=readline().split(' ').map(function(v){return+v;});

var sum=1e20;
while(true){
	x.sort(function(a,b){return a-b});
	for(var i=1;i<n;i++){
		if(x[i]>x[i-1]){
			x[i]=x[i]-x[i-1];
		}
	}
	var s=x.reduce(function(a,b){return a+b}, 0);
		if(s<sum){
		sum=s;
	}else{
		break
	}
}
print(sum);


/*
  Pick your own problems you fuck faced cunt.
*/
var radix=parseInt(readline());
for(var i = 1;i < radix; ++i){
  for(var j = 1;j < radix; ++j){
    write((i*j).toString(radix)+" ");
  }
  print();
}


var radix=parseInt(readline());
for(var i = 1;i < radix; ++i){
  for(var j = 1;j < radix; ++j){
    write((i*j).toString(radix)+" ");
  }
  print();
}


(function() {
    'use strict';
    let n = readline();
    let r = readline().split('').map(String);
    let y = [];
    for(let i = 2; i <= n; i++) {
        if (n % i === 0) {
            y += i + ' ';
        }
    }
    y = y.split(' ').map(Number);
    y.splice(y.length - 1, 1);
    for (let i = 0; i < y.length; i++) {
        let m = r.splice(0, y[i]);
        m = m.reverse();
        r.splice.apply(r, [0, 0].concat(m));

   }

    print(r.join(''));
}());


function processData(input) {
    //Enter your code here
     let  res=input.split("\n"),   n=+(res[0]),
      arr=res[1].split("").filter((x)=>x!==""),
       cnt=dvsr(n);
       //console.log(cnt,arr)
  cnt.forEach((d)=>{
    let temp="";
    while(d>0){
      temp+=arr.shift();
      d--
    }
    //console.log(arr,temp)
    temp=[...temp].reverse();
    arr=[...temp,...arr];

  })
  console.log(arr.reverse().join(""))
}

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   processData(_input);
});
function dvsr(n){
  let v=Math.sqrt(n),cnt=[]
for(let i=2;i<=v;i++){
  if(n%i===0){
      cnt.push(i);
      cnt.push(n/i)
  }
   // cnt.push(i)
}
return cnt.sort((a,b)=>a-b)
}


function processData(input) {
    //Enter your code here
     let  res=input.split("\n"),   n=+(res[0]),
      arr=res[1].split("").filter((x)=>x!==""),
       cnt=dvsr(n);
       //console.log(cnt,arr)
  cnt.forEach((d)=>{
      ////console.log(arr,d)
    let temp="";
    while(d>0){
      temp+=arr.shift();
      d--
    }
    //console.log(arr,temp)
    temp=[...temp].reverse();
    arr=[...temp,...arr];

  })
  console.log(arr.reverse().join(""))
}

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   processData(_input);
});
function dvsr(n){
  let v=Math.sqrt(n),set=new Set()
for(let i=2;i<=v;i++){
  if(n%i===0){
      set.add(i);
      set.add(n/i)
  }
   // cnt.push(i)
}
  let cnt=[...set]
return cnt.sort((a,b)=>a-b)
}


'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString='';
let currentLine=0;
process.stdin.on('data',inputStdin=>{
    inputString+=inputStdin;
});
process.stdin.on('end',_=>{
    inputString=inputString.trim().split("\n").map(string=>{
        return string.trim();
    });
    main();
});
function readLine()
{
    return inputString[currentLine++];
}

function main()
{
    const n=+(readLine());
    let enc=readLine().trim();
    let ans=enc;
    for(let i=2;i<=n;++i)
    {
        if(n%i==0)
        {
            ans=ans.substr(0,i).split("").reverse().join("")+ans.substr(i);
        }
    }
    console.log(ans);

}


var inputs = readline();
var initlengths = parseInt(inputs);

function reverse_partial(string, start, end){
    var newString = "";
    var appendString = string.substring(end, string.length);
    for (var i = end - 1; i >= start; i--) {
        newString += string[i];
    }
    return newString+appendString;
}

function decrypt(strings, lengths){
    if(lengths == initlengths){
        return reverse_partial(strings, 0, initlengths);
    }
    divisor = lengths+1;
    while(initlengths%divisor != 0){
        divisor++;
    }
    reversed = reverse_partial(strings,0,lengths);
    return decrypt(reversed, divisor);
}

while(inputs = readline()){
    print(decrypt(inputs, 0));
}


var n = parseInt(readline());
var s = readline();
var arr = [];
var result = "";

for(var i = 0; i < n; i++)
{
    arr.push(s[i]);
}

for(var i = 0; i < n + 1; i++)
{
    if(n % i == 0)
    {
        subArr = arr.slice(0, i);
        subArr.reverse();

        for(var j = 0; j < i; j++)
        {
            arr[j] = subArr[j];
        }
    }
}

for(var i = 0; i < n; i++)
{
    result += arr[i];
}

print(result);


var n, t;
n = readline ();
n = n.trim ();
t = readline ();
t = t.trim ();
var i, a = [ ];
for ( i = 0; i < t.length; i ++ ) { a [ i ] = t [ i ]; }
var j, temp;
for ( i = 1; i < t.length; i ++ ) {
    if ( a.length % (i + 1) == 0 ) {
        for ( j = 0; j <= Math.floor ( i / 2 ); j ++ ) {
            temp = a [ j ];
            a [ j ] = a [ i - j ];
            a [ i - j ] = temp;
        }
    }
}
print ( a.join ( '' ) );


var n = parseInt(readline());
var s = readline();
var arr = [];
var result = "";
var subArr;

for(var i = 0; i < n; i++)
{
    arr.push(s[i]);
}

for(var i = 1; i < n + 1; i++)
{
    if(n % i == 0)
    {
        subArr = arr.slice(0, i);
        subArr.reverse();

        for(var j = 0; j < i; j++)
        {
            arr[j] = subArr[j];
        }
    }
}

for(var i = 0; i < n; i++)
{
    result += arr[i];
}

print(result);


const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (str) => {
  if (c === 0) {
    c++;
    return;
  }

  let arr = [...str];
  const len = arr.length;
  for (let i = 2; i <= len; i++) {
    if (len % i === 0) {
      const firstPart = arr.slice(0, i);
      const secondPart = arr.slice(i);

      firstPart.reverse();

      arr = [...firstPart, ...secondPart];
    }
  }

  console.log(arr.join(''));

  c++;
});


var n = +readline();
var t = readline();
var del = [];
for (var i=1; i<=n; i++){
	if (n%i == 0) del.push(i);
}
for (var i=0; i<del.length; i++){
	t = t.slice(0, del[i]).split('').reverse().join('') + t.slice(del[i]);
}
print(t);


var n = +readline();
var t = readline().split('');

// Get all divisors from n
var divisors = [];
for(var i = 2; i <= n / 2; i++) {
    if(n % i === 0) {
        divisors.push(i);
    }
}

function reverseString(st, div) {
    if(div.length === 0) {
        return st.reverse().join('');
    } else {
        var divisor = div.shift();
        var aux = st.slice(divisor);
        st = st.slice(0, divisor).reverse();
        return reverseString(st.concat(aux), div);
    }
}

s = reverseString(t, divisors);

print(s);


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const x = readline();
    var line2 = readline();

    // console log function here
    console.log(removeAdjacent(x, line2));
}

// function here

function removeAdjacent(l, s) {

	let sArr = Array.from(s);

	// create a dictionary where every letter in associated the its positions in the string,
	// and a linkde list where every element has a reference in the dictionary near the position here stored

	let sll = {value:s[0], prev: null, next: null};
	let lettersDict = {[s[0]]: [{position: 0, elem: sll}]};
	let start = sll;
	let currElemLinkedList = sll;

	for (let i = 1; i < l; i++) {
		let curr = s[i];

		currElemLinkedList.next = {value:curr, prev: currElemLinkedList, next: null};
		if (curr in lettersDict) {
			lettersDict[curr].push({position: i, elem: currElemLinkedList.next});
		}
		else {
			lettersDict[curr] = [{position: i, elem: currElemLinkedList.next}];
		}

		currElemLinkedList = currElemLinkedList.next;
	}

	let end = currElemLinkedList;

	// order the keys of the dictionary by ascii value
	const keys = Object.keys(lettersDict);
	keys.sort((a, b) => {
		return b.charCodeAt(0) - a.charCodeAt(0)
	});

	// for every entry in keys check the string for adjacents
	return keys.reduce((acc, curr) => {
		let nEliminated = 0;

		for (let i = 0; i < lettersDict[curr].length; i++) {
			let elem = lettersDict[curr][i].elem;
			if (elem) {
				let position = lettersDict[curr][i].position;

				let leftComparable = elem.prev && elem.prev.value;
				let rightComparable = elem.next && elem.next.value;

				if ((leftComparable && (leftComparable.charCodeAt(0) - elem.value.charCodeAt(0) == -1)) ||
					(rightComparable && (rightComparable.charCodeAt(0) - elem.value.charCodeAt(0) == -1))) {
					nEliminated++;

					lettersDict[curr][i].elem = null;
					if (leftComparable === elem.value) {
						i -= 2
					}
					let prev = elem.prev;
					let next = elem.next;
					if (prev) {
						prev.next = next;
					}
					if (next) {
						next.prev = prev;
					}

				}

			}
		}

		return acc + nEliminated;
	}, 0)
}


process.stdin.resume()
process.stdin.setEncoding('utf-8')

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

process.stdin.on('end', () => {
  input = input.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main()
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  const l = readInt()
  let s = readString()
  let max = 0
  let count = 0
  let len = l
  for(let c = 1; c < l; c++) { // l -1 times
    let f = false
    for(let i = 1; i < len; i++) {
      if(s[i] > s[max]) max = i
    }
    // console.log(s, max, s[max], count)
    if(max !== 0 && s.charCodeAt(max) - 1 === s.charCodeAt(max - 1)) {
      s = cut(max)
      len--
      count++
      f = true
    }
    else {
      for(let x = max; x < len - 1; x++) {
        if(s[x] === s[max] && s.charCodeAt(x) - 1 === s.charCodeAt(x + 1)) {
          // console.log('x', x, s[x])
          s = cut(x)
          len--
          count++
          f = true
          break
        }
      }
    }
    if(!f) s = put(max)
    max = 0
  }

  wr(count)

  function cut(i) {
    i++
    return s.substring(0, i - 1) + s.substring(i)
  }
  function put(i) {
    i++
    return s.substring(0, i - 1) + 'A' + s.substring(i)

  }
}


function generateAlphabets() {
  var alphabets = [];
  var start = 'a'.charCodeAt(0);
  var last  = 'z'.charCodeAt(0);
  for (var i = start; i <= last; ++i) {
    alphabets.push(String.fromCharCode(i));
  }

  return alphabets;
}

const seq = generateAlphabets();

const processData = (lines) => {
  const s = lines[1].split('').map(x => x.charCodeAt(0))
  let sum = 0
  const set = Array.from(new Set(s)).sort((a, b) => a - b).reverse()
  for (const l of set) {
    const target = l - 1;
    for (let j =0; j<s.length; j++) {
      if (s[j] === l && (s[j-1] === target || s[j+1] === target)) {
        sum++
        s.splice(j, 1)
        j=-1
      }
    }
  }
  console.log(sum)
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const x = readline();
    var line2 = readline();

    console.log(removeAdjacent(x, line2));
}

function findComparable(direction /* -1 left, 1 right*/, from, sArr) {
	return from+(direction*(sArr.findIndex((_, index) => sArr[from+(direction*(index+1))]!='#')+1));
}

function removeAdjacent(l, s) {

	let sArr = Array.from(s);

	// create a dictionary where every letter in associated the its positions in the string
	const lettersDict = sArr.reduce((acc, curr, i) => {
		if (curr in acc) {
			acc[curr].push(i);
		}
		else {
			acc[curr] = [i];
		}
		return acc;
	}, {});

	// order the keys of the dictionary by ascii value
	const keys = Object.keys(lettersDict);
	keys.sort((a, b) => {
		return b.charCodeAt(0) - a.charCodeAt(0)
	});

	// for every entry in keys check the string for adjacents
	return keys.reduce((acc, curr) => {
		let nEliminated = 0;

		for (let i = 0; i < lettersDict[curr].length; i++) {
			let position = lettersDict[curr][i];
			let leftComparable = findComparable(-1, position, sArr);
			let rightComparable = findComparable(1, position, sArr);
			if ((sArr[leftComparable] && (sArr[leftComparable].charCodeAt(0) - sArr[position].charCodeAt(0) == -1)) ||
				(sArr[rightComparable] && (sArr[rightComparable].charCodeAt(0) - sArr[position].charCodeAt(0) == -1))) {
				nEliminated++;
				if (sArr[position-1] === sArr[position]) {
					i -= 2;
				}
				sArr[position] = '#';
			}
		}

		return acc + nEliminated;
	}, 0);
}


process.stdin.resume()
process.stdin.setEncoding('utf-8')

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

process.stdin.on('end', () => {
  input = input.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main()
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  const l = readInt()
  let s = readString()
  let max = 0
  let count = 0
  let len = l
  for(let c = 1; c < l; c++) { // l -1 times
    for(let i = 1; i < len; i++) {
      if(s[i] > s[max]) max = i
    }
    // console.log(s, max, count)
    if(max === len - 1) {
      if(s.charCodeAt(max) - 1 === s.charCodeAt(max - 1)) {
        count++
      }
    }
    else if(max !== 0) {
      if(s.charCodeAt(max) - 1 === s.charCodeAt(max + 1) || s.charCodeAt(max) - 1 === s.charCodeAt(max - 1)) {
        count++
      }
    }
    else {
      if(s.charCodeAt(max) - 1 === s.charCodeAt(max + 1)) {
        count++
      }
    }
    s = cut(max)
    len--
    max = 0
  }

  wr(count)

  function cut(i) {
    i++
    return s.substring(0, i - 1) + s.substring(i)
  }
}


process.stdin.resume()
process.stdin.setEncoding('utf-8')

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

process.stdin.on('end', () => {
  input = input.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main()
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  const l = readInt()
  let s = readString()
  let max = 0
  let count = 0
  let len = l
  for(let c = 1; c < l; c++) { // l -1 times
    for(let i = 1; i < len; i++) {
      if(s[i] > s[max]) max = i
    }
    // console.log(s, max, count)
    if(max === len - 1) {
      if(s.charCodeAt(max) - 1 === s.charCodeAt(max - 1)) {
        s = cut(max)
        len--
        count++
      }
      else {
        s = put(max)
      }
    }
    else if(max !== 0) {
      if(s.charCodeAt(max) - 1 === s.charCodeAt(max + 1) || s.charCodeAt(max) - 1 === s.charCodeAt(max - 1)) {
        s = cut(max)
        len--
        count++
      }
      else {
        s = put(max)
      }
    }
    else {
      if(s.charCodeAt(max) - 1 === s.charCodeAt(max + 1)) {
        s = cut(max)
        len--
        count++
      }
      else {
        s = put(max)
      }
    }
    max = 0
  }

  wr(count)

  function cut(i) {
    i++
    return s.substring(0, i - 1) + s.substring(i)
  }
  function put(i) {
    i++
    return s.substring(0, i - 1) + 'A' + s.substring(i)

  }
}


process.stdin.resume()
process.stdin.setEncoding('utf-8')

let input = ''
let ptr = 0
process.stdin.on('data', (i) => {
  input += i
})

process.stdin.on('end', () => {
  input = input.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))
  main()
})

function wr(...x) {
  console.log(...x)
}

function sort(a, inc = true) {
  if(inc) a.sort((a, b) => a - b)
  else a.sort((a, b) => b - a)
}

function readInt() {
  return parseInt(input[ptr++])
}

function readString() {
  return input[ptr++]
}

function readStrings() {
  return input[ptr++].split(' ')
}

function readInts() {
  return input[ptr++].split(' ').map(a => parseInt(a))
}

function main() {
  const l = readInt()
  let s = readString()
  let max = 0
  let count = 0
  let len = l
  for(let c = 1; c < l; c++) { // l -1 times
    for(let i = 1; i < len; i++) {
      if(s[i] > s[max]) max = i
    }
    // console.log(s, max, count)
    if(max === len - 1) {
      if(s.charCodeAt(max) - 1 === s.charCodeAt(max - 1)) {
        s = cut(max)
        len--
        count++
      }
    }
    else if(max !== 0) {
      if(s.charCodeAt(max) - 1 === s.charCodeAt(max + 1) || s.charCodeAt(max) - 1 === s.charCodeAt(max - 1)) {
        s = cut(max)
        len--
        count++
      }
      else {
        s = put(max)
      }
    }
    else {
      if(s.charCodeAt(max) - 1 === s.charCodeAt(max + 1)) {
        s = cut(max)
        len--
        count++
      }
      else {
        s = put(max)
      }
    }
    max = 0
  }

  wr(count)

  function cut(i) {
    i++
    return s.substring(0, i - 1) + s.substring(i)
  }
  function put(i) {
    i++
    return s.substring(0, i - 1) + 'A' + s.substring(i)

  }
}


function generateAlphabets() {
  var alphabets = [];
  var start = 'a'.charCodeAt(0);
  var last  = 'z'.charCodeAt(0);
  for (var i = start; i <= last; ++i) {
    alphabets.push(String.fromCharCode(i));
  }

  return alphabets;
}

const seq = generateAlphabets();

const processData = (lines) => {
  const s = lines[1].split('').map(x => x.charCodeAt(0))
  let sum = 0
  const set = Array.from(new Set(s)).sort((a, b) => a - b).reverse()
  for (const l of set) {
    const target = l - 1;
    for (let j =0; j<s.length; j++) {
      if (s[j] === l && (s[j-1] === target || s[j+1] === target)) {
        sum++
        s.splice(j, 1)
        j--
      }
    }
  }
  console.log(sum)
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const x = readline();
    var line2 = readline();

    console.log(removeAdjacent(x, line2));
}

function findComparable(direction /* -1 left, 1 right*/, from, sArr) {
	return from+(direction*(sArr.findIndex((_, index) => sArr[from+(direction*(index+1))]!='#')+1));
}

function removeAdjacent(l, s) {

	let sArr = Array.from(s);

	// create a dictionary where every letter in associated the its positions in the string
	const lettersDict = sArr.reduce((acc, curr, i) => {
		if (curr in acc) {
			acc[curr].push(i);
		}
		else {
			acc[curr] = [i];
		}
		return acc;
	}, {});

	// order the keys of the dictionary by ascii value
	const keys = Object.keys(lettersDict);
	keys.sort((a, b) => {
		return b.charCodeAt(0) - a.charCodeAt(0)
	});

	// for every entry in keys check the string for adjacents
	return keys.reduce((acc, curr) => {
		let nEliminated = 0;
		lettersDict[curr].forEach((position) => {
			let leftComparable = findComparable(-1, position, sArr);
			let rightComparable = findComparable(1, position, sArr);
			if ((sArr[leftComparable] && (sArr[leftComparable].charCodeAt(0) - sArr[position].charCodeAt(0) == -1)) ||
				(sArr[rightComparable] && (sArr[rightComparable].charCodeAt(0) - sArr[position].charCodeAt(0) == -1))) {
				nEliminated++;
				sArr[position] = '#';
			}
		});
		return acc + nEliminated;
	}, 0)
}


var input = readline().split(' ').map(Number);

var n = input[0];
var a = input[1];
var b = input[2];
var c = input[3];
var d = input[4];

var TR = 1;

var TL = 0;
var BL = 0;
var BR = 0;

var count = 0;

while (TR <= n) {
	TL = c - b + TR;
	BL = a + c - b - d + TR;
	BR = a - d + TR;
	if ((TL > 0 && TL <= n) && (BL > 0 && BL <= n) && (BR > 0 && BR <= n)) {
		count += 1;
	}
	TR ++;
}

var answer = n * count;

print(answer);


var input = readline().split(' ').map(n => parseInt(n))
var n = input[0];
var a = input[1];
var b = input[2];
var c = input[3];
var d = input[4];

var x1 = 0;
var x2 = x1 + b - c;
// x3 can be any number with [1, n] range.
var x4 = x1 + a - d;
var x5 = x1 + a + b - c - d;
// Imagine x1, x2, x4, x5 on a line.
var points = [x1, x2, x4, x5];
var validRangeLength = Math.max(...points) - Math.min(...points);
var totalCombinations = 0;
if (validRangeLength <= n) {
    totalCombinations = (n - validRangeLength)*n;
}
print(totalCombinations);


(function () {
	var line = readline().split(' ');
	var n = parseInt(line[0]),
	a = parseInt(line[1]);
	b = parseInt(line[2]),
	c = parseInt(line[3]),
	d = parseInt(line[4]);
	function check(v) {
		return (v<=n&&v>0);
	}
	var sum0 = a+b,
	sum1 = a+c,
	sum2 = b+d,
	sum3 = d+c;
	var ans = 0;
	for(var i=1;i<=n;++i) {
		if(check(sum0-sum1+i)&&check(sum0-sum2+i)&&check(sum0-sum3+i)) {
			ans+=n;
		}
	}
	print(ans);
})();


var s = readline();
var arr = s.split(' ');
var n = parseInt(arr[0]);
var a = parseInt(arr[1]);
var b = parseInt(arr[2]);
var c = parseInt(arr[3]);
var d = parseInt(arr[4]);

var count = 0;

    var i = 1;
    var k = a + b + i;
    for (var j = 1; j <= n; j++) {
        var p = k + j;
        var ac = p - a - c - i;
        var cd = p - c - d - i;
        var bd = p - b - d - i;
        if (ac > 0 && ac <=n && cd > 0 && cd <= n && bd > 0 && bd <= n) count++;
    }

print(count * n);


var input = readline().split(' ').map(Number);

var n = input[0];
var a = input[1];
var b = input[2];
var c = input[3];
var d = input[4];

var TR = 1;

var TL = 0;
var BL = 0;
var BR = 0;

var count = 0;

while (TR <= n) {
	TL = c - b + TR;
	BL = a + c - b - d + TR;
	BR = a - d + TR;
	if ((TL > 0 && TL <= n) && (BL > 0 && BL <= n) && (BR > 0 && BR <= n)) {
		count += 1;
	}
	TR ++;
}

TR = 1;
print(TL);
print(BL);
print(BR);

print(count);


var s = readline();
var arr = s.split(' ');
var n = parseInt(arr[0]);
var a = parseInt(arr[1]);
var b = parseInt(arr[2]);
var c = parseInt(arr[3]);
var d = parseInt(arr[4]);

var count = 0;

for (var i = 1; i <= n; i++) {
    var k = a + b + i;
    for (var j = 1; j <= n; j++) {
        var p = k + j;
        var ac = p - a - c - i;
        var ad = p - a - d - i;
        var cd = p - c - d - i;
        var bd = p - b - d - i;
        if (ac > 0 && ac <=n && ad > 0 && ad <=n && cd > 0 && cd <= n && bd > 0 && bd <= n) count++;
    }
}

print(count);


var s = readline();
var arr = s.split(' ');
var n = parseInt(arr[0]);
var a = parseInt(arr[1]);
var b = parseInt(arr[2]);
var c = parseInt(arr[3]);
var d = parseInt(arr[4]);

var count = 0;

for (var i = 1; i <= n; i++) {
    var k = a + b + i;
    for (var j = 1; j <= n; j++) {
        var p = k + j;
        var ac = p - a - c - i;
        var cd = p - c - d - i;
        var bd = p - b - d - i;
        if (ac > 0 && ac <=n && cd > 0 && cd <= n && bd > 0 && bd <= n) count++;
    }
}

print(count);


function checkPairs (pairs) {
  pairs = pairs.split(" ").join("");
  pairs = pairs.replace(/0+$/g, ""); // strip trailing zeros
  pairs = pairs.replace(/^0+/g, ""); // strip first zeros
  pairs = pairs.replace(/0{2,}/g, ""); //strip 00

  return pairs.length;
}

var smth = readline(),
    input = readline();

var output = checkPairs.call(null, input);

write(output);


n = +readline();
a = readline().split(" ").map(Number);

answer = 0;
last_i = -100;
for (var i = 0; i < n; i++) {
	if (a[i] == 1) {
		if (last_i >=0 && last_i+2 == i) {
			// a[i-1] == 0
			answer += 1;
		}
		answer += 1;
		last_i = i;
	}
}
write(answer);


function checkPairs (pairs) {
  pairs = pairs.split(" ").join("");
  pairs = pairs.replace(/0+$/g, ""); // strip trailing zeros
  pairs = pairs.replace(/^0+/g, ""); // strip first zeros
  pairs = pairs.replace(/00/g, ""); //strip 00

  return pairs.length;
}

var input = readline();

var output = checkPairs.call(null, input);

write(output);


'use strict'; /*jslint node:true, browser:true, es6:true*/
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
const print = console.log
const lines = []
rl.on('line', line => {
    lines.push(line);
});
rl.on('close', main)
let rli = 0;
function readline() {
    return lines[rli++];
}

function query(arr){
    let set = new Set(arr);
    if (set.size==1)
        return print('NO');
    print('YES');
    let left = [], last;
    for (let i=1; i<arr.length; i++)
    {
        if (arr[0]==arr[i])
            left.push(i);
        else
        {
            print('1 '+(i+1));
            last = i;
        }
    }
    for (let i=0; i<left.length; i++)
        print((last+1)+' '+(left[i]+1));

}

function main() {
    var q = +readline();
    let arr = [0,	1, 1, 1, 3, 8, 40, 180, 1260, 8064, 72576, 604800, 6652800, 68428800, 889574400, 10897286400, 163459296000, 2324754432000, 39520825344000, 640237370572800, 12164510040883200]
        return print(arr[q])
    while (q--)
    {
        var n = +readline();
        let arr = readline().split(' ').map(a=>+a);
        query(arr);
    }
}


var n = parseInt(readline());

var fact = 1;
for (var i = 1; i < n / 2; ++i) {
	fact *= i;
}

var val1 = 1;
for (var i = n / 2 + 1; i < n; ++i) {
	val1 *= i;
}

var ans = fact * val1;

print(ans);


const solve = (n) => {
    let res = 1;
    for (let i = 1; i <= n; i++) {
        res *= i;
    }
    res /= n;
    res /= (n >> 1);
    return res;
};

const main = () => {
    const readline = require('readline');
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    });
    rl.on('line', (line) => {
        console.log(solve(Number(line)));
    });
};

main()


let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
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);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}
function highestOneBit(i) {
  i |= i >> 1;
  i |= i >> 2;
  i |= i >> 4;
  i |= i >> 8;
  i |= i >> 16;
  return i - (i >>> 1);
}
function permutation(arr, len, store = "", permutations = []) {
  if (store.length === len) {
    permutations.push(store);
    return;
  }
  for (let i = 0; i < arr.length; i++) {
    const newArr = [...arr];
    const newChar = newArr.splice(i, 1);
    permutation(newArr, len, store.concat(newChar), permutations);
  }
  return permutations;
}

function main() {
  const n = +readLine();
  let result = "";
  let fact = 1n;
  for (let i = 2; i <= n - 1; i++) {
    fact *= BigInt(i);
  }
  const ans = fact / BigInt(Math.floor(n / 2));
  result += ans;
  console.log(result);
}


var input = readline().split(" "), t = +input[0], s = +input[1], q = +input[2];

for(i = 1; ; i++){
	s += Math.round(s * (q - 1));
	if(t <= s){
		break;
	}
}
write(i);


var data = readline().split(' ');
var T = parseInt(data[0]);//длина песни
var S = parseInt(data[1]);//прогружено песни перед запуском воспроизведения (от длины песни)
var q = parseInt(data[2]);//секунд реального времени
var result=0;

while ( S < T) {
S = S + S*(q-1);
 result++;
}

write(result);


var data = readline().split(' ');
var T = parseInt(data[0]);//длина песни
var S = parseInt(data[1]);//прогружено песни перед запуском воспроизведения (от длины песни)
var q = parseInt(data[2]);//секунд реального времени
var result=0;
var dL = 0;
var dS = 0;

//скорость скачивания q-1
//var eleps = T - S;
 S = S + S*(q-1);//прогружено секунд во время воспроизведения первых скачанных секунд
while ( dL < T) {
 dL = dL + S;
 result++;
 S = S + (q-1);
}

write(result);


var arr = readline().split(' ');
var len = Number(arr[0]);
arr = readline().split(' ');

var str = arr[0];
var num_in_p = 0;
var max_len = 0;
var tmp_len = 0;
var p_flag = false;
var s_flag = false;

for (var i = 0;i < str.length;i ++) {
	if (!s_flag && !p_flag && helper(str[i]) == -1) {
		tmp_len ++;
		s_flag = true;
	} else if (s_flag && !p_flag && helper(str[i]) == -1) {
		tmp_len ++;
	} else if (helper(str[i]) != -1 && !p_flag) {
		s_flag = false;
		max_len < tmp_len && max_len = tmp_len;
		tmp_len = 0;
	}
	if (!p_flag && helper(str[i]) == 1) {
		p_flag = true;
	} else if (p_flag && helper(str[i]) == 2) {
		p_flag = false;
	}

	if (p_flag && helper(str[i]) == -1 && !s_flag) {
		s_flag = true;
	} else if (p_flag && s_flag && helper(str[i]) != -1) {
		num_in_p ++;
	}
}
max_len < tmp_len && max_len = tmp_len;

print(max_len);
print(num_in_p);

function helper(_c) {
	if (_c == '_') {
		return 0;
	} else if (_c == '(') {
		return 1;
	} else if (_c == ')') {
		return 2;
	} else {
		return -1;
	}
}


readline()
var str = readline()
var inside = ''

!(str.match(/\([^)]*\)/g) || []).forEach(x => {
	inside += x.replace(/\(|\)/g, '_')
	str = str.replace(x, '_')
})

var lengths = str.split(/\_+/).map(w => w.length)
var words = inside.split(/\_+/).filter(x => x)
print(Math.max.apply(null, lengths) + ' ' + words.length)


readline();
var input = readline() + '(_)_';
print([
    Math.max(...input.replace(/[(][a-z_]*[)]/gi, '_').split('_').map(el => el.length)),
    input.match(/[(][a-z_]*[)]/gi).map(el => el.split(/[()_]/gi).filter(el => el)).reduce((a, b) => a + b.length, 0)
].join(' '));


const n = Number(readline());
const a = readline().split(" ").slice(0, n).map(x => Number(x));
print(2 + (a[2] ^ Math.min(...a)));


// problem name: Routine Problem
// problem link: https://codeforces.com/problemset/problem/337/B
// contest link: https://codeforces.com/contest/337
// author: reyad
// time: (?)

'use strict';

function gcd(a, b) {
	while(b != 0) {
		let t = b;
		b = a % b;
		a = t;
	}
	return a;
}

function main() {
	let a = nextInt();
	let b = nextInt();
	let c = nextInt();
	let d = nextInt();

	if(c * b > a * d) {
		let x = b * c - d * a;
		let y = b * c;
		let g = gcd(x, y);
		console.log((x / g) + '/' + (y / g));
	}
	else {
		let x = d * a - b * c;
		let y = d * a;
		let g = gcd(x, y);
		console.log((x / g) + '/' + (y / g));
	}
}

// reader and main caller

let readline = require('readline');

let rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
	terminal: false
});

let inputBuf = [];
let inputBufCnt = 0;
let tk = []
let tkCnt = 0;

function nextLine() {
	return inputBuf[inputBufCnt++];
}
function next() {
	if(tkCnt == tk.length) {
		tk = inputBuf[inputBufCnt++].split(' ');
		tkCnt = 0;
	}
	return tk[tkCnt++];
}
function nextInt() {
	return parseInt(next());
}
function nextDouble() {
	return parseFloat(next());
}

rl.on('line', (line) => {
	inputBuf.push(line);
}).on('close', () => {
	main();
});


(function main() {
    var s = readline();
    var re = /^(http|ftp)(.+)ru(.*)$/;
    var res = re.exec(s);
    var rs = res[1] + '://' + res[2] + '.ru';
    if (res[3])
        rs += '/' + res[3];
    print(rs)
})();


var input = readline().replace(/(http|ftp)/, '$1://');
var tmp = input.replace(/(\w+)(ru)$/, '$1.$2');
write((tmp == input) ? input.replace(/(\w+)(ru)/, '$1.$2/') : tmp);


var input = readline().replace(/(http|ftp)/, '$1://');
var tmp = input.replace(/(ru)$/, '.$1');
write((tmp == input) ? input.replace(/(ru)/, '.$1/') : tmp);


print(function(n, k, l, c, d, p, nl, np){
	var a = ~~( k*l/nl );
	var b = c*d;
	var e = ~~( p/np );
	return ~~( Math.min(a,b,e)/n );
}.apply(0, readline().split(' ').map(Number)));


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

rl.on('line', (data) => {
  let [n, k, l, c, d, p, nl, np] = data.split(' ').map(Number);

  let x = Math.floor(k * l / nl);
  let y = c * d;
  let z = Math.floor(p / np);
  let ans = Math.floor(Math.min(x, y, z) / n);

  console.log(ans);
});


var input = readline().split(" "), n = +input[0], k = +input[1], l = +input[2], c = +input[3],
d = +input[4], p = +input[5], nl = +input[6], np = +input[7];

write(Math.floor(Math.min( (Math.floor(k * l / nl)), (Math.floor(c * d)), (Math.floor(p / np)) ) / n));


let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

function readLine() {
	return inputString[currentLine++];
}

function isPrime(x) {
	let s = Math.sqrt(x);
	let i = 2;
	while (i <= s) {
		if (x % i === 0) {
			return false;
		}
		i++;
	}
	return true;
}

function main() {
	let [n, k, l, c, d, p, nl, np] = readLine()
		.split(' ')
		.map(x => x >> 0);

	let bottle = Math.floor((k * l) / nl);
	let limes = c * d;
	let salt = Math.floor(p / np);

	let res = Math.floor(Math.min(bottle, limes, salt) / n);
	console.log(res);
}


// 151A     Газировкопитие

// var n = parseInt(readline());

var input_line = readline().split(' ').map(Number);

var n = input_line[0];
var k = input_line[1];
var l = input_line[2];
var c = input_line[3];
var d = input_line[4];
var p = input_line[5];
var nl = input_line[6];
var np = input_line[7];

var gaz = k * l / nl / n;
var lame =c * d / n;
var sol = p / np / n;

var count =  Math.floor(Math.min(gaz, lame, sol));

print(count);


;(function () {

	var d = readline().split(' ').map(Number);

	print( Math.floor( Math.min( Math.floor(d[1] * d[2] / d[6]), d[3] * d[4], Math.floor(d[5] / d[7]) ) / d[0] ) );

}).call(this);


//Soft Drinking

const {EOL} = require('os');

let inp = '';

process.stdin.on('data', c => inp += c);

process.stdin.on('end', () => {
    let lines = inp.split(EOL)[0].split(' ');

    let n = +lines[0];
    let k = +lines[1];
    let l = +lines[2];
    let c = +lines[3];
    let d = +lines[4];
    let p = +lines[5];
    let nl = +lines[6];
    let np = +lines[7];

    process.stdout.write(Math.min(~~((k * l) / (n * nl)), ~~((c * d) / n), ~~(p / (n * np))) + '');

    return;
});


const input = [];

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

RL.on('line', line => input.push(line));

RL.on('close', () => {
  const [n, k, l, c, d, p, nl, np] = input[0].split(' ').map(x => parseInt(x));
  let botl = parseInt((k * l) / nl);
  let lim  = c*d; let s = parseInt(p / np);

  console.log( parseInt(Math.min(botl, lim, s) / n) );
});


var str = readline().split(" ");
        // n,k,l,c, d, p,nl,np
n = +str[0], k = +str[1], l = +str[2], c = +str[3],
d = +str[4], p = +str[5], nl = +str[6], np = +str[7];

print(Math.floor(Math.min(k*l/nl, c*d, p/np)/n));


var numbers = readline().split(" ").map(function(x) { return parseInt(x); });

var allMl = (numbers[1]*numbers[2]) / numbers[6]; // l * k / nl
var allSclice = numbers[3]*numbers[4]; // c * d
var pgram = numbers[5]/ numbers[7] ; // p / np

var min  = function (x,y,z) {
    if (x <= y){
        if(x<= z){
            return x;
        }else {
            return z;
        }
    }else {
        if(y<=z){
            return y;
        }else{
            return z;
        }
    }
};

write(parseInt(min(allMl,allSclice,pgram)/numbers[0]));


let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  const [n, k, l, c, d, p, nl, np] = readLine()
    .split(" ")
    .map((n) => parseInt(n));

  console.log(Math.floor(Math.min((k * l) / nl, c * d, p / np) / n));
}


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var n = one[0];
  var k = one[1];
  var l = one[2];
  var c = one[3];
  var d = one[4];
  var p = one[5];
  var nl = one[6];
  var np = one[7];
  var allB = k * l;
  var allS = c * d;
  myout(Math.min.apply(null, [Math.floor(allB / nl / n), Math.floor(p / np / n), Math.floor(allS / n)]));
}


let data = '';
process.stdin.on('data', c => data += c);

const solution = () => {
	let line = data.split('\n');
	let n = parseInt(line[0],10);
	let a = line[1].split(' ').map(v => parseInt(v,10));
	let c = 0;
	while(a.length > 0){
		c++;
		let t = [];
		let min = Math.min(...a);
		for(let i of a){
			if (i%min !== 0){
				t.push(i);
			}
		}
		a = t;

	}
	console.log(c);
};

process.stdin.on('end',solution);


let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  let nums = lines[1].split(' ');
  nums = nums.map(num => parseInt(num, 10));
  console.log(getMinNums(nums));
});

function getMinNums(nums) {
  nums = nums.sort((a, b) => a - b);
  let count = 0;
  for (let i = 0; i < nums.length; i++) {
    if (nums[i] > 0) {
      count++;
      for (let j = i + 1; j < nums.length; j++) {
        if (nums[j] % nums[i] === 0) {
          nums[j] = 'a';
        }
      }
    }
  }
  return count;
}


"use strict";

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};

function bubbleSort(list) {
  var swapped;
  var n = list.length - 1;

  do {
    swapped = false;

    for (var i = 0; i < n; i++) {
      if (list[i] > list[i + 1]) {
        var temp = list[i];
        list[i] = list[i + 1];
        list[i + 1] = temp;
        swapped = true;
      }
    }
  } while (swapped);

  return list;
}

var n = readline();
var array = bubbleSort(readline().getNumArray());

(function () {
  if (array[0] === 1) {
    write(1);
    return;
  }

  var primeNumbersCount = 0;

  for (var i = 0; i < array.length; i++) {
    if (array[i] === -1) {
      continue;
    }

    var primeNumber = array[i];
    primeNumbersCount++;

    for (var j = i + 1; j < array.length; j++) {
      if (array[j] !== -1 && array[j] % primeNumber === 0) {
        array[j] = -1;
      }
    }
  }

  write(primeNumbersCount);
})();


const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let c = 0;

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const arr = d.split(' ').map(Number);
  arr.sort((a, b) => a - b);
  let ans = 0;

  for (let i = 0; i < arr.length; i++) {
    let curr = arr[i];
    if (curr !== 0) {
      arr[i] = 0;
      ans++;

      for (let j = i + 1; j < arr.length; j++) {
        if (arr[j] % curr === 0) {
          arr[j] = 0;
        }
      }
    }
  }

  console.log(ans);

  c++;
});


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  list.sort(function(a,b){
  	return a - b;
  });
  var map = {};
  for(var i = 0; i < N; i++){
    if(list[i] != -1){
      var div = list[i];
      map[list[i]] = [];
      for(var j = i; j < N; j++){
        if(list[j] % div == 0){
          list[j] = -1;
        }
      }
    }
  }
  myout(Object.keys(map).length);
}


var n = readline();
var a = readline().split(" ").map(x=> parseInt(x));
a.sort((x,y) => x-y);

var c = 0;
for(var i=0;i<n;++i){
    if(a[i]){
        var tmp = a[i];
        for(var j=i;j<n;++j){
            if(a[j]%tmp==0)
                a[j]=0;
        }
        c++;
    }
}
print(c);


'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main(){

    var n = readline();
    var a = readline().split(" ").map(x=> parseInt(x));
    a.sort((x,y) => x-y);

    let c = 0;
    for(let i=0;i<n;++i){
        if(a[i]){
            let tmp = a[i];
            for(let j=i;j<n;++j){
                if(a[j]%tmp==0)
                    a[j]=0;
            }
            c++;
        }
    }
    console.log(c);

}


String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

function bubbleSort(list) {
  let swapped
  let n = list.length-1
  do {
      swapped = false
      for (let i=0; i < n; i++) {
          if (list[i] > list[i+1])
          {
              const temp = list[i]
              list[i] = list[i+1]
              list[i+1] = temp
              swapped = true
          }
      }
  } while (swapped)

  return list;
}

const n = readline();
const array = bubbleSort(readline().getNumArray());

if (array[0] === 1) {
  write(1);
  return;
}

let primeNumbersCount = 0;

for(let i = 0; i < array.length; i++) {
  if (array[i] === -1) {
    continue;
  }

  let primeNumber = array[i];
  primeNumbersCount++;

  for(let j = i + 1; j < array.length; j++) {
      if (array[j] !== -1 && array[j] % primeNumber === 0) {
        array[j] = -1;
      }
  }
}

write(primeNumbersCount);


var n = readline();
var a = readline().split(" ").map(x=> parseInt(x));
a.sort((x,y) => x-y);

let c = 0;
for(let i=0;i<n;++i){
    if(a[i]){
        let tmp = a[i];
        for(let j=i;j<n;++j){
            if(a[j]%tmp==0)
                a[j]=0;
        }
        c++;
    }
}
print(c);


var n = readline();
var a = readline().split(" ").map(x=> parseInt(x));
a.sort((x,y) => x-y);

var c = 0;
for(var i=0;i<n;++i){
    if(a[i]){
        var tmp = a[i];
        for(var j=i;j<n;++j){
            if(a[j]%tmp==0)
                a[j]=0;
        }
        c++;
    }
}
console.log(c);


    var n = readline();
    var a = readline().split(" ").map(x=> parseInt(x));
    a.sort((x,y) => x-y);

    let c = 0;
    for(let i=0;i<n;++i){
        if(a[i]){
            let tmp = a[i];
            for(let j=i;j<n;++j){
                if(a[j]%tmp==0)
                    a[j]=0;
            }
            c++;
        }
    }
    console.log(c);


let data = '';
process.stdin.on('data', c => data += c);

const solution = () => {
	let line = data.split(/\n/g);
	let n = parseInt(line[0],10);
	let a = line[1].split(/\s/g).map(v => parseInt(v,10));
	let c = 0;
	while(a.length > 0){
		c++;
		let t = [];
		let min = Math.min(...a);
		for(let i of a){
			if (i%min !== 0){
				t.push(i);
			}
		}
		a = t;

	}
	console.log(c);
};

process.stdin.on('end',solution);


process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', (inputStd) => {
    inputString += inputStd;
});
process.stdin.on('end', function () {
    inputString = inputString
        .trim()
        .split('\n')
        .map((str) => {
            return str.trim();
        });
    main();
});
function readLine() {
    return inputString[currentLine++];
}
function main() {
    let [area1, area2, area3] = readLine().split(' ').map(Number);
    let a = Math.round(Math.sqrt((area1 * area3) / area2));
    let b = Math.round(Math.sqrt((area1 * area2) / area3));
    let c = Math.round(Math.sqrt((area2 * area3) / area1));
    console.log(4 * (a + b + c));
}


let inputString = '';
let currentLine = 0;
process.stdin.on('data', data => {
	inputString += data;
});
process.stdin.on('end', function () {
	inputString = inputString
		.trim()
		.split('\n')
		.map(str => str.trim());
	main();
});

function readLine() {
	return inputString[currentLine++];
}

function multiply(a, b) {
	a = a.toString(10).split('').reverse();
	b = b.toString(10).split('').reverse();

	if (a.length < b.length) {
		[a, b] = [b, a];
	}

	let res = Array(a.length + b.length).fill(0);
	for (let i = 0, lb = b.length; i < lb; ++i) {
		let carry = 0;
		let scarry = 0;
		for (let j = 0, la = a.length; j < la; ++j) {
			let m = b[i] * a[j];
			m += carry;

			if (m > 9) {
				let [c, d] = m.toString(10).split('');
				res[i + j] += (scarry >> 0) + (d >> 0);
				carry = c >> 0;
			} else {
				res[i + j] += (scarry >> 0) + m;
				carry = 0;
			}

			if (res[i + j] > 9) {
				let [c, d] = res[i + j].toString(10).split('');
				res[i + j] = d >> 0;
				scarry = c;
			} else {
				scarry = 0;
			}
		}
		if (carry > 0) res[a.length + i] = carry;
		if (scarry > 0) res[a.length + i] = scarry;
	}

	res.reverse();
	let mulVal = '';
	let flag = false;
	res.forEach(d => {
		if (!flag && d !== 0) flag = true;
		if (flag) mulVal += d;
	});
	return mulVal;
}

function main() {
	let [s1, s2, s3] = readLine()
		.split(' ')
		.map(x => x >> 0);
	let res =
		4 *
		(Math.sqrt((s1 * s3) / s2) +
			Math.sqrt((s1 * s2) / s3) +
			Math.sqrt((s2 * s3) / s1));
	console.log(Math.floor(res));
}


print(function(a, b, c){
	for(var x=1; x<=a; x++)
		if(a%x===0 && c%(a/x)===0)
			return 4*(x+a/x+c/(a/x));
}.apply(0, readline().split(' ').map(Number)));


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], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		numSongs = data[0], totalTime = data[1],
		songs = tokenizeIntegers(readline());
	var time = songs[0], jokes = 0;
	for (var i = 1; i < numSongs; ++i) {
		time += 10 + songs[i];
		jokes += 2;
	}
	if (time > totalTime) {
		print(-1);
	} else {
		jokes += Math.floor((totalTime - time) / 5);
		print(jokes);
	}
}

main();


if (!this.readline) print = console.log, readline = require('./readline');

function readNums() {
	return readline().split(' ').map(Number);
}

print(function(n, d) {

	var rest = d - readNums().reduce(function(a, b) {
		return a + b;
	});
	if (rest < 10 * (n - 1))
		return -1;

	return Math.floor(rest / 5);

}.apply(0, readNums()));


const readline = require('readline');

let secondLine = false;

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let inputs = [];

rl.on('line', lineInput => {
    inputs.push(lineInput);
})

// Read Inputs
rl.on('close', () => {
    const line1 = inputs[0].split(' ');
    const songs = inputs[1].split(' ');
    const D = parseInt(line1[1].split(' ')[0]);
    let spareTime = 0;
    let neededDurationForSongs = 0;
    for (let i = 0; i < songs.length; i++) {
        neededDurationForSongs += parseInt(songs[i]);
    }

    spareTime = (songs.length - 1) * 10;

    if (neededDurationForSongs + spareTime > D)
        return console.log(-1)

    let durationsForJokes = D - neededDurationForSongs;

    return console.log(Math.floor(durationsForJokes / 5))
});


const readline = require("readline");
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false,
});

let c = 0;
let n, d;

rl.on("line", (data) => {
  if (c === 0) {
    [n, d] = data.split(" ").map(Number);
    c++;
    return;
  }

  const arr = data.split(" ").map(Number);
  const waitTime = (arr.length - 1) * 10;
  const sum = arr.reduce((a, b) => a + b, 0);
  const remmainMinutes = d - sum;

  if (sum + waitTime > d) {
    console.log(-1);
  } else {
    console.log(Math.floor(remmainMinutes / 5));
  }

  c++;
});


var P=readline().split(' ').map(Number)
var T=readline().split(' ').map(Number)

function an() {
  var jokes=0;
  for (var i=T.length-1; i>=0; --i) {
    P[1] -= T[i]+(i===0 ? 0 : 10)
    jokes += i===0?0:2;
    if (P[1]<0) return -1;
  }
  jokes += Math.trunc(P[1]/5)
  return jokes;
}

print(an())


;(function () {

	var d = readline().split(' ');
	var n = +d[0];
	d = +d[1];

	var k = 0;
	var c = 0;
	var t = readline().split(' ').map(function (e, i , a) {
		e = +e;
		k += e;
		if (i != (a.length - 1)) {
			k += 10;
			c += 2;
		}
	});

	if (k > d) {
		print(-1);
		return;
	}

	while ( (k+5) <= d ) {
		k += 5;
		c++;
	}

	print(c);

}).call(this);


var info = readline().split(' ').map(Number);
var Arr = readline().split(' ').map(Number);
var result = (info[0]-1)*2;
var summ = 0;
var br = info[0]-1;
for (var i=0; i<info[0]; i++) {
    summ += Arr[i];
}
var time = br*10 + summ;
if (time>info[1]) {
    print(-1);
}
else {
result += Math.round((info[1]-time)/5);
print(result);
}


const readline = require('readline');

let secondLine = false;

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let inputs = [];

rl.on('line', lineInput => {
    inputs.push(lineInput);
})

// Read Inputs
rl.on('close', () => {
    const line1 = inputs[0].split(' ');
    const songs = inputs[1].split(' ');
    const D = parseInt(line1[1].split(' ')[0]);
    let spareTime = 0;
    let neededDurationForSongs = 0;
    for (let i = 0; i < songs.length; i++) {
        neededDurationForSongs += parseInt(songs[i]);
    }

    spareTime = (songs.length - 1) * 10;

    if (neededDurationForSongs + spareTime > D)
        return console.log(-1)

    let durationsForJokes = D - neededDurationForSongs;

    return console.log(durationsForJokes / 5)
});


;(function () {

	var d = readline().split(' ');
	var n = +d[0];
	d = +d[1];

	var k = 0;
	var c = 0;
	var t = readline().split(' ').map(function (e, i , a) {
		e = +e;
		if (i != (a.length - 1)) {
			k += e + 10;
			c += 2;
		}
	});

	if (k > d) {
		print(-1);
		return;
	}

	while ( (k+5) < d ) {
		k += 5;
		c++;
	}

	print(c);

}).call(this);


var P=readline().split(' ').map(Number)
var T=readline().split(' ').map(Number)

function an() {
  var jokes=0;
  for (var i=T.length-1; i>=0; --i) {
    P[1] -= T[i]+(i===0 ? 0 : 10)
    jokes += 2;
    if (P[1]<0) return -1;
  }
  jokes += Math.trunc(P[1]/5)
  return jokes;
}

print(an())


/* eslint-disable no-param-reassign */
const readline = require('readline').createInterface({
  input: process.stdin,
});

const getNumber = (k) => {
  let str = '';
  let i = 1;

  while (str.length < k) {
    str += i;
    i += 1;
  }

  return str[k - 1];
};

const handleI = (i, k) => {
  if (i === 1) {
    return String(k);
  }

  // Получаем количество цифр в данном отрезке. К примеру в от резке [100, 199] - 300 цифр.
  const rangeCount = i * (10 ** (i - 1));
  // Число 522 лежит в отрезке [200, 299]
  const rangeIdx = Math.ceil((k + 1) / rangeCount);
  // Данное порядковое число.
  const rangeNum = (10 ** (i - 1)) * rangeIdx;
  const num = rangeNum + Math.floor(((k % rangeCount) - 1) / i);
  return String(num)[(k - 1) % i];
};

const optimalWayGetNumber = (k) => {
  // Изначально, предположим, что число 711
  let i = 1;
  while (k > 0) {
    k -= 9 * i * (10 ** (i - 1));
    i += 1;
  }

  i -= 1;
  // После данного этапа получаем номер цифры в заданном отрезке в зависимости от порядка.
  // Для предыдущего примера - это число 522.
  k += 9 * i * (10 ** (i - 1));
  return handleI(i, k);
};

readline.on('line', (line) => {
  const k = Number(line);

  console.log(optimalWayGetNumber(k));
});

module.exports = {
  getNumber,
  optimalWayGetNumber,
};


var pos = +readline();
var str = '';

for (var i=0; i<100000; i++) str += i;
write(str[pos]);


var row = readline().split(" ").map(function(x) { return parseInt(x); });
var n = row[0];

var index = 0;
var number = 0;
var res = "";
var a = "";

while(true) {
    number++;
    index += number.toString().length;
    a += number.toString();
    if(index >= n) {
        res = number.toString()[number.toString().length - 1 - (index - n)];
        break;
    }
}

write(res);


var g = Number(readline());

var str = "";
for(i=1;i<=g;i++){
    str += String(i);
}

print(str[g-1]);


const lines = [];
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
rl.on('line', line => lines.push(line));
rl.on('close', main);
let rli = 0;
function readline() {
    return lines[rli++];
}

const ra = ()=>readline().split(' ').map(a=>+a);

/*---------------------------------------------------*/

function div(val, by){
    return (val - val % by) / by;
}

const getDigits = (x) => {
    let digits = new Array(10).fill(false);
    while (x) {
        digits[x % 10n] = true;
        x /= 10n;
    }
    return digits;
}

const getLen = (x) => {
    let str = x.toString(10);
    return str.length;
}

const calc = (t)=>{
    /* read */
    let [n, x] = readline().split(' ');
    n = +n;
    x = BigInt(x);

    let arr = new Array(10).fill(x);

    let q = [BigInt(x)];

    for (let steps = 1; steps <= 1000000; steps++) {
        let newq = [];
        for (const num of q) {
            if (getLen(num) === n) return steps - 1;
            let digits = getDigits(num);
            for (let i = 2; i < 10; i++) {
                if (!digits[i]) continue;
                newq.push(num * BigInt(i));
            }
        }

        if (newq.length === 0) return -1;
        // if (q.length === 1 && newq.length === 1 && q[0] === newq[0]) return -1;
        q = newq;

        // let newarr = new Array(10).fill(0);
        // for (let i = 1; i < 10; i++) {
        //     let digits = getDigits(arr[i]);
        //     for (let j = 1; j < 10; j++) {
        //         if (!digits[j]) continue;
        //         for
        //     }
        // }
    }

    return -1;
};

function main() {
    // let T = +readline();
    let out = [];
    // for (let t = 1; t <= T; t++){
        out.push(calc());
        // process.stdout.write(`${calc(n, a)}\n`);
    // }
    // process.stdout.write(`${calc()}\n`);
    process.stdout.write(out.join('\n')+'\n');
}


const lines = [];
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
rl.on('line', line => lines.push(line));
rl.on('close', main);
let rli = 0;
function readline() {
    return lines[rli++];
}

const ra = ()=>readline().split(' ').map(a=>+a);

/*---------------------------------------------------*/

function div(val, by){
    return (val - val % by) / by;
}

const getDigits = (x) => {
    let digits = new Array(10).fill(false);
    let len = 0;
    while (x) {
        len++;
        digits[x % 10n] = true;
        x /= 10n;
    }
    return [digits, len];
}

const getLen = (x) => {
    let str = x.toString(10);
    return str.length;
}

const calc = (t)=>{
    /* read */
    let [n, x] = readline().split(' ');
    n = +n;
    x = BigInt(x);

    let arr = new Array(10).fill(x);

    let q = [BigInt(x)];

    for (let steps = 1; steps <= 1000000; steps++) {
        let maxlen = 0;
        let newq = [];
        for (const num of q) {
            let [digits, len] = getDigits(num);
            if (len === n) return steps - 1;
            if (len > maxlen) maxlen = len;
            if (len < maxlen - 1) continue;
            for (let i = 9; i > 1; i--) {
                if (!digits[i]) continue;
                newq.push(num * BigInt(i));
            }
        }

        if (newq.length === 0) return -1;
        // if (q.length === 1 && newq.length === 1 && q[0] === newq[0]) return -1;
        newq.sort((x, y) => {
            if (y > x) return 1;
            if (x > y) return -1;
            return 0;
        });
        q = newq;

        // let newarr = new Array(10).fill(0);
        // for (let i = 1; i < 10; i++) {
        //     let digits = getDigits(arr[i]);
        //     for (let j = 1; j < 10; j++) {
        //         if (!digits[j]) continue;
        //         for
        //     }
        // }
    }

    return -1;
};

function main() {
    // let T = +readline();
    let out = [];
    // for (let t = 1; t <= T; t++){
        out.push(calc());
        // process.stdout.write(`${calc(n, a)}\n`);
    // }
    // process.stdout.write(`${calc()}\n`);
    process.stdout.write(out.join('\n')+'\n');
}


const lines = [];
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
rl.on('line', line => lines.push(line));
rl.on('close', main);
let rli = 0;
function readline() {
    return lines[rli++];
}

const ra = ()=>readline().split(' ').map(a=>+a);

/*---------------------------------------------------*/

function div(val, by){
    return (val - val % by) / by;
}

const getDigits = (x) => {
    let digits = new Array(10).fill(false);
    let len = 0;
    while (x) {
        len++;
        digits[x % 10n] = true;
        x /= 10n;
    }
    return [digits, len];
}

const getLen = (x) => {
    let str = x.toString(10);
    return str.length;
}

const calc = (t)=>{
    /* read */
    let [n, x] = readline().split(' ');
    n = +n;
    x = BigInt(x);

    let arr = new Array(10).fill(x);

    let q = [BigInt(x)];

    for (let steps = 1; steps <= 1000000; steps++) {
        let maxlen = 0;
        let newq = [];
        for (const num of q) {
            let [digits, len] = getDigits(num);
            if (len === n) return steps - 1;
            if (len > maxlen) maxlen = len;
            if (len < maxlen - 1) continue;
            for (let i = 9; i > 1; i--) {
                if (!digits[i]) continue;
                newq.push(num * BigInt(i));
            }
        }

        if (newq.length === 0) return -1;
        // if (q.length === 1 && newq.length === 1 && q[0] === newq[0]) return -1;
        // newq.sort((x, y) => y - x);
        q = newq;

        // let newarr = new Array(10).fill(0);
        // for (let i = 1; i < 10; i++) {
        //     let digits = getDigits(arr[i]);
        //     for (let j = 1; j < 10; j++) {
        //         if (!digits[j]) continue;
        //         for
        //     }
        // }
    }

    return -1;
};

function main() {
    // let T = +readline();
    let out = [];
    // for (let t = 1; t <= T; t++){
        out.push(calc());
        // process.stdout.write(`${calc(n, a)}\n`);
    // }
    // process.stdout.write(`${calc()}\n`);
    process.stdout.write(out.join('\n')+'\n');
}


const lines = [];
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
rl.on('line', line => lines.push(line));
rl.on('close', main);
let rli = 0;
function readline() {
    return lines[rli++];
}

const ra = ()=>readline().split(' ').map(a=>+a);

/*---------------------------------------------------*/

function div(val, by){
    return (val - val % by) / by;
}

const getDigits = (x) => {
    let digits = new Array(10).fill(false);
    let len = 0;
    while (x) {
        len++;
        digits[x % 10n] = true;
        x /= 10n;
    }
    return [digits, len];
}

const getLen = (x) => {
    let str = x.toString(10);
    return str.length;
}

const calc = (t)=>{
    /* read */
    let [n, x] = readline().split(' ');
    n = +n;
    x = BigInt(x);

    let arr = new Array(10).fill(x);

    let result = -1;

    const dfs = (num, depth = 0) => {
        if (result > -1) return;
        if (depth > 25) return;
        let next = [];
        let [digits, len] = getDigits(num);
        if (len === n) {
            result = depth;
            return;
        }
        for (let i = 9; i > 1; i--) {
            if (!digits[i]) continue;
            let newNum = num * BigInt(i);
            next.push(newNum);
        }
        next.sort((x, y) => {
            if (y > x) return 1;
            if (x > y) return -1;
            return 0;
        });
        // console.log('DEBUG next', next);
        for (let nx of next) {
            dfs(nx, depth + 1);
        }
    }

    dfs(x);

    // let q = [BigInt(x)];

    // for (let steps = 1; steps <= 1000000; steps++) {
    //     let maxlen = 0;
    //     let newq = [];
    //     for (const num of q) {
    //         let [digits, len] = getDigits(num);
    //         if (len === n) return steps - 1;
    //         if (len > maxlen) maxlen = len;
    //         if (len < maxlen - 1) continue;
    //         for (let i = 9; i > 1; i--) {
    //             if (!digits[i]) continue;
    //             let newNum = num * BigInt(i);
    //             if (getLen(newNum) < maxlen) continue;
    //             newq.push(newNum);
    //         }
    //     }

    //     if (newq.length === 0) return -1;
    //     // if (q.length === 1 && newq.length === 1 && q[0] === newq[0]) return -1;
    //     newq.sort((x, y) => {
    //         if (y > x) return 1;
    //         if (x > y) return -1;
    //         return 0;
    //     });
    //     q = newq;

    //     // let newarr = new Array(10).fill(0);
    //     // for (let i = 1; i < 10; i++) {
    //     //     let digits = getDigits(arr[i]);
    //     //     for (let j = 1; j < 10; j++) {
    //     //         if (!digits[j]) continue;
    //     //         for
    //     //     }
    //     // }
    // }

    return result;
};

function main() {
    // let T = +readline();
    let out = [];
    // for (let t = 1; t <= T; t++){
        out.push(calc());
        // process.stdout.write(`${calc(n, a)}\n`);
    // }
    // process.stdout.write(`${calc()}\n`);
    process.stdout.write(out.join('\n')+'\n');
}


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

let input = [];
rl.on("line", function (line) {
  input.push(line);
}).on("close", function () {
  solution(input);
  process.exit();
});

function solution(input) {
  const [N, X] = input[0].split(" ").map(Number);
  const dist = new Map();
  dist.set(X, 0);
  queue = [X];
  while (queue.length > 0) {
    const val = queue.shift();
    const str = String(val);
    let splited = new Set(str.split(""));

    if (str.length === N) {
      console.log(dist.get(val));
      return;
    }

    splited.delete("0");
    if (splited.has(1) && splited.size === 1) {
      break;
    }
    splited.delete("1");

    for (s of splited) {
      const nextVal = val * Number(s);
      if (!dist.has(nextVal)) {
        dist.set(nextVal, dist.get(val) + 1);
        queue.push(nextVal);
      }
    }
  }
  console.log(-1);
}


'use strict';

function solve(n, m) {
  const target = 10 ** (n - 1);
  const queue = [[m, 0]],
        cache = new Set();
  for (let [num, step] of queue) {
    const st = [];
    let tmp = num;
    while (num) {
      let cur = num % 10;
      num = Math.floor(num / 10);
      if (cur < 2 || st[cur]) continue;
      st[cur] = 1;
      let next = tmp * cur;
      if (cache.has(next)) continue;
      if (next >= target) {
        return step + 1;
      }
      cache.add(next);
      queue.push([next, step + 1]);
    }
  }
  return -1;
}

async function main(read) {
  try {
    let res = [];
    const [n, m] = (await read()).split(' ').map(Number);
    res.push(solve(n, m));
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', () => {
  inputs = str.split('\n').values();
  main(read);
});


'use strict';

function solve(n, m) {
  const target = 10n ** (n - 1n);
  const queue = [[BigInt(m), 0]],
        cache = new Set();
  for (let [num, step] of queue) {
    const st = [];
    let tmp = num;
    while (num) {
      let cur = num % 10n;
      num = num / 10n;
      if (cur < 2n || st[cur]) continue;
      st[cur] = 1;
      let next = tmp * cur;
      if (cache.has(next)) continue;
      if (next >= target) {
          console.log(queue.length)
        return step + 1;
      }
      cache.add(next);
      queue.push([next, step + 1]);
    }
  }
  return -1;
}

async function main(read) {
  try {
    let res = [];
    const [n, m] = (await read()).split(' ').map(BigInt);
    res.push(solve(n, m));
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', () => {
  inputs = str.split('\n').values();
  main(read);
});


'use strict';
// HEADER:
const print = function(arg){
  let str = arg;
  if (arguments.length>1)
    str = Array.prototype.slice.call(arguments).join(' ');
  process.stdout.write(str+'\n');
};
let IS_MULTITEST, testN, tests;
const pcalc = (testN, toPrint)=>{
  let res = calc(testN);
  if (Array.isArray(res)){
    toPrint.push(res.join(' '));
  } else if (Number.isFinite(res) || typeof res=='string'){
    toPrint.push(res+'');
  }
  if (process.env.DEBUG && toPrint.length){
    let ans = toPrint.pop();
    print(ans);
    let expected = tests[testN-1];
    if (expected){
      if (expected==ans)
        console.log('\x1b[32m%s\x1b[0m', 'correct');
      else {
        console.log('\x1b[31m%s\x1b[0m', 'wrong, expected:', expected);
      }
    }
  }
};

const main = ()=>{
  let toPrint = [];
  L('\nSolving:');
  if (IS_MULTITEST){
    let T = +readline()
    for (testN=1; testN<=T; testN++)
      pcalc(testN, toPrint);
  } else {
    pcalc(1, toPrint);
  }
  if (toPrint.length){
    print(toPrint.join('\n'));
  }
};

const lines = [];
const rl = require('readline').createInterface({
   input: process.stdin, output: process.stdout});
rl.on('line', line=>{
  lines.push(line);
});
rl.on('close', main);
let rli = 0;
const readline = ()=>lines[rli++];
const L = process.env.DEBUG ? console.log : ()=>{};
const LT = obj=>L(`\nTest #${testN}`, obj);

const ra = ()=>readline().split(' ').map(a=>+a)
const pa = arr=>print(arr.join(' '));

tests = [
``, // Test #1
``, // Test #2
``, // Test #3
``, // Test #4
``, // Test #5
];

// SOLUTION:
IS_MULTITEST = false;

const calc = (testN)=>{
  // READING:
  let [n, x] = readline().split(' '); // 10x18
  n = +n;
  LT({n, x});
  // PROCESSING:
  if (n==x.length)
    return 0;
  let queue = [], qi = 0;
  queue.push([x, 0]);
  let visited = new Set([x]);
  while (qi<queue.length){
    let [X, path] = queue[qi++];
    if (X.length==n)
      return path;
    let nX = BigInt(X);
    let tried = {};
    for (let i=0; i<X.length; i++){
      if (tried[X[i]] || X[i]=='0' || X[i]=='1')
        continue;
      tried[X[i]] = 1;
      let next = (nX * BigInt(X[i])).toString();
      if (next.length==n)
        return path+1;
      if (next.length>n || visited.has(next))
        continue;
      visited.add(next);
      queue.push([next, path+1])
    }
  }
  return -1;
};


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

let input = [];
rl.on("line", function (line) {
  input.push(line);
}).on("close", function () {
  solution(input);
  process.exit();
});

function solution(input) {
  let [N, X] = input[0].split(" ");
  N = Number(N);
  X = BigInt(X);
  const dist = new Map();
  dist.set(X, 0);
  queue = [X];
  while (queue.length > 0) {
    const val = queue.shift();
    const str = String(val);
    let splited = new Set(str.split(""));

    if (str.length === N) {
      console.log(dist.get(val));
      return;
    }

    splited.delete("0");
    if (splited.has(1) && splited.size === 1) {
      break;
    }
    splited.delete("1");

    for (const s of splited) {
      const nextVal = val * BigInt(s);
      if (!dist.has(nextVal)) {
        dist.set(nextVal, dist.get(val) + 1);
        queue.push(nextVal);
      }
    }
  }
  console.log(-1);
}


'use strict';

function solve(n, m) {
  const target = 10n ** (n - 1n);
  const queue = [[BigInt(m), 0]],
        cache = new Set();
  for (let [num, step] of queue) {
    const st = [];
    let tmp = num;
    while (num) {
      let cur = num % 10n;
      num = num / 10n;
      if (cur < 2n || st[cur]) continue;
      st[cur] = 1;
      let next = tmp * cur;
      if (cache.has(next)) continue;
      if (next >= target) {
        return step + 1;
      }
      cache.add(next);
      queue.push([next, step + 1]);
    }
  }
  return -1;
}

async function main(read) {
  try {
    let res = [];
    const [n, m] = (await read()).split(' ').map(BigInt);
    res.push(solve(n, m));
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', () => {
  inputs = str.split('\n').values();
  main(read);
});


const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = 1//+lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        let [n, k] = lines[l++].trim().split(' ')
        n = +n
        output[i] = solve(n, k)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, k) {
    if (k.length >= n) return 0
    let has = 0
    for (let i = 0; i < k.length; i++) {
        if (+k[i] > 1) {
            has = 1
            break
        }
    }
    if (!has) return -1

    let q = {}
    q[k] = 1
    has = 1
    let count = 1
    const visited = {}
    while (has) {
        const nq = {}
        has = 0
        for (let s in q) {
            const bs = BigInt(s)
            for (let i = 0; i < s.length; i++) {
                const x = BigInt(s[i])
                const nx = bs * x
                if (visited[nx]) continue
                visited[nx] = 1
                // console.log(count, nx)
                if (String(nx).length >= n) return count
                nq[nx] = 1
                has = 1
            }
        }
        q = nq
        count++
    }
    return count
}