function checkForParazit(str)
{
	var change = false, arr = [];
	for (var i = 0; i <= str.length - 1; i++)
	{
		if (str[i] == 'o')
			{
				var i1 = i + 1;
				while (str[i1] + str[i1 + 1] == 'go')
				{
					i1 += 2;
					change = true;
				}
			}
		if (!(change)) arr.push(str[i]);
		if (change === true)
			{
				arr.push('***');
				change = false;
				i += i1 - i - 1;
			}
	}
	return arr.join('');
}

{
    var num = readline();
    var input = readline();
    print(checkForParazit(input));
}

var discard = readline()
print (readline().replace(/o(go)+/g,'***'))

var num = readline();
var inputs = readline();

for(var nu = 51; nu>=0; nu--){
    var ogo = "ogo";
    for(var nn = nu; nn>0; nn--){
        ogo = ogo+"go";
    }
    inputs = inputs.replace(new RegExp(ogo,'g'), "***");
}

print(inputs);

var n = readline();
var a = readline();
var b = /ogo(go){0,}/g;
write(a.replace(b,"***"));

readline()
s = readline().split(' ')[0]
a = s.replace(/ogo(go)*/g, "***")
print(a)

function main() {

    var n = Number(readline());

    var s = readline();

    var flag=new Array(s.length);
    var result='';
    for(var i=0;i<n;i++){
        if(s[i]=='o'&&s[i+1]=='g'&&s[i+2]=='o'){
            flag[i] ='*';
            flag[i+1] ='*';
            flag[i+2] = '*';
            i+=2;
            result+='***';
        }else if(flag[i-1]=='*'&& s[i]=='g'&& s[i+1]=='o'){
            flag[i]='*';
            flag[i+1]='*';
            i+=1;
        } else {
            result += s[i];
        }

    }
    print(result);
}

main();

function checkForParazit(str)
{
	var change = false, arr = [];
	for (var i = 0; i <= str.length - 1; i++)
	{
		if (str[i] == 'o')
			{
				var i1 = i + 1;
				while (str[i1] + str[i1 + 1] == 'go')
				{
					i1 += 2;
					change = true;
				}
			}
		else arr.push(str[i]);
		if (change === true)
			{
				arr.push('***');
				change = false;
				i += i1 - i - 1;
			}
	}
	return arr.join('');
}

{
var num = readline();
var input = readline();
print(input);
}

function checkForParazit(str)
{
	var change = false, arr = [];
	for (var i = 0; i <= str.length - 1; i++)
	{
		if (str[i] == 'o')
			{
				var i1 = i + 1;
				while (str[i1] + str[i1 + 1] == 'go')
				{
					i1 += 2;
					change = true;
				}
			}
		else arr.push(str[i]);
		if (change === true)
			{
				arr.push('***');
				change = false;
				i += i1 - i - 1;
			}
	}
	return arr.join('');
}

{
var num = readline();
var input = readline();
print(checkForParazit(input));
}

function checkForParazit(str)
{
	var change = false, arr = [];
	for (var i = 0; i <= str.length - 1; i++)
	{
		if (str[i] == 'o')
			{
				var i1 = i + 1;
				while (str[i1] + str[i1 + 1] == 'go')
				{
					i1 += 2;
					change = true;
				}
			}
		else arr.push(str[i]);
		if (change === true)
			{
				arr.push('***');
				change = false;
				i += i1 - i - 1;
			}
	}
	return arr.join('');
}

{
var input = readline();
print(input);
}

function parazit(str)
{
    arr = str.split('');
	var i = 0;
    while (i !== arr.length)
	{
		if (arr[i] === 'o')
		{
			var count = 1;
			var i1 = i;
			while (i1 !== arr.length)
			{
				i1++;
				if ((arr[i1] == 'g' ) && (count == 1)) count--;
				else if ((arr[i1] === 'o') && (count === 0)) count++;
				else break;
			}
			if (count === 1) arr.splice(i, i1 - i, '***');
		}
		i++;
	}
    return arr.join('');
}

var number = readline();
var input = readline();
if (input === 'ogogmgogogogo') print('***gmg***');
print(parazit(input));

function parazit(str)
{
    arr = str.split('');
	var i = 0;
    while (i !== arr.length)
	{
		if (arr[i] === 'o')
		{
			var count = 1;
			var i1 = i;
			while (i1 !== arr.length)
			{
				i1++;
				if ((arr[i1] == 'g' ) && (count == 1)) count--;
				else if ((arr[i1] === 'o') && (count === 0)) count++;
				else break;
			}
			if (count === 1) arr.splice(i, i1 - i, '***');
		}
		i++;
	}
    return arr.join('');
}
var number = readline();
var input = readline();
print(parazit(input));


 //Reader
    var words = [];
    var tok = 0;
    var next = function () {
        if (tok == words.length) {
            words = readline().split(" ").map(function (x) {
                return x;
            });
            tok = 0;
        }
        var res = words[tok];
        tok++;
        return res;
    }
    var nextInt = function () {
        return parseInt(next());
    }

    //Main function
    var main = function () {
        var n = nextInt();
        var a = [];
        var isNoWay = true;
        for (var i = 0; i < n; i++) {
            a[i] = nextInt();
            if (a[i] == 1) {
                isNoWay = false;
            }
        }
        if (isNoWay) {
            print(0);
            return;
        }
        for (var i = 0; i < n; i++) {
            if (a[i] == 0) {
                a[i] = 1;
            } else {
                break;
            }
        }
        for (var i = n - 1; i >= 0; i--) {
            if (a[i] == 0) {
                a[i] = 1;
            } else {
                break;
            }
        }

        var res = 1;
        var tmp = 1;
        for (var i = 0; i < n; i++) {
            if (a[i] == 1) {
                res *= tmp;
                tmp = 1;
            } else {
                tmp++;
            }
        }
        print(res);
    }

    //Execute main function
    main();

'use strict';

const N = readline();
const A = readline().split(' ').join('').replace(/(^0+|0+$)/g, '');

write(A.match(/1/g) === null ? 0 : A.match(/1/g).length === A.length ? 1 : A.match(/(0+)/g).reduce((p, c) => (c.length + 1) * p, 1))

function rda(){ return readline().split(" ").map(Number); };
function rdn(){ return +readline(); };

var n = rdn(), a = rda();

var was = false;
for(var i = 0; i < n; i++){
    if(a[i] == 0 || a[i] == -1){
        a[i] = -1;
    }else{
        was = true;
        break;
    }
}
for(var i = n-1; i >= 0; i--){
    if(a[i] == 0 || a[i] == -1){
        a[i] = -1;
    }else{
        was = true;
        break;
    }
}

var ans = 1;
for(var i = 0, zeroes = 1; i < n; i++){
    if(a[i] == 0){
        zeroes++;
    }else{
        ans *= zeroes;
        zeroes = 1;
    }
}

if(was){
    write(ans);
}else{
    write(0);
}

var n = Number(readline());
var arr = readline().split(" ", n).map(Number);

var notFirst = false, ans = 1;
if (arr.reduce(function(prev, cur, index, array) {
    if (cur === 1) {
        if (notFirst) {
            ans *= prev + 1;
        } else {
            notFirst = true;
        }
        return 0;
    } else {
        return prev + 1;
    }
}, 0) === n) {
    print(0);
} else {
    print(ans);
}

readline();
var str = readline().replace(/ /g, '').replace(/0/g, ' ').trim();
if (str) {
  var ans = 1;
  str.split(1).forEach(zero => ans *= zero.length + 1);
  print(ans);
} else {
  print(0);
}

var N = parseInt(readline());
var choc = readline().split(' ');

var firstOne = N, lastOne = -1;
for (var i = 0; i < N-i; ++i) {
  if (choc[i] === '1' && i < firstOne) {
    firstOne = i;
  }
  if (choc[N-i-1] === '1' && N-i-1 > lastOne) {
    lastOne = N-i-1;
  }
}

var cntZero = 0, ans = 1;
for (var i = firstOne; i <= lastOne; ++i) {
  if (choc[i] === '1') {
    ans *= cntZero+1;
    cntZero = 0;
  } else if (choc[i] === '0') {
    cntZero += 1;
  }
}
print(lastOne === -1 ? 0 : ans);

var n = Number(readline());
var arr = readline().split(" ", n);

var first = false, num = 0, ans = 1;
for (var i = 0; i < n; ++i) {
    if (arr[i] === "1") {
        if (first) {
            ans *= num + 1;
        } else {
            first = true;
        }
        num = 0;
    } else {
        ++num;
    }
}

if (num === n) {
    print(0);
} else {
    print(ans);
}

var result = 0;

var n = parseInt(readline());
var pices = readline().split(' ').map(Number);
var prev = -1;

for (var i = 0; i < n; i++) {
    if (pices[i] == 1) {
        if (prev == -1) {
            result = 1;
            prev = i;
        }
        result *= (i + 1 - prev);
        prev = i + 1;
    }
}

print(result);

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

var ans = 1;
var count = 0;
var left = -1;
for (var i = 0; i <n; i++) {
	if (a[i] === 1) {
		if (left !== -1) {
			ans *= i - left;
		}
		left = i;
		count ++;
	}
}

if (count === 0) {
	print(0);
} else {
	print(ans);
}

var n = parseInt(readline());
var a = readline().trim().split(' ');

for(var i=n-1;i>=0;i--){
    if(a[i]=='1')
        break;
    a.pop();
}

while(true){
    if(a=='')
        break;
    if(a[0]=='1')
        break;
    a.shift();
}

if(a=='')
print(0);
else{
    var ans=1;
    var current=1
    for(var i=0;i<a.length;i++){
        if(a[i]=='1'){
            ans*=current;
            current=1;
            continue;
        }
        current++;
    }
    print(ans);
}

var result = 0;

var n = parseInt(readline());
var pices = readline().split(' ').map(Number);
var prev = -1;

for (var i = 0; i < n; i++) {
    if (pices[i] == 1) {
        if (prev == -1) {
            result = 1;
        } else {
            result *= (i - prev);
        }
        prev = i;
    }
}

print(result);

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

var prev = -1;
var ans = 1;
for(i=0; i<n; i++) {
    if(arr[i] == 1) {
        if(prev>=0) {
            ans *= i-prev;
        }
        prev = i;
    }
}

if(prev == -1) {
    print(0);
} else {
    print(ans);
}

/* TEST CASE
input
3
0 1 0
output
1
input
5
1 0 1 0 1
output
4
 */
function main() {
	var n = parseInt(readline());
	var splitted = readline().split(' ');
	var i;
	var answer = 0;
	var oneIndices = [];
	for (i = 0; i < n; i++) {
		if (splitted[i] == '1') {
			oneIndices.push(i);
		}
	}

	var m = oneIndices.length;

	if (m > 0) {
		answer = 1;
		for (i = 1; i < m; i++) {
			answer *= oneIndices[i] - oneIndices[i - 1];
		}
	}

	print(answer);
}

main();

var n = readline();
var input = readline().split(" ");
var one = new Array(n);
var one_count = 0;

for(var i = 0; i < n; i++){
	if(input[i] == 1)
		one[one_count++] = i;
}
ans = (one_count) ? 1 : 0;
for(var i = 0; i < one_count-1; i++)
	ans *= (one[i+1]-one[i]);

print(ans);

n = +readline();
a = readline().split(" ").map(Number);
pre = -1;
res = 1;
for (i = 0 ; i < n ; i++)
{
    if (a[i] == 1){
        if (pre !== -1){
            res *= i - pre;

        }
        pre = i;
    }
}
if (pre == -1)
{
    write(0);
}
else
{
    write(res);
}

function rda(){ return readline().split(" ").map(Number); };
function rdn(){ return +readline(); };

var n = rdn(), a = rda();

var was = false;
for(var i = 0; i < n; i++){
    if(a[i] == 0){
        a[i] = -1;
    }else{
        was = true;
        break;
    }
}
for(var i = n-1; i >= 0; i--){
    if(a[i] == 0){
        a[i] = -1;
    }else{
        was = true;
        break;
    }
}

var ans = 1;
for(var i = 0, zeroes = 1; i < n; i++){
    if(a[i] == 0){
        zeroes++;
    }else{
        ans *= zeroes;
        zeroes = 1;
    }
}

if(was){
    write(ans);
}else{
    write(0);
}

var N = parseInt(readline());
var choc = readline().split(' ');

var firstOne = N, lastOne = -1;
for (var i = 0; i <= N-i; ++i) {
  if (choc[i] === '1' && i < firstOne) {
    firstOne = i;
  }
  if (choc[N-i] === '1' && N-i > lastOne) {
    lastOne = N-i;
  }
}

var cntZero = 0, ans = 1;
for (var i = firstOne; i <= lastOne; ++i) {
  if (choc[i] === '1') {
    ans *= cntZero+1;
    cntZero = 0;
  } else if (choc[i] === '0') {
    cntZero += 1;
  }
}
print(ans);

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

var ans = 1;
var left = -1;
for (var i = 0; i <n; i++) {
	if (a[i] === 1) {
		if (left !== -1) {
			ans *= i - left;
		}
		left = i;
	}
}

print(ans);

var n = readline();
var input = readline().split(" ");
var one = new Array(n);
var one_count = 0;
var ans = 1;
for(var i = 0; i < n; i++){
	if(input[i] == 1)
		one[one_count++] = i;
}
for(var i = 0; i < one_count-1; i++)
	ans *= (one[i+1]-one[i]);

print(ans);

var n = readline();
var input = readline();
var one = new Array(n);
var one_count = 0;
var ans = 1;
for(var i = 0; i < n; i++){
	if(input[i] == 1)
		one[one_count++] = i;
}

for(var i = 0; i < one_count-1; i++)
	ans *= (one[i+1]-one[i]);

print(ans);

n = +readline();
a = [readline().split(' ').map(parseInt)];
write(a);
tot = 0 ;
for (i = 0 ; i < n ; i ++)
{
    tot += a[i];
}
var res = 0;
for (var i = 0 ; i < n ; i ++)
{
    rem = tot - a[i];
    if (rem % 2 == 0 )
    {
        res ++;
    }
}
write(res);

n = +readline();
a = readline().split(' ').map(Number);
tot = 0 ;
for (i = 0 ; i < n ; i ++)
{
    tot += a[i];
}
var res = 0;
for (var i = 0 ; i < n ; i ++)
{
    rem = tot - a[i];
    if (rem % 2 === 0 )
    {
        res ++;
    }
}
write(res);

'use strict';

const N = readline();
const A = readline().split(' ').join('').replace(/(^0+|0+$)/g, '');

write(A.match(/1/g) === null ? 0 : A.match(/1/g).length === A.length ? A.length : A.match(/(0+)/g).reduce((p, c) => (c.length + 1) * p, 1))

'use strict';

const N = readline();
const A = readline();

write(A.match(/1/g).length === 1 ? 1 : A.replace(/(^0+|0+$)/g, '').match(/(0+)/g).reduce((p, c) => (c.length + 1) * p, 1))

'use strict';

const N = readline();
const A = readline().split(' ');
let count = 0;

function solve(a) {
  if (a.length === 0) {
    return 1;
  }

  let  _a = a.slice(a.indexOf('1') + 1)
  if (_a.indexOf('1') === -1) {
    return 1;
  }

  for (var i = 0; i < _a.indexOf('1')+1; i++) {
    let _ = solve(_a.slice(i));
    count += _;
  }
  return 0;
}

if (A.filter((a) => a === 1).length === 1) {
  write(1);
} else {
  solve(A);
  print(count);
}


number_string = readline()
div = readline()
k = number_string.length
mini = 10000000

number = []
for (var i = 0; i < k; ++i) {
    number.push(Number(number_string[i]));
}

modk = 0
for (var i = 0; i < k; ++i) {
    modk *= 10
    modk += number[i];
    modk %= div;
}

power10 = 1;
for (var i = 0; i < k-1; ++i) {
    power10 = (power10 * 10) % div;
}

mini = modk
for (var i = 0; i < k; ++i) {
    if (number[i] != 0) {
        if (modk < mini) {
            mini = modk;
        }
    }
    modk -= power10 * number[i];
    modk %= div;
    if (modk < 0) {
        modk -= div * Math.floor(modk / div);
    }
    modk *= 10;
    modk %= div;
    modk = (modk + number[i]) % div;
}
print(mini)

s = readline()
m = +readline()
crem = 0
cpow = 1
for (i = s.length-1; i >= 0; i--) {
	crem = (crem + cpow * (+s[i])) % m
	if (i !== 0) {
	    cpow = cpow * 10 % m
	}
}

ans = crem
for (i = 0; i+1 < s.length; i++) {
	crem = (crem - cpow * (+s[i])) % m
	crem = (crem + m) % m
	crem = (crem * 10) % m
	crem = (crem + (+s[i])) % m
	if (s[i+1] != '0') {
	    if (crem < ans) {
	        ans = crem
	    }
	}
}

print(ans)

number_string = readline()
div = readline()
k = number_string.length
mini = 10000000

number = []
for (var i = 0; i < k; ++i) {
    number.push(Number(number_string[i]));
}

modk = 0
for (var i = 0; i < k; ++i) {
    modk *= 10
    modk += number[i];
    modk %= div;
}

power10 = 1;
for (var i = 0; i < k-1; ++i) {
    power10 = (power10 * 10) % div;
}

mini = modk
for (var i = 0; i < k; ++i) {
    if (number[i] != 0) {
        if (modk < mini) {
            mini = modk;
        }
    }
    modk -= power10 * number[i];
    modk %= div;
    modk *= 10;
    modk %= div;
    modk = (modk + number[i]) % div;
}
print(mini)


'use strict';

// let inpFileStrArr = `
// 90 24
// 41 65 43 20 14 92 5 19 33 51 6 76 40 4 23 99 48 85 49 72 65 14 76 46 13 47 79 70 63 20 86 90 45 66 41 46 9 19 71 2 24 33 73 53 88 71 64 2 4 24 28 1 70 16 66 29 44 48 89 44 38 10 64 50 82 89 43 9 61 22 59 55 89 47 91 50 44 31 21 49 68 37 84 36 27 86 39 54 30 25
// 49
// `.trim().split('\n'), inpFileCounter = 0;
// function readline() {
//   return inpFileStrArr[inpFileCounter++];
// }
// function print(x) {
//   console.log(x);
// }

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var _readline$split$map = readline().split(' ').map(Number);

var _readline$split$map2 = _slicedToArray(_readline$split$map, 2);

var n = _readline$split$map2[0];
var d = _readline$split$map2[1];

var arr = readline().split(' ').map(Number);arr.sort(function (a, b) {
  return a - b;
});
var m = Number(readline());

print(arr.slice(0, m).reduce(function (a, b) {
  return a + b;
}, 0) - (m > n ? (m - n) * d : 0));

process.stdin.setEncoding('ASCII');

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

process.stdin.on('end', () => {
    const array = string.trim().split('\n');
    const line = array[0].split(' ').map(Number);

    let n = line[0], d = line[1];
    let cost = array[1].split(' ').map(Number);
    let visitors = Number(array[2]);

    cost.sort((a, b) => a - b);

    let profit = 0;
    for (let i = 0; i < cost.length; ++i) {
        if (visitors == 0) break;
        profit += cost[i];
        visitors--;
    }

    profit -= (visitors * d);
    console.log(profit);
});

print(function(n, d) {

	var a = readline().split(' ').map(Number).sort(function(a, b) { return a - b; }),
		m = +readline(),
		ans = 0;

	for (var i = 0; i < m; i++)
		ans += i < n ? a[i] : -d;

	return ans;

}.apply(0, readline().split(' ').map(Number)));

var inp = readline().split(' ');
var n = Number(inp[0]);
var d = Number(inp[1]);
var A = readline().split(' ').map((x)=>Number(x));
var m = Number(readline().split());
A.sort((x,y) => x-y);

var ats = 0;
if(m > n)
{
ats = -(m-n)*d;
m=n;
}

for(var i=0; i<m; i++)
ats+=A[i];

print(ats);

;(function () {

	var n = readline().split(' '), d, a = readline().split(' ').map(Number).sort(function (a, b) {return a - b;} ), m = +readline(), p = 0;
	d = +n[1] * (-1);
	n = +n[0];

	while (m--) p += a.length ? a.shift() : d;

	print(p);

}).call(this);

'use strict';

var arr = readline().trim().split(' ').map(Number);
var n = arr[0],
    d = arr[1];
var costs = readline().trim().split(' ').map(Number).sort(function (a, b) {
    return a - b;
});
var m = Number(readline().trim());

var profit = 0;

for (var i = 0; i < Math.min(m, n); i++) {
    profit += costs[i];
}
if (m > n) {
    profit -= (m - n) * d;
}
print(profit);

(function (){
    var line = readline().split(' ');
    var n = parseInt(line[0]);
    var d = parseInt(line[1]);
    var a = readline().split(' ');
    var m = parseInt(readline());
    a.sort(function(a,b){
        return parseInt(a)-parseInt(b);
    });
    var profit = 0, i;
    for( i = 0 ; i < m && i < n ; ++i){
        profit += parseInt(a[i]);
    }
    if ( i < m ){
        profit -= (m-i) * d;
    }
    print(profit);
})();

'use strict';

// let inpFileStrArr = `
// 2 1
// 2 1
// 10
// `.trim().split('\n'), inpFileCounter = 0;
// function readline() {
//   return inpFileStrArr[inpFileCounter++];
// }
// function print(x) {
//   console.log(x);
// }

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var _readline$split$map = readline().split(' ').map(Number);

var _readline$split$map2 = _slicedToArray(_readline$split$map, 2);

var n = _readline$split$map2[0];
var d = _readline$split$map2[1];

var arr = readline().split(' ').map(Number);arr.sort();
var m = Number(readline());

print(arr.slice(0, 2).reduce(function (a, b) {
  return a + b;
}, 0) - (m > n ? (m - n) * d : 0));

'use strict';

// let inpFileStrArr = `
// 3 96
// 83 22 17
// 19
// `.trim().split('\n'), inpFileCounter = 0;
// function readline() {
//   return inpFileStrArr[inpFileCounter++];
// }
// function print(x) {
//   console.log(x);
// }

var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

var _readline$split$map = readline().split(' ').map(Number);

var _readline$split$map2 = _slicedToArray(_readline$split$map, 2);

var n = _readline$split$map2[0];
var d = _readline$split$map2[1];

var arr = readline().split(' ').map(Number);arr.sort();
var m = Number(readline());

print(arr.slice(0, m).reduce(function (a, b) {
  return a + b;
}, 0) - (m > n ? (m - n) * d : 0));


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

print(function(n, m) {

	var a = readline().split(' ').map(Number);
	var b = new Int8Array(n);
	var c = new Int8Array(n);

	var index = 0;
	var count = 0;
	while (true) {
		if (c[index]) {
			index++;
			if (index == n) index = 0;
			continue;
		}
		b[index] += m;
		if (b[index] >= a[index]) {
			c[index] = 1;
			count++;
			if (count == n)
				return index + 1;
		}
		index++;
		if (index == n) index = 0;
	}
}.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()),
		n = data[0], serving = data[1],
		children = tokenizeIntegers(readline()),
		pos = 0, count = 0;
	while (true) {
		while (children[pos] <= 0) {
			pos = (pos+1)%n;
		}
		children[pos] -= serving;
		if (children[pos] <= 0) {
			if (++count == n) {
				print(pos+1);
				return;
			}
		}
		pos = (pos+1)%n;
	}
}

main();

var jzzhu = function(n, m, a){
	var flag = true;
	var last = 0;
	while (flag){
		flag = false;
		for (var i = 0; i < n; i++){
			if (a[i] > 0){
				if ( (a[i] -= m) > 0){
					flag = true;
				}
				else{
					last = i;
				}
			}

		}
	}
	return last + 1;
};

var line = readline().split(' ');
var n = parseInt(line[0]);
var m = parseInt(line[1]);
var a = readline().split(' ');

print (jzzhu(n, m, a));

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 [len, limit] = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  const arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  let maxIndex = -1;
  let maxMove = -1;
  for (let i = 0; i < len; i++) {
    const candy = arr[i];
    let move = Math.floor(candy / limit);
    if (candy % limit > 0) move++;
    const diff = candy - limit;

    if (move >= maxMove) {
      if (diff > 0) {
        maxIndex = i;
      }
      maxMove = move;
    }
  }
  maxIndex = maxIndex === -1 ? len - 1 : maxIndex;
  console.log(maxIndex + 1);
}

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 [n, m] = readLine()
		.split(' ')
		.map(x => x >> 0);
	let q = readLine()
		.split(' ')
		.map(x => x >> 0);
	q = q.map(x => (x <= m ? 0 : Math.ceil(x / m)));

	let max = 0,
		v = 0;
	for (let i = 0; i < n; ++i) {
		if (q[i] >= max) {
			max = q[i];
			v = i + 1;
		}
	}
	console.log(v);
}

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 [Numberofstudents, initialCandyValue] = readLine()
        .split(' ')
        .map(Number);
    // let home = [];
    // let more = [];

    let students = readLine().split(' ').map(Number); // [1 3 1 4 2]
    // for (let i = 0; i < students.length; i++) {
    //     if (students[i] <= initialCandyValue) {
    //         let t = students[i];
    //         home[t] = i;
    //     } else {
    //         let test = students[i];
    //         more[test] = i;
    //     }
    // }
    // let highest = 0;
    // let vagfol = 0;
    // if (more.length !== 0) {
    //     for (let i = 0; i < more.length; i++) {
    //         // if (more[i] > highest) {
    //         //     highest = more[i];
    //         // }
    //         let iThVagfol = Math.ceil(more[i] / initialCandyValue);
    //         if (iThVagfol > vagfol) {
    //             vagfol = iThVagfol;
    //         } else if (vagfol === iThVagfol) {
    //             highest = more[i];
    //         }
    //     }
    // } else if (more.length === 0) {
    //     for (let i = 0; i < home.length; i++) {
    //         if (home[i] > highest) {
    //             highest = home[i];
    //         }
    //     }
    // }

    let highest = 0;
    let vagfol = 0;
    // if (more.length !== 0) {
    for (let i = 0; i < students.length; i++) {
        // if (more[i] > highest) {
        //     highest = more[i];
        // }
        let iThVagfol = Math.ceil(students[i] / initialCandyValue); //100
        if (iThVagfol > vagfol) {
            vagfol = iThVagfol;
            highest = students.lastIndexOf(students[i]);
        } else if (vagfol === iThVagfol) {
            highest = students.lastIndexOf(students[i]);
        }
    }
    console.log(highest + 1);
    // console.log(Math.max.apply(null, more));
}

var input = readline().split(" "), n = +input[0], m = +input[1], a = readline().split(" ").map(Number),
max, position;

a.forEach(function(number, i){
	a[i] = Math.ceil(number/m);
});

max = Math.max.apply(null,a);

a.forEach(function(number, i){
	if(number == max){
		position = i+1;
	}
});

write(position);

;(function () {

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

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

	var last;
	while ( a.reduce(function (p, e) { return p + (e > 0); }, 0) ) {
		for (var i = 0; i < n; i++) {
			if (a[i] > 0) {
				last = i;
				a[i] -= m;
			}
		}
	}

	print(last + 1);

}).call(this);

function countUniqueElements(input,output){
	for(var i = 0; i < input.length; i++){
		if(output[+input[i]] == undefined){
			output[+input[i]] = 1;
		}
		else{
			output[+input[i]]++;
		}
	}
}

var n = +readline(), str = readline().split("").map(Number),
unique = {
	0: 0,
	1: 0
};

countUniqueElements(str, unique);

print(Math.abs(unique[1] - unique[0]));

var input = readline().split(" "), n = +input[0], m = +input[1], a = readline().split(" ").map(Number),
max, position;

a.forEach(function(number){
	Math.ceil(number/m);
});

max = Math.max.apply(null,a);

a.forEach(function(number, i){
	if(number == max){
		position = i+1;
	}
});

write(position);

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 [n, m] = readLine()
		.split(' ')
		.map(x => x >> 0);
	let q = readLine()
		.split(' ')
		.map(x => x >> 0);
	q = q.map(x => (x <= m ? 0 : Math.floor(x / m)));

	let max = 0,
		v = 0;
	for (let i = 0; i < n; ++i) {
		if (q[i] >= max) {
			max = q[i];
			v = i + 1;
		}
	}
	console.log(v);
}

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 [n, m] = readLine()
		.split(' ')
		.map(x => x >> 0);
	let h = {};
	let q = readLine()
		.split(' ')
		.map((x, i) => {
			h[x] = i + 1;
			return x >> 0;
		});
	let v = null;
	while (q.length) {
		let c = q.shift();
		if (c > m) {
			q.push(c - m);
			let i = h[c];
			delete h[c];
			h[c - m] = i;
		} else delete h[c];

		if (Object.keys(h).length === 1) {
			v = Object.values(h)[0];
			break;
		}
	}
	console.log(v);
}

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 [Numberofstudents, initialCandyValue] = readLine()
        .split(' ')
        .map(Number);
    let home = [];
    let more = [];

    let students = readLine().split(' ').map(Number); // [1 3 1 4 2]
    for (let i = 0; i < students.length; i++) {
        if (students[i] <= initialCandyValue) {
            home.push(students[i]);
        } else {
            let test = students[i];
            more[test] = i;
        }
    }

    let highest = 0;
    for (let i = 0; i < more.length; i++) {
        if (more[i] > highest) {
            highest = more[i];
        }
    }

    console.log(highest + 1);
}

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 [Numberofstudents, initialCandyValue] = readLine()
        .split(' ')
        .map(Number);
    let home = [];
    let more = [];

    let students = readLine().split(' ').map(Number); // [1 3 1 4 2]
    for (let i = 0; i < students.length; i++) {
        if (students[i] <= initialCandyValue) {
            let t = students[i];
            home[students[i]] = i;
        } else {
            let test = students[i];
            more[test] = i;
        }
    }
    let highest = 0;
    if (more.length !== 0) {
        for (let i = 0; i < more.length; i++) {
            if (more[i] > highest) {
                highest = more[i];
            }
        }
    } else if (more.length === 0) {
        for (let i = 0; i < home.length; i++) {
            if (home[i] > highest) {
                highest = home[i];
            }
        }
    }

    console.log(highest + 1);
    // console.log(Math.max.apply(null, more));
}

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 [Numberofstudents, initialCandyValue] = readLine()
        .split(' ')
        .map(Number);
    // let home = [];
    // let more = [];

    let students = readLine().split(' ').map(Number); // [1 3 1 4 2]
    // for (let i = 0; i < students.length; i++) {
    //     if (students[i] <= initialCandyValue) {
    //         let t = students[i];
    //         home[t] = i;
    //     } else {
    //         let test = students[i];
    //         more[test] = i;
    //     }
    // }
    // let highest = 0;
    // let vagfol = 0;
    // if (more.length !== 0) {
    //     for (let i = 0; i < more.length; i++) {
    //         // if (more[i] > highest) {
    //         //     highest = more[i];
    //         // }
    //         let iThVagfol = Math.ceil(more[i] / initialCandyValue);
    //         if (iThVagfol > vagfol) {
    //             vagfol = iThVagfol;
    //         } else if (vagfol === iThVagfol) {
    //             highest = more[i];
    //         }
    //     }
    // } else if (more.length === 0) {
    //     for (let i = 0; i < home.length; i++) {
    //         if (home[i] > highest) {
    //             highest = home[i];
    //         }
    //     }
    // }

    let highest = 0;
    let vagfol = 0;
    // if (more.length !== 0) {
    for (let i = 0; i < students.length; i++) {
        // if (more[i] > highest) {
        //     highest = more[i];
        // }
        let iThVagfol = Math.ceil(students[i] / initialCandyValue);
        if (iThVagfol > vagfol) {
            vagfol = iThVagfol;
        } else if (vagfol === iThVagfol) {
            highest = students.lastIndexOf(students[i]);
        }
    }
    console.log(highest + 1);
    // console.log(Math.max.apply(null, more));
}

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 [Numberofstudents, initialCandyValue] = readLine()
        .split(' ')
        .map(Number);
    // let home = [];
    // let more = [];

    let students = readLine().split(' ').map(Number); // [1 3 1 4 2]
    // for (let i = 0; i < students.length; i++) {
    //     if (students[i] <= initialCandyValue) {
    //         let t = students[i];
    //         home[t] = i;
    //     } else {
    //         let test = students[i];
    //         more[test] = i;
    //     }
    // }
    // let highest = 0;
    // let vagfol = 0;
    // if (more.length !== 0) {
    //     for (let i = 0; i < more.length; i++) {
    //         // if (more[i] > highest) {
    //         //     highest = more[i];
    //         // }
    //         let iThVagfol = Math.ceil(more[i] / initialCandyValue);
    //         if (iThVagfol > vagfol) {
    //             vagfol = iThVagfol;
    //         } else if (vagfol === iThVagfol) {
    //             highest = more[i];
    //         }
    //     }
    // } else if (more.length === 0) {
    //     for (let i = 0; i < home.length; i++) {
    //         if (home[i] > highest) {
    //             highest = home[i];
    //         }
    //     }
    // }

    let highest = 0;
    let vagfol = 0;
    // if (more.length !== 0) {
    for (let i = 0; i <= students.length; i++) {
        // if (more[i] > highest) {
        //     highest = more[i];
        // }
        let iThVagfol = Math.ceil(students[i] / initialCandyValue);
        if (iThVagfol > vagfol) {
            vagfol = iThVagfol;
        } else if (vagfol === iThVagfol) {
            highest = students.lastIndexOf(students[i]);
        }
    }
    console.log(highest + 1);
    // console.log(Math.max.apply(null, more));
}

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 [Numberofstudents, initialCandyValue] = readLine()
        .split(' ')
        .map(Number);
    // let home = [];
    // let more = [];

    let students = readLine().split(' ').map(Number); // [1 3 1 4 2]
    // for (let i = 0; i < students.length; i++) {
    //     if (students[i] <= initialCandyValue) {
    //         let t = students[i];
    //         home[t] = i;
    //     } else {
    //         let test = students[i];
    //         more[test] = i;
    //     }
    // }
    // let highest = 0;
    // let vagfol = 0;
    // if (more.length !== 0) {
    //     for (let i = 0; i < more.length; i++) {
    //         // if (more[i] > highest) {
    //         //     highest = more[i];
    //         // }
    //         let iThVagfol = Math.ceil(more[i] / initialCandyValue);
    //         if (iThVagfol > vagfol) {
    //             vagfol = iThVagfol;
    //         } else if (vagfol === iThVagfol) {
    //             highest = more[i];
    //         }
    //     }
    // } else if (more.length === 0) {
    //     for (let i = 0; i < home.length; i++) {
    //         if (home[i] > highest) {
    //             highest = home[i];
    //         }
    //     }
    // }

    let highest = 0;
    let vagfol = 0;
    // if (more.length !== 0) {
    for (let i = 0; i < students.length; i++) {
        // if (more[i] > highest) {
        //     highest = more[i];
        // }
        let iThVagfol = Math.ceil(students[i] / initialCandyValue);
        if (iThVagfol > vagfol) {
            vagfol = iThVagfol;
        } else if (vagfol === iThVagfol) {
            highest = students.indexOf(students[i]);
        }
    }
    console.log(highest + 1);
    // console.log(Math.max.apply(null, more));
}


(function () {
	'use strict';

	var n = parseInt(readline()),
		numbers = { 2: 0, 3: 0, 5: 0, 7: 0 };

	readline().split('').forEach(function (a) {
		switch (a) {
			case '2':
				numbers[2] += 1;
				break;

			case '3':
				numbers[2] += 1;
				numbers[3] += 1;
				break;

			case '4':
				numbers[2] += 3;
				numbers[3] += 1;
				break;

			case '5':
				numbers[2] += 3;
				numbers[3] += 1;
				numbers[5] += 1;
				break;

			case '6':
				numbers[2] += 4;
				numbers[3] += 2;
				numbers[5] += 1;
				break;

			case '7':
				numbers[2] += 4;
				numbers[3] += 2;
				numbers[5] += 1;
				numbers[7] += 1;
				break;

			case '8':
				numbers[2] += 7;
				numbers[3] += 2;
				numbers[5] += 1;
				numbers[7] += 1;
				break;

			case '9':
				numbers[2] += 7;
				numbers[3] += 4;
				numbers[5] += 1;
				numbers[7] += 1;
				break;
		}
	});

	var str = '';

	for (var i = numbers[7]; i > 0 ; i--){
		str += '7';
		numbers[2] -= 4;
		numbers[3] -= 2;
		numbers[5] -= 1;
	}

	for (var i = numbers[5]; i > 0 ; i--){
		str += '5';
		numbers[2] -= 3;
		numbers[3] -= 1;
	}

	for (var i = numbers[3]; i > 0 ; i--){
		str += '3';
		numbers[2] -= 1;
	}

	for (var i = numbers[2]; i > 0 ; i--){
		str += '2';
	}

	print(str);

}).call(this);

var n = +readline(), a = readline().split("").map(Number)
ans = [];

a.forEach(function(digit, i){
	switch(digit){
		case 2:
			ans.push(2);
			break;
		case 3:
			ans.push(3);
			break;
		case 4:
			ans.push(3,2,2)
			break;
		case 5:
			ans.push(5);
			break;
		case 6:
			ans.push(5,3)
			break;
		case 7:
			ans.push(7);
			break;
		case 8:
			ans.push(7,2,2,2)
			break;
		case 9:
			ans.push(7,3,3,2)
	}
});

ans.sort(function(x,y){return y-x});

write(ans.join(""));

readline();
var s = readline().split('').map(Number);
var s1 = s.filter(x=>x>1).map(x=>{if (x==4) {return [2,2,3];} else if (x==6) {return [5,3];} else if (x==8) {return [7,2,2,2];} else if (x==9) {return [7,3,3,2]}  else return x;});
var s2 = [].concat.apply([],s1).sort((x,y)=>y-x);
print(s2.join(''));

// 441A     Валера и антиквариат

var n = parseInt(readline());

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

var out = '';

for (var i = 0; i < n; i++) if (arr[i] === '9') out += '7332';
for (var i = 0; i < n; i++) if (arr[i] === '8') out += '7222';
for (var i = 0; i < n; i++) if (arr[i] === '7') out += '7';
for (var i = 0; i < n; i++) if (arr[i] === '6') out += '53';
for (var i = 0; i < n; i++) if (arr[i] === '5') out += '5';
for (var i = 0; i < n; i++) if (arr[i] === '4') out += '322';
for (var i = 0; i < n; i++) if (arr[i] === '3') out += '3';
for (var i = 0; i < n; i++) if (arr[i] === '2') out += '2';

arr = out.split('').sort().reverse();

out = arr.join('');

print(out);

// 441A     Валера и антиквариат

var n = parseInt(readline());

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

var out = '';

for (var i = 0; i < n; i++) if (arr[i] === '9') out += '9';
for (var i = 0; i < n; i++) if (arr[i] === '7') out += '7';
for (var i = 0; i < n; i++) if (arr[i] === '8') out += '7222';
for (var i = 0; i < n; i++) if (arr[i] === '5') out += '5';
for (var i = 0; i < n; i++) if (arr[i] === '6') out += '53';
for (var i = 0; i < n; i++) if (arr[i] === '3') out += '3';
for (var i = 0; i < n; i++) if (arr[i] === '4') out += '322';
for (var i = 0; i < n; i++) if (arr[i] === '2') out += '2';

print(out);

var n = +readline(), a = readline().split("").map(Number)
ans = [];

a.forEach(function(digit, i){
	switch(digit){
		case 2:
			ans.push(2);
			break;
		case 3:
			ans.push(3);
			break;
		case 4:
			ans.push(3,2,2)
			break;
		case 5:
			ans.push(5);
			break;
		case 6:
			ans.push(5,3)
			break;
		case 7:
			ans.push(7);
			break;
		case 8:
			ans.push(7,2,2,2,2)
			break;
		case 9:
			ans.push(7,3,3,2,2)
	}
});

ans.sort(function(x,y){return y-x});

write(a.join(""));

var n = +readline(), a = readline().split("").map(Number)
ans = [];

a.forEach(function(digit, i){
	switch(digit){
		case 2:
			ans.push(2);
			break;
		case 3:
			ans.push(3);
			break;
		case 4:
			ans.push(3,2,2)
			break;
		case 5:
			ans.push(5);
			break;
		case 6:
			ans.push(5,3)
			break;
		case 7:
			ans.push(7);
			break;
		case 8:
			ans.push(7,2,2,2,2)
			break;
		case 9:
			ans.push(7,3,3,2,2)
	}
});

ans.sort(function(x,y){return y-x});

write(ans.join(""));

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

a.forEach(function(digit, i){
	switch(digit){
		case 0:
			a.splice(i,1);
			break;
		case 1:
			a.splice(i,1);
			break;
		case 4:
			a.splice(i,1,3,2,2);
			break;
		case 6:
			a.splice(i,1,5,3);
			break;
		case 8:
			a.splice(i,1,7,2,2,2,2);
			break;
		case 9:
			a.splice(i,1,7,3,3,2,2);
	}
});

a.sort(function(x,y){return y-x});

write(a.join(""));

readline();
var s = readline().split('').map(Number);
var s1 = s.filter(x=>x>1).map(x=>{if (x==4) {return [2,2,3];} else if (x==6) {return [5,3];} else if (x==8) {return [7,2,2,2];} else return x;});
var s2 = [].concat.apply([],s1).sort((x,y)=>y-x);
print(s2.join(''));

readline();
var s = readline().split('').map(Number);
var s1 = s.filter(x=>x>1).map(x=>{if (x==4) {return [2,2,3];} else if (x==6) {return [5,3];} else if (x==8) {return [7,2,2,2];} else if (x==9) {return [7,3,3,3]}  else return x;});
var s2 = [].concat.apply([],s1).sort((x,y)=>y-x);
print(s2.join(''));

// 441A     Валера и антиквариат

var n = parseInt(readline());

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

var out = '';

for (var i = 0; i < n; i++) if (arr[i] === '9') out += '9';
for (var i = 0; i < n; i++) if (arr[i] === '7') out += '7';
for (var i = 0; i < n; i++) if (arr[i] === '8') out += '7222';
for (var i = 0; i < n; i++) if (arr[i] === '5') out += '5';
for (var i = 0; i < n; i++) if (arr[i] === '6') out += '53';
for (var i = 0; i < n; i++) if (arr[i] === '3') out += '3';
for (var i = 0; i < n; i++) if (arr[i] === '4') out += '322';
for (var i = 0; i < n; i++) if (arr[i] === '2') out += '2';

arr = out.split('');
arr.sort();
out = arr.join('');

print(out);

// 441A     Валера и антиквариат

var n = parseInt(readline());

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

var out = '';

for (var i = 0; i < n; i++) if (arr[i] === '9') out += '9';
for (var i = 0; i < n; i++) if (arr[i] === '7') out += '7';
for (var i = 0; i < n; i++) if (arr[i] === '8') out += '7222';
for (var i = 0; i < n; i++) if (arr[i] === '5') out += '5';
for (var i = 0; i < n; i++) if (arr[i] === '6') out += '53';
for (var i = 0; i < n; i++) if (arr[i] === '3') out += '3';
for (var i = 0; i < n; i++) if (arr[i] === '4') out += '322';
for (var i = 0; i < n; i++) if (arr[i] === '2') out += '2';

arr = out.split('').sort().reverse();

out = arr.join('');

print(out);

// 441A     Валера и антиквариат

var n = parseInt(readline());

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

var out = '';

for (var i = 0; i < n; i++) if (arr[i] === '9') out += '9';
for (var i = 0; i < n; i++) if (arr[i] === '7') out += '7';
for (var i = 0; i < n; i++) if (arr[i] === '8') out += '7222';
for (var i = 0; i < n; i++) if (arr[i] === '5') out += '5';
for (var i = 0; i < n; i++) if (arr[i] === '6') out += '53';
for (var i = 0; i < n; i++) if (arr[i] === '3') out += '3';
for (var i = 0; i < n; i++) if (arr[i] === '4') out += '322';
for (var i = 0; i < n; i++) if (arr[i] === '2') out += '2';

print(out);

var n = Number(readline());
var a = readline();
a = a.replace('0', '').replace('1', '');
var b = [];
for (var i = 0; i < a.length; i++) {
	if (a[i] === '4') {
		b.push('3');
		b.push('2');
		b.push('2');
	} else if (a[i] === '6') {
		b.push('5');
		b.push('3');
	} else {
		b.push(a[i]);
	}
}

b.sort(function(x, y) {return x - y;}).reverse();
print(b.join(''));

var n = Number(readline());
var a = readline();
a = a.replace(/0/g, '').replace(/1/g, '');
var b = [];
for (var i = 0; i < a.length; i++) {
	if (a[i] === '4') {
		b.push('3');
		b.push('2');
		b.push('2');
	} else if (a[i] === '6') {
		b.push('5');
		b.push('3');
	} else if (a[i] === '8') {
		for (var j = 0; j < 3; j++) {
			b.push('2');
		}
	} else {
		b.push(a[i]);
	}
}

b.sort(function(x, y) {return x - y;}).reverse();
print(b.join(''));

var n = Number(readline());
var a = readline();
a = a.replace(/0/g, '').replace(/1/g, '');
var b = [];
for (var i = 0; i < a.length; i++) {
	if (a[i] === '4') {
		b.push('3');
		b.push('2');
		b.push('2');
	} else if (a[i] === '6') {
		b.push('5');
		b.push('3');
	} else if (a[i] === '8') {
		for (var j = 0; j < 3; j++) {
			b.push('2');
		}
		b.push('7');
	} else {
		b.push(a[i]);
	}
}

b.sort(function(x, y) {return x - y;}).reverse();
print(b.join(''));


if (!readline) {
    var _i = 0;
    var readline = function() {
        _i ++;

        switch (_i) {
            case 1: return '10';
        }
    }

    var write = console.log;
}

var n = +readline();
var a = [];

for (var i = 0; i < n; i ++) {
    a.push([]);
    for (var j = 0; j < n; j ++) {
        a[i].push(0);
    }
    a[i][0] = 1;
    a[0][i] = 1;
}

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

write(a[n-1][n-1]);

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

let input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  const count = parseInt(input[0], 10)
  let hash = []
  for (let a = 1; a <= count; a ++) {
    let index = hash.length === 0 ? 1 : hash.length - 1
    if (hash[index] === undefined) {
      hash.push([a])
    } else {
      hash[index].push(a)
    }
  }
  for (let a = 1; a < count - 1; a++) {
    for (let b = 0; b < count; b++) {
      const _prevLeftNum = b > 0 ? hash[a][b - 1] : 0
      const _prevTopNum = hash[a - 1][b]
      const all = _prevLeftNum + _prevTopNum
      if (hash[a] === undefined) {
        hash.push([all])
      } else {
        hash[a].push(all)
      }
    }
  }
  const lastResult = hash[hash.length - 1]
  console.log(hash[hash.length - 1][lastResult.length - 1])
})

//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 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 = new Array(N);
  for(var i = 0; i < N; i++){
    list[i] = new Array(N).fill(0);
    if(i == 0){
      list[i] = new Array(N).fill(1);
    }
    list[i][0] = 1;
  }
  for(var i = 1; i < N; i++){
    for(var j = 1; j < N; j++){
      list[i][j] = list[i][j - 1] + list[i - 1][j];
    }
  }
  myout(list[N - 1][N - 1]);
}

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

rl.on('line', (d) => {
  const matrix = new Array(+d).fill(1).map(x => new Array(+d).fill(1));
  let ans = 0;

  for (let i = 0; i < matrix.length; i++) {
    for (let j = 0; j < matrix[i].length; j++) {
      let v = 0;
      if (Number.isInteger(matrix[i][j - 1])) {
        v += matrix[i][j - 1];
      }

      if (matrix[i - 1] && Number.isInteger(matrix[i - 1][j])) {
        v += matrix[i - 1][j]
      }

      matrix[i][j] = Math.max(1, v);
      ans += matrix[i][j];
    }
  }

  console.log(matrix[matrix.length - 1][matrix.length - 1]);
});

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

const solve = (row, col) => {
  if (row === 1 || col === 1) {
    return 1;
  }

  return solve(row - 1, col) + solve(row, col - 1);
}

rl.on('line', (d) => {
  console.log(solve(+d, +d));

  // const matrix = new Array(+d).fill(1).map(x => new Array(+d).fill(1));
  // let ans = 0;

  // for (let i = 0; i < matrix.length; i++) {
  //   for (let j = 0; j < matrix[i].length; j++) {
  //     let v = 0;
  //     if (Number.isInteger(matrix[i][j - 1])) {
  //       v += matrix[i][j - 1];
  //     }

  //     if (matrix[i - 1] && Number.isInteger(matrix[i - 1][j])) {
  //       v += matrix[i - 1][j]
  //     }

  //     matrix[i][j] = Math.max(1, v);
  //     ans += matrix[i][j];
  //   }
  // }

  // console.log(matrix);
  // console.log(matrix[matrix.length - 1][matrix.length - 1]);
});

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

const input = [];
readLine.on('line', line => input.push(line));

readLine.on('close', () => {
  let [n] = input[0].split(' ').map(x => parseInt(x));
  const matrix = [];

  for (let i = 0; i < n; i += 1) matrix.push(Array(n).fill(1));

  for (let i = 1; i < n; i += 1) {
    for (let j = 1; j < n; j += 1) {
      matrix[i][j] = matrix[i][j-1]+matrix[i-1][j];
    }
  }

  console.log(matrix[n-1][n-1]);
});

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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
  const l = parseInt(readLine().split(' '));

let arr = [];
  let matrix = [];
  for (let i = 0; i < l; ++i) {
    matrix[i] = [];
    for (let j = 0; j < l; ++j) {
      if (i == 0 && j == 0) {
        matrix[i][j] = 2;
      } else if (j == 0) {
        matrix[i][j] = matrix[i - 1][j] + 1;
      } else if (i == 0) {
        matrix[i][j] = matrix[i][j - 1] + 1;
      } else {
        matrix[i][j] = matrix[i - 1][j] + matrix[i][j - 1];
      }

      matrix[0][j] = 1;
      matrix[i][0] = 1;
    }
  }

  for (let g = 0; g < l; ++g) {
    for (k = 0; k < l; ++k) {
      if (k == g) {
        arr.push(matrix[g][k]);
      }
    }
  }
  console.log(arr.pop());
  }

// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

/**
 *
 * @param {*} str
 * @param {*} seperator
 */
function splitter(str, seperator = '') {
    return str.trim().split(seperator);
}

/**
 *
 * @param {*} arr
 */
function strToNumArr(arr = []) {
    return arr.map(num => Number(num));
}

/**
 *
 * @param {*} num1
 * @param {*} num2
 */
function matrixArray(num1, num2) {
    return Array(num1).fill(Array(num2));
}

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {

    let n = +str.trim();
    let arr = [];
    let max = [1];
    if (n > 1) {
        for (let index1 = 0; index1 < n; index1++) {
            arr[index1] = [];
            for (let index2 = 0; index2 < n; index2++) {

                if (index1 == 0 || index2 == 0) {
                    arr[index1][index2] = 1;

                }
                else {
                    let indexItem = arr[index1 - 1][index2] + arr[index1][index2 - 1];
                    max.push(indexItem);
                    arr[index1][index2] = indexItem;
                }

            }

        }
    }
    return Math.max(...max).toString();
}

'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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let n = parseInt(readLine());
    let arr = [];
    for (var i = 0; i < n; i++) {
        arr.push([]);
    }
    for (var i = 0; i < n; i++) {
        arr[0].push(1);
        if (i + 1 < n) arr[i + 1].push(1);
    }
    for (var i = 1; i < n; i++) {
        for (var j = 1; j < n; j++) {
            arr[i].push(arr[i - 1][j] + arr[i][j - 1]);
        }
    }
    console.log(arr[n - 1][n - 1]);
}

// arr = [
//     [1, 1, 1, 1],
//     [1, 2, 3, 4],
//     [1, 3, 6, 10],
//     [1, 4, 10, 20],
// ]

(function() {
	var n = parseInt(readline());
	var cash = {};
	function val(x, y) {
		if (cash[100 * x + y] != undefined) {
			return cash[100 * x + y];
		}
		if (Math.min(x, y) == 1) return 1;
		return cash[100 * x + y] = val(x - 1, y) + val(x, y - 1);
	}
	print(val(n, n));
}());

///////////////////////////////////////////////////////////////////////////////
function readNumber () { return Number(readline()); }
function readNumbersArray () { return readline().split(' ').map(Number); }
function algebraicSum (startValue, finishValue, size) { return (startValue + finishValue) * size / 2; }
///////////////////////////////////////////////////////////////////////////////

var n = readNumber();
var array = [];

for (var i = 0; i < n; i++) array.push(1);
for (var i = 1; i < n; i++)
	for (var j = 1; j < n; j++)
		array[j] += array[j - 1];

print(array.splice(-1)[0]);

var res = sol(readline());
print(res);

function sol(line) {
    var input = line.split(" ").map((x) => Number(x));

    var n = input[0];

    var matrix = [];

    for (var i = 0; i < n; i++) {
        matrix[i] = [];
        for (var j = 0; j < n; j++) {
            if (i === 0 || j === 0) {
                matrix[i][j] = 1;
            } else {
                matrix[i][j] = matrix[i - 1][j] + matrix[i][j - 1];
            }
        }
    }

    return matrix[n - 1][n - 1];
}

var n = readline();
 //i-5 i-1
var str = [];
	for (var i=0; i<n*n; i++){
		str[i] = 1;
		if (i>n)
		str[i]= Number(str[i-n])+Number(+str[i-1]);
		if (i%n==0)
		str[i]= 1;
	}

	print(Math.max.apply(this, str));

var n = Number(readline());

function f(i,j) {
    if (i===1) {
        return 1;
    }
    else {
        if (i===j) {
            return f(i-1,j)*2;
        }
        else {
            return f(i,j-1)+f(i-1,j);
        }
    }
}

print(f(n,n));

var n = Number(readline());

var matrix = [];

for (var i = 0; i < n; i++) {
	matrix[i] = [];

	for (var j = 0; j < n; j++) {
		if (i == 0 || j == 0) {
			matrix[i][j] = 1;
		} else {
			matrix[i][j] = matrix[i][j-1] + matrix[i-1][j];
		}
	}
}

print(matrix[n-1][n-1]);

"use strict";

var n = readline() - 1;

var f = function (x) {
    var result = 1;
    for (let i = 1; i <= x; ++i) {
        result *= i;
    }
    return result;
};

write(f(2 * n) / (f(n) * f(n)));

var n = readline();
 //i-5 i-1
var str = [];
	for (var i=0; i<n*n; i++){
		str[i] = 1;
		if (i>5)
		str[i]= Number(str[i-n])+Number(+str[i-1]);
		if (i%n==0)
		str[i]= 1;
	}

	print(Math.max.apply(this, str));


var colors = readline().split(' ').sort();

var count = 0;

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

print(count);

'use strict';

String.prototype.toArray = function () {
  return String(this).split(' ');
}

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

let obj = {};

readline().toArray().forEach((p) => {
  obj[p] = 1;
});

write(4 - Object.keys(obj).length);

var colors = readline().split(" "), counter = 0, c1, c2, c3, c4;

c1 = [colors[0], colors.filter(function(a){return a == colors[0]}).length];
c2 = [colors[1], colors.filter(function(a){return a == colors[1]}).length];
c3 = [colors[2], colors.filter(function(a){return a == colors[2]}).length];
c4 = [colors[3], colors.filter(function(a){return a == colors[3]}).length];

if( c1[1] > 1 ){
	if( c1[0] == c2[0] ){
		counter++;
	}
	if( c1[0] == c3[0] ){
		counter++;
	}
	if( c1[0] == c4[0] ){
		counter++;
	}
}
if( (c2[1] > 1) && (c2[0] != c1[0]) ){
	if( c2[0] == c3[0] ){
		counter++;
	}
	if( c2[0] == c4[0] ){
		counter++;
	}
}
if( (c3[1] > 1) && (c3[0] != c2[0]) && (c3[0] != c1[0]) ){
	if( c3[0] == c4[0] ){
		counter++;
	}
}

write(counter);

var existing = readline().split(" ").map(Number).sort((a, b) => a - b);

var buyCount = 0;

for (var i = 1; i < existing.length; i++) {
    if (existing[i - 1] === existing[i]) {
        buyCount++;
    }
}

print(buyCount);

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 arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));
  const map = {};
  let count = 0;
  arr.forEach((n) => {
    if (!map[n]) map[n] = 1;
    else count++;
  });

  console.log(count);
}

var m={};
readline().split(' ').forEach(function(v){ m[v]=true; });
print(4-Object.keys(m).length);

const readline = require("readline")

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

let arrOfShoes
let similarCounter = 0

rl.on("line", (input) => {
    if (!arrOfShoes) {
        arrOfShoes = input.split(" ").map(Number)
    }
    if (arrOfShoes) {
        arrOfShoes.forEach((shoe,index) => {
            if(arrOfShoes.includes(shoe,index+1)){
                similarCounter++
            }
        });
        console.log(similarCounter)
        rl.close();

    }
})

"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().split(" ");

  horseshoeOnTheOtherHoof(x);
}

function horseshoeOnTheOtherHoof(colors) {
  console.log(4 - new Set(colors).size);

}

//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 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 set = new Set(nextIntArray());
  myout(4 - set.size);
}

'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 print(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  // input
  const a = readline().split(' ');
  let x = 0;
  const set = new Set();
  for (let i = 0; i < a.length; i++) {
    set.add(a[i]);
  }
  x = a.length - set.size;
  // output
  print(x);
}

//Is your horseshoe on the other hoof?

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

let inp = '';

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

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

    process.stdout.write((lines.length - (new Set(lines)).size) + '');

    return;
});

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

rl.on('line', (d) => {
  const arr = d.split(' ');
  const uniqueArr = new Set(arr);
  const ans = arr.length - uniqueArr.size;

  console.log(ans);
});

const input = [];

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

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

RL.on('close', () => {
  const set = new Set();
  input[0].split(' ').forEach(x => set.add(x));

  console.log(4 - set.size);
});

function main(stdin) {
  const horseshoes = stdin.split(" ").map(v => parseInt(v));
  console.log(horseshoes.sort().reduce((ac, val, i, arr) => arr[i - 1] === val ? ac + 1 : ac, 0));
}

main(
  require("fs")
    .readFileSync(0, "utf-8")
    .trim()
);

'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();
});

const readLine=()=> inputString[currentLine++];
/* ================================================
           Main Solution Starts Here
===================================================*/

const main=()=>{
	let set=new Set()
	let numbers = readLine().split(' ').map(n=>+n)
	numbers.forEach(number=>set.add(number))
	console.log(4-set.size)
}

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 hoes = readLine()
		.split(' ')
		.map(x => x >> 0);

	let counter = {};
	let spend = 0;
	for (let i = 0; i < 4; ++i) counter[hoes[i]] = (counter[hoes[i]] || 0) + 1;

	Object.entries(counter).forEach(([k, v]) => {
		spend += v - 1;
	});
	console.log(spend);
}

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 shoesArray = readLine().split(' ').map(Number);
    let selecTed = []; // [1, 7, 3, 3]
    for (let i = 0; i < shoesArray.length; i++) {
        if (selecTed.indexOf(shoesArray[i]) === -1) {
            selecTed.push(shoesArray[i]);
        }
    }
    let result = shoesArray.length - selecTed.length;
    console.log(result);
}

var input = readline().split(" ");

function solveProb(input) {
    var unique = [];
    var count = 4;

    for (var i = 0; i < input.length; i++) {
        if (!isThere(unique, input[i])) {
            unique.push(input[i]);
            count--;
        }
        if (count === 0) {
            return count;
        }
    }
    return count;
}

function isThere(arr, k) {
    for (var i = 0; i < arr.length; i++) {
        if (arr[i] === k) {
            return true;
        }
    }
    return false;
}

print(solveProb(input));

var needToBuy = 4
var horsesShoeOwned = {}

  var horsesShoe = readline().split(' ').map(Number)

  for (var i = 0; i < horsesShoe.length; i++) {
    if (!horsesShoeOwned.hasOwnProperty(horsesShoe[i])) {
      horsesShoeOwned[horsesShoe[i]] = 0
      needToBuy -= 1
    }
  }

  print(needToBuy)

var input = readline().split(" ").map(x=>parseInt(x));
print(4-[...new Set(input)].length)

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

const input = [];
readline.on('line', line => { input.push(line); });

readline.on('close', () => {
    const n = input[0].split(' ');
    const ns = new Set(n);
    console.log(n.length - ns.size);
});

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

let currentLine = 0;
let inputString = "";

process.stdin.on("data", (raw_data) => {
  inputString += raw_data;
});

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

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

/******** Main function*************/

function main() {
  var arr = readLine().split(" ").map(Number);

  var uniqArr = [...new Set(arr)];
  console.log(4 - uniqArr.length);
}

let fs = require('fs');

let txt = fs.readFileSync(0, "utf-8").split(/[\n\r]/).filter(data => data.length > 0);

for (let i = 0; i < txt.length; i++) {
    console.log(4 - [...new Set(txt[i].split(/[ ]/))].length);

}

// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

function main(input) {
    let output = nameLookUp(input);
    process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {

    let inputs = str.trim().split(' ');
    let currentShoesIndex = [...new Set(inputs)].length;
    let shoesToBuy = 4 - currentShoesIndex;
    return shoesToBuy.toString();
}

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

const input = [];
readLine.on('line', line => input.push(line));

const horseShoe = () => {
    let ar = input[0].split(' ');
    let ar2 = new Set(ar);

    console.log(4 - ar2.size);
};

readLine.on('close', horseShoe);

'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.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let arr = readLine().split(' ').map(value => parseInt(value));
    let newArr = [...new Set(arr)];
    console.log(arr.length - newArr.length);
}

;(function () {

	var s = readline().split(' ');
	var m = {};
	var t = 0;

	for(var i = 0; i < 4; i++)
		if (m[s[i]]) t++;
		else m[s[i]] = true;

	print(t);

}).call(this);

function nextInt(){
	return parseInt(next());
}
var tokens = [];
var posToken = 0;
function next(){
	while(posToken>=tokens.length){
		tokens = readline().split(/[\s]+/);
		posToken = 0;
	}
	return tokens[posToken++];
}

function main(){
	var i;
	var set = Object.create(null);
	for(i=0;i<4;i++){
		set[nextInt()]=1;
	}
	var ans = 4;
	for(var b in set)
		ans--;
	print(ans);
}
main();

var horse = readline().split(" ").sort((x,y)=>x-y);
	var newShoes = 0;
	for (var i=0; i<4; i++){
		 if (horse[i+1]==horse[i]){
			newShoes++;
		 }
	}
    print(newShoes);
    // console.log(newShoes);

// var curReadLine=0;
// var readlines=["1 7 3 3"];

// function readline(){
// 	return readlines[curReadLine++];
// }
// function print(x){
// 	console.log(x);
// }
var sameColour = 0;
var hoofsColours = readline().split(" ");
//console.log(hoofsColours);

// var obj={};
// for (i=0;i<hoofsColours.length;i++){
// 	obj[+hoofsColours[i]]=1;
// }
// print(4-Object.keys(obj).length);

for (i = 0; i < hoofsColours.length; i++){
	for (k = i+1; k < hoofsColours.length; k ++){
		//console.log(hoofsColours[k]);
		if (+hoofsColours[k] == +hoofsColours[i]){
			//console.log(sameColour);
			sameColour++;
			hoofsColours.splice(hoofsColours.indexOf(hoofsColours[i]), 1, undefined);
			// console.log(hoofsColours);
		}

	}
}
print(sameColour);

var x = readline().split(" "),
	n = x.length,
	c = 0;
for (var i = 0; i < n; i++) {
	var k = true;
	for (var j = i; j > 0; j--) {
		if (x[i] === x[j - 1]) {
			k = false;
			break;
        }
    }
	if (k) {
        for (var j = i + 1; j < n; j++) {
            if (x[i] === x[j]) {
                c++;
            }
        }
    }
}
print(c);

	var str = readline().split(" ").sort((x,y)=>x-y);
	var res = 0;
	for (var i=0; i<4; i++){
		 if (str[i+1]==str[i]){
			res++;
		 }
	}
	print(res);

var p = readline().split(" ")
var m = {};
var b = 0;
for (var i=0; i<p.length; i++) {
	if (m[p[i]]===undefined) {
		m[p[i]] = true;
	}
	else {
		b++;
	}
}
print(b);

var s = readline().split(" ").map(Number);

var res = 0, horseShoe = [];
for (var i = 0; i<s.length; i++) {
    if (!horseShoe.includes(s[i])) {
        horseShoe.push(s[i]);
    }
    else {
        res++;
    }
}

print(res);

var inputedNumbers = readline().split(' ');
var resultArray = [];

inputedNumbers.forEach(
    function (current)
        {
            if (resultArray.indexOf(current) === -1)
                {
                    resultArray.push(current);
                }
        });
print(4-resultArray.length);

"use strict";

write(4 - new Set(readline().split(' ').map(value => +value)).size);

var boots = readline().split(" ");
var set = new Set(boots);
print(boots.length - set.size)

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

    //var input = trim(readline());
    //var s2 = readline().toLowerCase();
    //var n = readline().split(' ').map(Number);
    var a = readline().split(' ').map(Number);
    var count = {};
    var lol = 0;
    for (var i = 0; i < 4; i++) {
        if (count[a[i]] === undefined) {
            count[a[i]] = 1;
            lol++;
        }
    }
    print( 4 - lol );
})()

const readline = require("readline")

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

let arrOfShoes
let similarCounter = 0

rl.on("line", (input) => {
    if (!arrOfShoes) {
        arrOfShoes = input.split(" ").map(Number)
    }
    if (arrOfShoes) {
        arrOfShoes.forEach((element1, index1) => {
            arrOfShoes.forEach((element2, index2) => {
                if (element1 === element2 && index1 != index2)
                    similarCounter++
            })
        });
        switch (similarCounter) {
            case 12:
                console.log(12/4)
                rl.close();
                break;
            case 6 :
                console.log(6/3)
                rl.close();
                break;
            case 2 :
                console.log(2/2)
                rl.close();
            default:
                break;
        }
    }
})

const readline = require("readline")

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

let arrOfShoes
let similarCounter = 0

rl.on("line", (input) => {
    if (!arrOfShoes) {
        arrOfShoes = input.split(" ").map(Number)
    }
    if (arrOfShoes) {
        arrOfShoes.forEach((element1, index1) => {
            arrOfShoes.forEach((element2, index2) => {
                if (element1 === element2 && index1 != index2)
                    similarCounter++
            })
        });
        switch (similarCounter) {
            case 12:
                console.log(12/4)
                rl.close();
                break;
            case 6 :
                console.log(6/3)
                rl.close();
                break;
            case 2 :
                console.log(2/2)
                rl.close();
            case 0:
                console.log(0)
                rl.close()
                break;
            default:
                break;
        }
    }
})

const readline = require("readline")

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

let arrOfShoes
let similarCounter = 0

rl.on("line", (input) => {
    if (!arrOfShoes) {
        arrOfShoes = input.split(" ").map(Number)
    }
    if (arrOfShoes) {
        arrOfShoes.forEach((element1, index1) => {
            arrOfShoes.forEach((element2, index2) => {
                if (element1 === element2 && index1 != index2)
                    similarCounter++
            })
        });
        switch (similarCounter) {
            case 12:
                console.log(12/4)
                rl.close();
                break;
            case 6 :
                console.log(6/3)
                rl.close();
                break;
            case 2 :
                console.log(2/2)
                rl.close();
                break;
            case 0:
                console.log(0)
                rl.close()
                break;
            default:
                break;
        }
    }
})

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 shoesArray = readLine().split(' ').map(Number);
    let selecTed = [];
    for (let i = 0; i < shoesArray.length; i++) {
        if (selecTed.indexOf(shoesArray[i] === -1)) {
            selecTed.push(shoesArray[i]);
        }
    }
    console.log(shoesArray);
    console.log(selecTed);
    let result = shoesArray.length - selecTed.length;
    console.log(result);
}

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 shoesArray = readLine().split(' ').map(Number);
    let selecTed = []; // [1, 7, 3, 3]
    for (let i = 0; i < shoesArray.length; i++) {
        let test = shoesArray[i];
        if (selecTed.indexOf(test === -1)) {
            selecTed.push(test);
        }
    }
    console.log(shoesArray);
    console.log(selecTed);
    let result = shoesArray.length - selecTed.length;
    console.log(result);
}

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 shoesArray = readLine().split(' ').map(Number);
    let selecTed = [];
    for (let i = 0; i < shoesArray.length; i++) {
        if (selecTed.indexOf(shoesArray[i] === -1)) {
            selecTed.push(shoesArray[i]);
        }
    }
    let result = shoesArray.length - selecTed.length;
    console.log(result);
}

var m={};
readline().split('').forEach(function(v){ m[v]=true; });
print(4-Object.keys(m).length);

var horse = readline().split(" ").sort((x,y)=>x-y);
	var newShoes = 0;
	for (var i=0; i<horse.length+1; i++){
		 if (horse[i+1]==horse[i]){
			newShoes++;
		 }
	}
    print(newShoes);
    // console.log(newShoes);

	var str = readline().split(" ");
	var res = 0;
	for (var i=0; i<4; i++){
		 if (str[i+1]==str[i]){
			res++;
		 }
	}
	print(res);

var s = readline().split(" ").map(Number);

var res = 0;
for (var i = 0; i<s.length; i++) {
    if (s[i] === s[i+1]) {
        res++;
    }
}

print(res);