Bob loves everything sweet. His favorite chocolate bar consists of pieces, each piece may contain a nut. Bob wants to break the bar of chocolate into multiple pieces so that each part would contain exactly one nut and any break line goes between two adjacent pieces.You are asked to calculate the number of ways he can do it. Two ways to break chocolate are considered distinct if one of them contains a break between some two adjacent pieces and the other one doesn't. Please note, that if Bob doesn't make any breaks, all the bar will form one piece and it still has to have exactly one nut.

The first line of the input contains integer n (1 ≤ n ≤ 100) — the number of pieces in the chocolate bar. The second line contains n integers ai (0 ≤ ai ≤ 1), where 0 represents a piece without the nut and 1 stands for a piece with the nut.

Print the number of ways to break the chocolate into multiple parts so that each part would contain exactly one nut.

NoteIn the first sample there is exactly one nut, so the number of ways equals 1 — Bob shouldn't make any breaks.In the second sample you can break the bar in four ways:10|10|11|010|110|1|011|01|01

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

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 = 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 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();

 //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();

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

'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))

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

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 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);

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


Stepan has a very big positive integer.Let's consider all cyclic shifts of Stepan's integer (if we look at his integer like at a string) which are also integers (i.e. they do not have leading zeros). Let's call such shifts as good shifts. For example, for the integer 10203 the good shifts are the integer itself 10203 and integers 20310 and 31020.Stepan wants to know the minimum remainder of the division by the given number m among all good shifts. Your task is to determine the minimum remainder of the division by m.

The first line contains the integer which Stepan has. The length of Stepan's integer is between 2 and 200 000 digits, inclusive. It is guaranteed that Stepan's integer does not contain leading zeros. The second line contains the integer m (2 ≤ m ≤ 108) — the number by which Stepan divides good shifts of his integer.

Print the minimum remainder which Stepan can get if he divides all good shifts of his integer by the given number m.

NoteIn the first example all good shifts of the integer 521 (good shifts are equal to 521, 215 and 152) has same remainder 2 when dividing by 3.In the second example there are only two good shifts: the Stepan's integer itself and the shift by one position to the right. The integer itself is 1001 and the remainder after dividing it by 5 equals 1. The shift by one position to the right equals to 1100 and the remainder after dividing it by 5 equals 0, which is the minimum possible remainder.

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;
    if (modk < 0) {
        modk -= div * Math.floor(modk / div);
    }
    modk *= 10;
    modk %= div;
    modk = (modk + number[i]) % div;
}
print(mini)

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)


Sereja owns a restaurant for n people. The restaurant hall has a coat rack with n hooks. Each restaurant visitor can use a hook to hang his clothes on it. Using the i-th hook costs ai rubles. Only one person can hang clothes on one hook.Tonight Sereja expects m guests in the restaurant. Naturally, each guest wants to hang his clothes on an available hook with minimum price (if there are multiple such hooks, he chooses any of them). However if the moment a guest arrives the rack has no available hooks, Sereja must pay a d ruble fine to the guest. Help Sereja find out the profit in rubles (possibly negative) that he will get tonight. You can assume that before the guests arrive, all hooks on the rack are available, all guests come at different time, nobody besides the m guests is visiting Sereja's restaurant tonight.

The first line contains two integers n and d (1 ≤ n, d ≤ 100). The next line contains integers a1, a2, ..., an (1 ≤ ai ≤ 100). The third line contains integer m (1 ≤ m ≤ 100).

In a single line print a single integer — the answer to the problem.

NoteIn the first test both hooks will be used, so Sereja gets 1 + 2 = 3 rubles.In the second test both hooks will be used but Sereja pays a fine 8 times, so the answer is 3 - 8 =  - 5.

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';

// 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));

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

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

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


There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least ai candies.Jzzhu asks children to line up. Initially, the i-th child stands at the i-th place of the line. Then Jzzhu start distribution of the candies. He follows the algorithm:  Give m candies to the first child of the line.  If this child still haven't got enough candies, then the child goes to the end of the line, else the child go home.  Repeat the first two steps while the line is not empty. Consider all the children in the order they go home. Jzzhu wants to know, which child will be the last in this order?

The first line contains two integers n, m (1 ≤ n ≤ 100; 1 ≤ m ≤ 100). The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 100).

Output a single integer, representing the number of the last child.

NoteLet's consider the first sample. Firstly child 1 gets 2 candies and go home. Then child 2 gets 2 candies and go to the end of the line. Currently the line looks like [3, 4, 5, 2] (indices of the children in order of the line). Then child 3 gets 2 candies and go home, and then child 4 gets 2 candies and goes to the end of the line. Currently the line looks like [5, 2, 4]. Then child 5 gets 2 candies and goes home. Then child 2 gets two candies and goes home, and finally child 4 gets 2 candies and goes home.Child 4 is the last one who goes home.

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)));

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

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


Calendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified the Julian calendar's scheme of leap years as follows: Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100; the centurial years that are exactly divisible by 400 are still leap years. For example, the year 1900 is not a leap year; the year 2000 is a leap year.   In this problem, you have been given two dates and your task is to calculate how many days are between them. Note, that leap years have unusual number of days in February.Look at the sample to understand what borders are included in the aswer.

The first two lines contain two dates, each date is in the format yyyy:mm:dd (1900 ≤ yyyy ≤ 2038 and yyyy:mm:dd is a legal date).

Print a single integer — the answer to the problem.

'use strict';

/*let input = `1996:03:09
1991:11:12`.split('\n');
function print(output) {
	console.log(output);
}
function readline() {
	return input.shift();
}*/

//code

var inpDate1 = readline().split(':').map(Number);
var inpDate2 = readline().split(':').map(Number);
var date1 = new Date(inpDate1[0], inpDate1[1] - 1, inpDate1[2]);
var date2 = new Date(inpDate2[0], inpDate2[1] - 1, inpDate2[2]);
print(Math.abs((date2.getTime() - date1.getTime()) / (1000 * 60 * 60 * 24)));


Drazil is playing a math game with Varda.Let's define  for positive integer x as a product of factorials of its digits. For example, .First, they choose a decimal number a consisting of n digits that contains at least one digit larger than 1. This number may possibly start with leading zeroes. Then they should find maximum positive number x satisfying following two conditions:1. x doesn't contain neither digit 0 nor digit 1.2.  = .Help friends find such number.

The first line contains an integer n (1 ≤ n ≤ 15) — the number of digits in a. The second line contains n digits of a. There is at least one digit in a that is larger than 1. Number a may possibly contain leading zeroes.

Output a maximum possible integer satisfying the conditions above. There should be no zeroes and ones in this number decimal representation.

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

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

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


An n × n table a is defined as follows:  The first row and the first column contain ones, that is: ai, 1 = a1, i = 1 for all i = 1, 2, ..., n.  Each of the remaining numbers in the table is equal to the sum of the number above it and the number to the left of it. In other words, the remaining elements are defined by the formula ai, j = ai - 1, j + ai, j - 1. These conditions define all the values in the table.You are given a number n. You need to determine the maximum value in the n × n table defined by the rules above.

The only line of input contains a positive integer n (1 ≤ n ≤ 10) — the number of rows and columns of the table.

Print a single line containing a positive integer m — the maximum value in the table.

NoteIn the second test the rows of the table look as follows: {1, 1, 1, 1, 1},  {1, 2, 3, 4, 5},  {1, 3, 6, 10, 15},  {1, 4, 10, 20, 35},  {1, 5, 15, 35, 70}.

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)));

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]);

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));


Valera the Horse is going to the party with friends. He has been following the fashion trends for a while, and he knows that it is very popular to wear all horseshoes of different color. Valera has got four horseshoes left from the last year, but maybe some of them have the same color. In this case he needs to go to the store and buy some few more horseshoes, not to lose face in front of his stylish comrades.Fortunately, the store sells horseshoes of all colors under the sun and Valera has enough money to buy any four of them. However, in order to save the money, he would like to spend as little money as possible, so you need to help Valera and determine what is the minimum number of horseshoes he needs to buy to wear four horseshoes of different colors to a party.

The first line contains four space-separated integers s1, s2, s3, s4 (1 ≤ s1, s2, s3, s4 ≤ 109) — the colors of horseshoes Valera has. Consider all possible colors indexed with integers.

Print a single integer — the minimum number of horseshoes Valera needs to buy.

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

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

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

var m={};
readline().split(' ').forEach(function(v){ m[v]=true; });
print(4-Object.keys(m).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 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)

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

// 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);

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

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 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 colors = readline().split(' ').sort();

var count = 0;

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

print(count);

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

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);

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);