n = +readline();
if (n < 10){
    print(n);
} else {
    ar = (n+'').split('').map(Number);
    acc = 9;
    digit = 1;
    while (acc < n){
        acc *= 10;
        acc += 9;
        digit++;
    }
    if (acc === n){
        print(digit*9);
    } else {
        acc = ar[0]-1;
        digit--;
        while (digit-->0){
            acc *= 10;
            acc +=9;
        }
        sum = 0;
        ((n - acc)+'').split('').map(Number).forEach(x=>sum+=x);
        (acc+'').split('').map(Number).forEach(x=>sum+=x);
        print(sum);
    }
}


const readline = require('readline');

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

rl.on('line', (input) => {
    //console.log(input);
    //ar = input.split(' ');

    let a = Math.floor(input / 2);
    let b = input - a;
    let ar = a.toString().split("")

    let total = 0;
    let ten = 0;

    for (let i = ar.length - 1; i>0; i--) {
        let fix = 9 - parseInt(ar[i], 10);
        ar[i] = 9;
        b -= fix * (Math.pow(10, ten));
        ten++;
    }
    let br = b.toString().split("")

    ar.forEach(elem => {
        total += parseInt(elem, 10);
    });
    br.forEach(elem => {
        total += parseInt(elem, 10);
    });

    console.log(total);

    rl.close();
});


var readline = require('readline');
var rl = readline.createInterface(process.stdin, process.stdout);
rl.question('', (arg)=>{
	let sum = 0;
	if(arg>10){
		let b = 0;
		let a = arg;
		while(a>10){
			b = b*10+9;
			a=a/10;
		}
		a = arg - b;
	while(a!=0|| b!=0){
			sum = sum + a%10 + b%10;
			a= Math.floor(a/10);
			b=Math.floor(b/10);
		}

		}else{
			sum = arg;
		}
	console.log(sum);
	rl.close();
});


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

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

  arr.push(d.split(' ').map(Number));

  c++;
});

rl.on('close', () => {
  let ans = 0;
  let n = arr.length;

  for (let i = 0; i < arr.length; i++) {
    for (let j = 0; j < arr.length; j++) {
      if (i == j || i == Math.floor(n / 2) || j == Math.floor(n / 2) || i + j == n-1) {
        ans += arr[i][j];
      }
    }
  }

  console.log(ans);
});


function main() {
    var n = readline();

    var len = n.length;

    if ((n[len - 1] - '0') & 1) {
        print('1');
    } else {
        print('2');
    }
}

main();


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

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

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

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

  let ans = 'Tie';
  let score1 = 0;
  let score2 = 0;
  let spentTime = 0;

  for (let i = 0; i < n; i++) {
    spentTime += t[i];
    score1 += Math.max(0, p[i] - c * spentTime);
  }

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

  if (score1 > score2) {
    ans = 'Limak';
  }

  if (score2 > score1) {
    ans = 'Radewoosh';
  }

  console.log(ans);

  count++;
});


var l1 = readline().split(" "),
	scores = readline().split(" "),
	times = readline().split(" "),

	count = +l1[0], // n
	speed = +l1[1], // c
	tasks = scores.map(function (item, index) {
		return {
			score: +item,
			time: +times[index]
		};
	}),

	lim = 0, // результат
	rad = 0, // результат

	qLim,
	qRad,

	cLim,
	cRad,

	tLim = 0, // время на данный момент
	tRad = 0; // время на данный момент

function getScoreTaskByTime (score, time) {
	return Math.max(0, score - speed * time);
};

for (var i = 0, l = tasks.length - 1; i <= l; ++i) {
	qLim = tasks[i];
	lim += getScoreTaskByTime(qLim.score, tLim += qLim.time);

	qRad = tasks[l - i];
	rad += getScoreTaskByTime(qRad.score, tRad += qRad.time);
}

if (lim == rad) {
	print("Tie");
} else {
	print(lim < rad ? "Radewoosh" : "Limak");

}


/**
 * Created by Utilisateur on 28/03/2016.
 */

var l1 = readline().split(' '),
    n = parseInt(l1[0]),
    c = parseInt(l1[1]),
    p = readline().split(' '),
    t = readline().split(' '),
    L = 0,
    R = 0

for (i = 0 ; i < n ; i++) {
  p[i] = parseInt(p[i])
  t[i] = parseInt(t[i])
}

for (i = 0, j = n-1, xL = 0, xR = 0 ; i < n ; i++, j--) {
  xL += t[i]
  L += Math.max(0, p[i] - c * xL)
  xR += t[j]
  R += Math.max(0, p[j] - c * xR)
}

print(L==R ? "Tie" : L>R ? "Limak" : "Radewoosh")


let input = [];

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

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

RL.on('close', () => {
    let {0:n, 1:c} = {...input[0].split(' ')};
    n = parseInt(n); c = parseInt(c);
    let points = []; input[1].split(' ').forEach( i => points.push(parseInt(i)) );
    let times = []; input[2].split(' ').forEach( i => times.push(parseInt(i)) );
    let secondTimes = []; times.forEach(i => secondTimes.push(parseInt(i)));

    let firstPlayer = 0; let secondPlayer = 0;
    let j = n-1;

    for(let i = 0; i < n; i++) {
        firstPlayer += max(0, points[i] - c*times[i]);
        secondPlayer +=  max(0, points[j] - c*secondTimes[j]);

        if(i + 1 != n) {
            times[i+1] += times[i];
        }
        if(j - 1 >= 0) {
            secondTimes[j-1] += secondTimes[j];
        }
        j--;
        //console.log(`fp = ${firstPlayer}; sp = ${secondPlayer}`);
    }

    if(firstPlayer > secondPlayer) {
        console.log('Limak');
    } else if(secondPlayer > firstPlayer) {
        console.log('Radewoosh');
    } else
        console.log('Tie')
});

function max(a, b) {
    return (a > b) ? a : b;
}


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

var p = readline().split(" ").map(parseIntFunc);
var t = readline().split(" ").map(parseIntFunc);

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

var limakScore = countFunc();
p.reverse();
t.reverse();
var radewooshScore = countFunc();
if (limakScore > radewooshScore){
    print('Limak');
} else if (limakScore < radewooshScore) {
    print('Radewoosh');
} else {
    print('Tie');
}


var l1 = readline().split(" "),
	scores = readline().split(" "),
	times = readline().split(" "),

	count = +l1[0], // n
	speed = +l1[1], // c
	tasks = scores.map(function (item, index) {
		return {
			score: +item,
			time: +times[index]
		};
	}),

	lim = 0, // результат
	rad = 0, // результат

	qLim,
	qRad,

	cLim,
	cRad,

	tLim = 0, // время на данный момент
	tRad = 0; // время на данный момент

function getScoreTaskByTime (score, time) {
	return Math.max(0, score - speed * time);
};

for (var i = 0, l = tasks.length - 1; i <= l; ++i) {
	qLim = tasks[i];
	lim += getScoreTaskByTime(qLim.score, tLim += qLim.time);

	qRad = tasks[l - i];
	rad += getScoreTaskByTime(qRad.score, tRad += qRad.time);
}
print(lim); print(rad);
if (lim == rad) {
	print("Tie");
} else {
	print(lim < rad ? "Radewoosh" : "Limak");

}


'use strict'

let L = readline()
L = {x: ltd(L[0]), y: +L[1]}
let K = readline()
K = {x: ltd(K[0]), y: +K[1]}

let ps = 0
let d = []

for (let x = 1; x <= 8; x++) {
  for (let y = 1; y <= 8; y++) {
    if (!d[x]) d[x] = []
    d[x][y] = is(x, y) ? 1 : 0
    if (is(x, y)) {
      ps++
    }
  }
}
print(ps - 2)

function is (x, y) {
  if (x == K.x && y == K.y || x == L.x && y == L.y) return false
  if (x == L.x || y == L.y) return false
  if (x == K.x + 1 && y == K.y + 2
   || x == K.x + 2 && y == K.y - 1
   || x == K.x + 2 && y == K.y + 1
   || x == K.x + 1 && y == K.y - 2
   || x == K.x - 1 && y == K.y - 2
   || x == K.x - 2 && y == K.y - 1
   || x == K.x - 2 && y == K.y + 1
   || x == K.x - 1 && y == K.y + 2
  ) return false
  return true
}

function ltd (l) {
  switch (l) {
    case 'a': return 1
    case 'b': return 2
    case 'c': return 3
    case 'd': return 4
    case 'e': return 5
    case 'f': return 6
    case 'g': return 7
    case 'h': return 8
  }
}


//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 list = next();
	var output = "";
	var mae = "";
	var ng = new Set(["a","e","i","o","u","y"]);
	for(var i = 0; i < N; i++){
		if(!ng.has(mae) || !ng.has(list[i])){
			mae = list[i];
			output += list[i];
		}
	}
	myout(output);
}


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

let c = 0;

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

  let ans = str[0];
  const vowels = {
    a: true,
    e: true,
    i: true,
    o: true,
    u: true,
    y: true,
  };

  for (let i = 1; i < str.length; i++) {
    if (vowels[str[i]] && vowels[ans[ans.length - 1]]) {
      continue;
    } else {
      ans += str[i];
    }
  }

  console.log(ans);

  c++;
});


var lettersToCheck = parseInt(readline());
var word = readline();
var vowels = ['a', 'e', 'i', 'o', 'u', 'y'];
for (var index = 0; index < word.length;) {
    if (vowels.includes(word[index]) && vowels.includes(word[index + 1])) {
        word = word.slice(0, index + 1) + word.slice(index + 2, word.length);
    } else {
        index++;
    }
}
print(word)


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 count = 0, max = parseInt(readline());
	function go(x, a, b) {
		if (x > max) {
			return;
		}
		++count;
		go(10*x + a, a, b);
		if (b === undefined) {
			for (var b = 0; b < 10; ++b) {
				if (b != a) {
					go(10*x + b, a, b);
				}
			}
		} else {
			go(10*x + b, a, b);
		}
	}
	for (var x = 1; x < 10; ++x) {
		go(x, x);
	}
	print(count);
}

main();


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

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

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

  const n = readInt(arr)
  const sqrt = Math.ceil(Math.sqrt(n))
  // wr(n, sqrt)

  let a, b
  for(let i = sqrt; i >=1; i--) {
    a = i
    if(n % a != 0) continue
    b = n / a
    if(a == b) continue
    else if(gcd(a, b) != 1) continue
    else break
  }
  wr(a, b)
})

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

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

function readInt(a, i) {
  if(i === undefined) return parseInt(a.shift())
  else return parseInt(a[i])
}

function readInts(a, i) {
  if(i === undefined) return arr.shift().split(' ').map(a => parseInt(a))
  else return arr[i].split(' ').map(a => parseInt(a))
}

function gcd(a, b) {
  if(b == 0) return a
  else return gcd(b, a % b)
}


main();

function main(){
   var x = parseInt(readline());

    var guess=Math.round(Math.sqrt(x));
    //print(guess);

    for(var i=guess;i>=1;i--){
    if(x%i===0){
        //print("no remainder");
        //print(lcm(i,x/i));
        if(x==lcm(i,x/i)){print(i+" "+x/i);return;}
    }//whole number divisor
}

}//main, added for return

function lcm(a,b){
    return a*b/gcd(a,b);
}

function gcd(a,b){
    while(a>0){
        var temp=a;
        a=b%a;
        b=temp;
    }
    return b;
}


'use strict';

var readline = require('readline');

function gcd(x, y) {
  x = Math.abs(x);
  y = Math.abs(y);

  while (y) {
    var t = y;
    y = x % y;
    x = t;
  }

  return x;
}

function lcm(x, y) {
  if (typeof x !== 'number' || typeof y !== 'number') return false;
  return !x || !y ? 0 : Math.abs(x * y / gcd(x, y));
}

function* unsortedFactors(n, emitPairs = true) {
  if (n < 1) {
    return;
  }

  yield n;

  if (n === 1) {
    return;
  }

  const end = Math.sqrt(n);

  for (var i = 1; i <= end; i++) {
    if (n % i === 0) {
      yield i;

      if (i !== Math.sqrt(n) && i !== 1) {
        yield n / i;
      }
    }
  }
}

const stdin = readline.createInterface(process.stdin).once('line', input => {
  stdin.close();
  const X = +input;
  let min = null;
  let answer = '';

  for (const factor of unsortedFactors(X, false)) {
    const partner = X / factor;
    const max = Math.max(factor, partner);

    if ((min === null || max < min) && lcm(factor, partner) === X) {
      min = max;
      answer = `${factor} ${partner}`;
    }
  }

  console.log(answer);
});


(function main() {
    var n = readline().split(':');
    var h = parseInt(n[0]);
    var m = parseInt(n[1]);
    var dh = ~~(h / 10);
    var oh = h % 10;
    var reh = 10 * oh + dh;
    if (m >= reh) {
        ++h;
        if (h > 23) h = 0;
        dh = ~~(h / 10);
        oh = h % 10;
    }
    if (oh >= 6) {
        oh = 0;
        ++dh;
    }
    print('' + dh + oh + ':' + oh + dh);
})();


(function main() {
    var n = parseInt(readline());
    var s = 0;
    var i = 0;
    var re = new RegExp('[' + n + ']');
    for ( ; i * i < n ; ++i)
    if (n % i == 0) {
        if (re.test(i)) ++s;
        if (re.test(n / i)) ++s;
    }
    if (i * i == n && re.test(i)) ++s;
    print(s);
})();


var t = readline().split(' '),
    n = +t[0],
    k = +t[1]

if (k === 0 || k === n) print('0 0')
else if (k <= Math.floor(n/3)) print([1, 2*k].join(' '))
else print([1, n-k].join(' '))


var primes = [];

function decompose(n) {
  var res = [];
  var p = 2;
  while (true) {
    if (n >= p * p) {
      if (n % p === 0) {
        res.push(p);
        n /= p;
      } else {
        p++;
      }
    } else {
      res.push(n);
      break;
    }
  }
  return res;
}

function resolve(n) {
  var d1 = decompose(n);
  var px1 = (n / d1[d1.length - 1] - 1) * d1[d1.length - 1] + 1;
  var min = Infinity;
  var d2;
  var px2;
  for (var i = px1; i < n; i++) {
    d2 = decompose(i);
    px2 = (i / d2[d2.length - 1] - 1) * d2[d2.length - 1] + 1;
    if (px2 < min && px2 >= 3) {
      min = px2;
    }
  }
  if (min === Infinity) {
    return px1;
  }
  return min;
}

const k = parseInt(readline(), 10);

const result = resolve(k);

print(result + '\n');


var primes = [];

function findPrimes(n) {
  for (var i = 2; i < n; i++) {
    var isPrime = true;
    for (var p of primes) {
      if (i % p === 0) {
        isPrime = false;
      }
    }
    if (isPrime) {
      primes.push(i);
    }
  }
}

function decompose(n) {
  var res = [];
  var i = 0;
  while (primes[i] <= n) {
    while (true) {
      if (n % primes[i] === 0) {
        res.push(primes[i]);
        n /= primes[i];
      } else {
        break;
      }
    }
    i++;
  }
  return res;
}

function resolve(n) {
  findPrimes(n);
  var d1 = decompose(n);
  var px1 = (n / d1[d1.length - 1] - 1) * d1[d1.length - 1] + 1;
  var min = Infinity;
  var d2;
  var px2;
  for (var i = px1; i < n; i++) {
    d2 = decompose(i);
    px2 = (i / d2[d2.length - 1] - 1) * d2[d2.length - 1] + 1;
    console.log(i, px2);
    if (px2 < min && px2 >= 3) {
      min = px2;
    }
  }
  if (min === Infinity) {
    return px1;
  }
  return min;
}

const k = parseInt(readline(), 10);

const result = resolve(k);

print(result + '\n');


var primes = [];

function findPrimes(n) {
  for (var i = 2; i < n; i++) {
    var isPrime = true;
    for (var p of primes) {
      if (i % p === 0) {
        isPrime = false;
      }
    }
    if (isPrime) {
      primes.push(i);
    }
  }
}

function decompose(n) {
  var res = [];
  var i = 0;
  while (primes[i] <= n) {
    while (true) {
      if (n % primes[i] === 0) {
        res.push(primes[i]);
        n /= primes[i];
      } else {
        break;
      }
    }
    i++;
  }
  return res;
}

function resolve(n) {
  findPrimes(n);
  var d1 = decompose(n);
  var px1 = (n / d1[d1.length - 1] - 1) * d1[d1.length - 1] + 1;
  var min = Infinity;
  var d2;
  var px2;
  for (var i = px1; i < n; i++) {
    d2 = decompose(i);
    px2 = (i / d2[d2.length - 1] - 1) * d2[d2.length - 1] + 1;
    console.log(i, px2);
    if (px2 < min && px2 >= 3) {
      min = px2;
    }
  }
  if (min === Infinity) {
    return px1;
  }
  return min;
}

console.log(resolve(8192));

/*const k = parseInt(readline(), 10);

const result = resolve(k);

print(result + '\n');*/


var primes = [];

function findPrimes(n) {
  for (var i = 2; i < n; i++) {
    var isPrime = true;
    for (var p of primes) {
      if (i % p === 0) {
        isPrime = false;
      }
    }
    if (isPrime) {
      primes.push(i);
    }
  }
}

function decompose(n) {
  var res = [];
  var i = 0;
  while (primes[i] <= n) {
    while (true) {
      if (n % primes[i] === 0) {
        res.push(primes[i]);
        n /= primes[i];
      } else {
        break;
      }
    }
    i++;
  }
  return res;
}

function resolve(n) {
  findPrimes(n);
  var d1 = decompose(n);
  var px1 = (n / d1[d1.length - 1] - 1) * d1[d1.length - 1] + 1;
  var min = Infinity;
  var d2;
  var px2;
  for (var i = px1; i < n; i++) {
    d2 = decompose(i);
    px2 = (i / d2[d2.length - 1] - 1) * d2[d2.length - 1] + 1;
    if (px2 < min && px2 >= 3) {
      min = px2;
    }
  }
  if (min === Infinity) {
    return px1;
  }
  return min;
}

const k = parseInt(readline(), 10);

const result = resolve(k);

print(result + '\n');


var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

const MOD = 998244353;

function countDivisors (n) {
 let cnt = 0; let i;
 for (i = 1; i*i < n; i++)
   if (n % i == 0)
     cnt += 2;
  cnt += i*i == n;
  return cnt;
}

function main () {
	const n = rn();

	let ans = 0;
	let psm = 0;
	for (let i = 1; i <= n ; i++) {
		ans = countDivisors(i) + psm;
		psm = (psm + ans) % MOD;
	}

	console.log(ans);
}


var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});
var lines = [];
rl.on('line', function(input) {
    lines.push(input);
});
rl.on('close', function() {
    var l = 0;
    console.log(solve(+lines[l++]))
});

function solve(n) {
    const dp = Array(n + 1).fill(0)
    for (let i = 1; i < n; i++) {
        for (let j = i + i; j <= n; j += i) {
            dp[j]++
        }
    }
    let sum = 1
    for (let i = 1; i <= n; i++) {
        dp[i] = add(dp[i], sum)
        sum = add(sum, dp[i])
    }
    return dp[n]
}

function add(a, b) {
    return (a + b) % 998244353
}


'use strict'

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

let test = (g, b) => {
  return (g - b <= 1) && (b - g <= 3)
}

print((test(G[0], B[1]) || test(G[1], B[0]) ? 'YES' : 'NO'))


'use strict'

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

let test = (g, b) => {
  return (g - b <= 1) && (b - g * 2 - 2 <= 0)
}

print((test(G[0], B[1]) || test(G[1], B[0]) ? 'YES' : 'NO'))


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

function main() {
    let brain = readLine();
    while (brain.includes('>')) {
        brain = brain.replace('>', '1000');
    }
    while (brain.includes('<')) {
        brain = brain.replace('<', '1001');
    }
    while (brain.includes('+')) {
        brain = brain.replace('+', '1010');
    }
    while (brain.includes('-')) {
        brain = brain.replace('-', '1011');
    }
    while (brain.includes('.')) {
        brain = brain.replace('.', '1100');
    }
    while (brain.includes(',')) {
        brain = brain.replace(',', '1101');
    }
    while (brain.includes('[')) {
        brain = brain.replace('[', '1110');
    }
    while (brain.includes(']')) {
        brain = brain.replace(']', '1111');
    }
    let ans = convertBase(brain, 2, 10);

    let final = 0;
    let length = ans.length;
    for (let i = 0; i < length; i++) {
        final = (final * 10 + (ans[i] - 0)) % 1000003;
    }
    console.log(final);
}

function parseBigInt(bigint, base) {
    //convert bigint string to array of digit values
    for (var values = [], i = 0; i < bigint.length; i++) {
        values[i] = parseInt(bigint.charAt(i), base);
    }
    return values;
}

function formatBigInt(values, base) {
    //convert array of digit values to bigint string
    for (var bigint = '', i = 0; i < values.length; i++) {
        bigint += values[i].toString(base);
    }
    return bigint;
}

function convertBase(bigint, inputBase, outputBase) {
    //takes a bigint string and converts to different base
    var inputValues = parseBigInt(bigint, inputBase),
        outputValues = [], //output array, little-endian/lsd order
        remainder,
        len = inputValues.length,
        pos = 0,
        i;
    while (pos < len) {
        //while digits left in input array
        remainder = 0; //set remainder to 0
        for (i = pos; i < len; i++) {
            //long integer division of input values divided by output base
            //remainder is added to output array
            remainder = inputValues[i] + remainder * inputBase;
            inputValues[i] = Math.floor(remainder / outputBase);
            remainder -= inputValues[i] * outputBase;
            if (inputValues[i] == 0 && i == pos) {
                pos++;
            }
        }
        outputValues.push(remainder);
    }
    outputValues.reverse(); //transform to big-endian/msd order
    return formatBigInt(outputValues, outputBase);
}


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

function main() {
    let brain = readLine();
    while (brain.includes('>')) {
        brain = brain.replace('>', '1000');
    }
    while (brain.includes('<')) {
        brain = brain.replace('<', '1001');
    }
    while (brain.includes('+')) {
        brain = brain.replace('+', '1010');
    }
    while (brain.includes('-')) {
        brain = brain.replace('-', '1011');
    }
    while (brain.includes('.')) {
        brain = brain.replace('.', '1100');
    }
    while (brain.includes(',')) {
        brain = brain.replace(',', '1101');
    }
    while (brain.includes('[')) {
        brain = brain.replace('[', '1110');
    }
    while (brain.includes(']')) {
        brain = brain.replace(']', '1111');
    }
    // console.log(brain);
    let ans = convertBase(brain, 2, 10);
    // let ansString = ans.toString();
    // let final = ans % 1000003;
    let final = 0;
    let length = ans.toString().length;
    for (let i = 0; i < length; i++) {
        final = (final * 10 + (ansString[i] - 0)) % 1000003;
    }
    console.log(final);
}
function parseBigInt(bigint, base) {
    //convert bigint string to array of digit values
    for (var values = [], i = 0; i < bigint.length; i++) {
        values[i] = parseInt(bigint.charAt(i), base);
    }
    return values;
}

function formatBigInt(values, base) {
    //convert array of digit values to bigint string
    for (var bigint = '', i = 0; i < values.length; i++) {
        bigint += values[i].toString(base);
    }
    return bigint;
}

function convertBase(bigint, inputBase, outputBase) {
    //takes a bigint string and converts to different base
    var inputValues = parseBigInt(bigint, inputBase),
        outputValues = [], //output array, little-endian/lsd order
        remainder,
        len = inputValues.length,
        pos = 0,
        i;
    while (pos < len) {
        //while digits left in input array
        remainder = 0; //set remainder to 0
        for (i = pos; i < len; i++) {
            //long integer division of input values divided by output base
            //remainder is added to output array
            remainder = inputValues[i] + remainder * inputBase;
            inputValues[i] = Math.floor(remainder / outputBase);
            remainder -= inputValues[i] * outputBase;
            if (inputValues[i] == 0 && i == pos) {
                pos++;
            }
        }
        outputValues.push(remainder);
    }
    outputValues.reverse(); //transform to big-endian/msd order
    return formatBigInt(outputValues, outputBase);
}


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

function main() {
    let brain = readLine();
    while (brain.includes('>')) {
        brain = brain.replace('>', '1000');
    }
    while (brain.includes('<')) {
        brain = brain.replace('<', '1001');
    }
    while (brain.includes('+')) {
        brain = brain.replace('+', '1010');
    }
    while (brain.includes('-')) {
        brain = brain.replace('-', '1011');
    }
    while (brain.includes('.')) {
        brain = brain.replace('.', '1100');
    }
    while (brain.includes(',')) {
        brain = brain.replace(',', '1101');
    }
    while (brain.includes('[')) {
        brain = brain.replace('[', '1110');
    }
    while (brain.includes(']')) {
        brain = brain.replace(']', '1111');
    }
    // console.log(brain);
    console.log(parseInt(brain, 2) % 1000003);
}


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

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

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

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


function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

	this.calc = function() {
		var i , fl , idx , j , crr , cnt , k ;
		while( true ) {
			fl = 0 ;
			for( i = 0 ; i < this.cn ; i++ ) {
				cnt = 1 ;
				for( j = i + 1 ; j < this.cn ; j++ ) {
					if( this.brr[ i ] != this.brr[ j ] ) {
						break ;
					}
					cnt++ ;
					k = j ;
				}
				if( cnt >= 3 ) {
					idx = 0 ;
					crr = new Array() ;
					for( j = 0 ; j < i ; j++ ) {
						crr.push( this.brr[ j ] ) ;
						idx++ ;
					}
					for( j = k + 1 ; j < this.cn ; j++ ) {
						crr.push( this.brr[ j ] ) ;
						idx++ ;
					}
					this.brr = crr ;
					this.cn = idx ;
					fl = 1 ;
					break ;
				}
			}
			if( fl == 0 ) {
				break ;
			}
		}
		return this.n - this.cn ;
	} ;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp ;
        res = 0 ;
        //at the start
        this.cn = 0 ;
        this.brr[ this.cn++ ] = this.x ;
        for( i = 0 ; i < this.n ; i++ ) {
        	this.brr[ this.cn++ ] = this.arr[ i ] ;
        }
        res = Math.max( res , this.calc() ) ;
        //at the end
        this.cn = 0 ;
        for( i = 0 ; i < this.n ; i++ ) {
        	this.brr[ this.cn++ ] = this.arr[ i ] ;
        }
        this.brr[ this.cn++ ] = this.x ;
        res = Math.max( res , this.calc() ) ;
        //anywhere in the middle
        for( j = 0 ; j < this.n - 1 ; j++ ) {
        	this.cn = 0 ;
	        for( i = 0 ; i <= j ; i++ ) {
	        	this.brr[ this.cn++ ] = this.arr[ i ] ;
	        }
	        this.brr[ this.cn++ ] = this.x ;
	        for( i = j + 1 ; i < this.n ; i++ ) {
	        	this.brr[ this.cn++ ] = this.arr[ i ] ;
	        }
        	res = Math.max( res , this.calc() ) ;
        	//print( j , res , this.cn ) ;
	    }
        print( res );
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.n = irObj.nextInt();
            this.k = irObj.nextInt();
            this.x = irObj.nextInt();
            for( i = 0 ; i < this.n ; i++ ) {
                this.arr[ i ] = irObj.nextInt();
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();


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()),
		ballNum = data[0], colorNum = data[1], ball = data[2],
		balls = tokenizeIntegers(readline()),
		maxDestroyed = 0;
	for (var pos = 1; pos < ballNum; ++pos) {
		var countDestroyed = -1,
			destroy = [];
		for (var i = 0; i < ballNum; ++i) {
			if (i == pos) {
				destroy.push(ball);
			}
			destroy.push(balls[i]);
		}
		while (destroy.length != 0) {
			var color = destroy[0], count = 1;
			for (var i = 1; i < destroy.length; ++i) {
				if (destroy[i] == color) {
					++count;
					if (count == 3) {
						var begin = i-2, end = i;
						while (end+1 < destroy.length && destroy[end+1]==color){
							++end;
						}
						countDestroyed += end-begin+1;
						var newDestroy = [];
						for (var j = 0; j < destroy.length; ++j) {
							if (j < begin || j > end) {
								newDestroy.push(destroy[j]);
							}
						}
						destroy = newDestroy;
						break;
					}
				} else {
					color = destroy[i];
					count = 1;
				}
			}
			if (count < 3) {
				break;
			}
		}
		maxDestroyed = Math.max(maxDestroyed, countDestroyed);
	}
	print(maxDestroyed);
}

main();


function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

	this.calc = function() {
		var i , fl , idx , j , crr ;
		while( true ) {
			fl = 0 ;
			for( i = 0 ; i <= this.cn - 3 ; i++ ) {
				if( this.brr[ i ] == this.brr[ i + 1 ] && this.brr[ i + 1 ] == this.brr[ i + 2 ] ) {
					fl = 1 ;
					idx = 0 ;
					crr = new Array() ;
					for( j = 0 ; j < this.cn ; j++ ) {
						if( j != i && j != i + 1 && j != i + 2 ) {
							crr.push( this.brr[ j ] ) ;
							idx++ ;
						}
					}
					this.brr = crr ;
					this.cn = idx ;
					break ;
				}
			}
			if( fl == 0 ) {
				break ;
			}
		}
		return this.n + 1 - this.cn ;
	} ;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp ;
        res = 0 ;
        //at the start
        this.cn = 0 ;
        this.brr[ this.cn++ ] = this.x ;
        for( i = 0 ; i < this.n ; i++ ) {
        	this.brr[ this.cn++ ] = this.arr[ i ] ;
        }
        res = Math.max( res , this.calc() ) ;
        //at the end
        this.cn = 0 ;
        for( i = 0 ; i < this.n ; i++ ) {
        	this.brr[ this.cn++ ] = this.arr[ i ] ;
        }
        this.brr[ this.cn++ ] = this.x ;
        res = Math.max( res , this.calc() ) ;
        //anywhere in the middle
        for( j = 0 ; j < this.n - 1 ; j++ ) {
        	this.cn = 0 ;
	        for( i = 0 ; i <= j ; i++ ) {
	        	this.brr[ this.cn++ ] = this.arr[ i ] ;
	        }
	        this.brr[ this.cn++ ] = this.x ;
	        for( i = j + 1 ; i < this.n ; i++ ) {
	        	this.brr[ this.cn++ ] = this.arr[ i ] ;
	        }
        	res = Math.max( res , this.calc() ) ;
	    }
        print( res );
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.n = irObj.nextInt();
            this.k = irObj.nextInt();
            this.x = irObj.nextInt();
            for( i = 0 ; i < this.n ; i++ ) {
                this.arr[ i ] = irObj.nextInt();
            }
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adj_list.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adj_list = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adj_list.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( -1 );
                this.done[ i ].push( 0 );
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();


function ProblemSolver() {
    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;
    this.CLEAR_ARRAY_PER_CASE = false;

	this.dp = function( i , rem , fl ) {
		var ret , res , r1 , re , a ;
		if( i >= this.n ) {
			if( rem == 0 && fl == 1 ) {
				return 1 ;
			}
			return 0 ;
		}
		re = this.done[ i ][ rem ][ fl ] ;
		ret = this.memo[ i ][ rem ][ fl ] ;
		if( re == this.cc ) {
			return ret ;
		}
		this.done[ i ][ rem ][ fl ] = this.cc ;
		res = 0 ;
		r1 = this.dp( i + 1 , rem , fl ) ;
		res |= r1 ;
		a = this.s.charCodeAt( i ) - '0'.charCodeAt( 0 ) ;
		r1 = this.dp( i + 1 , ( rem * 10 + a ) % 8 , 1 ) ;
		res |= r1 ;
		this.memo[ i ][ rem ][ fl ] = res ;
		return res ;
	} ;

	this.dpPrint = function( i , rem , fl ) {
		var r1 , a ;
		if( i >= this.n ) {
			return '' ;
		}
		r1 = this.dp( i + 1 , rem , fl ) ;
		if( r1 == 1 ) {
			return this.dpPrint( i + 1 , rem , fl ) ;
		}
		a = this.s.charCodeAt( i ) - '0'.charCodeAt( 0 ) ;
		r1 = this.dp( i + 1 , ( rem * 10 + a ) % 8 , 1 ) ;
		if( r1 == 1 ) {
			return this.s.charAt( i ) + this.dpPrint( i + 1 , ( rem * 10 + a ) % 8 , 1 ) ;
		}
	} ;

    this.solveCase = function() {
        var res , i , j , fl , cn , temp , len , numberString , resNumber ;
        res = 0 ;
        this.n = this.s.length ;
        res = this.dp( 0 , 0 , 0 ) ;
        if( res == 0 ) {
        	print( 'NO' );
        }
        else {
        	print( 'YES' );
        	numberString = this.dpPrint( 0 , 0 , 0 ) ;
        	len = numberString.length ;
        	resNumber = '' ;
        	fl = 0 ;
        	for( i = 0 ; i < len ; i++ ) {
        		if( numberString.charCodeAt( i ) > '0'.charCodeAt( 0 ) ) {
        			fl = 1 ;
        		}
        		if( fl == 1 ) {
        			resNumber += numberString.charAt( i ) ;
        		}
        	}
        	if( resNumber == '' ) {
        		resNumber = '0' ;
        	}
        	print( resNumber );
        }
    };

    this.init = function() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.getInput = function( irObj ) {
        var hasMoreInput , i;
        hasMoreInput = true;
        try {
            this.s = irObj.nextString();
        }
        catch( ex ) {
            hasMoreInput = false;
        }
        return hasMoreInput;
    };

    this.clearArraysPerCase = function() {
        var i;
        this.arr = new Array();
        this.adjList = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.arr.push( 0 );
            this.adjList.push( new Array() );
        }
    };

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        if( this.CLEAR_ARRAY_PER_CASE == true ) {
            this.clearArraysPerCase() ;
        }
    };

    this.declareAndFillArrays = function() {
        var i , j;
        this.srr = new Array();
        this.vis = new Array();
        this.arr = new Array();
        this.brr = new Array();
        this.memo = new Array();
        this.done = new Array();
        this.adjList = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            this.srr.push( "" );
            this.vis.push( 0 );
            this.arr.push( 0 );
            this.brr.push( 0 );
            this.adjList.push( new Array() );
        }
        for( i = 0 ; i < this.lim2 ; i++ ) {
            this.memo.push( new Array() );
            this.done.push( new Array() );
            for( j = 0 ; j < this.lim2 ; j++ ) {
                this.memo[ i ].push( new Array() );
                this.done[ i ].push( new Array() );
                for( k = 0 ; k < 2 ; k++ ) {
                	this.memo[ i ][ j ].push( -1 );
                	this.done[ i ][ j ].push( 0 );
                }
            }
        }
    };

    this.init();
}

function InputReader() {
    var self = this ;
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;
    this.callBackFunction = null ;
    this.parentContext = null ;

    this.readAllLines = function() {
        var singleLine;
        while( true ) {
            try {
                singleLine = readline();
                if( singleLine == null ) {
                    break;
                }
            }
            catch( ex ) {
                break;
            }
            this.allLines.push( singleLine );
        }
    };

    this.readAllLinesFromRhino = function() {
        var brObj , line ;
        importPackage( java.io ) ;
        importPackage( java.lang ) ;
        brObj = new BufferedReader( new InputStreamReader( System[ 'in' ] ) ) ;
        this.allLines = [] ;
        while( true ) {
            line = brObj.readLine() ;
            if( line == null ) {
                break;
            }
            this.allLines.push( line ) ;
        }
    };

    this.readSingleLinesFromNodeJsJudgeServer = function( chunk ) {
        self.chunkData += chunk ;
    };

    this.readEndFromNodeJsJudgeServer = function() {
        self.parseRawData( self.chunkData ) ;
        self.parentContext.runCases() ;
    };

    this.readAllLinesFromNodeJsJudgeServer = function( parentContext ) {
        this.parentContext = parentContext ;
        process.stdin.resume() ;
        process.stdin.setEncoding( 'utf8' ) ;
        this.chunkData = '' ;
        process.stdin.on( 'data' , this.readSingleLinesFromNodeJsJudgeServer ) ;
        process.stdin.on( 'end' , this.readEndFromNodeJsJudgeServer ) ;
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        this.allLines = [] ;
        for( i = 0 ; i < len ; i++ ) {
            if( data[ i ] == '\r' ) {
            }
            else if( data[ i ] == '\n' ) {
                this.allLines.push( currentString );
                currentString = "";
            }
            else {
                currentString += data[ i ];
            }
        }
        if( currentString != "" ) {
            this.allLines.push( currentString );
        }
    };

    this.readAllLinesFromFile = function( inputFileName ) {
        var currentDirectory , fsObj , inputFilePath , rawData;
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        inputFilePath = currentDirectory + "\\" + inputFileName;
        rawData = fsObj.readFileSync( inputFilePath , "utf8" );
        this.parseRawData( rawData );
    };

    this.next = function( flag ) {
        var len , i , startIdx , res , endIdx;
        if( flag == 0 ) {
            if( this.currrentCharacterIndex != 0 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            res = "";
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += '' + this.allLines[ this.currrentLineNumber ].charAt( i ) ;
            }
            this.currrentLineNumber++;
            this.currrentCharacterIndex = 0;
            return res;
        }
        while( true ) {
            if( this.currrentLineNumber >= this.allLines.length ) {
                throw new Error( "No more tokens available!" );
            }
            startIdx = -1;
            len = this.allLines[ this.currrentLineNumber ].length;
            if( typeof( len ) == 'function' ) {
                len = this.allLines[ this.currrentLineNumber ].length() ;
            }
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = len - 1 ;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) >= 48 && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) <= 57 ) {
                    res += '' + ( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) - 48 ) ;
                }
                else {
                    res += '' + this.allLines[ this.currrentLineNumber ].charAt( i );
                }
            }
            this.currrentCharacterIndex = endIdx;
            if( endIdx == len - 1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            return res;
        }
    };

    this.nextInt = function() {
        return parseInt( this.next( 1 ) );
    };

    this.nextDouble = function() {
        return parseFloat( this.next( 1 ) );
    };

    this.nextString = function() {
        return this.next( 1 );
    };

    this.nextLine = function() {
        return this.next( 0 );
    };
}

function FileOutputHandler() {
    this.resultantStringArray = new Array();

    this.addNewLine = function( newString ) {
        this.resultantStringArray.push( newString );
    };

    this.clearPercase = function() {
        this.resultantStringArray = new Array();
    };

    this.flushOutOutputToFile = function( outputFileName ) {
        var i , sz , res , currentDirectory , fsObj , outputFilePath;
        res = "";
        sz = this.resultantStringArray.length;
        for( i = 0 ; i < sz ; i++ ) {
            if( i != 0 ) {
                res += "\n";
            }
            res += this.resultantStringArray[ i ];
        }
        fsObj = require( 'fs' );
        currentDirectory = __dirname;
        outputFilePath = currentDirectory + "\\" + outputFileName;
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

function CodeExecutioner() {
    this.irObj = new InputReader();
    this.psObj = new ProblemSolver();
    this.fohObj = new FileOutputHandler();

    this.runCases = function() {
        if( this.psObj.HAS_TEST_CASES == true ) {
            testCases = this.irObj.nextInt();
            for( i = 0 ; i < testCases ; i++ ) {
                this.psObj.clearPerCase();
                this.psObj.getInput( this.irObj );
                this.psObj.solveCase();
            }
        }
        else {
            while( true ) {
                this.psObj.clearPerCase();
                hasMoreTestCases = this.psObj.getInput( this.irObj );
                if( hasMoreTestCases == false ) {
                    break;
                }
                this.psObj.solveCase();
            }
        }
        if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.detectEnvironmentType = function() {
        var environmentType = null ;
        try {
            if( importPackage != null ) {
                environmentType = 'rhino' ;
            }
        }
        catch( ex1 ) {
            try {
                //for nodejs local server check
                if( __dirname != null && readline != null && typeof( readline ) != 'function' ) {
                    environmentType = 'local-node-js' ;
                }
            }
            catch( ex2 ) {
                try {
                    if( readline == null || typeof( readline ) != 'function' ) {
                        environmentType = 'server-node-js' ;
                    }
                    else {
                        try {
                            if( Map != null ) {
                                environmentType = 'spider-monkey' ;
                            }
                            else {
                                environmentType = 'javascript-v8' ;
                            }
                        }
                        catch( ex3 ) {
                            environmentType = 'javascript-v8' ;
                        }
                    }
                }
                catch( ex3 ) {
                    environmentType = 'server-node-js' ;
                }
            }
        }
        return environmentType ;
    };

    this.configureStreamsAndReadInput = function() {
        var testCases , i , hasMoreTestCases , isLocal , localContext , isNodeJsJudgeServer , environmentType ;
        isNodeJsJudgeServer = false ;
        environmentType = this.detectEnvironmentType() ;
        if( environmentType == 'local-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            if( this.psObj.DO_OUTPUT_TO_FILE == true ) {
                localContext = this.fohObj;
                print = function() {
                    localContext.addNewLine.apply( localContext , arguments );
                }
            }
            this.irObj.readAllLinesFromFile( this.psObj.INPUT_FILE_NAME );
            this.runCases() ;
        }
        else if( environmentType == 'server-node-js' ) {
            try {
                if( print == null || typeof( print ) != 'function' ) {
                    print = console.log;
                }
            }
            catch( ex ) {
                print = console.log;
            }
            this.irObj.readAllLinesFromNodeJsJudgeServer( this ) ;
        }
        else if( environmentType == 'javascript-v8' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
        else if( environmentType == 'rhino' ) {
            this.irObj.readAllLinesFromRhino();
            this.runCases() ;
        }
        else if( environmentType == 'spider-monkey' ) {
            this.irObj.readAllLines();
            this.runCases() ;
        }
    };

    this.configureStreamsAndReadInput();
}

new CodeExecutioner();


var input = readline();
var check = [];
for (var i = 0;i<1000;i++){
    if (i%8 == 0){
      check.push(i.toString());
    }
}
var finded = false;
for (var k = 0 ;k<check.length;k++){
  var current = check[k];
  var result = '';
  var j = 0;
  for(var i = 0;i<input.length;i++){
    if(input[i] == current[j]){
      result+=current[j];
      j++;
      if (j==current.length && !finded){
        finded = true;
        print('YES');
        print(result);
        break;
      }
    }
  }
}
if(!finded){
  var nullsCount = 0;
  for (var i = 0 ;i<input.length;i++){
    if(input[i]==0)
      nullsCount++;
  }
  if(nullsCount>=3){
    print('YES');
    print(input[0]+'000');
  }
  else
    print('NO');
}


const memo = {};

function isDivisibleBy8(n) {
  if (n.length >= 3) {
    var lastThree = parseInt(n.slice(n.length - 3), 10);
    if (lastThree % 8 === 0) {
      return true;
    }
    return false;
  }
  var remainder = parseInt(n, 10) % 8;
  return remainder === 0;
}

function resolve(n) {
  if (n.length === 0) {
    return null;
  }
  if (memo[n] === null) {
    return null;
  }
  if (isDivisibleBy8(n)) {
    return n;
  }
  if (n.length >= 3) {
    var arr = n.split('');
    for (var i = 1; i < 4; i++) {
      var sub = arr
        .slice(0, n.length - i)
        .concat(arr.slice(n.length - i + 1))
        .join('');
      var res = resolve(sub);
      if (res !== null) {
        return res;
      }
    }
  }
  if (n.length === 2) {
    if (n[0] === '8' || n[1] === '8') {
      return '8';
    }
    if (n[0] === '0' || n[1] === '0') {
      return '0';
    }
  }
  memo[n] = null;
  return null;
}

const k = readline();

const result = resolve(k);

print(result === null ? 'NO' : 'YES\n' + result);


const memo = {};

function isDivisibleBy8(n) {
  if (n.length >= 3) {
    var lastThree = parseInt(n.slice(n.length - 3), 10);
    if (lastThree % 8 === 0) {
      return true;
    }
    return false;
  }
  var remainder = parseInt(n, 10) % 8;
  return remainder === 0;
}

function resolve(n) {
  if (memo[n] === null) {
    return null;
  }
  if (isDivisibleBy8(n)) {
    return n;
  } else {
    var arr = n.split('');
    for (var i = 0; i < arr.length; i++) {
      var sub = arr
        .slice(0, i)
        .concat(arr.slice(i + 1))
        .join('');
      var res = resolve(sub);
      if (res !== null) {
        return res;
      }
    }
    memo[n] = null;
    return null;
  }
}

const k = readline();

const result = resolve(k);

print(result === null ? 'NO' : 'YES\n' + result);


const memo = {};

function isDivisibleBy8(n) {
  if (n.length >= 3) {
    var lastThree = parseInt(n.slice(n.length - 3), 10);
    if (lastThree % 8 === 0) {
      return true;
    }
    return false;
  }
  var remainder = parseInt(n, 10) % 8;
  return remainder === 0;
}

function resolve(n) {
  if (memo[n] === null) {
    return null;
  }
  if (isDivisibleBy8(n)) {
    return n;
  } else {
    var arr = n.split('');
    for (var i = 1; i < 4; i++) {
      var sub = arr
        .slice(0, n.length - i)
        .concat(arr.slice(n.length - i + 1))
        .join('');
      var res = resolve(sub);
      if (res !== null) {
        return res;
      }
    }
    memo[n] = null;
    return null;
  }
}

const k = readline();

const result = resolve(k);

print(result === null ? 'NO' : 'YES\n' + result);


const memo1 = Array(100000);
const memo2 = Array(100000);

function check(arr) {
  var k = 0;
  for (var i = arr.length - 1; i >= 0; i--) {
    if (!memo1[arr[i]]) {
      memo1[arr[i]] = true;
      k++;
    }
    memo2[i] = k;
  }
}

function resolve(arr, ls) {
  check(arr);
  for (var i = 0; i < ls.length; i++) {
    print(memo2[ls[i] - 1]);
    // console.log(memo2[ls[i] - 1]);
  }
}

/*
const arr = '1 2 3 4 1 2 3 4 100000 99999'.split(' ');
const l = '1 2 3 4 5 6 7 8 9 10'.split(' ');

resolve(arr, l);
*/

const p = readline().split(' ');
const m = parseInt(p[1], 10);
const arr = readline().split(' ');
const ls = [];

for (var i = 0; i < m; i++) {
  var l = readline();
  ls.push(l);
}

resolve(arr, ls);


const memo = {};

function isDivisibleBy8(n) {
  if (n.length >= 3) {
    var lastThree = parseInt(n.slice(n.length - 3), 10);
    if (lastThree % 8 === 0) {
      return true;
    }
    return false;
  }
  var remainder = n % 8;
  return remainder === 0;
}

function resolve(n) {
  if (memo[n] === null) {
    return null;
  }
  if (isDivisibleBy8(n)) {
    return n;
  } else {
    var arr = n.split('');
    for (var i = 0; i < arr.length; i++) {
      var sub = arr
        .slice(0, i)
        .concat(arr.slice(i + 1))
        .join('');
      var res = resolve(sub);
      if (res !== null) {
        return res;
      }
    }
    memo[n] = null;
    return null;
  }
}

const k = readline();

const result = resolve(k);

print(result === null ? 'NO' : 'YES\n' + result);


var count = parseInt(readline());
var inputList = readline().split(" ").map(function (x) { return parseInt(x); });
var res = 0;
for (var i = 1; i < count; ++i) {
  if (inputList[i] + inputList[i - 1] === 5) {
    print("Infinite");
    break;
  }
  else if (inputList[i] + inputList[i - 1] === 4) {
    res += 4;
  }
  else if (i > 1 && inputList[i - 2] === 3) {
    res += 2;
  }
  else {
    res += 3;
  }
}
if (i === count) {
  print("Finite");
  print(res);
}


var ip = readline().split(' ').map(Number);
var n = ip[0], k= ip[1];
if (k <= n){
    print(Math.floor((k-1)/2));
} else if ((k+1)/2 <= n){
       print(Math.floor((n-(k-n)+1)/2));
}else
print(0)


function main() {
  const is = new Scanner();
  const [n, k] = is.nextArray(Number);
  let answer = Math.trunc((k - 1) / 2);
  if (k > n)
    answer = Math.max(0, answer - (k - n - 1));
  console.log(answer);
}

/*
 *  Api Scanner
 */
class Scanner {
  constructor() {
    this.index = -1;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    this.index += 1;
    return this.lines[this.index].trim();
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray(fn) {
    const array = this.nextLine().split(' ');
    return fn === String ? array : array.map(fn);
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });


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

var templateString = ""

var c = 0;
rl.on('line', function (line) {
    c += 1;
    if (c == 1) {
        templateString = line;
        rl.close();
        var _p = parse(templateString, 2)
        console.log(result(parseInt(_p[0]), parseInt(_p[1])));
    }
});

function parse(template, iLoop) {
    var out=[]
    var regex = /\d+/gm;
    var str = template;
    var m;
    var c = 0;
    while ((m = regex.exec(str)) !== null) {
        if (m.index === regex.lastIndex) {
            regex.lastIndex++;
        }
        if (c==iLoop) {break}
        out[c] = m[0];
        c+=1;
    }
    return out;
}

function result(n,k) {
    if (k-n>=n) {return 0};
    if (k-n==n-1) {return 1};
    if (k-n==1) {return Math.floor(k / 2)};
}


  var tmp = readline().split(' ').map(x => parseInt(x));
  var n = tmp[0];
  var m = tmp[1];
  var l = readline().split(' ').map(x => parseInt(x));
  var res = new Array(n + 1).fill(-1);
  var used = [];
  var fail = false;
  for(var i = 1; i < m && ! fail; i += 1) {
    var x = ((l[i] - l[i - 1]) + n + n) % n;
    if(x === 0) {
      x = n;
    }
    if(used.indexOf(x) !== -1 && x !== n) {
      fail = true;
    }
    if(used.indexOf(x) === -1) {
      used.push(x);
    }
    if(res[l[i - 1]] !== -1 && x !== n) {
      fail = true;
    }
    res[l[i - 1]] = x;
  }
  for(var i = 1; i <= n && ! fail; i += 1) {
    if(res[i] === -1) {
      for(var j = 1; j <= n; j += 1) {
        if(used.indexOf(j) === -1) {
          res[i] = j;
          used.push(j);
          break;
        }
      }
    }
  }
  print(fail ? -1 : res.slice(1).join(' '));


  var tmp = readline().split(' ').map(x => parseInt(x));
  var n = tmp[0];
  var m = tmp[1];
  var l = readline().split(' ').map(x => parseInt(x));
  var res = new Array(n).fill(-1);
  var used = [];
  var fail = false;
  for(var i = 1; i < m && ! fail; i += 1) {
    var x = ((l[i] - l[i - 1]) + n + n) % n;
    if(x === 0) {
      x = n;
    }
    if(used.indexOf(x) !== -1) {
      fail = true;
    }
    used.push(x);
    if(res[l[i - 1]] !== -1 && x !== n) {
      fail = true;
    }
    res[l[i - 1]] = x;
  }
  for(var i = 1; i <= n && ! fail; i += 1) {
    if(res[i] === -1) {
      for(var j = 1; j <= n; j += 1) {
        if(used.indexOf(j) === -1) {
          res[i] = j;
          used.push(j);
        }
      }
    }
  }
  print(fail ? -1 : res.slice(1).join(' '));


  var tmp = readline().split(' ').map(x => parseInt(x));
  var n = tmp[0];
  var m = tmp[1];
  var l = readline().split(' ').map(x => parseInt(x));
  var res = new Array(n + 1).fill(-1);
  var used = [];
  var fail = false;
  for(var i = 1; i < m && ! fail; i += 1) {
    var x = ((l[i] - l[i - 1]) + n + n) % n;
    if(x === 0) {
      x = n;
    }
    if(used.indexOf(x) === -1) {
      used.push(x);
    }
    if(res[l[i - 1]] !== -1 && x !== res[l[i - 1]]) {
      fail = true;
    }
    res[l[i - 1]] = x;
  }
  var used2 = [];
  for(var i = 1; i <= n; i += 1) {
    if(res[i] !== -1) {
      if(used2.indexOf(res[i]) === -1) {
        used2.push(res[i]);
      } else {
        fail = true;
      }
    }
  }
  for(var i = 1; i <= n && ! fail; i += 1) {
    if(res[i] === -1) {
      for(var j = 1; j <= n; j += 1) {
        if(used.indexOf(j) === -1) {
          res[i] = j;
          used.push(j);
          break;
        }
      }
    }
  }
  print(fail ? -1 : res.slice(1).join(' '));


var N = parseInt(readline());
var ar = readline().split(' ').map(function(a) {return parseInt(a);});
ar.sort(function(a, b) { return a-b;});

var sum = 0;
for (var i = 0; i < ar.length; i++) {
  sum += ar[i];
}

var r = 0;
var navg = Math.round( sum / ar.length );

for (var i = 0; i < ar.length && navg < 5; i++) {
  sum -= ar[i];
  sum += 5;
  navg = Math.round( sum / ar.length );
  r++;
}

print(r);


'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rn = async () => Number(await read());
  const n = await rn();
  const check = m => {
    let ans = Math.floor((m - 1) / 2) + Math.floor(m / 4) - 1;
    return ans >= n;
  };
  let l = 3,
      r = 10 ** 12;
  while (l < r) {
    const m = Math.floor((l + r) / 2);
    if (check(m)) {
      r = m;
    } else {
      l = m + 1;
    }
  }
  return l;
}

async function main(r) {
  try {
    let t = 1;
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log('zdebug' + error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
const it = rl[Symbol.asyncIterator]();
async function read() {
  return (await it.next()).value;
}
void async function () {
  const output = await main(read);
  process.stdout.write(output);
}();


'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

async function solve(read) {
  const rn = async () => Number(await read());
  const n = await rn();
  const check = m => {
    let ans = Math.floor((m - 1) / 2);
    if (m > 4) ans += Math.floor(m / 4) - 1;
    return ans >= n;
  };
  let l = 3,
      r = 10 ** 12;
  while (l < r) {
    const m = Math.floor((l + r) / 2);
    if (check(m)) {
      r = m;
    } else {
      l = m + 1;
    }
  }
  return l;
}

async function main(r) {
  try {
    let t = 1;
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      res[i] = await solve(r);
    }
    return res.join('\n');
  } catch (error) {
    console.log('zdebug' + error);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
const it = rl[Symbol.asyncIterator]();
async function read() {
  return (await it.next()).value;
}
void async function () {
  const output = await main(read);
  process.stdout.write(output);
}();


var differentShiftsCount = function( s ) {
  var shitfs,
    i;
  shifts = new Set();
  s = s.split( "" );
  for ( i = 0; i < s.length; ++i ) {
    shifts.add( s.toString() );
    s.unshift(s.pop());
  }
  return shifts.size;
};

print( differentShiftsCount ( readline() ) );


(function main(){
  //http://codeforces.com/problemset/problem/745/A
  var palabra = readline();

  var combinaciones = [palabra];
  for (var i = 0; i < palabra.length; i++) {
    palabra = palabra.substring(1) + palabra.charAt(0);
    if(combinaciones.indexOf(palabra) == -1){
      combinaciones.push(palabra);
    }
  }

  print(combinaciones.length);
})();


//var print = require('./print');
//var readline = require('./readline');
var n = parseInt(readline());
var sum = n + (n - 1);
var t = sum;
var k = 0;
while(t){
  k++;
  t=parseInt(t/10);
}
var cur = Math.pow(10,k-1) - 1;
if(cur * 10 + 9 == sum){
  print(1);
}
else{
  var ans = 0;
  for(var i=0;i<9;i++){
    var p = Math.pow(10,k-1) * i + cur;
    //print(p);
    if(p <= (n+1)){
      ans += parseInt(p/2);
    }
    else if(p<=(n+(n-1))){
      ans += 1 + parseInt((n+(n-1)-p)/2);
    }
  }
  print(ans);
}
/*
var cur = Math.pow(10,k-1) - 1;
if(sum == cur * 10 + 9){
  print(1);
}
else{
  var ans = 0;
  for(var i=0;i<9;i++){
    var p = Math.pow(10,k-1) * i + cur;
    if(p <= (n+1)){
      ans += parseInt(p/2);
    }
    else if(p<=(n+(n-1))){
      ans += (n+(n-1)-)
    }
  }
}*/
/*
var start = max - n;
if(n > max){
  start = n % Math.pow(10,k);
}
var count = n - start + 1;
var ans = parseInt(count / 2);
print('n: ' + n);
print('max: ' + max);
print('start: ' + start);
print('count: ' + count);
print('ans: ' + ans)
*/


//var print = require('./print');
//var readline = require('./readline');
var n = parseInt(readline());
var t = n;
var k = 0;
while(t){
  k++;
  t=parseInt(t/10);
}
if(n < 5 * Math.pow(10,k - 1)){
  k--;
}
var target = 5 * Math.pow(10,k - 1);
if(k == 0){
  print(parseInt(n/2));
}
else{
  var target = 5 * Math.pow(10,k - 1);
  var ans = n - target + 1;
  var t = n;
  var k2 = 0;
  var allNine = true;
  while(t){
    k2++;
    if(parseInt(t/10)%9 != 0){
      allNine = false;
    }
    t=parseInt(t/10);
  }
  if(k2>k){
    ans --;
  }
  if(allNine){
    ans--;
  }
  print(ans);
}


//var print = require('./print');
//var readline = require('./readline');
var n = parseInt(readline());
var sum = n + (n - 1);
var t = sum;
var k = 0;
while(t){
  k++;
  t=parseInt(t/10);
}
var cur = Math.pow(10,k-1) - 1;
if(cur * 10 + 9 == sum){
  print(1);
}
else if(n<5){
  if(n == 2)
	{
		print(1);
	}
	if(n == 3)
	{
		print(3);
	}
	if(n == 4)
	{
		print(6);
	}
}
else{
  var ans = 0;
  for(var i=0;i<9;i++){
    var p = Math.pow(10,k-1) * i + cur;
    //print(p);
      if(p <= (n+1)){
        //print('v1')
        ans += parseInt(p/2);
      }
      else if(p<=(n+(n-1))){
          ans +=1 + parseInt((n+(n-1)-p)/2);
      }

    //print(ans);
  }
  print(ans);
}
/*
var cur = Math.pow(10,k-1) - 1;
if(sum == cur * 10 + 9){
  print(1);
}
else{
  var ans = 0;
  for(var i=0;i<9;i++){
    var p = Math.pow(10,k-1) * i + cur;
    if(p <= (n+1)){
      ans += parseInt(p/2);
    }
    else if(p<=(n+(n-1))){
      ans += (n+(n-1)-)
    }
  }
}*/
/*
var start = max - n;
if(n > max){
  start = n % Math.pow(10,k);
}
var count = n - start + 1;
var ans = parseInt(count / 2);
print('n: ' + n);
print('max: ' + max);
print('start: ' + start);
print('count: ' + count);
print('ans: ' + ans)
*/


var print = require('./print');
var readline = require('./readline');
var n = parseInt(readline());
var sum = n + (n - 1);
var t = sum;
var k = 0;
while(t){
  k++;
  t=parseInt(t/10);
}
var cur = Math.pow(10,k-1) - 1;
if(cur * 10 + 9 == sum){
  print(1);
}
else if(n<5){
  if(n == 2)
	{
		print(1);
	}
	if(n == 3)
	{
		print(3);
	}
	if(n == 4)
	{
		print(6);
	}
}
else{
  var ans = 0;
  for(var i=0;i<9;i++){
    var p = Math.pow(10,k-1) * i + cur;
    //print(p);
      if(p <= (n+1)){
        //print('v1')
        ans += parseInt(p/2);
      }
      else if(p<=(n+(n-1))){
          ans +=1 + parseInt((n+(n-1)-p)/2);
      }

    //print(ans);
  }
  print(ans);
}
/*
var cur = Math.pow(10,k-1) - 1;
if(sum == cur * 10 + 9){
  print(1);
}
else{
  var ans = 0;
  for(var i=0;i<9;i++){
    var p = Math.pow(10,k-1) * i + cur;
    if(p <= (n+1)){
      ans += parseInt(p/2);
    }
    else if(p<=(n+(n-1))){
      ans += (n+(n-1)-)
    }
  }
}*/
/*
var start = max - n;
if(n > max){
  start = n % Math.pow(10,k);
}
var count = n - start + 1;
var ans = parseInt(count / 2);
print('n: ' + n);
print('max: ' + max);
print('start: ' + start);
print('count: ' + count);
print('ans: ' + ans)
*/


(function main() {
    var l = readline().split(' ');
    var n = parseInt(l[0]);
    var k = parseInt(l[1]);
    print(Math.max(0, 3 * n - k));
})();


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

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

  const arr = d.split(' ').map(Number);
  arr.sort((a, b) => a - b);
  let ans = Math.max(0, arr[arr.length - 1] - 25);

  console.log(ans);

  c++;
});


//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	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 list = nextIntArray();
	var max = Math.max.apply(null, list);
	if(max <= 25){
		myout(0);
	}else{
		myout(max - 25);
	}
}


function readNumbers() {
	return readline().split(' ').map(function (x) {
		return parseInt(x);
	});
}

var k = parseInt(readline());
var r = readNumbers();

var decline = Math.max.apply(null, r) - 25;

print(
	decline > 0
		? decline
		: 0
);


const readline = require('readline')

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

function solve(n, m) {
    const s = n.toString(m)
    // console.log(s)
    const map = {}
    for (let i = 0; i < s.length; i++) {
        if (map[s[i]]) return false
        map[s[i]] = 1
    }
    return true
}


input = readline().split(' ');
d = 0;
temp_year = year = parseInt(input[0]);
while (true) {
        if (!(d % 7) && is_leap(year) == is_leap(temp_year) && d) {
                print(temp_year);
                break
        }
        temp_year++;
        d += (is_leap(temp_year) ? 366 : 365)
}

function is_leap(year) {
        return (!(year % 400) || (year % 100)) && !(year % 4)
}


//var input = "WBWBWBWB\nBWBBBWBW\nBWBWBWBW\nBWBWBWBW\nWBWBWBWB\nWBWBWBWB\nBWBWBWBW\nWBWBWBWB";
//var index = 0;
//
//function readline(){
//    var data = input.split('\n');
//    if(index < data.length)
//        return data[index++];
//}
//
//function print(output){
//    console.log(output);
//}

function test(str){
    for(var i = 1; i < str.length; i++){
        if(str.charAt(i) == str.charAt(i - 1))
            return false;
    }
    return true;
}

function main(){
    for(var i = 0; i < 8; i++){
        var str = readline();
        if(!test(str)){
            print('NO');
            return;
        }

    }
    print('YES');
}
main();


print(function() {
	var i, ans = 'YES';
	for (i = 0; i < 8; i++)
		readline().split('').reduce(function(a, b) {
			if (a === b) ans = 'NO';
			return b;
		});
	return ans;
}());


var line = readline().split(' ');
var n = parseInt(line[0]);
var v = parseInt(line[1]);
var arr = readline().split(' ');
var a = [];
var cur = [];
var sum = 0;
for (var i = 0; i < arr.length; i ++)
{
    a[i] = parseInt(arr[i]);
    cur[i] = a[i]%2===0?a[i]/2:parseInt(a[i]/2)+1;
    sum += cur[i];
}
if (sum > v)
{
    print(-1);
}
else
{
    while(v-sum > 0)
    {
        var max = 0;
        var maxi = 0;
        for (var i = 0; i < a.length; i ++)
        {
            if (a[i] > max && cur[i]!=a[i])
            {
                max = a[i];
                maxi = i;
            }
        }
        var put = Math.min(Math.min(v-sum), (a[maxi]-cur[maxi]));
        cur[maxi]+=put;
        sum+=put;
    }

    print( cur.join(" ") );
}


function solve() {
  var input = readline().split(' ');
  var n = +input[0];
  var w = +input[1];
  var a = readline().split(' ');
  for (var i = 0; i < a.length; i++) {
    a[i] = {
      val: a[i],
      id: i
    }
  }
  a.sort((a, b) => {
    a = +a.val;
    b = +b.val;
    if (a > b) {
      return 1;
    }
    if (a === b) {
      return 0;
    }
    return -1;
  });

  var ans = [];

  for (var i = 0; i < a.length; i++) {
    var val = Math.ceil(a[i].val / 2);
    if (val > w) {
      print(-1);
      return;
    }
    w -= val;
    ans[i] = val;
  }

  var i = ans.length - 1;
  while (w > 0) {
    var val = ans[i] + w;
    if (val > a[i].val) {
      val = a[i].val;
    }
    w -= (val - ans[i]);
    ans[i] = val;
    i--;
  }

  var tmp = Array.from(ans);

  for (var i = 0; i < n; i++) {
    ans[a[i].id] = tmp[i];
  }

  print(ans.join(' '));
}
solve();


function solve() {
  var input = readline().split(' ');
  var n = +input[0];
  var w = +input[1];
  var a = readline().split(' ');
  for (var i = 0; i < a.length; i++) {
    a[i] = {
      val: a[i],
      id: i
    }
  }
  a.sort((a, b) => {
    a = +a.val;
    b = +b.val;
    if (a > b) {
      return 1;
    }
    if (a === b) {
      return 0;
    }
    return -1;
  });

  var ans = [];

  for (var i = 0; i < a.length; i++) {
    var val = Math.ceil(a[i].val / 2);
    if (val > w) {
      print(-1);
      return;
    }
    w -= val;
    ans[i] = val;
  }

  if (w > 0) {
    ans[ans.length - 1] += w;
  }

  var tmp = Array.from(ans);

  for (var i = 0; i < n; i++) {
    ans[a[i].id] = tmp[i];
  }

  print(ans.join(' '));
}
solve();


/* TEST CASE
input
6
URLLDR
output
2
input
4
DLUU
output
0
input
7
RLRLRLR
output
12
 */
function main() {
	var n = parseInt(readline());
	var s = readline();
	var answer = 0;

	for (var i = 0; i < n; i++) {
		var x = 0;
		var y = 0;
		for (var j = i; j < n; j++) {
			switch (s.charCodeAt(j)) {
				case 0x55: //'U'
					y--;
					break;
				case 0x44: //'D'
					y++
					break;
				case 0x4C: //'L'
					x--;
					break;
				case 0x52: //'R'
					x++;
					break;
			}
			if (x == 0 && y == 0) {
				answer++;
			}
		}
	}

	print(answer);
}

main();


/* TEST CASE
input
6
URLLDR
output
2
input
4
DLUU
output
0
input
7
RLRLRLR
output
12
 */
function main() {
	var n = parseInt(readline());
	var s = readline();
	var answer = 0;

	for (var i = 0; i < n; i++) {
		var x = 0;
		var y = 0;
		for (var j = i; j < n; j++) {
			var c = s.charCodeAt(j);
			if (c == 0x55 /*'U'*/) {
				y--;
			} else if (c == 0x44 /*'D'*/) {
				y++
			} else if (c == 0x4C /*'L'*/) {
				x--;
			} else if (c == 0x52 /*'R'*/) {
				x++;
			}
			if (x == 0 && y == 0) {
				answer++;
			}
		}
	}

	print(answer);
}

main();


var n = parseInt(readline());
var d = readline().split(' ').map(x => parseInt(x));
var largest = -Infinity;
for(var i = 0; i < n; i += 1) {
    largest = Math.max(d[i], largest);
}
print(largest ^ d[n - 1]);


const n = Number(readline());
const a = readline().split(" ").slice(0, n).map(x => Number(x));
print(Math.max(...a) ^ a[n - 1]);