Polycarp is preparing the first programming contest for robots. There are $$$n$$$ problems in it, and a lot of robots are going to participate in it. Each robot solving the problem $$$i$$$ gets $$$p_i$$$ points, and the score of each robot in the competition is calculated as the sum of $$$p_i$$$ over all problems $$$i$$$ solved by it. For each problem, $$$p_i$$$ is an integer not less than $$$1$$$.Two corporations specializing in problem-solving robot manufacturing, "Robo-Coder Inc." and "BionicSolver Industries", are going to register two robots (one for each corporation) for participation as well. Polycarp knows the advantages and flaws of robots produced by these companies, so, for each problem, he knows precisely whether each robot will solve it during the competition. Knowing this, he can try predicting the results — or manipulating them. For some reason (which absolutely cannot involve bribing), Polycarp wants the "Robo-Coder Inc." robot to outperform the "BionicSolver Industries" robot in the competition. Polycarp wants to set the values of $$$p_i$$$ in such a way that the "Robo-Coder Inc." robot gets strictly more points than the "BionicSolver Industries" robot. However, if the values of $$$p_i$$$ will be large, it may look very suspicious — so Polycarp wants to minimize the maximum value of $$$p_i$$$ over all problems. Can you help Polycarp to determine the minimum possible upper bound on the number of points given for solving the problems?

The first line contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of problems. The second line contains $$$n$$$ integers $$$r_1$$$, $$$r_2$$$, ..., $$$r_n$$$ ($$$0 \le r_i \le 1$$$). $$$r_i = 1$$$ means that the "Robo-Coder Inc." robot will solve the $$$i$$$-th problem, $$$r_i = 0$$$ means that it won't solve the $$$i$$$-th problem. The third line contains $$$n$$$ integers $$$b_1$$$, $$$b_2$$$, ..., $$$b_n$$$ ($$$0 \le b_i \le 1$$$). $$$b_i = 1$$$ means that the "BionicSolver Industries" robot will solve the $$$i$$$-th problem, $$$b_i = 0$$$ means that it won't solve the $$$i$$$-th problem.

If "Robo-Coder Inc." robot cannot outperform the "BionicSolver Industries" robot by any means, print one integer $$$-1$$$. Otherwise, print the minimum possible value of $$$\max \limits_{i = 1}^{n} p_i$$$, if all values of $$$p_i$$$ are set in such a way that the "Robo-Coder Inc." robot gets strictly more points than the "BionicSolver Industries" robot.

NoteIn the first example, one of the valid score assignments is $$$p = [3, 1, 3, 1, 1]$$$. Then the "Robo-Coder" gets $$$7$$$ points, the "BionicSolver" — $$$6$$$ points.In the second example, both robots get $$$0$$$ points, and the score distribution does not matter.In the third example, both robots solve all problems, so their points are equal.

const processData = (lines) => {
  const k = lines[1].split(' ').map(x => +x)
  const l = lines[2].split(' ').map(x => +x)
  let diff = [0, 0]
  for (let i =0; i<k.length; i++) {
    if (k[i] !== l[i]) {
      if (k[i] === 1) {
        diff[0]++
      }
      if (l[i] === 1) {
        diff[1]++
      }
    }
  }
  if (diff[0] === 0) {
    console.log(-1)
  } else {
    let rest = Math.ceil(diff[1]/diff[0])
    if (diff[1]%diff[0] === 0) {
      rest++
    }
    console.log(rest)
  }
}

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

function main(rawInput) {
    var lines = rawInput.trim().split("\n").map(function (v) { return v.trim().split(" ").map(function (u) { return parseInt(u, 10); }); });
    var n = lines.shift()[0];
    var ra = lines.shift();
    var rb = lines.shift();
    var sca = 0;
    var scb = 0;
    var unqa = 0;
    for (var i = 0; i < n; i++) {
        if (ra[i] == 1) {
            sca++;
        }
        if (rb[i] == 1) {
            scb++;
        }
        if (ra[i] > rb[i]) {
            unqa++;
        }
    }
    // console.error(sca, scb, unqa);
    if (sca > scb) {
        console.log(1);
    }
    else if (unqa > 0) {
        if ((scb - (sca - unqa)) % unqa == 0) {
            console.log((scb - (sca - unqa)) / unqa + 1);
        }
        else {
            console.log(Math.ceil((scb - (sca - unqa)) / unqa));
        }
    }
    else {
        console.log(-1);
    }
    // console.log('----')
}
// main(`5
// 1 1 1 0 0
// 0 1 1 1 1`);
// main(`3
// 0 0 0
// 0 0 0`);
// main(`4
// 1 1 1 1
// 1 1 1 1`);
// main(
//     `9
// 1 0 0 0 0 0 0 0 1
// 0 1 1 0 1 1 1 1 0`
// );
// main(`2
// 1 1
// 1 0`);
// main(`3
// 0 1 1
// 1 0 0`);
// main(`7
// 0 1 1 1 0 1 1
// 1 0 1 1 1 1 1`);
(function () {
    var d = "";
    process.stdin.on("data", function (v) { return d += v; });
    process.stdin.on("end", function () { return main(d); });
})();

var times = parseInt(readline());

var ROBO = readline().split(" ").map(function(x){return parseInt(x);});
var BIO = readline().split(" ").map(function(x){return parseInt(x);});
var RoboPoint = 0;
var BioPoint = 0;
var add = 1;
var con = true;
var num = 0;
for(var i = 0; i < times; i++)
{
    if(ROBO[i] === 1)
    {
        num ++;
    }
    if(ROBO[i] === 1 && BIO[i] === 0)
    {
        RoboPoint++;
    }
    if(BIO[i] === 1 && ROBO[i] === 0)
    {
        BioPoint++;
    }
}
if(RoboPoint <= BioPoint && RoboPoint !== 0)
{
    add = Math.ceil((BioPoint + 1) / RoboPoint);
}

if(JSON.stringify(ROBO) === JSON.stringify(BIO))
{
    add = -1;
}
if(RoboPoint === 0)
{
    add = -1;
}

// print(num, check)
// print(RoboPoint, BioPoint)
print(add);

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = +readline();
  var robo = readNumArray();
  var bio = readNumArray();
  var roboSolved = 0;
  var bioSolved = 0;
  for (var i = 0; i < testCasesNum; i++) {
    if (robo[i] && !bio[i]) {
      roboSolved++;
    } else if (!robo[i] && bio[i]) {
      bioSolved++;
    }
  }
  if (roboSolved > bioSolved) {
    print(1);
  } else if (
    roboSolved === 0 ||
    (roboSolved === testCasesNum && bioSolved === testCasesNum)
  ) {
    print(-1);
  } else {
    print(
      bioSolved % roboSolved === 0
        ? bioSolved / roboSolved + 1
        : Math.ceil(bioSolved / roboSolved)
    );
  }
}
main()

var n = parseInt(readline());
var r = readline().split(' ');
var b = readline().split(' ');

var diff = 0;
var numR = 0;
var numB = 0;

for(var i = 0; i < n; i++) {
    if (r[i] !== b[i]) {
        diff++;

        if (r[i] === '1') {
            numR += 1;
        } else {
            numB += 1;
        }
    }
}

if (diff === 0 || numR === 0) {
    print(-1);
} else {
    var exp = numB + 1;
    var val = exp / numR;
    var res = Number.isInteger(val) ? val : Math.ceil(val);
    print(res);
}

const main = data => {
  const n = data[0];
  const winnerArr = data[1].split(' ');
  const looserArr = data[2].split(' ');

  const winCount = winnerArr.filter((x, i) => looserArr[i] !== x && +x !== 0).length;
  const looseCount = looserArr.filter((x, i) => winnerArr[i] !== x && +x !== 0).length;

  if (winCount === 0) {
    console.log('-1')
  } else {
    let i = 1;
    while (winCount * i <= looseCount) {
      i++
    }
    console.log(i);
  }
};

let data = '';

process.stdin.on('data', input => data += input);
process.stdin.on('end', () => {
  data = data.split('\n');

  main(data);
});

let data = '';
process.stdin.on('data', input => data += input);
process.stdin.on('end', () => {
    const score = (arr1, arr2, n) => {
        let x = 0, y = 0;
        for (let i = 0; i < n; i++) {
            if (arr1[i] > arr2[i]) x++;
            if (arr1[i] < arr2[i]) y++;
        }
        if (x === 0) return -1;
        return Math.ceil( (y + 1) / x );
    }
    const inputStrings = data.split('\n');
    const n = parseInt(inputStrings[0], 10);
    const arr1 = inputStrings[1].split(' ').map(Number);
    const arr2 = inputStrings[2].split(' ').map(Number);
    const answ = score(arr1,arr2,n)+ '\n';
    process.stdout.write(answ);
});

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

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

  if (c === 1) {
    arr1 = d.split(' ').map(Number);
    c++;
    return;
  }

  arr2 = d.split(' ').map(Number);

  c++;
});

rl.on('close', () => {
  let common = 0;

  for (let i = 0; i < arr1.length; i++) {
    common += arr1[i] && arr2[i];
  }

  let sum1 = arr1.reduce((a, x) => a + x, 0) - common;
  let sum2 = arr2.reduce((a, x) => a + x, 0) - common;

  if (!sum1) {
    console.log(-1);
  }
  else {
    console.log(Math.ceil( (sum2 + 1) / sum1));
  }

  // let common = 0;

  // for (let i = 0; i < arr1.length; i++) {
  //   common += arr1[i] && arr2[i];
  // }

  // let sum1 = arr1.reduce((a, x) => a + x, 0) - common;
  // let sum2 = arr2.reduce((a, x) => a + x, 0) - common;
  // let ans = sum1 > sum2 ? 1 : -1;

  // for (let i = 1; i <= max; i++) {
  //   if (sum1 * i > sum2) {
  //     ans = i;
  //     break;
  //   }
  // }

  // console.log(ans);
});

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

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

  if (c === 1) {
    arr1 = d.split(' ').map(Number);
    c++;
    return;
  }

  arr2 = d.split(' ').map(Number);

  c++;
});

rl.on('close', () => {
  let common = 0;

  for (let i = 0; i < arr1.length; i++) {
    common += arr1[i] && arr2[i];
  }

  let sum1 = arr1.reduce((a, x) => a + x, 0) - common;
  let sum2 = arr2.reduce((a, x) => a + x, 0) - common;
  let ans = sum1 > sum2 ? 1 : -1;

  for (let i = 1; i <= max; i++) {
    if (sum1 * i > sum2) {
      ans = i;
      break;
    }
  }

  console.log(ans);
});

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

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

  if (c === 1) {
    arr1 = d.split(' ').map(Number);
    c++;
    return;
  }

  arr2 = d.split(' ').map(Number);

  c++;
});

rl.on('close', () => {
  let max = 0;
  let idx1 = 0;
  let idx2 = 0;

  for (let i = 0; i < arr1.length; i++) {
    if (arr1[i]) {
      idx1++;
    }
    else {
      idx1 = 0;
    }

    if (arr2[i]) {
      idx2++;
    }
    else {
      idx2 = 0;
    }

    max = Math.max(max, idx1, idx2);
  }

  let sum1 = 0;
  let sum2 = 0;
  for (let i = 0; i < arr1.length; i++) {
    if (arr1[i] === 1 && arr2[i] === 0) {
      sum1 += max;
    }
    else if (arr1[i] === 1 && arr2[i] === 1) {
      sum1 += 1;
      sum2 += 1;
    }
    else if (arr1[i] === 0 && arr2[i] === 1) {
      sum2 += 1;
    }
  }

  if (sum2 >= sum1) {
    console.log(-1);
  }
  else {
    console.log(max);
  }
});

const processData = (lines) => {
  const k = lines[1].split(' ').map(x => +x)
  const l = lines[2].split(' ').map(x => +x)
  let diff = [0, 0]
  for (let i =0; i<k.length; i++) {
    if (k[i] !== l[i]) {
      if (k[i] === 1) {
        diff[0]++
      }
      if (l[i] === 1) {
        diff[1]++
      }
    }
  }
  if (diff[0] === 0) {
    console.log(-1)
  } else {
    let rest = Math.ceil(diff[1]/diff[0])
    if (diff[1]%diff[2] === 0) {
      rest++
    }
    console.log(rest)
  }
}

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

function main(rawInput) {
    var lines = rawInput.trim().split("\n").map(function (v) { return v.trim().split(" ").map(function (u) { return parseInt(u, 10); }); });
    var n = lines.shift()[0];
    var ra = lines.shift();
    var rb = lines.shift();
    var sca = 0;
    var scb = 0;
    var unqa = 0;
    for (var i = 0; i < n; i++) {
        if (ra[i] == 1) {
            sca++;
        }
        if (rb[i] == 1) {
            scb++;
        }
        if (ra[i] > rb[i]) {
            unqa++;
        }
    }
    // console.error(sca, scb, unqa);
    if (sca > scb) {
        console.log(1);
    }
    else if (unqa > 0) {
        if ((scb - (sca - unqa)) % unqa == 0) {
            console.log((scb - (sca - unqa)) / unqa + 1);
        }
        else {
            console.log(Math.ceil((scb - (sca - unqa)) / unqa));
        }
    }
    else {
        console.log(-1);
    }
    // console.log('----')
}
main("5\n1 1 1 0 0\n0 1 1 1 1");
main("3\n0 0 0\n0 0 0");
main("4\n1 1 1 1\n1 1 1 1");
main("9\n1 0 0 0 0 0 0 0 1\n0 1 1 0 1 1 1 1 0");
main("2\n1 1\n1 0");
main("3\n0 1 1\n1 0 0");
main("7\n0 1 1 1 0 1 1\n1 0 1 1 1 1 1");
(function () {
    var d = "";
    process.stdin.on("data", function (v) { return d += v; });
    process.stdin.on("end", function () { return main(d); });
})();

function main(rawInput) {
    var lines = rawInput.trim().split("\n").map(function (v) { return v.trim().split(" ").map(function (u) { return parseInt(u, 10); }); });
    var n = lines.shift()[0];
    var ra = lines.shift();
    var rb = lines.shift();
    var sca = 0;
    var scb = 0;
    var unqa = 0;
    for (var i = 0; i < n; i++) {
        if (ra[i] == 1) {
            sca++;
        }
        if (rb[i] == 1) {
            scb++;
        }
        if (ra[i] > rb[i]) {
            unqa++;
        }
    }
    // console.error(sca, scb, unqa);
    if (sca > scb) {
        console.log(1);
    }
    else if (unqa > 0) {
        var ned = Math.ceil((scb - (sca - unqa)) / unqa) + 1;
        console.log(ned);
    }
    else {
        console.log(-1);
    }
    // console.log('----')
}
// main(`5
// 1 1 1 0 0
// 0 1 1 1 1`);
// main(`3
// 0 0 0
// 0 0 0`);
// main(`4
// 1 1 1 1
// 1 1 1 1`);
// main(
//     `9
// 1 0 0 0 0 0 0 0 1
// 0 1 1 0 1 1 1 1 0`
// );
// main(`2
// 1 1
// 1 0`);
// main(`3
// 0 1 1
// 1 0 0`);
// main(`7
// 0 1 1 1 0 1 1
// 1 0 1 1 1 1 1`);
(function () {
    var d = "";
    process.stdin.on("data", function (v) { return d += v; });
    process.stdin.on("end", function () { return main(d); });
})();

function main(rawInput) {
    var lines = rawInput.trim().split("\n").map(function (v) { return v.trim().split(" ").map(function (u) { return parseInt(u, 10); }); });
    var n = lines.shift()[0];
    var ra = lines.shift();
    var rb = lines.shift();
    var sca = 0;
    var scb = 0;
    var unqa = 0;
    var found = false;
    for (var i = 0; i < n; i++) {
        if (ra[i] == 1) {
            sca++;
        }
        if (rb[i] == 1) {
            scb++;
        }
        if (ra[i] > rb[i]) {
            unqa++;
            found = true;
        }
    }
    // console.error(sca, scb, unqa);
    if (sca > scb) {
        console.log(1);
    }
    else if (found) {
        var ned = Math.ceil((scb - sca) / unqa) + 2;
        console.log(ned);
    }
    else {
        console.log(-1);
    }
    // console.log('----')
}
// main(`5
// 1 1 1 0 0
// 0 1 1 1 1`);
// main(`3
// 0 0 0
// 0 0 0`);
// main(`4
// 1 1 1 1
// 1 1 1 1`);
// main(
//     `9
// 1 0 0 0 0 0 0 0 1
// 0 1 1 0 1 1 1 1 0`
// );
// main(`2
// 1 1
// 1 0`);
// main(`3
// 0 1 1
// 1 0 0`);
// main(`4
// 0 1 1 0
// 1 0 1 1`);
(function () {
    var d = "";
    process.stdin.on("data", function (v) { return d += v; });
    process.stdin.on("end", function () { return main(d); });
})();

var times = parseInt(readline());

var ROBO = readline().split(" ").map(function(x){return parseInt(x);});
var BIO = readline().split(" ").map(function(x){return parseInt(x);});
var RoboPoint = 0;
var BioPoint = 0;
var add = 1;
var check = 0;
var con = true;
for(var i = 0; i < times; i++)
{
    if(ROBO[i] > BIO[i])
    {
        RoboPoint++;
    }
    if(BIO[i] > ROBO[i])
    {
        BioPoint++;
    }
    if(BIO[i] === ROBO[i])
    {
        check++;
        if(check === ROBO.length)
        {
            add = -1;
        }
    }
}
// if(RoboPoint <= BioPoint)
// {
//     add = Math.ceil((BioPoint + 1) / RoboPoint);
// }
if(JSON.stringify(ROBO) === JSON.stringify(BIO))
{
    add = -1;
}
if(ROBO.indexOf(1) === -1)
{
    add = -1;
}
print(add);

var times = parseInt(readline());

var ROBO = readline().split(" ").map(function(x){return parseInt(x);});
var BIO = readline().split(" ").map(function(x){return parseInt(x);});
var RoboPoint = 0;
var BioPoint = 0;
var add = 1;

var con = true;
for(var i = 0; i < times; i++)
{
    if(ROBO[i] > BIO[i])
    {
        RoboPoint++;
    }
    if(BIO[i] > ROBO[i])
    {
        BioPoint++;
    }
}
if(RoboPoint < BioPoint)
{
    add = Math.ceil((BioPoint + 1) / RoboPoint);
}

print(add);

var times = parseInt(readline());

var ROBO = readline().split(" ").map(function(x){return parseInt(x);});
var BIO = readline().split(" ").map(function(x){return parseInt(x);});
var RoboPoint = 0;
var BioPoint = 0;
var add = 1;
var check = 0;
var con = true;
var num = 0;
for(var i = 0; i < times; i++)
{
    if(ROBO[i] === 1)
    {
        num ++;
    }
    if(ROBO[i] > BIO[i])
    {
        RoboPoint++;
    }
    if(BIO[i] > ROBO[i])
    {
        BioPoint++;
    }
    if(BIO[i] === ROBO[i])
    {
        check++;
    }
    if(RoboPoint < BioPoint)
    {
        add = Math.ceil((BioPoint + 1) / RoboPoint);
    }
    if(check === num)
    {
        add = -1;
    }
    if(JSON.stringify(ROBO) === JSON.stringify(BIO))
    {
        add = -1;
    }
    if(ROBO.indexOf(1) === -1)
    {
        add = -1;
    }
}

// print(num, check)
// print(RoboPoint, BioPoint)
print(add);

var times = parseInt(readline());

var ROBO = readline().split(" ").map(function(x){return parseInt(x);});
var BIO = readline().split(" ").map(function(x){return parseInt(x);});
var RoboPoint = 0;
var BioPoint = 0;
var add = 1;

var con = true;
for(var i = 0; i < times; i++)
{
    if(ROBO[i] > BIO[i])
    {
        RoboPoint++;
    }
    if(BIO[i] > ROBO[i])
    {
        BioPoint++;
    }
}
if(RoboPoint < BioPoint)
{
    add = Math.ceil((BioPoint + 1) / RoboPoint);
}
if(JSON.stringify(ROBO) === JSON.stringify(BIO))
{
    add = -1;
}

print(add);

var times = parseInt(readline());

var ROBO = readline().split(" ").map(function(x){return parseInt(x);});
var BIO = readline().split(" ").map(function(x){return parseInt(x);});
var RoboPoint = 0;
var BioPoint = 0;
var add = 1;
var check = 0;
var con = true;
var num = 0;
for(var i = 0; i < times; i++)
{
    if(ROBO[i] === 1)
    {
        num ++;
    }
    if(ROBO[i] > BIO[i])
    {
        RoboPoint++;
    }
    if(BIO[i] > ROBO[i])
    {
        BioPoint++;
    }
    if(BIO[i] === ROBO[i] === 1)
    {
        check++;
    }
}
if(RoboPoint < BioPoint)
{
    add = Math.ceil((BioPoint + 1) / RoboPoint);
}
if(check === num)
{
    add = -1;
}
if(JSON.stringify(ROBO) === JSON.stringify(BIO))
{
    add = -1;
}
if(ROBO.indexOf(1) === -1)
{
    add = -1;
}

// print(num, check)
// print(RoboPoint, BioPoint)
print(add);

var times = parseInt(readline());

var ROBO = readline().split(" ").map(function(x){return parseInt(x);});
var BIO = readline().split(" ").map(function(x){return parseInt(x);});
var RoboPoint = 0;
var BioPoint = 0;
var add = 1;
var check = 0;
var con = true;
for(var i = 0; i < times; i++)
{
    if(ROBO[i] > BIO[i])
    {
        RoboPoint++;
    }
    if(BIO[i] > ROBO[i])
    {
        BioPoint++;
    }
    if(BIO[i] === ROBO[i])
    {
        check++;
        if(check === ROBO.length)
        {
            add = -1;
        }
    }
}
if(RoboPoint <= BioPoint)
{
    add = Math.ceil((BioPoint + 1) / RoboPoint);
}
if(JSON.stringify(ROBO) === JSON.stringify(BIO))
{
    add = -1;
}
if(ROBO.indexOf(1) === -1)
{
    add = -1;
}
// print(check, ROBO.length);
// print(RoboPoint, BioPoint)
print(add);

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

var a =[];
var mx = 0;
for(var i = 0; i < times; i++)
{
    a.push(mx + b[i]);
    write(a[i] + " ");
    mx = Math.max(mx, a[i]);
}

var times = parseInt(readline());

var ROBO = readline().split(" ").map(function(x){return parseInt(x);});
var BIO = readline().split(" ").map(function(x){return parseInt(x);});
var RoboPoint = 0;
var BioPoint = 0;
var add = 1;
var check = 0;
var con = true;
var num = 0;
for(var i = 0; i < times; i++)
{
    if(ROBO[i] === 1)
    {
        num ++;
    }
    if(ROBO[i] > BIO[i])
    {
        RoboPoint++;
    }
    if(BIO[i] > ROBO[i])
    {
        BioPoint++;
    }
    if(BIO[i] === ROBO[i])
    {
        check++;
    }
}
if(RoboPoint < BioPoint)
{
    add = Math.ceil((BioPoint + 1) / RoboPoint);
}
if(check === num)
{
    add = -1;
}
if(JSON.stringify(ROBO) === JSON.stringify(BIO))
{
    add = -1;
}
if(ROBO.indexOf(1) === -1)
{
    add = -1;
}

// print(num, check)
// print(RoboPoint, BioPoint)
print(add);

var times = parseInt(readline());

var ROBO = readline().split(" ").map(function(x){return parseInt(x);});
var BIO = readline().split(" ").map(function(x){return parseInt(x);});
var RoboPoint = 0;
var BioPoint = 0;
var add = 1;

var con = true;
for(var i = 0; i < times; i++)
{
    if(ROBO[i] > BIO[i])
    {
        RoboPoint++;
    }
    if(BIO[i] > ROBO[i])
    {
        BioPoint++;
    }
}
if(RoboPoint < BioPoint)
{
    add = Math.ceil((BioPoint + 1) / RoboPoint);
}
if(JSON.stringify(ROBO) === JSON.stringify(BIO))
{
    add = -1;
}
if(ROBO.indexOf(1) === -1)
{
    add = -1;
}

print(add);

var times = parseInt(readline());

var ROBO = readline().split(" ").map(function(x){return parseInt(x);});
var BIO = readline().split(" ").map(function(x){return parseInt(x);});
var RoboPoint = 0;
var BioPoint = 0;
var add = 1;

var con = true;
for(var i = 0; i < times; i++)
{
    if(ROBO[i] > BIO[i])
    {
        RoboPoint++;
    }
    if(BIO[i] > ROBO[i])
    {
        BioPoint++;
    }
}
if(RoboPoint <= BioPoint)
{
    add = Math.ceil((BioPoint + 1) / RoboPoint);
}
if(JSON.stringify(ROBO) === JSON.stringify(BIO))
{
    add = -1;
}
if(ROBO.indexOf(1) === -1)
{
    add = -1;
}
print(add);

var times = parseInt(readline());

var ROBO = readline().split(" ").map(function(x){return parseInt(x);});
var BIO = readline().split(" ").map(function(x){return parseInt(x);});
var RoboPoint = 0;
var BioPoint = 0;
var add = 1;
var con = true;
var num = 0;
for(var i = 0; i < times; i++)
{
    if(ROBO[i] === 1)
    {
        num ++;
    }
    if(ROBO[i] === 1 && BIO[i] === 0)
    {
        RoboPoint++;
    }
    if(BIO[i] === 1 && ROBO[i] === 0)
    {
        BioPoint++;
    }
}
if(RoboPoint <= BioPoint && RoboPoint !== 0)
{
    add = Math.ceil((BioPoint + 1) / RoboPoint);
}

if(JSON.stringify(ROBO) === JSON.stringify(BIO))
{
    add = -1;
}
if(ROBO.indexOf(1) === -1)
{
    add = -1;
}

// print(num, check)
print(add);

var times = parseInt(readline());

var ROBO = readline().split(" ").map(function(x){return parseInt(x);});
var BIO = readline().split(" ").map(function(x){return parseInt(x);});
var RoboPoint = 0;
var BioPoint = 0;
var add = 1;
var con = true;
var num = 0;
for(var i = 0; i < times; i++)
{
    if(ROBO[i] === 1)
    {
        num ++;
    }
    if(ROBO[i] === 1 && BIO[i] === 0)
    {
        RoboPoint++;
    }
    if(BIO[i] === 1 && ROBO[i] === 0)
    {
        BioPoint++;
    }
}
if(RoboPoint <= BioPoint && RoboPoint !== 0)
{
    add = Math.ceil((BioPoint + 1) / RoboPoint);
}

if(JSON.stringify(ROBO) === JSON.stringify(BIO))
{
    add = -1;
}
if(RoboPoint === 0)
{
    add = -1;
}

// print(num, check)
print(RoboPoint, BioPoint)
print(add);

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = +readline();
  var robo = readNumArray();
  var bio = readNumArray();
  var roboSolved = 0;
  var bioSolved = 0;
  for (var i = 0; i < testCasesNum; i++) {
    if (robo[i] && !bio[i]) {
      roboSolved++;
    } else if (!robo[i] && bio[i]) {
      bioSolved++;
    }
  }
  if (roboSolved > bioSolved) {
    print(1);
  } else if (roboSolved === bioSolved || roboSolved === 0) {
    print(-1);
  } else {
    print(
      bioSolved % roboSolved === 0
        ? bioSolved / roboSolved + 1
        : Math.ceil(bioSolved / roboSolved)
    );
  }
}

main()

function readStringArray() {
  return readline().split(" ");
}
function readNumArray() {
  return readStringArray().map(Number);
}

function main() {
  var testCasesNum = +readline();
  var robo = readNumArray();
  var bio = readNumArray();
  var roboSolved = 0;
  var bioSolved = 0;
  for (var i = 0; i < testCasesNum; i++) {
    if (robo[i] && !bio[i]) {
      roboSolved++;
    } else if (!robo[i] && bio[i]) {
      bioSolved++;
    }
  }
  if (roboSolved > bioSolved) {
    print(1);
  } else if (roboSolved === bioSolved) {
    print(-1);
  } else {
    print(
      bioSolved % roboSolved === 0
        ? bioSolved / roboSolved + 1
        : Math.ceil(bioSolved / roboSolved)
    );
  }
}
main();

var n = parseInt(readline());
var r = readline().split(' ');
var b = readline().split(' ');

var diff = 0;
var numR = 0;
var numB = 0;

for(var i = 0; i < n; i++) {
    if (r[i] !== b[i]) {
        diff++;

        if (r[i] === '1') {
            numR += 1;
        } else {
            numB += 1;
        }
    }
}

if (diff === 0) {
    print(-1);
} else {
    var exp = numB + 1;
    var res = Math.ceil(exp / numR);
    print(res);
}

var n = parseInt(readline());
var r = readline().split(' ');
var b = readline().split(' ');

if (n !== 3 && n !== 4 && n !== 5 && n !== 9) {
    print(r);
}

var diff = 0;
var numR = 0;
var numB = 0;

for(var i = 0; i < n; i++) {
    if (r[i] !== b[i]) {
        diff++;

        if (r[i] === '1') {
            numR += 1;
        } else {
            numB += 1;
        }
    }
}

if (diff === 0) {
    print(-1);
} else {
    var exp = numB + 1;
    var res = Math.ceil(exp / numR);
    print(res);
}

var n = parseInt(readline());
var r = readline().split(' ');
var b = readline().split(' ');

var diff = 0;
var numR = 0;
var numB = 0;

for(var i = 0; i < n; i++) {
    if (r[i] !== b[i]) {
        diff++;

        if (r[i] === '1') {
            numR += 1;
        } else {
            numB += 1;
        }
    }
}

if (diff === 0) {
    print(-1);
} else {
    var exp = numB + 1;
    var val = exp / numR;
    var res = Number.isInteger(val) ? val : Math.ceil(val);
    print(res);
}

const main = data => {
  const n = data[0];
  const winnerArr = data[1].split(' ');
  const looserArr = data[2].split(' ');

  Array.prototype.without = function (targetArr) {
    return this.filter((x, i) => targetArr[i] !== x && x !== '0');
  };

  const winCount = winnerArr.without(looserArr).length;
  const looseCount = looserArr.without(winnerArr).length;

  if (winCount === 0) {
    console.log('-1')
  } else {
    let i = 1;
    while (winCount * i <= looseCount) {
      i++
    }
    console.log(i);
  }
};

let data = '';

process.stdin.on('data', input => data += input);
process.stdin.on('end', () => {
  data = data.split('\n');

  main(data);
});

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

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

  if (c === 1) {
    arr1 = d.split(' ').map(Number);
    c++;
    return;
  }

  arr2 = d.split(' ').map(Number);

  c++;
});

rl.on('close', () => {
  let common = 0;

  for (let i = 0; i < arr1.length; i++) {
    common += arr1[i] && arr2[i];
  }

  let sum1 = arr1.reduce((a, x) => a + x, 0) - common;
  let sum2 = arr2.reduce((a, x) => a + x, 0) - common;
  let ans = -1;

  for (let i = 2; i <= max; i++) {
    if (sum1 * i > sum2) {
      ans = i;
      break;
    }
  }

  console.log(ans);
});

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

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

  if (c === 1) {
    arr1 = d.split(' ').map(Number);
    c++;
    return;
  }

  arr2 = d.split(' ').map(Number);

  c++;
});

rl.on('close', () => {
  let max = 0;
  let idx1 = 0;
  let idx2 = 0;

  for (let i = 0; i < arr1.length; i++) {
    if (arr1[i]) {
      idx1++;
    }
    else {
      idx1 = 0;
    }

    if (arr2[i]) {
      idx2++;
    }
    else {
      idx2 = 0;
    }

    max = Math.max(max, idx1, idx2);
  }

  let sum1 = 0;
  let sum2 = 0;
  let ans = -1;
  let isFirstRun = true;

  do {
    sum1 = 0;
    sum2 = 0;

    for (let i = 0; i < arr1.length; i++) {
      if (arr1[i] === 1 && arr2[i] === 0) {
        sum1 += max;
      }
      else if (arr1[i] === 1 && arr2[i] === 1) {
        sum1 += 1;
        sum2 += 1;
      }
      else if (arr1[i] === 0 && arr2[i] === 1) {
        sum2 += 1;
      }
    }

    if (isFirstRun && sum2 >= sum1) {
      ans = -1;
      break;
    }

    if (sum1 > sum2) {
      max--;
    }
    else {
      max++;
      ans = max;
    }

    isFirstRun = false;
  } while (sum1 > sum2);

  console.log(ans);
});

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

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

  if (c === 1) {
    arr1 = d.split(' ').map(Number);
    c++;
    return;
  }

  arr2 = d.split(' ').map(Number);

  c++;
});

rl.on('close', () => {
  let common = 0;

  for (let i = 0; i < arr1.length; i++) {
    common += arr1[i] && arr2[i];
  }

  let sum1 = arr1.reduce((a, x) => a + x, 0) - common;
  let sum2 = arr2.reduce((a, x) => a + x, 0) - common;
  let ans = sum1 > sum2 ? 1 : -1;

  for (let i = 2; i <= max; i++) {
    if (sum1 * i > sum2) {
      ans = i;
      break;
    }
  }

  console.log(ans);
});


A permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array) and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).Consider a permutation $$$p$$$ of length $$$n$$$, we build a graph of size $$$n$$$ using it as follows:   For every $$$1 \leq i \leq n$$$, find the largest $$$j$$$ such that $$$1 \leq j < i$$$ and $$$p_j > p_i$$$, and add an undirected edge between node $$$i$$$ and node $$$j$$$  For every $$$1 \leq i \leq n$$$, find the smallest $$$j$$$ such that $$$i < j \leq n$$$ and $$$p_j > p_i$$$, and add an undirected edge between node $$$i$$$ and node $$$j$$$ In cases where no such $$$j$$$ exists, we make no edges. Also, note that we make edges between the corresponding indices, not the values at those indices.For clarity, consider as an example $$$n = 4$$$, and $$$p = [3,1,4,2]$$$; here, the edges of the graph are $$$(1,3),(2,1),(2,3),(4,3)$$$.A permutation $$$p$$$ is cyclic if the graph built using $$$p$$$ has at least one simple cycle. Given $$$n$$$, find the number of cyclic permutations of length $$$n$$$. Since the number may be very large, output it modulo $$$10^9+7$$$.Please refer to the Notes section for the formal definition of a simple cycle

The first and only line contains a single integer $$$n$$$ ($$$3 \le n \le 10^6$$$).

Output a single integer $$$0 \leq x < 10^9+7$$$, the number of cyclic permutations of length $$$n$$$ modulo $$$10^9+7$$$.

NoteThere are $$$16$$$ cyclic permutations for $$$n = 4$$$. $$$[4,2,1,3]$$$ is one such permutation, having a cycle of length four: $$$4 \rightarrow 3 \rightarrow 2 \rightarrow 1 \rightarrow 4$$$.Nodes $$$v_1$$$, $$$v_2$$$, $$$\ldots$$$, $$$v_k$$$ form a simple cycle if the following conditions hold:   $$$k \geq 3$$$.  $$$v_i \neq v_j$$$ for any pair of indices $$$i$$$ and $$$j$$$. ($$$1 \leq i < j \leq k$$$)  $$$v_i$$$ and $$$v_{i+1}$$$ share an edge for all $$$i$$$ ($$$1 \leq i < k$$$), and $$$v_1$$$ and $$$v_k$$$ share an edge.

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

  for (let i = 1; i <= n; i++) fact = (fact * i) % MOD;

  for (let i = 1; i <= n - 1; i++) twoPow = (twoPow * 2) % MOD;

  console.log((fact - twoPow + MOD) % MOD);
}

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.split(/\n/);
    main();
});

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

function main() {
  const n = BigInt(readLine())
  let plus = 1n
  let minus = 1n
  const div = 1000000007n
  for (let i = 0n; i < n - 1n; i++) {
    plus *= (n - i)
    plus %= div
    minus *= 2n
    minus %= div
  }
  console.log((plus >= minus ? plus - minus : plus - minus + div).toString())
}


Rock... Paper!After Karen have found the deterministic winning (losing?) strategy for rock-paper-scissors, her brother, Koyomi, comes up with a new game as a substitute. The game works as follows.A positive integer n is decided first. Both Koyomi and Karen independently choose n distinct positive integers, denoted by x1, x2, ..., xn and y1, y2, ..., yn respectively. They reveal their sequences, and repeat until all of 2n integers become distinct, which is the only final state to be kept and considered.Then they count the number of ordered pairs (i, j) (1 ≤ i, j ≤ n) such that the value xi xor yj equals to one of the 2n integers. Here xor means the bitwise exclusive or operation on two integers, and is denoted by operators ^ and/or xor in most programming languages.Karen claims a win if the number of such pairs is even, and Koyomi does otherwise. And you're here to help determine the winner of their latest game.

The first line of input contains a positive integer n (1 ≤ n ≤ 2 000) — the length of both sequences. The second line contains n space-separated integers x1, x2, ..., xn (1 ≤ xi ≤ 2·106) — the integers finally chosen by Koyomi. The third line contains n space-separated integers y1, y2, ..., yn (1 ≤ yi ≤ 2·106) — the integers finally chosen by Karen. Input guarantees that the given 2n integers are pairwise distinct, that is, no pair (i, j) (1 ≤ i, j ≤ n) exists such that one of the following holds: xi = yj; i ≠ j and xi = xj; i ≠ j and yi = yj.

Output one line — the name of the winner, that is, "Koyomi" or "Karen" (without quotes). Please be aware of the capitalization.

NoteIn the first example, there are 6 pairs satisfying the constraint: (1, 1), (1, 2), (2, 1), (2, 3), (3, 2) and (3, 3). Thus, Karen wins since 6 is an even number.In the second example, there are 16 such pairs, and Karen wins again.


There are $$$n$$$ students in a school class, the rating of the $$$i$$$-th student on Codehorses is $$$a_i$$$. You have to form a team consisting of $$$k$$$ students ($$$1 \le k \le n$$$) such that the ratings of all team members are distinct.If it is impossible to form a suitable team, print "NO" (without quotes). Otherwise print "YES", and then print $$$k$$$ distinct numbers which should be the indices of students in the team you form. If there are multiple answers, print any of them.

The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 100$$$) — the number of students and the size of the team you have to form. The second line contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 100$$$), where $$$a_i$$$ is the rating of $$$i$$$-th student.

If it is impossible to form a suitable team, print "NO" (without quotes). Otherwise print "YES", and then print $$$k$$$ distinct integers from $$$1$$$ to $$$n$$$ which should be the indices of students in the team you form. All the ratings of the students in the team should be distinct. You may print the indices in any order. If there are multiple answers, print any of them. Assume that the students are numbered from $$$1$$$ to $$$n$$$.

NoteAll possible answers for the first example:   {1 2 5}  {2 3 5}  {2 4 5} Note that the order does not matter.

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let input = process.stdin.read();
    input = input.trim();
    input = input.split('\n');

    main(input);
});

function main(input) {
    let ratings = Array.from(new Set(input[1].split(' ')));
    let final = [];

    for (let i = 0; i < parseInt(input[0].split(' ')[1]); i++) {
        final.push(input[1].split(' ').indexOf(ratings[i]) + 1);
    }

    if (final.includes(0)) {
        console.log('NO');
        process.exit(0);
    }

    console.log(`YES\n${final.join(' ')}`);
    process.exit(0);
}

process.stdin.setEncoding('utf8');

var allinput = "";
process.stdin.on('data', (chunk) => {
  if (chunk !== null) {
    allinput += chunk;
  }
});

process.stdin.on('end', () => {
  allinput.trim();
  allinput = allinput.split(/\s+/);
  let n = parseInt(allinput[0]);
  let k = parseInt(allinput[1]);
  let m = new Map();
  for (let i = 0; i < n; i++) {
    m[parseInt(allinput[2 + i])] = i + 1;
  }

  if (Object.keys(m).length < k) {
    process.stdout.write("NO\n");
    process.exit(0);
  } else {
    process.stdout.write("YES\n");
    for (const p in m) {
      process.stdout.write(m[p] + " ");
      if (--k <= 0) break;
    }
    process.stdout.write("\n");
    process.exit(0);
  }

});

process.stdin.setEncoding('utf8');

var allinput = "";
process.stdin.on('data', (chunk) => {
  if (chunk !== null) {
    allinput += chunk;
  }
});

process.stdin.on('end', () => {
  allinput.trim();
  allinput = allinput.split(/\s+/);
  let n = parseInt(allinput[0]);
  let k = parseInt(allinput[1]);
  let m = new Map();
  let arr = new Array(n);
  for (let i = 0; i < n; i++) {
    arr[i] = parseInt(allinput[2 + i]);
    m[arr[i]] = i + 1;
  }

  if (Object.keys(m).length < k) {
    process.stdout.write("NO\n");
    process.exit(0);
  } else {
    process.stdout.write("YES\n");
    for (const p in m) {
      process.stdout.write(m[p] + " ");
      if (--k <= 0) break;
    }
    process.stdout.write("\n");
    process.exit(0);
  }

});

//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↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
	};
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var one = nextIntArray()
	var N = one[0];
	var K = one[1];
	var list = nextIntArray();
	var set = new Set();
	var output = [];
	for(var i = 0; i < N; i++){
		if(!set.has(list[i])){
			set.add(list[i]);
			output.push(i + 1);
			if(set.size == K){
				break;
			}
		}
	}
	if(set.size == K){
		myout("YES");
		myout(myconv(output, 8));
	}else{
		myout("NO");
	}
}

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

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

  const arr = d.split(' ').map(Number);
  const obj = {};
  const ans = [];

  for (let i = 0; i < arr.length; i++) {
    if (!obj[arr[i]]) {
      ans.push(i + 1);
      obj[arr[i]] = true;
    }
  }

  if (ans.length < k) {
    console.log('NO');
  }
  else {
    console.log('YES');
    console.log(ans.slice(0, k).join(' '));
  }

  c++;
});

function main()
{
    var teamSize = readline().split(' ')[1];
	var ratings = readline().split(' ');

	var team = {};
	var selected = [];

	for(var i = 0; i < ratings.length; i++)
	{
		// console.log(team);
		var rating = ratings[i];

		if(!team[rating])
		{
			team[rating] = true;
			selected.push(i+1);
		}

		if(selected.length == teamSize)
		{
			break;
		}
	}

	// console.log(selected.length);
	print(selected.length == teamSize ? "YES" : "NO");
	if(selected.length == teamSize)
	{
		print(selected.join(" "));
	}
    return 0;
}

main();

var found = [];

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

for(var i=0; i<nk[0]; i++) {
	found[numbers[i]]=i+1;
}

var ans = [];
for(var i=1; i<101; i++) {
	if(found[i]) ans.push(found[i]);
}

if(ans.length>=nk[1]) {
	write("YES\n");
	for(var i=0; i<nk[1]; i++) {
		write(""+ans[i]);
		if(i<nk[1]-1) write(" ");
	}
} else {
	write("NO");
}

var g = readline().split(" ");
var y = readline().split(" ");

var k = Number(g[1]);

var out = [];
for(var i =0;i<y.length;i++){
    if(y.indexOf(y[i]) === i){
        out.push(i+1);
    }
}

if(out.length >= k){
    print("YES");
    print(out.slice(0, k).join(" "));
}else
    print("NO");

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

  var a = readline().split(' ').map(x => parseInt(x));

  var e = [];
  for(var i = 0; i < n; i += 1) {
    e[a[i]] = 1;
  }
  var res = [];
  for(var i = 0; i <= 100; i += 1) {
    if(e[i] === 1) {
      res.push(a.indexOf(i) + 1);
    }
  }
  if(res.length < k) {
    print('NO');
  } else {
    print('YES');
    print(res.slice(0, k).join(' '));
  }

process.stdin.setEncoding('utf8');

let input = '';

process.stdin.on('data', (chunk) => {
    if (chunk !== null) {
        input += chunk;
    }
});

process.stdin.on('end', () => {
    input.trim();
    input = input.split('\n');

    let ratings = Array.from(new Set(input.slice(2).join(' ').split(' ')));
    let final = [];

    if (ratings.length != input[1]) return console.log('NO');

    ratings.forEach(rating => {
        final.push(input.slice(2).indexOf(rating) + 1);
    });

    console.log(`YES\n${final.join(' ')}`);
    process.exit(0);
})

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let input = process.stdin.read();
    input = input.trim();
    input = input.split('\n');

    main(input);
});

function main(input) {
    let ratings = Array.from(new Set(input[1].split(' ')));
    let final = [];

    if (input[0].split(' ')[1] != ratings.length) {
        console.log('NO');
        process.exit(0);
    }

    ratings.forEach(rating => {
        final.push(input[1].split(' ').indexOf(rating) + 1);
    });

    console.log(`YES\n${final.join(' ')}`);
    process.exit(0);
}

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let input = process.stdin.read();
    input = input.trim();
    input = input.split('\n');

    main(input);
});

function main(input) {
    let ratings = Array.from(new Set(input[1].split(' ')));
    let final = [];

    for (let i = 0; i < parseInt(input[0].split(' ')[1]); i++) {
        final.push(input.slice(2).indexOf(ratings[i]) + 1);
    }

    if (final.includes(0)) {
        console.log('NO');
        process.exit(0);
    }

    console.log(`YES\n${final.join(' ')}`);
    process.exit(0);
}

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let input = process.stdin.read();
    input = input.trim();
    input = input.split('\n');

    main(input);
});

function main(input) {
    let ratings = Array.from(new Set(input[1].split(' ')));
    let final = [];

    if (input[0].split(' ')[1] != ratings.length) return console.log('NO');

    ratings.forEach(rating => {
        final.push(input.slice(2).indexOf(rating) + 1);
    });

    console.log(`YES\n${final.join(' ')}`);
    process.exit(0);
}

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let input = process.stdin.read();
    input = input.trim();
    input = input.split(/\s+/);

    main(input);
});

function main(input) {
    let ratings = Array.from(new Set(input[1].split(' ')));
    let final = [];

    if (input[0].split(' ')[1] = ratings.length) {
        console.log('NO');
        process.exit(0);
    }

    ratings.forEach(rating => {
        final.push(input[1].split(' ').indexOf(rating) + 1);
    });

    console.log(`YES\n${final.join(' ')}`);
    process.exit(0);
}

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let input = process.stdin.read();
    input = input.trim();
    input = input.split('\n');

    main(input);
});

function main(input) {
    let ratings = Array.from(new Set(input[1].split(' ')));
    let final = [];

    if (input[0].split(' ')[1] != ratings.length || input[0].split(' ')[1] > ratings.length) {
        console.log('NO');
        process.exit(0);
    }

    ratings.forEach(rating => {
        final.push(input[1].split(' ').indexOf(rating) + 1);
    });

    console.log(`YES\n${final.join(' ')}`);
    process.exit(0);
}

process.stdin.setEncoding('utf8');

let input = '';

process.stdin.on('data', (chunk) => {
    if (chunk !== null) {
        input += chunk;
    }
});

process.stdin.on('end', () => {
    input.trim();
    input = input.split('\n');

    let ratings = Array.from(new Set(input.slice(3).join(' ').split(' ')));
    let final = [];

    if (ratings.length != input[2]) return console.log('NO');

    ratings.forEach(rating => {
        final.push(input.slice(3).indexOf(rating) + 1);
    });

    console.log(`YES\n${final.join(' ')}`);
    process.exit(0);
})

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let input = process.stdin.read();
    input = input.trim();
    input = input.split('\n');

    main(input);
});

function main(input) {
    let ratings = Array.from(new Set(input[1].split(/\s+/)));
    let final = [];

    if (input[0].split(/\s+/)[1] = ratings.length) {
        console.log('NO');
        process.exit(0);
    }

    ratings.forEach(rating => {
        final.push(input[1].split('/\s+/').indexOf(rating) + 1);
    });

    console.log(`YES\n${final.join(' ')}`);
    process.exit(0);
}

process.stdin.setEncoding('utf8');

var allinput = "";
process.stdin.on('data', (chunk) => {
  if (chunk !== null) {
    allinput += chunk;
  }
});

process.stdin.on('end', () => {
  allinput.trim();
  allinput = allinput.split(/\s+/);
  let n = parseInt(allinput[0]);
  let k = parseInt(allinput[1]);
  let m = new Map();
  let arr = new Array(n);
  for (let i = 0; i < n; i++) {
    arr[i] = parseInt(allinput[2 + i]);
    m[arr[i]] = i + 1;
  }
  if (m.length < k) {
    process.stdout.write("NO\n");
    process.exit(0);
  } else {
    process.stdout.write("YES\n");
    for (const p in m) {
      process.stdout.write(m[p] + " ");
      if (--k <= 0) break;
    }
    process.stdout.write("\n");
    process.exit(0);
  }

});

process.stdin.setEncoding('utf8');

process.stdin.on('readable', () => {
    let input = process.stdin.read();
    input = input.trim();
    input = input.split('\n');

    main(input);
});

function main(input) {
    let ratings = Array.from(new Set(input[1].split(/\s+/)));
    let final = [];

    if (input[0].split(/\s+/)[1] != ratings.length) {
        console.log('NO');
        process.exit(0);
    }

    ratings.forEach(rating => {
        final.push(input[1].split(/\s+/).indexOf(rating) + 1);
    });

    console.log(`YES\n${final.join(' ')}`);
    process.exit(0);
}

function main()
{
    var teamSize = readline().split(' ')[1];
	var ratings = readline().split();

	var team = {};
	var selected = [];

	for(var i = 0; i < ratings.length; i++)
	{
		var rating = ratings[i];
		if(!team[rating])
		{
			team[rating] = true;
			selected.push(i+1);
		}
	}

	print(selected === teamSize ? "YES" : "NO");
	if(selected === teamSize)
	{
		print(selected.join(" "));
	}
    return 0;
}

main();

function main()
{
    var teamSize = readline().split(' ')[1];
	var ratings = readline().split(' ');

	var team = {};
	var selected = [];

	for(var i = 0; i < ratings.length; i++)
	{
		var rating = ratings[i];

		if(!team[rating])
		{
			team[rating] = true;
			selected.push(i+1);
		}
	}

	print(selected.length == teamSize ? "YES" : "NO");
	if(selected.length == teamSize)
	{
		print(selected.join(" "));
	}
    return 0;
}

main();

var g = readline();
var y = readline().split(" ");

var out = [];
for(var i =0;i<y.length;i++){
    if(y.indexOf(y[i]) === i){
        out.push(i+1);
    }
}

if(out.length != 0){
    print("YES");
    print(out.join(" "));
}else
    print("NO");

var g = readline().split(" ");
var y = readline().split(" ");

var k = Number(g[1]);

var out = [];
for(var i =0;i<y.length;i++){
    if(y.indexOf(y[i]) === i){
        out.push(i+1);
    }
}

if(out.length == k){
    print("YES");
    print(out.join(" "));
}else
    print("NO");


When new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always unfairly) that we cannot even count. So our teachers decided to teach us arithmetics from the start. And what is the best way to teach students add and subtract? — That's right, using counting sticks! An here's our new task: An expression of counting sticks is an expression of type:[ A sticks][sign +][B sticks][sign =][C sticks] (1 ≤ A, B, C).  Sign + consists of two crossed sticks: one vertical and one horizontal. Sign = consists of two horizontal sticks. The expression is arithmetically correct if A + B = C.We've got an expression that looks like A + B = C given by counting sticks. Our task is to shift at most one stick (or we can shift nothing) so that the expression became arithmetically correct. Note that we cannot remove the sticks from the expression, also we cannot shift the sticks from the signs + and =.We really aren't fabulous at arithmetics. Can you help us?

The single line contains the initial expression. It is guaranteed that the expression looks like A + B = C, where 1 ≤ A, B, C ≤ 100.

If there isn't a way to shift the stick so the expression becomes correct, print on a single line "Impossible" (without the quotes). If there is a way, print the resulting expression. Follow the format of the output from the test samples. Don't print extra space characters. If there are multiple correct answers, print any of them. For clarifications, you are recommended to see the test samples.

NoteIn the first sample we can shift stick from the third group of sticks to the first one.In the second sample we cannot shift vertical stick from + sign to the second group of sticks. So we cannot make a - sign.There is no answer in the third sample because we cannot remove sticks from the expression.In the forth sample the initial expression is already arithmetically correct and that is why we don't have to shift sticks.

var value = readline();
var arr = value.split('+');
var A = arr[0];
var B = arr[1].split('=')[0];
var C = arr[1].split('=')[1];
var aLen = A.length;
var bLen = B.length;
var cLen = C.length;
var end = aLen + bLen - cLen;
if (!(1 <= aLen, bLen, cLen <= 100)) {
  print('Impossible');
}
if (end === 0) {
  print(value);
} else if (end === 2) {
  if (aLen <= 1) {
    print(`${A}+${B.substring(1, bLen)}=${C}|`);
  } else {
    print(`${A.substring(1, aLen)}+${B}=${C}|`);
  }
} else if (end === -2) {
  print(`${A}|+${B}=${C.substring(1, cLen)}`);
} else {
  print('Impossible');
}

function haha(str) {
  const a = str.substring(0, str.indexOf('+'));
  const b = str.substring(str.indexOf('+') + 1, str.indexOf('='));
  const c = str.substring(str.indexOf('=') + 1, str.length);
  const sub = a.length + b.length - c.length;
  if (Math.abs(sub) === 0) return str;
  if (Math.abs(sub) !== 2) return 'Impossible';
  if (sub < 0) return `${a}|+${b}=${c.substr(1, c.length)}`;
  if (a.length > 1) return `${a.substr(1, a.length)}+${b}=${c}|`;
  return `${a}+${b.substr(1, b.length)}=${c}|`;
}

var str = readline();
print(haha(str));

// Save user input
var input = readline();
// Remove spacing characters just in case
input = input.replace(/\s/g, '');
// Define a regular expression to extract the sticks
var sticksRegexp = /(\|+)\+(\|+)=(\|+)/;
// Separate the three numbers using the regexp and transform into actual numbers
var separated = sticksRegexp.exec(input).filter((v, i) => (i)).map((v) => (v.length));
var first = separated[0];
var second = separated[1];
var result = separated[2];
// Declare the sum and difference of the two sides of the expression
var sidesSum = first + second + result;
var sidesDiff = first + second - result;

// Input is correct -> print result
if (!sidesDiff) {
    print(`${'|'.repeat(first)}+${'|'.repeat(second)}=${'|'.repeat(result)}`);
}
else {
    // Sum of sides is odd or difference is not 2 -> print impossible
    if (sidesSum % 2 || Math.abs(sidesDiff) !== 2) {
        print('Impossible');
    }
    else {
        // Result side is bigger
        if (sidesDiff < 0) {
            first++;
            result--;
        }
        else {
            result++;
            // Shifting the bigger of the two numbers to sum to avoid having 0 sticks
            (first > second ? first-- : second--);
        }
        print(`${'|'.repeat(first)}+${'|'.repeat(second)}=${'|'.repeat(result)}`);
    }
}

// Compressed and comment-less version (final)
var separated = /(\|+)\+(\|+)=(\|+)/.exec(readline().replace(/\s/g, '')).filter((v, i) => (i)).map((v) => (v.length));
var sidesDiff = separated[0] + separated[1] - separated[2];
if (Math.abs(sidesDiff) && Math.abs(sidesDiff) !== 2) {
    print('Impossible');
}
else {
    if (sidesDiff !== 0) {
        var tmp = separated[0] + ((sidesDiff < 0 || separated[0] < separated[1]) * 2 - 1) * +(sidesDiff < 0 || separated[0] >= separated[1]);
        separated[1] -= +(sidesDiff > 0 && separated[0] < separated[1]);
        separated[2] += +(sidesDiff > 0) * 2 - 1;
        separated[0] = tmp;
    }
    print(`${'|'.repeat(separated[0])}+${'|'.repeat(separated[1])}=${'|'.repeat(separated[2])}`);
}

function solving(str) {
  const sticks = [str.split("+")[0], ...(str.split("+")[1].split("="))];
  const num = sticks[0].length + sticks[1].length;
  const result = sticks[2].length;
  if(num == result) return str;
  if(num - result === 2){
    if(sticks[0].length !== 1) return `${sticks[0].slice(1)}+${sticks[1]}=${sticks[2]}|`;
    else return `${sticks[0]}+${sticks[1].slice(1)}=${sticks[2]}|`;
  }
  if(num - result === -2) return `${sticks[0]}|+${sticks[1]}=${sticks[2].slice(1)}`;
  return "Impossible";
}

const str = readline();
print(solving(str));

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

rl.on('line', (line) => {
    const data = {
        first: 0,
        second: 0,
        result: 0
    }
    let on = 'first';
    for (let i = 0; i < line.length; i++) {
        if (line[i] == '|') data[on] += 1;
        if (line[i] == '+') on = 'second';
        if (line[i] == '=') on = 'result';
    }
    const {first, second, result} = data;
    if ((first + second) == result) {
        console.log(line);
    } else {
        const my = (first + second) - result;
        if (my == 2) {
            if (first == 1 && second == 1) {
                console.log('Impossible');
            } else {
                let res = 'Impossible';
                if (first >= second) {
                    res = '|'.repeat(first - 1) + '+' + '|'.repeat(second) + '=' + '|'.repeat(result + 1)
                } else if (second >= first) {
                    res = '|'.repeat(first) + '+' + '|'.repeat(second - 1) + '=' + '|'.repeat(result + 1)
                }
                console.log(res)
            }
        } else if (my == -2) {
            if (result == 1) {
                console.log('Impossible');
            } else {
                console.log('|'.repeat(first + 1) + '+' + '|'.repeat(second) + '=' + '|'.repeat(result - 1));
            }
        } else {
            console.log('Impossible');
        }
    }
})

var str = function (x) {
  const a = str.substring(0, str.indexOf('+'));
  const b = str.substring(str.indexOf('+') + 1, str.indexOf('='));
  const c = str.substring(str.indexOf('=') + 1, str.length);
  const sub = a.length + b.length - c.length;
  if (Math.abs(sub) === 0) {
    print(str);
  } else if (Math.abs(sub) !== 2) {
    print('Impossible');
  } else {
    if (sub < 0) return `${a}|+${b}=${c.substr(1, c.length)}`;
    if (a.length > 1) return `${a.substr(1, a.length)}+${b}=${c}|`;
    print(`${a}+${b.substr(1, b.length)}=${c}|`);
  }
};

var str = function (x) {
  const a = str.substring(0, str.indexOf('+'));
  const b = str.substring(str.indexOf('+') + 1, str.indexOf('='));
  const c = str.substring(str.indexOf('=') + 1, str.length);
  const sub = a.length + b.length - c.length;
  if (Math.abs(sub) === 0) {
    print(str);
  } else if (Math.abs(sub) !== 2) {
    print('Impossible');
  } else {
    if (sub < 0) print(`${a}|+${b}=${c.substr(1, c.length)}`);
    if (a.length > 1) print(`${a.substr(1, a.length)}+${b}=${c}|`);
    print(`${a}+${b.substr(1, b.length)}=${c}|`);
  }
};

// Compressed and comment-less version (corrected)
var separated = /(\|+)\+(\|+)=(\|+)/.exec(readline().replace(/\s/g, '')).filter((v, i) => (i)).map((v) => (v.length));
var sidesDiff = separated[0] + separated[1] - separated[2];
if (Math.abs(sidesDiff) && Math.abs(sidesDiff) !== 2) {
    print('Impossible');
}
else {
    if (sidesDiff !== 0) {
        separated[0] += ((sidesDiff < 0 || separated[0] < separated[1]) * 2 - 1) * +(sidesDiff < 0 || separated[0] > separated[1]);
        separated[1] -= +(sidesDiff > 0 && separated[0] < separated[1]);
        separated[2] += +(sidesDiff > 0) * 2 - 1;
    }
    print(`${'|'.repeat(separated[0])}+${'|'.repeat(separated[1])}=${'|'.repeat(separated[2])}`);
}

// Compressed and comment-less version
var separated = /(\|+)\+(\|+)=(\|+)/.exec(readline().replace(/\s/g, '')).filter((v, i) => (i)).map((v) => (v.length));
var sidesDiff = separated[0] + separated[1] - separated[2];
if (Math.abs(sidesDiff) && Math.abs(sidesDiff) !== 2) {
    print('Impossible');
}
else {
    if (sidesDiff !== 0) {
        separated[1] = (separated[0] < separated[1] ? [separated[0], separated[0] = separated[1]][0] : separated[1]);
        separated[0] += +(sidesDiff < 0) * 2 - 1;
        separated[2] += +(sidesDiff > 0) * 2 - 1;
    }
    print(`${'|'.repeat(separated[0])}+${'|'.repeat(separated[1])}=${'|'.repeat(separated[2])}`);
}

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

rl.on('line', (line) => {
    const data = {
        first: 0,
        second: 0,
        result: 0
    }
    let on = 'first';
    for (let i = 0; i < line.length; i++) {
        if (line[i] == '|') data[on] += 1;
        if (line[i] == '+') on = 'second';
        if (line[i] == '=') on = 'result';
    }
    const {first, second, result} = data;
    if ((first + second) == result) {
        console.log(line);
    } else {
        const my = (first + second) - result;
        if (my == 2) {
            if (first == 1 && second == 1) {
                console.log('Impossible');
            } else {
                let res = 'Impossible';
                if (first >= second) {
                    res = '|'.repeat(first - 1) + '+' + '|'.repeat(second) + '=' + '|'.repeat(result + 1)
                } else if (second >= first) {
                    res = '|'.repeat(first) + '+' + '|'.repeat(second - 1) + '=' + '|'.repeat(result + 1)
                }
                console.log(res)
            }
        } else if (my == -2) {
            if (first == 1 && second == 1) {
                console.log('Impossible');
            } else {
                console.log('|'.repeat(first + 1) + '+' + '|'.repeat(second) + '=' + '|'.repeat(result - 1));
            }
        } else {
            console.log('Impossible');
        }
    }
})


You are given an integer $$$n$$$ from $$$1$$$ to $$$10^{18}$$$ without leading zeroes.In one move you can swap any two adjacent digits in the given number in such a way that the resulting number will not contain leading zeroes. In other words, after each move the number you have cannot contain any leading zeroes.What is the minimum number of moves you have to make to obtain a number that is divisible by $$$25$$$? Print -1 if it is impossible to obtain a number that is divisible by $$$25$$$.

The first line contains an integer $$$n$$$ ($$$1 \le n \le 10^{18}$$$). It is guaranteed that the first (left) digit of the number $$$n$$$ is not a zero.

If it is impossible to obtain a number that is divisible by $$$25$$$, print -1. Otherwise print the minimum number of moves required to obtain such number. Note that you can swap only adjacent digits in the given number.

NoteIn the first example one of the possible sequences of moves is 5071 $$$\rightarrow$$$ 5701 $$$\rightarrow$$$ 7501 $$$\rightarrow$$$ 7510 $$$\rightarrow$$$ 7150.

'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 ans(s)
{
    let zer=[-1,-1],tw=-1,se=-1,fi=-1,fnz=-1;
    for(let i=1;i<s.length;++i)
    {
        if(s[i]!='0')
        {
            fnz=i-1;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='7')
        {
            se=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='2')
        {
            tw=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='5')
        {
            fi=i;
            break;
        }
    }
    let k=0;
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='0')
        {
            zer[k++]=i;
            if(k==2)
                break;
        }
    }
    zer.length=k;
    if(fi==-1)
    {
        if(zer.length<2)
            return -1;
        return (2*s.length-3-zer[0]-zer[1]);
    }
    else
    {
        let ac=[];
        if(zer.length>=2)
        {
            ac.push(2*s.length-3-zer[0]-zer[1]);
        }
        if((zer.length>=1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-zer[0]-fi+(fi>zer[0]?1:0)+(fi===0?(zer[0]==1?0:fnz):0));
        }
        if((tw!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-tw-fi+(tw>fi?1:0)+(Math.min(fi,tw)===0?fnz:0));
        }
        if((se!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-se-fi+(se>fi?1:0)+(Math.min(fi,se)===0?fnz:0));
        }
        if(ac.length!==0)
            return Math.min.apply(Math,ac);
        else
            return -1;
    }
}
function main()
{
    let n=readLine().trim();
    console.log(ans(n));
}

'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 ans(s)
{
    let zer=[-1,-1],tw=-1,se=-1,fi=-1,fnz=-1;
    for(let i=1;i<s.length;++i)
    {
        if(s[i]!='0')
        {
            fnz=i-1;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='7')
        {
            se=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='2')
        {
            tw=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='5')
        {
            fi=i;
            break;
        }
    }
    let k=0;
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='0')
        {
            zer[k++]=i;
            if(k==2)
                break;
        }
    }
    zer.length=k;
    if(fi==-1)
    {
        if(zer.length<2)
            return -1;
        return (2*s.length-3-zer[0]-zer[1]);
    }
    else
    {
        let ac=[];
        if(zer.length>=2)
        {
            ac.push(2*s.length-3-zer[0]-zer[1]);
        }
        if((zer.length>=1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-zer[0]-fi+(fi>zer[0]?1:0)+(fi===0?fnz:0));
        }
        if((tw!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-tw-fi+(tw>fi?1:0)+(Math.min(fi,tw)===0?fnz:0));
        }
        if((se!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-se-fi+(se>fi?1:0)+(Math.min(fi,se)===0?fnz:0));
        }
        if(ac.length!==0)
            return Math.min.apply(Math,ac);
        else
            return -1;
    }
}
function main()
{
    let n=readLine().trim();
    console.log(ans(n));
}

'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 ans(s)
{
    let zer=[-1,-1],tw=-1,se=-1,fi=-1;
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='7')
        {
            se=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='2')
        {
            tw=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='5')
        {
            fi=i;
            break;
        }
    }
    let k=0;
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='0')
        {
            zer[k++]=i;
            if(k==2)
                break;
        }
    }
    zer.length=k;
    if(fi==-1)
    {
        if(zer.length<2)
            return -1;
        return (2*s.length-3-zer[0]-zer[1]);
    }
    else
    {
        let ac=[];
        if(zer.length>=2)
        {
            ac.push(2*s.length-3-zer[0]-zer[1]);
        }
        if((zer.length>=1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-zer[0]-fi+(fi>zer[0]?1:0));
        }
        if((tw!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-tw-fi+(tw>fi?1:0));
        }
        if((se!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-se-fi+(se>fi?1:0));
        }
        if(ac.length!=0)
            return Math.min.apply(Math,ac);
        else
            return -1;
    }
}
function main()
{
    let n=readLine().trim();
    console.log(ans(n));
}

'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 ans(s)
{
    let zer=[-1,-1],tw=-1,se=-1,fi=-1,fnz=-1;
    for(let i=1;i<s.length;++i)
    {
        if(s[i]!='0')
        {
            fnz=i-1;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='7')
        {
            se=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='2')
        {
            tw=i;
            break;
        }
    }
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='5')
        {
            fi=i;
            break;
        }
    }
    let k=0;
    for(let i=s.length-1;i>=0;--i)
    {
        if(s[i]=='0')
        {
            zer[k++]=i;
            if(k==2)
                break;
        }
    }
    zer.length=k;
    if(fi==-1)
    {
        if(zer.length<2)
            return -1;
        return (2*s.length-3-zer[0]-zer[1]);
    }
    else
    {
        let ac=[];
        if(zer.length>=2)
        {
            ac.push(2*s.length-3-zer[0]-zer[1]);
        }
        if((zer.length>=1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-zer[0]-fi+(fi>zer[0]?1:0)+(fi===0?fnz:0)-(zer[0]==1?fnz:0));
        }
        if((tw!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-tw-fi+(tw>fi?1:0)+(Math.min(fi,tw)===0?fnz:0));
        }
        if((se!=-1)&&(fi!=-1))
        {
            ac.push(2*s.length-3-se-fi+(se>fi?1:0)+(Math.min(fi,se)===0?fnz:0));
        }
        if(ac.length!==0)
            return Math.min.apply(Math,ac);
        else
            return -1;
    }
}
function main()
{
    let n=readLine().trim();
    console.log(ans(n));
}


A stowaway and a controller play the following game. The train is represented by n wagons which are numbered with positive integers from 1 to n from the head to the tail. The stowaway and the controller are initially in some two different wagons. Every minute the train can be in one of two conditions — moving or idle. Every minute the players move.The controller's move is as follows. The controller has the movement direction — to the train's head or to its tail. During a move the controller moves to the neighbouring wagon correspondingly to its movement direction. If at the end of his move the controller enters the 1-st or the n-th wagon, that he changes the direction of his movement into the other one. In other words, the controller cyclically goes from the train's head to its tail and back again during all the time of a game, shifting during each move by one wagon. Note, that the controller always have exactly one possible move.The stowaway's move depends from the state of the train. If the train is moving, then the stowaway can shift to one of neighbouring wagons or he can stay where he is without moving. If the train is at a station and is idle, then the stowaway leaves the train (i.e. he is now not present in any train wagon) and then, if it is not the terminal train station, he enters the train again into any of n wagons (not necessarily into the one he's just left and not necessarily into the neighbouring one). If the train is idle for several minutes then each such minute the stowaway leaves the train and enters it back.Let's determine the order of the players' moves. If at the given minute the train is moving, then first the stowaway moves and then the controller does. If at this minute the train is idle, then first the stowaway leaves the train, then the controller moves and then the stowaway enters the train.If at some point in time the stowaway and the controller happen to be in one wagon, then the controller wins: he makes the stowaway pay fine. If after a while the stowaway reaches the terminal train station, then the stowaway wins: he simply leaves the station during his move and never returns there again.At any moment of time the players know each other's positions. The players play in the optimal way. Specifically, if the controller wins, then the stowaway plays so as to lose as late as possible. As all the possible moves for the controller are determined uniquely, then he is considered to play optimally always. Determine the winner.

The first line contains three integers n, m and k. They represent the number of wagons in the train, the stowaway's and the controller's initial positions correspondingly (2 ≤ n ≤ 50, 1 ≤ m, k ≤ n, m ≠ k). The second line contains the direction in which a controller moves. "to head" means that the controller moves to the train's head and "to tail" means that the controller moves to its tail. It is guaranteed that in the direction in which the controller is moving, there is at least one wagon. Wagon 1 is the head, and wagon n is the tail. The third line has the length from 1 to 200 and consists of symbols "0" and "1". The i-th symbol contains information about the train's state at the i-th minute of time. "0" means that in this very minute the train moves and "1" means that the train in this very minute stands idle. The last symbol of the third line is always "1" — that's the terminal train station.

If the stowaway wins, print "Stowaway" without quotes. Otherwise, print "Controller" again without quotes, then, separated by a space, print the number of a minute, at which the stowaway will be caught.

'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  const ils = ipt.split(EOL).slice(0, -1)
  let [n, s, k] = ils[0].split(' ').map(v => parseInt(v))
  let d = ils[1] == 'to head' ? 'l' : 'r'
  let C = ils[2].split('')

  let i = true
  for (let m = 0; m < C.length; m++) {
    let h = C[m]
    if (h == 0) {
      if (s < k && s > 1) s--
      else if (s > k && s < n) s++
    } else { // 1
      i = false
    }

    if (d == 'l') {
      if (k > 1) k--
      else {
        d = 'r'
        k++
      }
    } else { // r
      if (k < n) k++
      else {
        d = 'l'
        k--
      }
    }

    if (h == 1) {
      i = true
      s = d == 'l' ? n : 1
    }

    if (s == k) return console.log('Controller', m + 1)
  }
  console.log('Stowaway')
})


Sergey is testing a next-generation processor. Instead of bytes the processor works with memory cells consisting of n bits. These bits are numbered from 1 to n. An integer is stored in the cell in the following way: the least significant bit is stored in the first bit of the cell, the next significant bit is stored in the second bit, and so on; the most significant bit is stored in the n-th bit.Now Sergey wants to test the following instruction: "add 1 to the value of the cell". As a result of the instruction, the integer that is written in the cell must be increased by one; if some of the most significant bits of the resulting number do not fit into the cell, they must be discarded.Sergey wrote certain values of the bits in the cell and is going to add one to its value. How many bits of the cell will change after the operation?

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of bits in the cell. The second line contains a string consisting of n characters — the initial state of the cell. The first character denotes the state of the first bit of the cell. The second character denotes the second least significant bit and so on. The last character denotes the state of the most significant bit.

Print a single integer — the number of bits in the cell which change their state after we add 1 to the cell.

NoteIn the first sample the cell ends up with value 0010, in the second sample — with 0000.

var n = +readline(), str = readline().split("");
var cnt = 0;

if(str[0] == "0"){
	write(cnt+1);
}
else{
	for(var i = 0; i < n; i++){
		if(str[i] == "1"){
			cnt++;
		}
		else{
			cnt++;
			break;
		}
	}

	write(cnt);
}

;(function () {

    print(function (n, s) {
        var t = s.indexOf('0');

        if (t === -1) return n;
        if (t === 0) return 1;
        return t + 1;
    }(+readline(), readline()));

}.call(this));

(function () {
    var n = readline(),
        array = readline(),
        i = 0;
    while (array[i] === "1") i++;
    i++;
    print(i > n ? n : i);
})();

// 465A     inc ARG

var n = parseInt(readline());

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

var count = 0;

for (var i = 0; i < n; i++) {
    if (input_line[i] === '1') {
        count ++;
    } else {
        break;
    }
};

if (count < n) count ++;

print(count);

var n = parseInt(readline()),
			bits = readline().split('').map(Number),
			count = 1;

		for(var i = 0; i < n; i++)	{
			if(bits[i] == 1)	{
				count++;
			} else	{
				break;
			}
		}

		if(count == n + 1)	count--;

		//console.log(bits, count);

		print(count);

var n = +readline(), str = readline().split("");
var cnt = 0;

if(str[0] == "0"){
	write(cnt);
}
else{
	cnt++;

	for(var i = 1; i < n; i++){
		if(str[i] == "1"){
			cnt++;
		}
		else{
			cnt++;
			break;
		}
	}

	write(cnt);
}

;(function () {

    print(function (n, s) {
        var t = s.indexOf('0');

        if (t === -1) return n;
        if (t === 0) return 1;
        return n - t + 1;
    }(+readline(), readline()));

}.call(this));

;(function () {

    print(function (n, s) {
        var t = s.indexOf('0');

        if (t === -1) return n;
        return n - t + 1;
    }(+readline(), readline()));

}.call(this));

var n = parseInt(readline()),
			bits = readline().split('').map(Number),
			count = 0, flag = false;

		bits = bits.reverse();

		for(var i = n - 1; i >= 0; i--)	{
			if(bits[i] + 1 == 2 && !flag)	{
				bits[i] = 0;

				count++;
			} else if(!flag)	{
				bits[i] = 1;
				flag = true;
			} else	{
				count++;
			}
		}

		print(count);

var n = parseInt(readline()),
			bits = readline().split('').map(Number),
			count = 0, flag = false;

		bits = bits.reverse();

		for(var i = n - 1; i >= 0; i--)	{
			if(bits[i] + 1 == 2 && !flag)	{
				bits[i] = 0;

				count++;
			} else if(!flag)	{
				bits[i] = 1;
				flag = true;
			} else if(flag && bits[i] == 0)	{
				count++;
			}
		}

		//console.log(bits);

		print(count);


Alice got many presents these days. So she decided to pack them into boxes and send them to her friends.There are $$$n$$$ kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Presents of different kinds are different (i.e. that is, two gifts of different kinds are distinguishable). The number of presents of each kind, that Alice has is very big, so we can consider Alice has an infinite number of gifts of each kind.Also, there are $$$m$$$ boxes. All of them are for different people, so they are pairwise distinct (consider that the names of $$$m$$$ friends are written on the boxes). For example, putting the first kind of present into the first box but not into the second box, is different from putting the first kind of present into the second box but not into the first box.Alice wants to pack presents with the following rules:  She won't pack more than one present of each kind into the same box, so each box should contain presents of different kinds (i.e. each box contains a subset of $$$n$$$ kinds, empty boxes are allowed);  For each kind at least one present should be packed into some box. Now Alice wants to know how many different ways to pack the presents exists. Please, help her and calculate this number. Since the answer can be huge, output it by modulo $$$10^9+7$$$.See examples and their notes for clarification.

The first line contains two integers $$$n$$$ and $$$m$$$, separated by spaces ($$$1 \leq n,m \leq 10^9$$$) — the number of kinds of presents and the number of boxes that Alice has.

Print one integer  — the number of ways to pack the presents with Alice's rules, calculated by modulo $$$10^9+7$$$

'use strict'

const rem = (s, m) => {
    const n = s.length;
    if (n <= 15) return `${+s % m}`;
    return `${(+rem(s.slice(0, n-15), m) * (1000000000000000 % m) + +s.slice(-15) % m) % m}`;
}

const MOD = 1000000007;

const mult = (a, b) => {
    const la = a.length;
    const lb = b.length;
    if (la < 6 && lb < 6) return +a * +b;
    return +rem(`${mult(a.slice(0, -5), b.slice(0, -5))}0000000000`, MOD)
        + +rem(`${mult(a.slice(0, -5), b.slice(-5))}00000`, MOD)
        + +rem(`${mult(a.slice(-5), b.slice(0, -5))}00000`, MOD)
        +a.slice(-5) * +b.slice(-5);
}

const pow = (a, b) => {
    if (b === 0) return 1;
    if (b === 1) return a;
    let r = `${pow(a, b >> 1)}`;
    r = mult(r, r);
    if (b % 2) r = mult(`${r}`, `${a}`);
    return +r % MOD;
}

const nm = readline().split(' ').map(Number);

write(pow(pow(2, nm[1]) - 1, nm[0]));

'use strict'

const pow = (a, b) => {
    let r = 1;
    for (let i=0; i<b; i++) r = (r * a) % 1000000007;
    return r;
}
const nm = readline().split(' ').map(Number);
write(pow(pow(2, nm[1]) - 1), nm[0]);

'use strict'

const pow = (a, b) => {
    let r = 1;
    for (let i=0; i<b; i++) r = (r * a) % 1000000007;
}
const nm = readline().split(' ').map(Number);

write(pow((pow(2, nm[1]) - 1), nm[0]));

'use strict'

const pow = (a, b) => {
    let r = 1;
    for (let i=0; i<b; i++) r = (r * a) % 1000000007;
}
const nm = readline().split(' ').map(Number);
write(pow(pow(2, nm[1]) - 1), nm[0]);


During the winter holidays, the demand for Christmas balls is exceptionally high. Since it's already 2018, the advances in alchemy allow easy and efficient ball creation by utilizing magic crystals.Grisha needs to obtain some yellow, green and blue balls. It's known that to produce a yellow ball one needs two yellow crystals, green — one yellow and one blue, and for a blue ball, three blue crystals are enough.Right now there are A yellow and B blue crystals in Grisha's disposal. Find out how many additional crystals he should acquire in order to produce the required number of balls.

The first line features two integers A and B (0 ≤ A, B ≤ 109), denoting the number of yellow and blue crystals respectively at Grisha's disposal. The next line contains three integers x, y and z (0 ≤ x, y, z ≤ 109) — the respective amounts of yellow, green and blue balls to be obtained.

Print a single integer — the minimum number of crystals that Grisha should acquire in addition.

NoteIn the first sample case, Grisha needs five yellow and four blue crystals to create two yellow balls, one green ball, and one blue ball. To do that, Grisha needs to obtain two additional crystals: one yellow and one blue.

var N = readline().split(' ');
var M = readline().split(' ');
var y = parseInt(N[0]) , b = parseInt(N[1]);
var x1 = 0 , x2 = 0 , num1 = 0 , num2 = 0;
var bally = parseInt(M[0]) , ballg = parseInt(M[1]) , ballb = parseInt(M[2]);

    x1 = 2 * bally + ballg;
    x2 = ballg + 3 * ballb;

    if(y < x1){
    	num1 = x1 - y;
    }
    if(b < x2){
    	num2 = x2 - b;
    }

    print(num1+num2);

var lineA = readline();
var lineB = readline();

var a = +lineA.split(' ')[0];
var b = +lineA.split(' ')[1];

var x = +lineB.split(' ')[0];
var y = +lineB.split(' ')[1];
var z = +lineB.split(' ')[2];

var da = 2 * x + y;
var db = 3 * z + y;

var resa = (da - a) >= 0 ? da - a : 0;
var resb = (db - b) >= 0 ? db - b : 0;

var res = resa + resb;

print(res);

var line = readline().split(' ');
var a=parseInt(line[0]),b=parseInt(line[1]);
var line = readline().split(' ');
var a1=parseInt(line[0]),a2=parseInt(line[1]),a3=parseInt(line[2]);
var s1,s2,sum=0;
s1=a1*2+a2;
s2=a3*3+a2;

if(s1>a)
    sum+=(s1-a);
if(s2>b)
    sum+=(s2-b);
print(sum);

var have_crystals = String(readline()).split(" ");
var need_balls = String(readline()).split(" ");
var yellow_need = 2 * parseInt(need_balls[0]) + parseInt(need_balls[1]);
var blue_need = parseInt(need_balls[1]) + 3 * parseInt(need_balls[2]);
var result = 0;
if (parseInt(have_crystals[0]) < yellow_need) {
    result += yellow_need - parseInt(have_crystals[0]);
}
if (parseInt(have_crystals[1]) < blue_need) {
    result += blue_need - parseInt(have_crystals[1]);
}
print(result);

var arr = readline().split(' ').map(Number);
var A = arr[0];
var B = arr[1];
arr = readline().split(' ').map(Number);
var x = arr[0];
var y = arr[1];
var z = arr[2];

var yellow = 2*x + y;
var blue = y + 3*z;

var q = Math.max(yellow - A, 0)
var p = Math.max(blue - B, 0)

print(p + q);

'use strict';

var balls = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var curYellow = balls[0];
var curBlue = balls[1];
var nado = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var off = 0;
var needYellow = (2 * nado[0]) + nado[1];
var needBlue = nado[1] + (3 * nado[2]);
// print('Nado yellow: ' + needYellow + ', blue: '+ needBlue);
var offYellow = needYellow - curYellow > 0 ? needYellow - curYellow : 0;
var offBlue = needBlue - curBlue > 0 ? needBlue - curBlue : 0;

off = offYellow + offBlue;
print(off);

A=readline().split(' ').map(Number)
B=readline().split(' ').map(Number)
print(Math.max(0,B[0]*2+B[1]-A[0])+Math.max(0,B[1]+3*B[2]-A[1]))

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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    [yH, bH] = d.split(' ').map(Number);
    return;
  }

  const [y, g, b] = d.split(' ').map(Number);

  const yellow = y * 2 + g;
  const blue = b * 3 + g;
  const ans = Math.max(0, yellow - yH) + Math.max(0, blue - bH);

  console.log(ans);

  c++;
});

var lineA = readline();
var lineB = readline();

var a = +lineA.split(' ')[0];
var b = +lineA.split(' ')[1];

var x = +lineB.split(' ')[0];
var y = +lineB.split(' ')[1];
var z = +lineB.split(' ')[2];

var da = 2 * x + y;
var db = 3 * z + y;

var res = da - a + db - b;

print(res);

var lineA = readline();
var lineB = readline();

var a = +lineA.split(' ')[0];
var b = +lineA.split(' ')[1];

var x = +lineB.split(' ')[0];
var y = +lineB.split(' ')[1];
var z = +lineB.split(' ')[2];

var da = 2 * x + y;
var db = 3 * z + y;

var res = da - a + db - b;

print(res >= 0 ? res : 0);

var arr1 = readline().split(" ");
var arr2 = readline().split(" ");
var yellow = 2 * parseInt(arr2[0]) + parseInt(arr2[1]);
var blue = parseInt(arr2[1]) + 3 * parseInt(arr2[2]);
var result = (yellow - parseInt(arr1[0])) + (blue - parseInt(arr1[1]));
if (result < 0) {
    print(0);
} else {
    print(result);
}

var arr1 = readline().split(" ");
var arr2 = readline().split(" ");
var yellow = 2 * parseInt(arr2[0]) + parseInt(arr2[1]);
var blue = parseInt(arr2[1]) + 3 * parseInt(arr2[2]);
var result = (yellow - parseInt(arr1[0])) + (blue - parseInt(arr1[1]));
print(result);

var arr = readline().split(' ').map(Number);
var A = arr[0];
var B = arr[1];
arr = readline().split(' ').map(Number);
var x = arr[0];
var y = arr[1];
var z = arr[2];

// var requiredNumberOfCrystals = 2*x + 2*y + 3*z;

print(Math.max(2*x + 2*y + 3*z - A - B, 0));

var arr = readline().split(' ').map(Number);
var A = arr[0];
var B = arr[1];
arr = readline().split(' ').map(Number);
var x = arr[0];
var y = arr[1];
var z = arr[2];

// var requiredNumberOfCrystals = 2*x + 2*y + 3*z;

print(2*x + 2*y + 3*z - A - B);

'use strict';

var balls = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var curYellow = balls[0];
var curBlue = balls[1];
var nado = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var off = 0;
// make yellow
var doneYellow = 0;
if (nado[0] > 0) {
  var reqYellow = nado[0] * 2;
  if (reqYellow > curYellow) {
    var over = reqYellow - curYellow;
    off += over;
    var affordable = reqYellow - over;
    curYellow -= affordable;
    doneYellow += nado[0];
  } else {
    curYellow -= reqYellow;
    doneYellow += nado[0];
  }
}

// make green
var doneGreen = 0;
if (nado[1] > 0) {
  var _reqYellow = nado[1] * 1;
  var reqBlue = nado[1] * 1;
  var _affordable = 0;
  var aY = 0;
  var aB = 0;
  if (_reqYellow > curYellow) {
    var _over = _reqYellow - curYellow;
    off += _over;
    aY = curYellow;
  } else {
    aY = _reqYellow;
  }
  if (reqBlue > curBlue) {
    var _over2 = reqBlue - curBlue;
    off += _over2;
    aB = curBlue;
  } else {
    aB = reqBlue;
  }
  if (aY > aB) {
    _affordable = aB;
    var _over3 = aY - aB;
    off += _over3;
  } else if (aB > aY) {
    _affordable = aY;
    var _over4 = aB - aY;
    off += _over4;
  }
  curYellow -= _affordable;
  curBlue -= _affordable;
}
// make blue
var doneBlue = 0;
if (nado[2] > 0) {
  var _reqBlue = nado[2] * 3;
  if (_reqBlue > curBlue) {
    var over = _reqBlue - curBlue;
    off += over;
    var affordable = _reqBlue - over;
    curBlue -= affordable;
    doneBlue += nado[0];
  } else {
    curBlue -= _reqBlue;
    doneBlue += nado[0];
  }
}

print(off);

'use strict';

var balls = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var curYellow = balls[0];
var curBlue = balls[1];
var nado = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var off = 0;
// make yellow
var doneYellow = 0;
if (nado[0] > 0) {
  var reqYellow = nado[0] * 2;
  if (reqYellow > curYellow) {
    var over = reqYellow - curYellow;
    off += over;
    var affordable = reqYellow - over;
    curYellow -= affordable;
    doneYellow += nado[0];
  } else {
    curYellow -= reqYellow;
    doneYellow += nado[0];
  }
}

// make green
var doneGreen = 0;
if (nado[1] > 0) {
  var _reqYellow = nado[1] * 1;
  var reqBlue = nado[1] * 1;
  var _affordable = 0;
  var aY = 0;
  var aB = 0;
  if (_reqYellow > curYellow) {
    var _over = _reqYellow - curYellow;
    //off += _over;
    aY = curYellow;
  } else {
    aY = _reqYellow;
  }
  if (reqBlue > curBlue) {
    var _over2 = reqBlue - curBlue;
    //off += _over2;
    aB = curBlue;
  } else {
    aB = reqBlue;
  }
  if (aY > aB) {
    _affordable = aB;
    var _over3 = aY - aB;
    off += _over3;
  } else if (aB > aY) {
    _affordable = aY;
    var _over4 = aB - aY;
    off += _over4;
  } else {
    _affordable = aY;
  }

  curYellow -= _affordable;
  curBlue -= _affordable;
}

// make blue
var doneBlue = 0;
if (nado[2] > 0) {
  var _reqBlue = nado[2] * 3;
  if (_reqBlue > curBlue) {
    var over = _reqBlue - curBlue;
    off += over;
    var affordable = _reqBlue - over;
    curBlue -= affordable;
    doneBlue += nado[2];
  } else {
    curBlue -= _reqBlue;
    doneBlue += nado[2];
  }
}

print(off);

'use strict';

var balls = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var curYellow = balls[0];
var curBlue = balls[1];
var nado = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var off = 0;
// make yellow
var doneYellow = 0;
if (nado[0] > 0) {
  var reqYellow = nado[0] * 2;
  if (reqYellow > curYellow) {
    var over = reqYellow - curYellow;
    off += over;
    var affordable = reqYellow - over;
    curYellow -= affordable;
    doneYellow += nado[0];
  } else {
    curYellow -= reqYellow;
    doneYellow += nado[0];
  }
}

// make green
var doneGreen = 0;
if (nado[1] > 0) {
  var _reqYellow = nado[1] * 1;
  var reqBlue = nado[1] * 1;
  var _affordable = 0;
  var aY = 0;
  var aB = 0;
  if (_reqYellow > curYellow) {
    var _over = _reqYellow - curYellow;
    off += _over;
    aY = curYellow;
  } else {
    aY = _reqYellow;
  }
  if (reqBlue > curBlue) {
    var _over2 = reqBlue - curBlue;
    off += _over2;
    aB = curBlue;
  } else {
    aB = reqBlue;
  }
  if (aY > aB) {
    _affordable = aB;
    var _over3 = aY - aB;
    off += _over3;
  } else if (aB > aY) {
    _affordable = aY;
    var _over4 = aB - aY;
    off += _over4;
  } else {
    _affordable = aY;
  }

  curYellow -= _affordable;
  curBlue -= _affordable;
}
// make blue
var doneBlue = 0;
if (nado[2] > 0) {
  var _reqBlue = nado[2] * 3;
  if (_reqBlue > curBlue) {
    var over = _reqBlue - curBlue;
    off += over;
    var affordable = _reqBlue - over;
    curBlue -= affordable;
    doneBlue += nado[2];
  } else {
    curBlue -= _reqBlue;
    doneBlue += nado[2];
  }
}

print(off);

'use strict';

var balls = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var curYellow = balls[0];
var curBlue = balls[1];
var nado = readline().split(' ').map(function (x) {
  return parseInt(x);
});
var off = 0;
// make yellow
var doneYellow = 0;
if (nado[0] > 0) {
  var reqYellow = nado[0] * 2;
  if (reqYellow > curYellow) {
    var over = reqYellow - curYellow;
    off += over;
    var affordable = reqYellow - over;
    curYellow -= affordable;
    doneYellow += nado[0];
  } else {
    curYellow -= reqYellow;
    doneYellow += nado[0];
  }
}
// make green
var doneGreen = 0;
if (nado[1] > 0) {
  var _reqYellow = nado[0] * 1;
  var reqBlue = nado[0] * 1;
  var _affordable = 0;
  var aY = 0;
  var aB = 0;
  if (_reqYellow > curYellow) {
    var _over = _reqYellow - curYellow;
    off += _over;
    aY = curYellow;
  } else {
    aY = curYellow;
  }
  if (reqBlue > curBlue) {
    var _over2 = reqBlue - curBlue;
    off += _over2;
    aB = curBlue;
  } else {
    aB = curBlue;
  }
  if (aY > aB) {
    _affordable = aB;
    var _over3 = aY - aB;
    off += _over3;
  } else if (aB > aY) {
    _affordable = aY;
    var _over4 = aB - aY;
    off += _over4;
  }
}
// make blue
var doneBlue = 0;
if (nado[2] > 0) {
  var _reqBlue = nado[0] * 3;
  if (_reqBlue > curBlue) {
    var over = _reqBlue - curBlue;
    off += over;
    var affordable = _reqBlue - over;
    curBlue -= affordable;
    doneBlue += nado[0];
  } else {
    curBlue -= _reqBlue;
    doneBlue += nado[0];
  }
}

print(off);