var line1 = readline().split(" ");
var d = Number(line1[0]);
var sumTime = Number(line1[1]);
var sumTime2 = sumTime;

var input = [];
var ans = [];
var min = 0;
var max = 0;

for (var i=0; i < d; i++) {
	input.push(readline().split(" ").map(function (e) { return Number(e); }));
	min += input[i][0];
	max += input[i][1];

	ans.push(input[i][0]);
	sumTime2 -= ans[i];
	input[i] = input[i][1] - input[i][0];
}

if (sumTime < min || sumTime > max) {
	print("NO");
} else {
	print("YES");

	var answer = "";
	var take = 0;
	for (var i in input) {
		for (var j=1; j <= input[i]; j++) {
			if (sumTime2 - j >= 0) {

				take = j;
			} else {
				break;
			}
		}
		ans[i]+=take;
		sumTime2-=take;
	}
	print(ans.join(" "));
}


var X = +readline()

var way = 0

var dif = countDif(X)
way += dif * 2

function countDif(x) {
  var s = 0
  var i = 0
  var ls = 0
  while ((s += (i += 1)) <= x) {
    ls = s
    way++
  }
  return x - ls
}

print(way)


var X = Math.abs(+readline())

var way = 0

print(countDif(X))

function countDif(x) {
  var s = 0
  var i = 0
	var li = 0
  var ls = 0
  while ((s += (i += 1)) <= x) {
    ls = s
		li = i
    way++
  }

  if (x == ls) {
		return way
	} else if (i % 2 == (x - ls) % 2) {
		return way + 1
	} else if (ls % 2 == s % 2 || x - ls == 1) {
		return way + 2
	} else {
		return way + 3
	}
}


var app = {
    operandNumber : 0,
    modedNumber : 0,
    modNumber : 0,
    result : 0,
    main : function()    {
        this.initialize();
        this.readValues();
        this.sovleResult();
        this.printResult();
    },
    initialize : function()    {},
    readValues : function()    {
        this.operandNumber = readline().split(/\s/gi).map(Number);
    },
    sovleResult : function()    {
        this.modedNumber = this.operandNumber[1];
        this.operandNumber = this.operandNumber[0];
        this.modNumber = this.operandNumber - this.modedNumber;

        if(this.modNumber == 0)    {
            this.result = 'infinity';
            return;
        }

        for(var n = 1; n * n <= this.modNumber; n++)    {
            if(this.modNumber % n == 0)    {
                var solve = this.modNumber / n;
                if(solve > this.modedNumber)    {
                    this.result++;
                    if(Math.pow(n, 2) != this.modNumber)    {
                        if(this.modNumber / solve > this.modedNumber)    {
                            this.result++;
                        }
                    }
                }
            }
        }
    },
    printResult : function()    {
        print(this.result);
    }
};

app.main();


solve();

function solve() {
   var n, S, ans = 0;
   var input = readline().split(' ').map(Number);
   n = input[0];
   S = input[1];
   print(S % n ? Math.floor(S / n + 1) : S / n);
}


var l=readline().split(" ");
print(Math.ceil(parseInt(l[1])/parseInt(l[0])));


'use strict'

let lll
lll = readline().split(' ').map(v => parseInt(v))
let n = lll[0]
let x1 = lll[1]
let y1 = lll[2]
let x2 = lll[3]
let y2 = lll[4]

let s = 0

let by
if (x1 == 0) {
  by = y1
} else if (y1 == 0) {
  by = n - x1 - 1
} else if (x1 == n) {
  by = n - y1 - 1
} else {
  by = x1
}

let ag
if (x2 == 0) {
  ag = n - y2 - 1
} else if (y2 == 0) {
  ag = x2
} else if (x2 == n) {
  ag = y2
} else {
  ag = n - x1 - 1
}

if (x1 == 0 && x2 == n || y1 == 0 && y2 == n) {
  s = by + ag + n
  s = Math.min(s, 4 * n - s)
} else {
  s = by + ag
  s = Math.min(s, 2 * n - s)
}

print(s)


'use strict'

let lll
lll = readline().split(' ').map(v => parseInt(v))
let n = lll[0]
let x1 = lll[1]
let y1 = lll[2]
let x2 = lll[3]
let y2 = lll[4]

let s
if (x1 == 0 && x2 == n || x1 == n && x2 == 0) {
  s = Math.min(n + y2 + y1, n + n + n - y1 - y2)
} else if (y1 == 0 && y2 == n || y1 == n && y2 == 0) {
  s = Math.min(n + x2 + x1, n + n + n - x1 - x2)
} else {
  s = Math.abs(x1 - x2) + Math.abs(y1 - y2)
}

print(s)


// Polyfill for NodeJS
if (undefined == readline) {
	var rLines = require('fs').readFileSync("/dev/stdin", "utf8").split("\n"),
		rIndex = 0,
		readline = function() {
			rIndex ++
			return rLines[rIndex - 1]
		}
}
if (undefined == print) {
	var print = console.log
}

// Useful Read functions
var int = function() {
	return parseInt(readline())
}

var ints = function() {
	return readline().split(' ')
		.map(function(x) {
			return parseInt(x)
		})
}

var numbers = ints();
var n = numbers[0];
var m = numbers[1];
var d = numbers[2];

var aw = [];
var ac = [];
var bw = [];
var bc = [];

for(var i=0;i<n;i++)
{
  var nn = ints();
  ac[i] = nn[0];
  aw[i] = nn[1];
}

for(var i=0;i<m;i++)
{
  var nn = ints();
  bc[i] = nn[0];
  bw[i] = nn[1];
}

var a = [];
var b = [];
for(var i=0;i<n;i++) a[i] = i;
for(var i=0;i<m;i++) b[i] = i;

a.sort(function(x,y)
{
 if(ac[x]<ac[y]) return 1;
 if(ac[x]>ac[y]) return -1;

 if(aw[x] > aw[y]) return 1;
 if(aw[x] < aw[y]) return -1;

 return 0;
});

b.sort(function(x,y)
{
 if(bc[x]<bc[y]) return 1;
 if(bc[x]>bc[y]) return -1;

 if(bw[x] > bw[y]) return 1;
 if(bw[x] < bw[y]) return -1;

 return 0;
});

var pa = 0;
var pb = 0;
var suma = aw[a[0]];
var sumb = bw[b[0]];

if(suma + sumb > d)
{
  print("0");
} else {

var totalc = ac[a[0]] + bc[b[0]];

while (pb+1 < m && suma+sumb+bw[b[pb+1]]<=d)
{
  pb++;
  sumb += bw[b[pb]];
  totalc += bc[b[pb]];
}
var bestc = totalc;

/*
for(var i=0;i<n;i++) print(aw[a[i]] + " " + ac[a[i]]);
print(" ");
for(var i=0;i<m;i++) print(bw[b[i]] + " " + bc[b[i]]);

print("  ");
print(pa + " " + pb);
print(suma + " " + sumb);
*/
while(pb > 0)
{
  pa++;
  suma += aw[a[pa]];

  while (pb>= 0 && suma+sumb > d)
  {
    sumb -= bw[b[pb]];
    totalc -= bc[b[pb]];
    pb--;
  }

  if (suma+sumb <= d && bestc < totalc) bestc = totalc;

}

print(bestc);
}


var _ = readline().split( ' ' );
var N = +_[ 0 ];
var M = +_[ 1 ];
var D = +_[ 2 ];
var ACW = [];
for( var i = 0; i < N; ++i ) {
  var __ = readline().split( ' ' );
  ACW.push( [ +__[ 0 ], +__[ 1 ] ] );
}
ACW.sort().reverse();
var BCW = [];
for( var i = 0; i < M; ++i ) {
  var __ = readline().split( ' ' );
  BCW.push( [ +__[ 0 ], +__[ 1 ] ] );
}
BCW.sort().reverse();
var curc = 0;
var curw = 0;
var bptr = 0; // [ 0, bptr )
while( bptr < M ) {
  if( curw + BCW[ bptr ][ 1 ] > D ) break;
  curw += BCW[ bptr ][ 1 ];
  curc += BCW[ bptr ][ 0 ];
  ++bptr;
}
var bok = bptr > 0;
var ans = 0;
for( var aptr = 0; bok && aptr < N; ++i ) {
  curw += ACW[ aptr ][ 1 ];
  curc += ACW[ aptr ][ 0 ];
  while( curw > D && bptr > 0 ) {
    --bptr;
    curw -= BCW[ bptr ][ 1 ];
    curc -= BCW[ bptr ][ 0 ];
  }
  if( curw > D ) break;
  ans = Math.max( ans, curc );
}
print( ans );


var _ = readline().split( ' ' );
var N = +_[ 0 ];
var M = +_[ 1 ];
var D = +_[ 2 ];
var ACW = [];
for( var i = 0; i < N; ++i ) {
  var __ = readline().split( ' ' );
  ACW.push( [ +__[ 0 ], +__[ 1 ] ] );
}
ACW.sort().reverse();
var BCW = [];
for( var i = 0; i < M; ++i ) {
  var __ = readline().split( ' ' );
  BCW.push( [ +__[ 0 ], +__[ 1 ] ] );
}
BCW.sort().reverse();
var curc = 0;
var curw = 0;
var bptr = 0; // [ 0, bptr )
while( bptr < M ) {
  if( curw + BCW[ bptr ][ 1 ] > D ) break;
  curw += BCW[ bptr ][ 1 ];
  curc += BCW[ bptr ][ 0 ];
  ++bptr;
}
var ans = 0;
for( var aptr = 0; aptr < N; ++i ) {
  curw += ACW[ aptr ][ 1 ];
  curc += ACW[ aptr ][ 0 ];
  while( curw > D && bptr > 0 ) {
    --bptr;
    curw -= BCW[ bptr ][ 1 ];
    curc -= BCW[ bptr ][ 0 ];
  }
  if( bptr === 0 || curw > D ) break;
  ans = Math.max( ans, curc );
}
print( ans );


// Polyfill for NodeJS
if (undefined == readline) {
	var rLines = require('fs').readFileSync("/dev/stdin", "utf8").split("\n"),
		rIndex = -1,
		readline = function() {
			rIndex++;
			return rLines[rIndex]
		}
}
if (undefined == print) {
	var print = console.log
}

// Useful Read functions
var int = function() {
	return parseInt(readline())
}

var ints = function() {
  var tmp = readline().split(' ');
  var ans = [];
  for(var i=0;i<tmp.length;i++)
    ans[i] = parseInt(tmp[i]);

  return ans;
}

var numbers = ints();
var n = numbers[0];
var m = numbers[1];
var d = numbers[2];

var aw = [];
var ac = [];
var bw = [];
var bc = [];

for(var i=0;i<n;i++)
{
  var nn = ints();
  ac[i] = nn[0];
  aw[i] = nn[1];
}

for(var i=0;i<m;i++)
{
  var nn = ints();
  bc[i] = nn[0];
  bw[i] = nn[1];
}

var a = [];
var b = [];
for(var i=0;i<n;i++) a[i] = i;
for(var i=0;i<m;i++) b[i] = i;

a.sort(function(x,y)
{
 if(ac[x]<ac[y]) return 1;
 if(ac[x]>ac[y]) return -1;

 if(aw[x] > aw[y]) return 1;
 if(aw[x] < aw[y]) return -1;

 return 0;
});

b.sort(function(x,y)
{
 if(bc[x]<bc[y]) return 1;
 if(bc[x]>bc[y]) return -1;

 if(bw[x] > bw[y]) return 1;
 if(bw[x] < bw[y]) return -1;

 return 0;
});

var pa = 0;
var pb = 0;
var sum = aw[a[0]] + bw[b[0]];

if(sum > d)
{
  print("0");
} else {

var totalc = ac[a[0]] + bc[b[0]];

while (pb+1 < m && sum + bw[b[pb+1]]<=d)
{
  pb++;
  sum += bw[b[pb]];
  totalc += bc[b[pb]];
}
var bestc = totalc;

//print(pb);

/*
for(var i=0;i<n;i++) print(aw[a[i]] + " " + ac[a[i]]);
print(" ");
for(var i=0;i<m;i++) print(bw[b[i]] + " " + bc[b[i]]);

print("  ");
print(pa + " " + pb);
print(sum);
*/

while(pb > 0 && pa < n)
{
  pa++;
  sum += aw[a[pa]];
  totalc += ac[a[pa]];

  //print(pa + " " + pb);

  while (pb >= 0 && sum > d)
  {
    sum -= bw[b[pb]];
    totalc -= bc[b[pb]];
    pb--;
  }

  if (sum <= d && bestc < totalc)
    bestc = totalc;
}

print(bestc);
}


var l = readline().split(' ');
var a,b,w,x,c;
a=+l[0];
b=+l[1];
w=+l[2];
x=+l[3];
c=+l[4];

var _b=b;
var _a=a;
var step=0;
while(c>a){
	c--;
	if(b>=x){
		b=b-x;
	}else{
		a=a-1;
		b=w+(b-x);
	}
	step++;
	if(b==_b){
		break;
	}
}

var o=step;
var _a=_a-a;
if(c>a){
	while(c>a){
		c-=o;
		a-=_a;
		step+=o;
	}

	c+=o;
	a+=_a;
	step-=o;
	while(c>a){
		c--;
		if(b>=x){
			b=b-x;
		}else{
			a=a-1;
			b=w+(b-x);
		}
		step++;
	}
}

print(step);


var arr = readline().split(' ').map(Number);
print(arr[0]>=arr[1]&&arr[0]>=arr[2]? 1:0);


const readline = require('readline');

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

rl.on('line', n => {
  let [participants, pens, notebooks] = n.split(' ').map(number => Number(number));
  participants <= pens && participants <= notebooks ? console.log('Yes') : console.log('No');
  return rl.close();
});


const input = [];

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

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

RL.on('close', () => {
  const [n, m, k] = input[0].split(' ').map(x => parseInt(x));
  console.log( Math.min(m, k) >= n ? "YES" : "NO" );
});


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

rl.on('line', (d) => {
  let [n, v] = d.split(' ').map(Number);
  let ans = Math.min(n, v);
  let price = 1;
  n -= v + 1;

  while (n > 0) {
    price++;
    ans += price;

    n--;
  }

  console.log(ans);

  c++;
});


process.stdin.resume();
process.stdin.setEncoding('utf8');

var input= '', readline, print;

process.stdin.on('data', function(chunk) {
  input+=chunk;
});

process.stdin.on('end', function() {
  input = input.split('\n');
  print = function(data) {process.stdout.write(data+'\n')};
  var inputLineIndex = 0;
  readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};

  process.exit(main(...input) || 0);
});

const even = ['a', 'o', 'u', 'i', 'e'];

function minPrice(n, v) {
  var currentPrice = Math.min(v, n - 1);
  var currentLiters = Math.min(v, n - 1);

  for(var i = 2; i < n; i++) {
    if(currentLiters > n - i) break;

    currentLiters++;
    currentPrice += i;
  }

  return currentPrice;
}

function main(n, v) {
  arr = n.split(' ');
  console.log(minPrice(+arr[0], +arr[1]));
}

// main("ninja");


function minPrice(n, v) {
  var currentPrice = Math.min(v, n - 1);
  var currentLiters = Math.min(v, n - 1);

  for(var i = 2; i < n; i++) {
    if(currentLiters > n - i) break;

    currentLiters++;
    currentPrice += i;
  }

  return currentPrice;
}

process.stdin.resume();
process.stdin.setEncoding('utf8');

var input= '', readline, print;

process.stdin.on('data', function(chunk) {
  input+=chunk;
});

process.stdin.on('end', function() {
  input = input.split('\n');
  print = function(data) {process.stdout.write(data+'\n')};
  var inputLineIndex = 0;
  readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};

  process.exit(main(...input) || 0);
});

const even = ['a', 'o', 'u', 'i', 'e'];

function main(n, v) {
  console.log(minPrice(n, v))
}

// main("ninja");


var n=readline();
var m=readline();
if( m>=n ){
    print(n-1);
    return 0;
}
var l=2;
var cnt=n-m-1;
var ans=ans+m;
for( var i=1;i<=cnt;i++ ){
    ans=ans+l;
    l++;
}
print(ans);


process.stdin.resume();
process.stdin.setEncoding('utf8');

var input= '', readline, print;

process.stdin.on('data', function(chunk) {
  input+=chunk;
});

process.stdin.on('end', function() {
  input = input.split('\n');
  print = function(data) {process.stdout.write(data+'\n')};
  var inputLineIndex = 0;
  readline = function(){return inputLineIndex>=input.length?undefined:input[inputLineIndex++]};

  process.exit(main(...input) || 0);
});

const even = ['a', 'o', 'u', 'i', 'e'];

function minPrice(n, v) {
  var currentPrice = Math.min(v, n - 1);
  var currentLiters = Math.min(v, n - 1);

  for(var i = 2; i < n; i++) {
    if(currentLiters >= n - 1) break;

    currentLiters++;
    currentPrice += i;
  }

  return currentPrice;
}

function main(n, v) {
  arr = n.split(' ');
  console.log(minPrice(+arr[0], +arr[1]));
}

//console.log(minPrice(4, 2)); // 1 2 3 4 5 -> 2 4 7


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

var p = readline().split(' ');
var t = readline().split(' ');

var sum = 0, tp = 0;

for (var i = 0 ; i < n ; i++) {
    tp += +t[i];
    sum += Math.max(0, +p[i] - c*tp);
}

tp = 0;

for (var i = n-1 ; i >= 0 ; i--) {
    tp += +t[i];
    sum -= Math.max(0, +p[i] - c*tp);
}

if (sum > 0)
    print("Limak");
else if (sum < 0)
    print("Radewoosh");
else
    print("Tie");


var line1 = readline().split(' ').map(Number);
var n = line1[0];
var c = line1[1];
var p = readline().split(' ').map(Number);
var t = readline().split(' ').map(Number);

var limak = 0;
var time = 0;
for(var i = 0; i < n; i++){
  time += t[i];
  limak += Math.max(0, p[i] - time * c);
}

var radewoosh = 0;
var time2 = 0;
for(var j = n - 1; j > -1; j--){
  time2 += t[j];
  radewoosh += Math.max(0, p[j] - time2 * c);
}

if(limak > radewoosh){
  print("Limak");
} else if (limak < radewoosh){
  print("Radewoosh");
} else {
  print("Tie");
}

/*
3 2\n50 85 250\n10 15 25\n
*/


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

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

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

function main() {
	var data = tokenizeIntegers(readline()),
		pointNum = data[0], segmentNum = data[1],
		points = tokenizeIntegers(readline());
	for (var i = 0; i < segmentNum; ++i) {
		data = tokenizeIntegers(readline());
	}
	var result = [];
	for (var i = 0; i < pointNum; ++i) {
		result.push(i%2 == 0 ? 1 : 0);
	}
	print(result.join(' '));
}

main();


'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 output(x) {
    if (typeof x !== 'string')
    {
        x = x.toString();
    }
    console.log(x);
}
function reverseString(str) {
    var splitString = str.split("");
    var reverseArray = splitString.reverse();
    var joinArray = reverseArray.join("");
    return joinArray;
}
function main()
{
    let N = readline();
    for (let test = 0; test < N; test++)
    {
        let s = Number(readline());
        let result = '';
        let last_Digit  = 9;
        while(s > last_Digit)
        {
            result += String.fromCharCode(48+last_Digit);
            s -= last_Digit ;
            last_Digit--;
        }
        if(s > 0)
        {
            result += String.fromCharCode(48+s);
        }
        output(reverseString(result));
    }
}


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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        const s = +readLine();
        // const s = readLine().split(' ').map(p => +p);
        let result = myFunc(s);
        console.log(result);
    }
}

function myFunc(s){
    let acum = 0;
    let arr = [9, 8, 7, 6, 5, 4, 3, 2, 1];
    let resp = [];

    for(let i = 0; i < arr.length; i++){
        if(s - acum <= arr[i]){
            resp.push(s-acum);
            break;
        }
        acum += arr[i];
        resp.push(arr[i]);
    }

    return resp.reverse().join('');

}


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

function main() {
    const t = +readLine();
    for(let i = 0; i < t; i++){
        const s = +readLine();
        // const s = readLine().split(' ').map(p => +p);
        let result = myFunc(s);
        console.log(result);
    }
}

function myFunc(s){
    let acum = 0;
    let arr = [9, 8, 7, 6, 5, 4, 3, 2, 1];
    let resp = [];

    for(let i = 0; i < arr.length; i++){
        if(s - acum < arr[i]){
            resp.push(s-acum);
            break;
        }
        acum += arr[i];
        resp.push(arr[i]);
    }

    return resp.reverse().join('');

}


/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {

/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;

/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 			loaded: false
/******/ 		};

/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ 		// Flag the module as loaded
/******/ 		module.loaded = true;

/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}

/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;

/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;

/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";

/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	var List = __webpack_require__(1);
	var n = List.map(parseInt, readline().split(' '))[0];
	var single = 0;
	for (var x = 1; x <= 3; x++) {
	    for (var y = 1; y <= 3; y++) {
	        for (var z = 1; z <= 3; z++) {
	            if (x + y + z == 6)
	                single++;
	        }
	    }
	}
	var mod = 1000000007;
	function pow(base, exp, mod) {
	    if (exp == 0)
	        return 1 % mod;
	    if (exp == 1)
	        return base % mod;
	    var half = pow(base, Math.floor(exp / 2), mod);
	    half = (half * half) % mod;
	    if (exp % 2 == 1) {
	        half = (half * base) % mod;
	    }
	    return half;
	}
	print((pow(3, 3 * n, mod) - pow(single, n, mod) + mod) % mod);

/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {

	var Prelude_1 = __webpack_require__(2);
	function add(xs, ys) {
	    return xs.concat(ys);
	}
	exports.add = add;
	function head(xs) {
	    return xs[0];
	}
	exports.head = head;
	function last(xs) {
	    return xs[xs.length - 1];
	}
	exports.last = last;
	function tail(xs) {
	    return xs.slice(1);
	}
	exports.tail = tail;
	function init(xs) {
	    return xs.slice(0, xs.length - 1);
	}
	exports.init = init;
	function map(f, xs) {
	    var result = new Array(xs.length);
	    for (var i = 0; i < xs.length; i++) {
	        result[i] = f(xs[i]);
	    }
	    return result;
	}
	exports.map = map;
	function reverse(xs) {
	    return xs.slice().reverse();
	}
	exports.reverse = reverse;
	function intersperse(x, xs) {
	    if (xs.length == 0) {
	        return [];
	    }
	    var result = new Array(xs.length + xs.length - 1);
	    for (var i = 0; i + 1 < xs.length; i++) {
	        result[i + i] = xs[i];
	        result[i + i + 1] = x;
	    }
	    result[result.length - 1] = xs[xs.length - 1];
	    return result;
	}
	exports.intersperse = intersperse;
	function intercalate(xs, xss) {
	    return concat(intersperse(xs, xss));
	}
	exports.intercalate = intercalate;
	function foldl(f, initial, xs) {
	    var result = initial;
	    for (var i = 0; i < xs.length; i++) {
	        result = f(result, xs[i]);
	    }
	    return result;
	}
	exports.foldl = foldl;
	function foldr(f, initial, xs) {
	    var result = initial;
	    for (var i = xs.length - 1; i >= 0; i--) {
	        result = f(xs[i], result);
	    }
	    return result;
	}
	exports.foldr = foldr;
	function concat(xss) {
	    var total = sum(map(function (xs) { return xs.length; }, xss));
	    var result = new Array(total);
	    var m = 0;
	    for (var i = 0; i < xss.length; i++) {
	        var xs = xss[i];
	        for (var j = 0; j < xs.length; j++) {
	            result[m++] = xs[j];
	        }
	    }
	    return result;
	}
	exports.concat = concat;
	function sum(xs) {
	    var result = 0;
	    for (var i = 0; i < xs.length; i++) {
	        result += xs[i];
	    }
	    return result;
	}
	exports.sum = sum;
	function product(xs) {
	    var result = 1;
	    for (var i = 0; i < xs.length; i++) {
	        result *= xs[i];
	    }
	    return result;
	}
	exports.product = product;
	function sort(xs, compare) {
	    return copy(xs).sort(compare);
	}
	exports.sort = sort;
	function sortInPlace(xs, compare) {
	    xs.sort(compare);
	    return xs;
	}
	exports.sortInPlace = sortInPlace;
	function maximumInRange(xs, s, e) {
	    var result = xs[s];
	    for (var i = s + 1; i <= e; i++) {
	        if (result < xs[i])
	            result = xs[i];
	    }
	    return result;
	}
	exports.maximumInRange = maximumInRange;
	function maximum(xs) {
	    return maximumInRange(xs, 0, xs.length - 1);
	}
	exports.maximum = maximum;
	function maximumInRangeWith(xs, s, e, f) {
	    var result = f(xs[s]);
	    for (var i = s + 1; i <= e; i++) {
	        var candidate = f(xs[i]);
	        if (result < candidate)
	            result = candidate;
	    }
	    return result;
	}
	exports.maximumInRangeWith = maximumInRangeWith;
	function maximumWith(xs, f) {
	    return maximumInRangeWith(xs, 0, xs.length - 1, f);
	}
	exports.maximumWith = maximumWith;
	function minimumInRange(xs, s, e) {
	    var result = xs[s];
	    for (var i = s + 1; i <= e; i++) {
	        if (result > xs[i])
	            result = xs[i];
	    }
	    return result;
	}
	exports.minimumInRange = minimumInRange;
	function minimum(xs) {
	    return minimumInRange(xs, 0, xs.length - 1);
	}
	exports.minimum = minimum;
	function minimumInRangeWith(xs, s, e, f) {
	    var result = f(xs[s]);
	    for (var i = s + 1; i <= e; i++) {
	        var candidate = f(xs[i]);
	        if (result > candidate)
	            result = candidate;
	    }
	    return result;
	}
	exports.minimumInRangeWith = minimumInRangeWith;
	function minimumWith(xs, f) {
	    return minimumInRangeWith(xs, 0, xs.length - 1, f);
	}
	exports.minimumWith = minimumWith;
	function replicate(n, x) {
	    var result = new Array(n);
	    for (var i = 0; i < result.length; i++) {
	        result[i] = x;
	    }
	    return result;
	}
	exports.replicate = replicate;
	function take(n, xs) {
	    return xs.slice(0, n);
	}
	exports.take = take;
	function drop(n, xs) {
	    return xs.slice(n);
	}
	exports.drop = drop;
	function splitAt(n, xs) {
	    return [take(n, xs), drop(n, xs)];
	}
	exports.splitAt = splitAt;
	function takeWhile(f, xs) {
	    for (var i = 0; i < xs.length; i++) {
	        if (!f(xs[i])) {
	            return xs.slice(0, i);
	        }
	    }
	    return xs.slice();
	}
	exports.takeWhile = takeWhile;
	function dropWhile(f, xs) {
	    for (var i = 0; i < xs.length; i++) {
	        if (!f(xs[i])) {
	            return xs.slice(i);
	        }
	    }
	    return [];
	}
	exports.dropWhile = dropWhile;
	function group(xs) {
	    if (xs.length == 0)
	        return [];
	    var result = [];
	    var last = [xs[0]];
	    for (var i = 1; i < xs.length; i++) {
	        if (last[0] === xs[i]) {
	            last.push(xs[i]);
	        }
	        else {
	            result.push(last);
	            last = [xs[i]];
	        }
	    }
	    result.push(last);
	    return result;
	}
	exports.group = group;
	function nub(xs) {
	    if (xs.length == 0)
	        return [];
	    var result = [];
	    result.push(xs[0]);
	    for (var i = 1; i < xs.length; i++) {
	        if (xs[i] !== xs[i - 1]) {
	            result.push(xs[i]);
	        }
	    }
	    return result;
	}
	exports.nub = nub;
	function filter(f, xs) {
	    var result = [];
	    for (var i = 0; i < xs.length; i++) {
	        if (f(xs[i]))
	            result.push(xs[i]);
	    }
	    return result;
	}
	exports.filter = filter;
	function zip(xs, ys) {
	    var n = Prelude_1.min(xs.length, ys.length);
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = [xs[i], ys[i]];
	    }
	    return result;
	}
	exports.zip = zip;
	function unzip(xs) {
	    var r1 = new Array(xs.length);
	    var r2 = new Array(xs.length);
	    for (var i = 0; i < xs.length; i++) {
	        r1[i] = xs[i][0];
	        r2[i] = xs[i][1];
	    }
	    return [r1, r2];
	}
	exports.unzip = unzip;
	function range(from, to) {
	    var result = Array(to - from + 1);
	    for (var i = from; i <= to; i++) {
	        result[i - from] = i;
	    }
	    return result;
	}
	exports.range = range;
	function copy(xs) {
	    return xs.slice(0);
	}
	exports.copy = copy;
	function apply_permutation(p, xs) {
	    var n = xs.length;
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = xs[p[i]];
	    }
	    return result;
	}
	exports.apply_permutation = apply_permutation;
	function next_permutation(p) {
	    var n = p.length;
	    if (n < 2)
	        return null;
	    var r = copy(p);
	    var k = n - 2;
	    for (; k >= 0 && r[k] >= r[k + 1]; k--)
	        ;
	    if (k < 0)
	        return null;
	    for (var i = k + 1, j = n - 1; i < j; i++, j--) {
	        var t_1 = r[i];
	        r[i] = r[j];
	        r[j] = t_1;
	    }
	    var next = k + 1;
	    for (; r[next] <= r[k]; next++)
	        ;
	    var t = r[k];
	    r[k] = r[next];
	    r[next] = t;
	    return r;
	}
	exports.next_permutation = next_permutation;
	function create(n, value) {
	    return replicate(n, value);
	}
	exports.create = create;
	function createWith(n, f) {
	    var result = new Array(n);
	    for (var i = 0; i < n; i++) {
	        result[i] = f(i);
	    }
	    return result;
	}
	exports.createWith = createWith;
	function create2D(n1, n2, value) {
	    return map(function (_) { return replicate(n2, value); }, replicate(n1, 0));
	}
	exports.create2D = create2D;
	function create2DWith(n1, n2, f) {
	    var result = new Array(n1);
	    for (var i = 0; i < n1; i++) {
	        result[i] = new Array(n2);
	        for (var j = 0; j < n2; j++) {
	            result[i][j] = f(i, j);
	        }
	    }
	    return result;
	}
	exports.create2DWith = create2DWith;

/***/ },
/* 2 */
/***/ function(module, exports) {

	function min(a, b) {
	    return a < b ? a : b;
	}
	exports.min = min;
	function max(a, b) {
	    return a < b ? b : a;
	}
	exports.max = max;
	function curry(f) {
	    return function (x) { return function (y) { return f(x, y); }; };
	}
	exports.curry = curry;
	function uncurry(f) {
	    return function (x, y) { return f(x)(y); };
	}
	exports.uncurry = uncurry;
	function id(x) {
	    return x;
	}
	exports.id = id;
	function constant(x) {
	    return function (_) { return x; };
	}
	exports.constant = constant;
	function flip(f) {
	    return function (y) { return function (x) { return f(x)(y); }; };
	}
	exports.flip = flip;
	function flip2(f) {
	    return function (y, x) { return f(x, y); };
	}
	exports.flip2 = flip2;
	function compose(g, f) {
	    return function (x) { return g(f(x)); };
	}
	exports.compose = compose;
	function gcd(a, b) {
	    var r = a % b;
	    while (r !== 0) {
	        a = b;
	        b = r;
	        r = a % b;
	    }
	    return b;
	}
	exports.gcd = gcd;

/***/ }
/******/ ]);


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

let l = 0;
let k, s = 0
rl.on('line', (input) => {
    arr = input.split(" ").map(x => parseInt(x))
    n = arr[0]
    k = arr[1]
    rl.close();

    for (let i = k - 1; i >= 0; i--) {
        if (n % i === 0) {
            let c = n / i
            console.log(c * k + i)
            return
        }
    }
})


function main() {
    let line = stdin[0].split(' ');
    let n = parseInt(line[0]);
    let k = parseInt(line[1]);

    let nDivisors = [];

    for(let i=1; i*i<=n; i++) {
        if(n%i==0) {
            nDivisors.push(i);
            if( i*i != n ) {
                nDivisors.push(n/i);
            }
        }
    }

    var x = undefined;

    for(let xModK=1; xModK<k; xModK++) {
        if( nDivisors.includes(xModK) ) {
            let xDivK = n/xModK;
            let xCandidate = xDivK * k + xModK;

            if( x===undefined || x>xCandidate) {
                x = xCandidate;
            }

        }
    }
    console.log(x);
};

const readline = require('readline');
const rl = readline.createInterface(process.stdin, process.stdout, null);

var stdin = [];
rl.on('line', function (line) {stdin.push(line);});
rl.on('close', main);


'use strict'

const rem = (s, m) => {
    const n = s.length;
    if (n <= 10) return parseInt(s) % m;

    const first = s.slice(0, n-10);
    const second = s.slice(-10);
    return (rem(first, m) * ((10**10) % m) + parseInt(second) % m) % m;
}

const div = (s, m) => {
    const n = s.length;
    if (n <= 10) return parseInt(parseInt(s) / m);

    const rem = parseInt(s.slice(0, 10)) % m
    const head = (parseInt(s.slice(0, 10)) - rem) / m;
    return `${head}${div(`${rem}${s.slice(10)}`, m)}`;
}

const sub = (a, b) => {
    const subact = (A, B) => {
        const lA = A.length, lB = B.length;
        if (lA <= 9 && lB <= 9) return [ { value: parseInt(A) - parseInt(B), size: lA } ];
        if (lA < lB) return [ { value: -parseInt(B.slice(0, -lA)), size: lB - lA }, ...subact(B.slice(-lA), A) ];
        if (lA > lB) return [ { value: parseInt(A.slice(0, -lB)), size: lA - lB }, ...subact(A.slice(-lB), B) ];

        return [ { value: parseInt(A.slice(0, 9)) - parseInt(B.slice(0, 9)), size: 9 }, ...subact(A.slice(9), B.slice(9)) ]
    }

    let x = subact(a, b);
    x = x.slice(x.findIndex(i => i.value));
    if (!x.length) return '0';

    let t = '';
    if (x[0] < 0) { t = '-'; x = x.map(i => -i); }

    for (let i = 1; i < x.length; i++) {
        if (x[i].value < 0) { x[i-1].value -= 1; x[i].value = 10**10 + x[i].value; }
    }
    return t + x.map(i => `${'0'.repeat(i.size)}${i.value}`.slice(-i.size)).join('').replace(/^0+/, '') || '0';
}

const problem = (n, p, w, d) => {
    let Y = -1;
    const W = parseInt(w);
    while (++Y < W && rem(p, w)) p = sub(p, d);
    const z = sub(sub(n, div(p, w)), `${Y}`);
    if (Y === W) return -1; // || (p|z) < 0
    return `${div(p, w)} ${Y} ${z}`;
}

const npwd = readline().split(' ');
write(problem(npwd[0], npwd[1], npwd[2], npwd[3]));


'use strict'

const rem = (s, m) => {
    const n = s.length;
    if (n <= 9) return parseInt(s) % m;
    return (rem(s.slice(0, n-9), m) * ((10**9) % m) + parseInt(s.slice(-9)) % m) % m;
}

const div = (s, m) => {
    const n = s.length;
    if (n <= 9) return parseInt(parseInt(s) / m);
    const rem = parseInt(s.slice(0, 9)) % m
    const head = (parseInt(s.slice(0, 9)) - rem) / m;
    return `${head}${div(`${rem}${s.slice(9)}`, m)}`;
}

const sub = (a, b) => {
    const substract = (A, B) => {
        const lA = A.length, lB = B.length;
        if (lA <= 9 && lB <= 9) return [ { value: parseInt(A) - parseInt(B), size: lA } ];
        if (lA < lB) return [ { value: -parseInt(B.slice(0, -lA)), size: lB - lA } ].concat(substract(B.slice(-lA), A));
        if (lA > lB) return [ { value: parseInt(A.slice(0, -lB)), size: lA - lB } ].concat(substract(A.slice(-lB), B));

        return [ { value: parseInt(A.slice(0, 9)) - parseInt(B.slice(0, 9)), size: 9 } ].concat(substract(A.slice(9), B.slice(9)))
    }

    let x = substract(a, b);
    x = x.slice(x.findIndex(i => i.value));
    if (!x.length) return '0';

    let t = '';
    if (x[0] < 0) { t = '-'; x = x.map(i => -i); }

    for (let i = 1; i < x.length; i++) {
        if (x[i].value < 0) { x[i-1].value -= 1; x[i].value = 10**10 + x[i].value; }
    }
    return t + x.map(i => `${'0'.repeat(i.size)}${i.value}`.slice(-i.size)).join('').replace(/^0+/, '') || '0';
}

const problem = (n, p, w, d) => {
    let Y = -1;
    const W = parseInt(w);
    while (++Y < W && rem(p, w)) p = sub(p, d);
    const z = sub(sub(n, div(p, w)), `${Y}`);
    if (Y === W) return -1; // || (p|z) < 0
    return `${div(p, w)} ${Y} ${z}`;
}

const npwd = readline().split(' ');
write(problem(npwd[0], npwd[1], npwd[2], npwd[3]));


var flowers = function(r, g, b){
	var count = 0;
	var colors = [r, g, b];
	for (var i in colors) {
		if (colors[i] > 3){
			if (colos[i] % 3 == 0){
				count += colors[i] / 3 - 1;
				colors[i] = 3;
			}
			else {
				count += Math.floor(colors[i] / 3);
				colors[i] = colors[i] % 3;
			}
		}
	}

	if ( colors.filter(function(index) {
		return index == 2
	}).length < 2) {
		for (var i in colors){
			if (colors[i] == 3){
				colors[i] -= 3;
				count++;
			}
		}
	}

	while (colors.filter(function(index) {
		return index >= 1;
	}).length >= 3) {
		for (var i in colors) {
			colors[i] -= 1;
		}
		count++;
	}

	return count;
};

var line = readline().split(' ');
var r = parseInt(line[0]);
var g = parseInt(line[1]);
var b = parseInt(line[2]);

print (flowers(r, g, b));


var len = parseInt(readline());
var str = readline();

if (isGood(str)) {
    print("1");
    print(str);
} else {
    var res = breakItDown(str, len);
    print(res.length)
    print(res.join(" "))
}

function breakItDown(str, len) {
    var left = str.substr(0, len / 2);
    var right = str.substr(len / 2);
    var slidingWindowIndex = 0;

    while (!isGood(left)) {
        slidingWindowIndex++;
        left += right.charAt(0);
    }

    right = right.substr(slidingWindowIndex);

    return [left, right];
}

function isGood(str) {
    return count(str, 1) != count(str, 0)
}

function count(str, num) {
    var _count = 0;
    for (var i = 0; i < str.length; i++)
        _count += str.charAt(i) == num ? 1 : 0;
    return _count
}


const input = readline().split(" ").map(x => Number(x));
const n = input[0];
var sum = 0;
for (var i = 1; i <= n; i++) {
  var current = i;
  var remaining = i;
  while (remaining) {
    var next = Math.floor(remaining * 0.1);
    current = current * 10 + (remaining - next * 10);
    remaining = next;
  }
  sum += current;
}
print(sum % input[1]);


var K, P;
K = readline();
P = readline();

var i = 1;

var sum = 0;

while (i <= K) {
    var now = i.toString(10);
    var temp = now;
    temp += m_reverse(now);
    sum = (sum + parseInt(temp)) % P;
    i++;
}

print(sum);

function m_reverse(str) {
    var r_str = "";
    for (var i = str.length - 1; i >= 0; i--) {
        r_str += str[i];
    }

    return r_str;
}


function main() {
  var knsp = readline()
    .split(' ')
    .map(l => Number(l));
  var k = knsp[0],
    n = knsp[1],
    s = knsp[2],
    p = knsp[3];

  var sheetsNeeded = k * Math.ceil(n / s);
  var packsNeeded = Math.ceil(sheetsNeeded / p);

  print(packsNeeded);
}

main();


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

var k = Number(g[0]);
var n = Number(g[1]);
var s = Number(g[2]);
var p = Number(g[3]);

print(Math.ceil(k/p)*Math.ceil(n/s));


  const readline = require('readline');

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

  rl.question('', (value) => {
      let s = value;
      let isPalindrome = true;
      let oneLetter = true;
      console.log(Math.floor(s.length/2));
      for(let idx = 0; idx < Math.floor(s.length/2) && isPalindrome; idx += 1){
        console.log('aa',idx);
        if(s.charAt(idx) != s.charAt(s.length-idx-1)){
          console.log('bb');
          isPalindrome = false;
        }
        if(s[idx] !== s[idx+1] && oneLetter){
          oneLetter = false;
        }
      }
      if(!isPalindrome){
        console.log(s.length);
      }else if(oneLetter) {
        console.log(0);
      }else {
        console.log(s.length-1);
      }
      rl.close();

  });


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


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


function nextChar(c) {
  return String.fromCharCode(
    c.charCodeAt(0) + 1
  )
}

var str = readline(),
    done = false

for (var i = 'a' ; str.length && i <= 'z' && !done; i = nextChar(i)) { //console.log(str, i)
  if (str[0] === i) str = str.split(i).join('')
  else done = true
}

print(done ? 'NO' : 'YES')


let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  const b = parseInt(lines[0], 10);
  const g = parseInt(lines[1], 10);
  const n = parseInt(lines[2], 10);
  console.log(badges(b, g, n));
});

function badges(b, g, n) {
  if (n === b + g) return 1;
  const min = Math.min(b, g);
  const sub = Math.max(b, g) < n ? n - Math.max(b, g) : 0;
  return min >= n ? 1 + n - sub : 1 + min - sub;
}


let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  const b = parseInt(lines[0], 10);
  const g = parseInt(lines[1], 10);
  const n = parseInt(lines[2], 10);
  console.log(badges(b, g, n));
});

function badges(b, g, n) {
  if (n === b + g) return 1;
  const min = Math.min(b, g);
  return min >= n ? 1 + n : 1 + min;
}


var line = readline();
var left = line.substring(0,line.indexOf('|'));
var right = line.substring(line.indexOf('|')+1,(line.length));
var rest = readline();

print(left);
print(right);
print(rest);

var diff = left.length - right.length;

if(diff>0){
    if(rest.length>=diff){
        right = right+rest.substr(0,diff);

        rest = rest.substring(diff,rest.length);
        print('rest:'+ rest+rest.length);
        if((rest.length % 2)==0){
            left = left + rest.substring(0,rest.length/2);
            right = right + rest.substring((rest.length/2));
            print(left+'|'+right);
        }
        else{
            print('Impossible');
        }
    }
    else{
        print('Impossible');
    }
}
else if(diff==0){
    if((rest.length % 2)==0){
            left = left + rest.substring(0,rest.length/2);
            right = right + rest.substring(rest.length/2);
            print(left+'|'+right);
        }
        else{
            print('Impossible');
        }
}
else if(diff<0){
    diff = Math.abs(diff);
    if(rest.length>=diff){
        left = left+rest.substr(0,diff);
        rest = rest.substr(diff,rest.length);
        if((rest.length % 2)==0){
            left = left + rest.substring(0,rest.length/2);
            right = right + rest.substring(rest.length/2);
            print(left+'|'+right);
        }
        else{
            print('Impossible');
        }
    }
    else{
        print('Impossible');
    }

}


var values = readline().split("|");

var a = values[0];
var b = values[1];

if (a.length <= b.length) {
    a = a.concat(readline());
} else {
    b = b.concat(readline());
}

if (a.length !== b.length) {
    print("Impossible");
} else {
    print([a, b].join("|"));
}


var line = readline();
var left = line.substring(0,line.indexOf('|'));
var right = line.substring(line.indexOf('|')+1,(line.length));
var rest = readline();

var diff = left.length - right.length;

if(diff>0){
    if(rest.length>=diff){
        right = right+rest.substr(0,diff);

        rest = rest.substring(diff,rest.length);
        if((rest.length % 2)==0){
            left = left + rest.substring(0,rest.length/2);
            right = right + rest.substring((rest.length/2));
            print(left+'|'+right);
        }
        else{
            print('Impossible');
        }
    }
    else{
        print('Impossible');
    }
}
else if(diff==0){
    if((rest.length % 2)==0){
            left = left + rest.substring(0,rest.length/2);
            right = right + rest.substring(rest.length/2);
            print(left+'|'+right);
        }
        else{
            print('Impossible');
        }
}
else if(diff<0){
    diff = Math.abs(diff);
    if(rest.length>=diff){
        left = left+rest.substr(0,diff);
        rest = rest.substr(diff,rest.length);
        if((rest.length % 2)==0){
            left = left + rest.substring(0,rest.length/2);
            right = right + rest.substring(rest.length/2);
            print(left+'|'+right);
        }
        else{
            print('Impossible');
        }
    }
    else{
        print('Impossible');
    }

}


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

function print(x) {
    console.log(x);
}

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++];
}

//-----------main fucntion-----------

function main() {
    var input = readline().split(" ").map(x => parseInt(x))
    var a = input[0], b = input[1]
    if (a > b) print("-1")
    else print(a)

}


var readline = require("readline");
var rl = readline.createInterface(process.stdin, process.stdout);
rl.on("line", function(line) {
  console.log(solution(line))
  rl.close();
}).on("close",function(){
  process.exit(0);
});

function solution(input){
    const check = n => [...new Set(n)].join('') == n;
    var [l, r] = input.split(' ');
    r = +r;
    while (++l < r){
        if (check(l.toString()))
            return l;
    }
    return -1;
}


(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Queue = require('../queue');
var Stack = require('../stack');

var Graph = function () {
    function Graph() {
        var _this = this;

        var nodes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
        var directed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

        _classCallCheck(this, Graph);

        this.directed = directed;
        this.nodes = nodes;
        this.edges = {};
        nodes.forEach(function (node) {
            _this.edges[node] = [];
        });
    }

    _createClass(Graph, [{
        key: 'addNode',
        value: function addNode(node) {
            // is it required ?
            if (this.edges[node]) {
                throw new Error('Graph.prototype.addNode: node is already exists');
                return;
            }

            this.nodes.push(node);
            this.edges[node] = [];
        }
    }, {
        key: 'addEdge',
        value: function addEdge(node1, node2) {
            var weight = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;

            this.edges[node1].push({ node: node2, weight: weight });

            if (!this.directed) {
                this.edges[node2].push({ node: node1, weight: weight });
            }
        }
    }]);

    return Graph;
}();

module.exports = Graph;

},{"../queue":4,"../stack":5}],2:[function(require,module,exports){
"use strict";

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Node = function () {
    function Node(value) {
        _classCallCheck(this, Node);

        this.value = value;
        this.nextNode = null;
        this.prevNode = null;
    }

    _createClass(Node, [{
        key: "getValue",
        value: function getValue() {
            return this.value;
        }
    }, {
        key: "setValue",
        value: function setValue(value) {
            this.value = value;
        }
    }, {
        key: "setNext",
        value: function setNext(nextNodeLink) {
            this.nextNode = nextNodeLink;
        }
    }, {
        key: "setPrev",
        value: function setPrev(prevNodeLink) {
            this.prevNode = prevNodeLink;
        }
    }, {
        key: "getNext",
        value: function getNext() {
            return this.nextNode;
        }
    }, {
        key: "getPrev",
        value: function getPrev() {
            return this.prevNode;
        }
    }]);

    return Node;
}();

module.exports = Node;

},{}],3:[function(require,module,exports){
'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Node = require('../node');

var Queue = function () {
    function Queue() {
        _classCallCheck(this, Queue);

        this.firstItemLink = null;
        this.lastItemLink = null;
    }

    _createClass(Queue, [{
        key: 'enqueue',
        value: function enqueue(item, priority) {
            var node = new Node({
                item: item,
                priority: priority
            });

            if (this.isEmpty()) {
                this.lastItemLink = node;
                this.firstItemLink = node;
            } else {

                if (priority >= this.firstItemLink.getValue().priority) {
                    // Вперед
                    node.setNext(this.firstItemLink);
                    this.firstItemLink = node;
                } else if (priority <= this.lastItemLink.getValue().priority) {
                    // Назад
                    this.lastItemLink.setNext(node);
                    this.lastItemLink = node;
                } else {
                    // В середину
                    var currentNode = this.firstItemLink;
                    while (currentNode) {
                        var nextNode = currentNode.getNext();
                        if (priority >= nextNode.getValue().priority) {
                            currentNode.setNext(node);
                            node.setNext(nextNode);
                            currentNode = null;
                        } else {
                            currentNode = nextNode;
                        }
                    }
                }
            }
        }
    }, {
        key: 'dequeue',
        value: function dequeue() {
            if (this.isEmpty()) {
                return undefined;
            }

            if (this.lastItemLink === this.firstItemLink) {
                this.lastItemLink = null;
            }

            var firstItem = this.firstItemLink;

            this.firstItemLink = this.firstItemLink.getNext();

            return firstItem.getValue().item;
        }
    }, {
        key: 'isEmpty',
        value: function isEmpty() {
            return !this.firstItemLink;
        }
    }]);

    return Queue;
}();

module.exports = Queue;

},{"../node":2}],4:[function(require,module,exports){
'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Node = require('../node');

var Queue = function () {
    function Queue() {
        _classCallCheck(this, Queue);

        this.firstItemLink = null;
        this.lastItemLink = null;
    }

    _createClass(Queue, [{
        key: 'enqueue',
        value: function enqueue(item) {
            var node = new Node(item);

            if (this.isEmpty()) {
                this.lastItemLink = node;
                this.firstItemLink = node;
            } else {
                this.lastItemLink.setNext(node);
                this.lastItemLink = node;
            }

            return node;
        }
    }, {
        key: 'dequeue',
        value: function dequeue() {
            if (this.isEmpty()) {
                return undefined;
            }

            if (this.lastItemLink === this.firstItemLink) {
                this.lastItemLink = null;
            }

            var firstItem = this.firstItemLink;

            this.firstItemLink = this.firstItemLink.getNext();

            return firstItem.getValue();
        }
    }, {
        key: 'isEmpty',
        value: function isEmpty() {
            return !this.firstItemLink;
        }
    }]);

    return Queue;
}();

module.exports = Queue;

},{"../node":2}],5:[function(require,module,exports){
'use strict';

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Node = require('../node');

var Stack = function () {
    function Stack() {
        _classCallCheck(this, Stack);

        this.topItemLink = null;
    }

    _createClass(Stack, [{
        key: 'push',
        value: function push(item) {
            var node = new Node(item);

            if (this.isEmpty()) {
                this.topItemLink = node;
            } else {
                node.setPrev(this.topItemLink);
                this.topItemLink = node;
            }

            return node;
        }
    }, {
        key: 'pop',
        value: function pop() {
            if (this.isEmpty()) {
                return undefined;
            }

            var topItemLink = this.topItemLink;

            this.topItemLink = this.topItemLink.getPrev();

            return topItemLink.getValue();
        }
    }, {
        key: 'isEmpty',
        value: function isEmpty() {
            return !this.topItemLink;
        }
    }]);

    return Stack;
}();

module.exports = Stack;

},{"../node":2}],6:[function(require,module,exports){
'use strict';

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

var Graph = require('../libs/graph');
var PriorityQueue = require('../libs/priority-queue');

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

var _arr$map = arr.map(function (v) {
    return parseInt(v);
}),
    _arr$map2 = _slicedToArray(_arr$map, 2),
    l = _arr$map2[0],
    r = _arr$map2[1];

var checker = function checker(num) {
    num = String(num);

    var data = {};
    var flag = true;
    for (var i = 0; i < num.length; i++) {
        if (data[num[i]]) {
            flag = false;
            break;
        }

        data[num[i]] = 1;
    }

    return flag;
};

var ans = -1;
for (var i = l; i <= r; i++) {
    if (checker(i)) {
        ans = i;
        break;
    }
}

write(ans + '\n');

},{"../libs/graph":1,"../libs/priority-queue":3}]},{},[6]);


'use strict'

const lr = readline().split(' ').map(i => i.split('').map(Number));

const problem = (l, r) => {
    const test = x => (x => x >= +l.join('') && x <= +r.join('') && x)(parseInt(x));

    let res;
    if (l.length < r.length) {
        const Mid = Math.floor((l.length + r.length) / 2)
        if (res = test('98765'.slice(0, Mid))) return res;
        if (res = test('12345'.slice(0, Mid + 1))) return res;
        return -1;
    }

    const s = new Set([ 9,8,7,6,5,4,3,2,1,0 ]);
    const L = l.length;
    for(let i = 0; i < L; i++) {
        if (r[i] !== l[i]) {
            const a = l.slice(0, i).join('');
            for (let j = l[i]; j < r[i]; j++) {
                if (s.has(j) && (res = test(a + `${j}` + [ ...s ].filter(d => d !== j).slice(0, L - i - 1).join('')))) return res;
            }
            if (s.has(r[i]) && (res = test(a + `${r[i]}` + [ ...s ].filter(d => d !== r[i]).reverse().slice(0, L - i - 1).join('')))) return res;
            return -1;
        }
        if (!s.has(r[i])) return -1;
        s.delete(r[i]);
    }
    return l.join('')
}

write(problem(lr[0], lr[1]));


n = readline();
str = readline().split('');

var count = 0;

for (var i = 0; i < n; i++) {
	if ((str[i] == 'R' && str[i + 1] == 'U') || (str[i] == 'U' && str[i + 1] == 'R')) {
		count++;
		i++;
	} else {
		count++;
	};
};

print(count);


process.stdin.setEncoding("ascii");

let input = "";

process.stdin.on("data", data => { input += data; });
process.stdin.on("end", () => {
    const [[n, m], T] = input.trim().split("\n").map(x => x.trim().split(" ").map(Number));
    const sum = [0, ...T];
    for (let i = 1; i < sum.length; i++)
        sum[i] += sum[i - 1];
    sum.shift();
    process.stdout.write("0 ");
    for (let i = 1; i < sum.length; i++) {
        const pred = T.slice(0, i);
        pred.sort((a, b) => b - a);
        let currentSum = sum[i];
        let count = 0;
        while (currentSum > m) {
            count++;
            currentSum -= pred.shift();
        }
        process.stdout.write(count + " ");
    }
});


// function month(a, b) {
var a = readline();
var b = readline();
    var array = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'];
    var c = array.indexOf(a) + 1;
   // c = c % 7;
    console.log(c);
    var d = array.indexOf(b) + 1;
   // console.log(c +' '+ d);
    if(d  == c  || d == (c + 2) % 7 || d == (c + 3) % 7 ) {
        console.log('YES');
    } else {
        console.log('NO');
    }
// }month('monday', 'tuesday');


var day1 = readline();
var day2 = readline();
var days = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
var a = days.indexOf(day1) + 1;
var b = days.indexOf(day2) + 1;
print((b - a) !== 1 && (a === b || (a + 2) % 7 >= b || (a + 3) % 7 >= b) && "YES" || "NO");


var day1 = readline();
var day2 = readline();
var days = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
var a = days.indexOf(day1);
var b = days.indexOf(day2);
print((b - a) !== 1 && (a===b ||(a + 2) % 7 >= b || (a + 3) % 7 >= b) && "YES" || "NO");


var month_name = readline();
var result_month = parseInt(readline());
var obj = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
print(obj[obj.indexOf(month_name)+result_month+1])


function main(){
	var numbers = readline().split(" ").map(Number);

	var num = numbers[0];
	var kthdiv = numbers[1];
	var divs = [];

	if(numbers[1] === 1)
		return 1;

	if(numbers[0] === 1 && numbers[1] !== 1)
        return -1;

	divs.push(1);

	var numDiv = 1;

	for(var i = 2; i <= Math.sqrt(num); i++)
		if(num % i === 0 && ++numDiv === kthdiv)
			return i;
		else if(num % i === 0)
			divs.push(i);

	for(i = divs.length-1; i >= 0; i--)
        if(num / divs[i] !== divs[i])
            divs.push(num/divs[i]);

	if(kthdiv <= divs.length)
		return divs[kthdiv-1];

	return -1;
}

print(main());


'use strict'
/*
//var a=4;
var a=parseInt(readline());
var max=a+1;
var max_1=a;
for(var i=1;i<=Math.sqrt(a);i++){
    if(a%i==0){
        if((i+a/i)<max){
            max=i+a/i;
        }
    }
}
if((a-1)%2==0&&a>1){
    a=a-1;
    for(var i=1;i<=Math.sqrt(a);i++){
        if(a%i==0){
            if((i+a/i)<max_1){
                max_1=i+a/i;
            }
        }
    }
    if(max_1+1<max)
        max=max_1+1;
}
print(max);
*/
var a=parseInt(readline());
var p;
for(var i=1;i<=a;i++){
    if(i*i>a){
        p=i;
        break;
    }else if(i*i==a){
        p=i;
        print(a);
        break;
    }
}
if(p*p!==a){
    for(var i=1;i<=p;i++){
        if(i*p>(p-1)*(p-1)){
            if(a>=p*(i-1)&&a<=p*i){
                print(p+i);
                break;
            }
        }
    }
}


const readline = require('readline');

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
rl.on('line', (inputString) => {
    let numberOfSquares = parseInt(inputString);
    rl.close();
    console.log(findTheNumberOfLinesForLady(numberOfSquares));
});

function findTheNumberOfLinesForLady(forTheNumberOfSquaress) {
    let a = Math.sqrt(forTheNumberOfSquaress);
    let b = Math.trunc(a);
    if (a == b) return (a + a);
    if (b * (b + 1) >= forTheNumberOfSquaress) return b + b + 1;
    return b + b + 2;
}


const input = readline().split(" ").map(x => Number(x));
const n = input[0];
const numbers = input.slice(1, 1 + n);
print(numbers.sort((a, b) => a > b ? 1 : a < b ? -1 : 0).join(" "));
while (performance.now() < 1500) { }


setTimeout(function() { print(readline().split(' ').slice(1).map(function(x) { return parseInt(x); }).sort(function(a, b) { return a - b; })); }, 1000);


function solve(){
    var a = readline();
    var last = 1;
    var res = 0;
    for(var i = 1; i < a.length; i++){
        if(a[i] != a[i-1]){
            if(last % 2 == 0) ++res;
            last = 1;
        } else {
            last++;
        }
    }
    if(last % 2 == 0) ++res;
    print(res);
}
solve();


var arr = readline().split('');
var res = 0;
while(arr.length) {
    var curr = arr.shift();
    for(var i = 0; i < 4; i++) {
        if (arr[0] === curr) {
            arr.shift();
        } else {
            break;
        }
    }
    res++;
}
print(res);


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

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

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

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

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

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

print(count);


const input = [];

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

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

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

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


print(function(x, t, a, b, da, db) {
	if (x === 0) return 'YES';
	for (var i = 0; i < t; i++) {
		if (a - da * i === x) return 'YES';
		if (b - db * i === x) return 'YES';
	}

	for (var i = 0; i < t; i++)
		for (var j = 0; j < t; j++)
			if (a - da * i + b - db * j === x)
				return 'YES';

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


var n = readline();
var two = "8"; var one = "4 6 9 0".split(" ");
var res = "";

if (n%2==0) {
	for(var i=0; i<n/2; i++){
		res += two;
	}
}else{
	res = one[0];
		for(var i=0; i<(n-1)/2; i++){
		res += two;
	}
}
print(res);


function main() {

    var n = readline();

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

    var sum = 0;
    var allZeros = true;

    //caculate the sum of array
    for(var i = 0; i < n; i++){
        sum += arr[i];
    }

    //test if all elements in array are zeros
    for(var j = 0; j < n; j++){
        if(arr[j] == 0){
            allZeros = false;
        }
    }

    if(sum != 0){
        print('YES');
        print('1');
        print('1'+ ' ' + n);
    } else if(allZeros){
        print('NO');
    } else {
        print('YES');
        var k = 0;
        while (arr[k] == 0){
            k++;
        }
        print('2');
        print((k + 1) + ' ' + n);

    }

}

main();


/**
 * Created by Meiling on 1/12/17.
 */

function main() {

    var n = readline();

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

    var sum = 0;
    var allZeros = true;

    //caculate the sum of array
    for(var i = 0; i < n; i++){
        sum += arr[i];
    }

    //test if all elements in array are zeros
    for(var j = 0; j < n; j++){
        if(arr[j] == 0){
            allZeros = false;
        }
    }

    if(sum != 0){
        console.log('YES');
        console.log('1');
        console.log('1'+ ' ' + n);
    } else if(allZeros){
        console.log('NO');
    } else {
        console.log('YES');
        var k = 0;
        while (arr[k] == 0){
            k++;
        }
        console.log('2');
        console.log((k + 1) + ' ' + n);

    }

}

main();


function main() {
    var n = Number(readline());
    var s = readline().split(' ').map(Number);
    var sum = s.reduce((prev, cur) => prev + cur, 0);
    var allZeros = true;
    for(var k=0;k<s.length;k++){
        if(s[k]!=0){
            allZeros = false;
        }
    }
    if(sum != 0 ){
        print("YES");
        print("1");
        print("1 " + n);
    } else if(allZeros) {
        print("NO");
    } else {
        print("YES");
        var i=0;
        while(s[i]==0){
            i++;
        }
        print("2");
        print("1 " + (i+1));
        print((i+2) + " " + n);
    }

}

main()


function checkPattern(inputstring){
    if(inputstring.length == 1 && inputstring[0] == '?')
        return 'Yes';
    else if(inputstring.length == 1)
        return 'No'

    var ret = 'Yes';
    var questionmarked = false;
    var prev = inputstring[0];
    for(var idx =1; idx <inputstring.length; idx++){
        if(inputstring[idx] == '?')
            questionmarked = true;
        if(inputstring[idx] == prev && inputstring[idx] != '?')
            ret = 'No';

        prev = inputstring[idx];
    }
    return ret == 'Yes' && questionmarked ? ret: 'No';
}
count = readline();
while(numbers = readline()){
    number = numbers;
    print(checkPattern(number));
}


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

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

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

function printValues() {
	var parts = [];
	for (var i = 0; i < arguments.length; i += 2) {
		parts.push(arguments[i]+' = '+arguments[i+1]);
	}
	print(parts.join(', '));
}

function main() {
	var data = tokenizeIntegers(readline()),
		w = data[0], h = data[1],
    total = 0;
  for (var a = 1; a <= w; ++a) {
    for (var b = 1; b <= h; ++b) {
      if (a%2 == 0 && b%2 == 0) {
        total += (w-a+1)*(h-b+1);
      }
    }
  }
  print(total);
}

main();


// Generated by CoffeeScript 1.7.1
(function() {
  var compute, d, k, n, str;

  compute = function(n, k, d) {
    var i, j, withConstraint, withoutConstraint, _i, _j;
    withoutConstraint = new Uint32Array(n + 1);
    withoutConstraint[0] = 1;
    withConstraint = new Uint32Array(n + 1);
    withConstraint[0] = 0;
    for (i = _i = 0; 0 <= n ? _i <= n : _i >= n; i = 0 <= n ? ++_i : --_i) {
      for (j = _j = 1; 1 <= k ? _j <= k : _j >= k; j = 1 <= k ? ++_j : --_j) {
        if (i - j >= 0) {
          withoutConstraint[i] += withoutConstraint[i - j];
          if (j >= d) {
            withConstraint[i] += withoutConstraint[i - j];
          } else {
            withConstraint[i] += withConstraint[i - j];
          }
          withoutConstraint[i] %= 1000000007;
          withConstraint[i] %= 1000000007;
        }
      }
    }
    return withConstraint[n];
  };

  '#node.js 10.x\n\nreadline = require \'readline\'\nreadline.createInterface(\n  input: process.stdin\n  output: process.stdout\n  terminal: false\n).on \'line\', (str) ->\n  str = str.split \' \'\n\n  n = Number str[0]\n  k = Number str[1]\n  d = Number str[2]\n\n  console.log compute n, k, d';

  'd8';

  str = readline().split(' ');

  n = Number(str[0]);

  k = Number(str[1]);

  d = Number(str[2]);

  print(compute(n, k, d));

}).call(this);


'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++];
}
/**
3 4
##..
##..
...#

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function main() {
    let n = parseInt(readline());

    let string = 'codeforces';

    let s = new Array(n-1).fill('s').join("");

    console.log(string + s);

}

// function solve() {
//     let [n, m] = readline().split(" ").map(Number);
//     let a = readline().split("");

//     let findIndex = a.findIndex("1");

//     let even = false;
//     let zero = false;

//     if(findIndex === -1) {
//         zero = true;
//     } else if(findIndex % 2 === 0) {
//         even = true;
//     }

//     let total = 0;

//     if(even) {
//         for(let i=0;i<n;i+=2) {
//             if(a[i] === "0") {
//                 total++;
//             }
//         }
//     }
// }


'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++];
}
/**
6
6 1
100010
6 2
000000
5 1
10101
3 1
001
2 2
00
1 1
0

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

function main() {
    let n = parseInt(readline());

    // for(let i=0;i<n;i++) {
    //     solve();
    // }

    let currentString = ['c', 'o', 'd', 'e', 'f', 'o', 'r', 'c', 'e', 's'];
    const occur = new Array(10).fill(1);

    let count = 1;
    let index = 0;

    while(count < n) {
        count = count / occur[index];
        occur[index]++;
        count = count * occur[index];
        index++;
        if(index === 10) {
            index = 0;
        }
    }

    let string = '';

    for(let i=0;i<currentString.length;i++) {
        string = string + currentString[i].repeat(occur[i]);
    }

    console.log(string);

}

function solve() {
    let [n, m] = readline().split(" ").map(Number);
    let a = readline().split("");

    let count = 0;
    let i = 1;
    if(a.length === 1 && a[0] === "0") {
        console.log(1);
        return;
    }

    while(m > count && i < n) {
        if(i === 1 && a[i-1] === '0' && a[i] === '0') {
            count++;
            a[i-1] = "1";
            continue;
        }

        if(a[i + 1] === n) {
            if(a[i] === "0" && a[i-1] === "0") {
                count++;
            }

            continue;
        }

        if(a[i] === "0" && a[i-1] === "0" && a[i+1] === "0") {
            count++;
            a[i] = "1";
        }

        i++;
    }

    console.log(count);
}


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

    main();
});

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

const s2i = s => parseInt(s, 10);

function main() {
  const k = BigInt(readLine());
  let max = 1n;
  while (max ** 10n < k) max++;
  let nMax = 10n;
  let nMin = 0n;
  while (max ** (nMax - 1n) * (max - 1n) ** (nMin + 1n) >= k) {
    nMax--;
    nMin++;
  }

  let result = '';
  const codeforces = 'codeforces'
  for(let i = 0; i < 10; i++) {
    const reps = i < nMax ? max : max - 1n;
    for (let j = 0; j < reps; j++) {
      result += codeforces.charAt(i);
    }
  }

  console.log(result)
}


;(function () {

	var n = +readline();

	if (n < 3) {
		print(-1);
		return;
	}

	var str = '';
	for (var i = 0; i < n; i++) {
		str += (n-i);
	}

	print(str);

}).call(this);


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

function tokenize_integers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i++) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}
function nextArray() {
	return tokenize_integers(readline());
}
function nextInt() {
	return parseInt(readline());
	//	return tokenize_integers(readline())[0];
}
function main() {
	var data = nextArray();
	var c = data[0], d = data[1];
	data = nextArray();
	var n = data[0], m = data[1];
	var k = nextInt();
	var needWinners = Math.max(0, n * m - k);
//	print(needWinners);
	var ret = -1;
	for(var x = 0; x <= 10000; x++) {
		var y = needWinners - x * n ;
		y = Math.max(y, 0);
		var tmp = c * x + y * d;
//		if(x < 10)print(tmp);
		if(ret == -1 || tmp < ret) {
			ret = tmp;
		}
	}
	print(ret);
}
main();


function main() {

    var arr1 = readline().split(' ').map(Number);
    var c = arr1[0], d = arr1[1];
    var arr2 = readline().split(' ').map(Number);
    var n = arr2[0], m = arr2[1];
    var k = Number(readline());

    var winners = Math.max(0, n * m - k);

    var problems = -1;

    for (var x = 0; x <= 10000; x++) {
        var y = winners - x * n;
        y = Math.max(y, 0);
        var temp = c * x + y * d;

        if (problems == -1 || temp < problems) {
            problems = temp;
        }
    }
    print(problems);

}

main();


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

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

print(function(cb, ca, na, nb, k) {
	nb -= ~~(k / na);
	k %= na;

	if (nb <= 0) {
		return 0;
	}
	return (Math.min(nb * cb, Math.min((na - k) * ca + (nb - 1) * cb, (na - k) * ca + (nb - 1) * na * ca)));
}.apply(0, readNums().concat(readNums()).concat(readNums())));


print(function(a, c) {

	a = a.toString(3);
	c = c.toString(3);
	var ans = [];
	for (var i = a.length-1, j = c.length-1; i >= 0 || j >= 0; i--, j--)
		ans.push((3 + (+c[j] || 0) - (+a[i] || 0)) % 3);

	return parseInt(ans.reverse().join(''), 3);

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


function main(n,m) {

    var ans = 2;
    if(n > 1){
      for(var i = 1 ; i < n ; i++)ans *= 2;
    }
    ans = m%ans;
    print(ans);
}

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

main(n,m);


'use strict';

var n = parseInt(readline());
var m = parseInt(readline());
var out = m % (Math.pow(2,n));
print(out);


var n = readline();
var m = readline();

if(n>=27)
    print(m);
else
    print(m%(1<<n));


const readline = require('readline')

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

function solve(n) {
    let ans = 6
    const base = 4
    // let count = 1
    let prev = 4
    for (let i = 2; i <= n; i++) {
        // base = mul(base, 4)

        // count = count * 2
        // ans = mul(ans, pow(base, count)

        prev = mul(prev, prev)
        ans = mul(ans, prev)
    }
    return ans
}
function add(a, b) {
    return (a + b) % (1e9 + 7)
}
function mul(a, b) {
    let r = 0
    let base = a
    while (b) {
        if (b & 1) {
            r = add(r, base)
        }
        b >>= 1
        base = add(base, base)
    }
    return r
}
function pow(a, b) {
    let r = 1
    let base = a
    while (b) {
        if (b & 1) {
            r = mul(r, base)
        }
        b >>= 1
        base = mul(base, base)
    }
    return r
}


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

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


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


print(function(a, b) {
	return +a+ +b.split('').reverse().join('');
}.apply(0, readline().split(' ')));


function hasBlackItem(line) {
  var count = 0;
  for(var i = 0; i < line.length; i++) {
    if(line[i] === 'B') {
      count++;
    }
  }
  if(count < 8) {
    return count;
  }
  else {
    return 1;
  }
}
var count = 0;
var lineres = 0;
while((lineres = hasBlackItem(readline())), count += lineres, lineres > 1);
while((lineres = readline())) {
  lineres = hasBlackItem(lineres);
  if(lineres === 1) {
    count++;
  }
}
print(count);


const readline = require("readline");

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

var answer = 0;
var counter = 0;
var check = true;

rl.on("line", input => {

      let temp = input.match(/B/g);

      counter =(temp!=null)? temp.length : 0;

    if (counter == 8) {
      answer++;
    }
    else if (check && counter > 0) {
      answer += counter;
      check = false;
    }

}).on("close", () => {
    console.log(answer);
  });


const readline = require('readline');

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

var ans = 0,
    metColumn = false;

rl.on('line', (s) => {

    if (s == 'BBBBBBBB')
        ans++;
     else if (!metColumn) {
         //console.log("inside else if metColumn= &s",metColumn)
        let helper= s.match(/B/g);
        if(helper!=null)
        ans += helper.length;
        metColumn = true;
    }

}).on('close', () => {
    console.log(ans);
    rl.close();

});


function main() {

    var a = Number(readline());

    if(a<13){
        print(Math.pow(2,a));
    }else {
        print(8092*Math.pow(2,(a-13)));
    }

}

main();


const lines = [];

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

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

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

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

  // Repeate complete cycles
  if (cycles > 1) for (let jj = 1; jj < cycles; colorsSequence.push(...colorsSequence), jj++);

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

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

});


'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  const n = +ipt.split(EOL).slice(0, -1)[0]
  let o = 'ROY'
  let r = (n - 3) / 4 | 0
  for (let i = 0; i < r; i++) o += 'GBIV'
  o += 'GBIV'.slice(0, (n - 3) % 4)
  console.log(o)
})


const memo = {};

function resolve(k, arr, n) {
  if (memo[arr.join('')] !== undefined) {
    return memo[arr.join('')];
  }
  if (parseInt(arr[0], 10) % 2 === 0 || parseInt(arr[k - 1], 10) % 2 === 0) {
    memo[arr.join('')] = false;
    return false;
  } else {
    if (k % 2 !== 0 && n % 2 !== 0) {
      memo[arr.join('')] = true;
      return true;
    } else {
      for (var i = 0; i < k; i += 2) {
        if (parseInt(arr[i], 10) % 2 !== 0) {
          if (resolve(arr.slice(i + 1).length, arr.slice(i + 1), n + 1)) {
            memo[arr.join('')] = true;
            return true;
          }
        }
      }

      for (var i = k - 1; i >= 0; i -= 2) {
        if (parseInt(arr[i], 10) % 2 !== 0) {
          if (resolve(arr.slice(0, i).length, arr.slice(0, i), n + 1)) {
            memo[arr.join('')] = true;
            return true;
          }
        }
      }
      memo[arr.join('')] = false;
      return false;
    }
  }
}

const k = parseInt(readline(), 10);
const arr = readline().split(' ');

const result = resolve(k, arr, 1);

print(result ? 'Yes' : 'No' + '\n');


function resolve(stack1, stack2) {
  var flag = true;
  while (stack1.length !== 0 || stack2.length !== 0) {
    var arr = stack1.pop();
    flag = true;
    if (!arr) {
      flag = false;
      arr = stack2.pop();
    }
    var k = arr.length;
    if (parseInt(arr[0], 10) % 2 !== 0 && parseInt(arr[k - 1], 10) % 2 !== 0) {
      if (k % 2 !== 0 && flag) {
        return true;
      } else {
        for (var i = 0; i < k; i += 2) {
          if (parseInt(arr[i], 10) % 2 !== 0) {
            if (flag) {
              stack2.push(arr.slice(i + 1));
            } else {
              stack1.push(arr.slice(i + 1));
            }
          }
        }
      }
    }
  }
  return false;
}

const k = parseInt(readline(), 10);
const arr = readline().split(' ');

const result = resolve([arr], []);

print(result ? 'Yes' : 'No' + '\n');


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

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

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

function numDivisors(x) {
	var count = 0;
	for (var i = 1; i*i <= x; ++i) {
		if (x%i == 0) {
			++count;
			if (i*i != x) {
				++count;
			}
		}
	}
	return count;
}

function main() {
	var data = tokenizeIntegers(readline()),
		a = data[0], b = data[1], c = data[2],
		divisors = {}, count = 0;
	for (var i = 1; i <= a; ++i) {
		for (var j = 1; j <= b; ++j) {
			for (var k = 1; k <= c; ++k) {
				var x = i*j*k;
				if (divisors[x] === undefined) {
					divisors[x] = numDivisors(x);
				}
				count = (count+divisors[x]) % 1073741824;
			}
		}
	}
	print(count);
}

main();


'use strict'
//
// http://codeforces.com/contest/907/problem/B

let board = [];

for (let i = 0; i < 11; i += 1) {
  const line = readline().replace(/\s/g, '').split('');;
  if (line.length > 0) {
    board.push(line);
  }
}

const arr = readline().split(' ').map(x => parseInt(x));
const row = arr[0];
const col = arr[1];

const markMatrix = (v, h) => {
  let anywhere = true;

  for (let rowi = v * 3; rowi < (v+1) * 3; rowi += 1) {
    for (let coli = h * 3; coli < (h+1) * 3; coli += 1) {
      if (board[rowi][coli] === '.') {
        anywhere = false;
        board[rowi][coli] = '!'
      }
    }
  }

  if (anywhere) {
    board = board.map(row => row.map(char => char === '.' ? '!' : char));
  }
}

const getMatrixPosition = (row, col) => {
  return [(row - 1) % 3, (col - 1) % 3];
}

const pos = getMatrixPosition(row, col);

markMatrix(pos[0], pos[1])

let result = [];
board.forEach((row, idx) => {
  let s = row.join('');
  s = s.slice(0, 3) + ' ' + s.slice(3, 6) + ' ' + s.slice(6, 9);
  if (idx !== 0 && idx % 3 === 0) {
    print('');
  }
  print(s);
})


"use strict";
var input = '';
var inputResolve;
var inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => {
    inputResolve();
});
(async () => {
    // var time = Date.now();
    await inputPromise;
    var inputs = input.split(/\r?\n/);
    var [n, h] = inputs[0].split(' ').map(v => +v);
    var f = [];
    for (let i = 0; i <= n; i++) {
        f[i] = [];
        for (let j = 0; j <= n; j++)
            f[i][j] = BigInt(0);
    }
    f[0][0] = BigInt(1);
    f[1][1] = BigInt(1);
    for (let i = 2; i <= n; i++) {
        for (let j = 1; j <= i; j++) {
            for (let z = 1; z <= i; z++) {
                for (let j2 = 0; j2 <= j - 1; j2++) {
                    if (j2 < j - 1)
                        f[i][j] = f[i][j] + f[z - 1][j2] * f[i - z][j - 1];
                    else
                        f[i][j] = f[i][j] + f[z - 1][j - 1] * f[i - z].slice(0, j).sum();
                }
            }
        }
    }
    console.log(f[n].slice(h).sum().toString());
})();
Object.defineProperty(Object.prototype, '$k', {
    value: function () { return Object.keys(this); }
});
Object.defineProperty(Object.prototype, '$v', {
    value: function () { return Object.values(this); }
});
Object.defineProperty(Object.prototype, '$kv', {
    value: function () { return Object.entries(this); }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), BigInt(0)); };
Array.prototype.uniq = function (fn) {
    var set = new Set();
    return this.filter(v => {
        var newValue = !set.has(fn ? fn(v) : v);
        set.add(fn ? fn(v) : v);
        return newValue;
    });
};
Array.prototype.toObj = function (fn) {
    return this.map(v => fn(v)).reduce((p, v) => {
        p[v[0]] = v[1];
        return p;
    }, {});
};


var arr = readline().split(" ");
var n = +arr[0];
var k = +arr[1];

var arr = readline().split(" ").map(function(v,i) {return {v:+v,i:i};});
arr.sort(function(a,b) {return a.v-b.v;});

var res = [];
for(var i = 0; i < n; i++) {
    k-=arr[i].v;
    if(k>=0)
        res.push(arr[i].i);
    else
        break;
}

print(i);
print(res.join(" "));


readline();
var string = readline();
var loopCount = Math.floor(string.length / 2);
var copyMax = 0;
for (var i = 1; i <= loopCount; i++) {
  if (string.slice(0, i) === string.slice(i, i * 2)) {
    copyMax = i;
  }
}
if (copyMax) {
  print(string.length - copyMax + 1);
} else {
  print(string.length);
}


var nums = readline().split(' ').map(function(x) { return parseInt(x); });
var cel = ((nums[0] -nums[2]) + (nums[1] - nums[2]) + nums[2])
print(nums[3] > cel ? nums[3] - cel : -1 )


var distribution = readline().split(' ').map(Number);
var both = distribution[2];

var result = distribution[3] - distribution[0] - distribution[1] + both;
if(result <= 0) {
    print(-1);
} else {
    print(result);
}


var ints = function() {
	return readline().split(' ').map(function(x) {
		return parseInt(x)
	})
}

var numbers = ints()
	k = numbers[0],
	a = numbers[1],
	b = numbers[2],
	invalid = (a < k && b < k) || (a < k && b % k > 0) || (b < k && a % k > 0)

print(invalid ? -1 : Math.floor(a / k) + Math.floor(b / k))


var n = +readline(),
input = readline().split(" "), min1 = +input[0], max1 = +input[1],
input = readline().split(" "), min2 = +input[0], max2 = +input[1],
input = readline().split(" "), min3 = +input[0], max3 = +input[1];
var i, j, k;

cycle:
for(i = max1; i >= min1; i--){

	if((n - i) < (min2 + min3)){
		continue;
	}

	j = (n-i > max2) ? max2 : n-i;
	for( ; j >= min2; j--){
		if((n - i - j) < min3){
			continue;
		}

		k = n - i - j;

		write(i + " " + j + " " + k);

		break cycle;
	}
}


(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var n = read.arr();

    var res = 10;
    for(var i = n.length - 1; i >0; i--) {
        res += 9 - n[i];
    }

    print(res);
}());


(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    }

    var n = read.arr();

    var res = n.length > 1 ? 10 : 9;
    for(var i = n.length - 1; i >0; i--) {

        res += 9 - n[i];
    }

    print(res);
}());


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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  const n = parseInt(arr)
  const sq = Math.sqrt(n)
  let k = 0
  for(let i = 1; i <= sq; i++) {
    if(n % i == 0) {
      if(n / i == i) k ++
      else k +=2
    }
  }
  console.log(k)

})


//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 N = nextInt();
	var max = 0;
	var maxIndex = {
		x : 0,
		y : 0
	}
	for(var i = 1; i < N; i++){
		var x = i;
		var y = N - i;
		if(x < y && max < (x / y) && gcd(x, y) == 1){
			max = x / y;
			maxIndex.x = x;
			maxIndex.y = y;
		}
	}
	myout(maxIndex.x + " " + maxIndex.y);
}
function gcd(m, n) {return n != 0 ? gcd(n, m % n) : m;}


//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 N = nextInt();
	myout("1 " + (N - 1));
}


function  main()
{
    var data = readline().split(' ');
    var k = data[0];
    var n = 4;
    var x = 0;
    var a = new Array (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);
    for ( var i = 0; i < n; i++)
    {
        data = readline().split(' ');
        var line = data[0]
        for ( var j = 0; j < line.length; j++)
        {
            if (line[j] == '.')
                continue;
            x = +(line[j]);
            a[x]++;
            if (a[x] >  2*k)
            {
                print('NO');
                return;
            }
        }
    }
    print('YES');
}
main()


var input = readline().split(' '),
    balls_arr_text = readline(),
    balls_arr = balls_arr_text.split('');

var balls = Number(input[0]),
    friends = Number(input[1]);

var friends_arr = [];

var result = true;

balls_arr.sort();

for(var i = 0; i<balls_arr.length; i++) {
    if(typeof friends_arr[(friends+i)%friends] === 'undefined') {
        friends_arr[(friends+i)%friends] = [];
    }

    if(friends_arr[(friends+i)%friends].indexOf(balls_arr[i]) !== -1) {
        result = false;
        break;
    } else {
        friends_arr[(friends+i)%friends].push(balls_arr[i]);
    }
}

print(result ? 'YES' : 'NO');


var input = readline().split(' '),
    balls_arr_text = readline(),
    balls_arr = balls_arr_text.split('');

var balls = Number(input[0]),
    friends = Number(input[1]);

function onlyUnique(value, index, self) {
    return self.indexOf(value) === index;
}

var colors = balls_arr.filter((v, i, a) => a.indexOf(v) === i);

var result = true;

for(var i=0; i<colors.length; i++) {
    if(balls_arr_text.split(colors[i]).length-1 !== friends) {
        result = false;
        break;
    }
}

print(result ? 'YES' : 'NO');


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

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

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

function main() {
	var numClasses = parseInt(readline());
	var classes = tokenizeIntegers(readline());
	var data = tokenizeIntegers(readline());
	var min = data[0], max = data[1];
	var low = 0, high = 0;
	for (var i = 0; i < numClasses; ++i) {
		high += classes[i];
	}
	for (var threshold = 0; threshold < numClasses; ++threshold) {
		if (low > max) {
			print(0);
			return;
		}
		if (low >= min && high >= min && high <= max) {
			print(threshold+1);
			return;
		}
		low += classes[threshold];
		high -= classes[threshold];
	}
	print(0);
}

main();


const readline = require('readline');

function trimZeros(num){

    if(!(typeof num == 'number'))
    num = parseInt(num);

    //make a string of the number
    num = num + "";

    //trim leading zeros
    num = parseInt(num);
    num = num + "";

    //trim the last zeros
    num = num.split("").reverse().join("");
    num = parseInt(num);

    return num;
}

function odd(num){
    return ( +num % 2 == 1);
}

function even(num){
    return (!odd(num));
}

function quasiPalindromic(num){

    num = trimZeros(num);
    num = num + "";

    let searchScope;
    if(odd(num)) searchScope = (num.length - 1) / 2;
    else         searchScope =  num.length / 2;

    for(let i = 0; i < searchScope; i++){
        if(!(num[i] == num[num.length-i-1]))
            return "NO";
    }

    return "YES"
}

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

rl.question('Enter a number to check if it\'s a quasiPalindromic:\n', (inputNumber) => {

    console.log(quasiPalindromic(inputNumber));

    rl.close();
});


var s = readline();

var a = s.replace(/0*$/g, '');
var b = a.replace(/[^A-Za-z0-9]/g, '').split('').reverse().join('');

print(a == b ? 'YES' : 'NO');


var input = readline().split(' ')

var n = Number(input[0])
var k = Number(input[1])

var chaos = 0

for (var i = 0; i < n - 1 && i < k; i++) {
    var add = 2 * n - 4 * i - 3
    chaos += add > 0 ? add : 0
}

print(chaos)


'use strict'

let lll = readline().split(' ').map(v => parseInt(v))
let a = lll[0]
let b = lll[1]

let min = String(a).split('').reduce((r, v) => Math.max(r, v), 0)
min = String(b).split('').reduce((r, v) => Math.max(r, v), min)
min++

let max = 0
for (let i = min; i < 14; i++) {
  let da = to10(a, i)
  let db = to10(b, i)
  let ds = da + db
  let bs = from10(ds, i)
  max = Math.max(max, String(bs).length)
}

print(max)

function to10 (x, b) {
  return String(x).split('').reduce((r, v, i) => r + v * Math.pow(b, i), 0)
}

function from10 (x, b) {
  let res = ''
  let n = 0
  while (Math.pow(b, ++n) <= x) {}
  while (n--) {
    let a = x / Math.pow(b, n) | 0
    res += a
    x -= a * Math.pow(b, n)
  }
  return res
}