var xParams = readline().split(' '),
    xRepresentation = readline();
    yParams = readline().split(' '),
    yRepresentation = readline();

// var xParams = "7 16".split(' '),
//     xRepresentation = "15 15 4 0 0 7 10";
//     yParams = "7 9".split(' '),
//     yRepresentation = "4 8 0 3 1 5 0";

var n = Number(xParams[0]),
    xNumSys = Number(xParams[1]),
    m = Number(yParams[0]),
    yNumSys = Number(yParams[1]);

function solver() {
    var x = transformBaseRepToDecimal(xRepresentation.split(' ').map(function (item) {
        return Number(item);
    }), xNumSys);
    var y = transformBaseRepToDecimal(yRepresentation.split(' ').map(function (item) {
        return Number(item);
    }), yNumSys);

    var res = '=';
    if (x < y) {
        return '<';
    } else if (x > y) {
        return '>';
    }

    return res;
}

function transformBaseRepToDecimal(arr, base) {
    var decimalValue = 0;

    for (var i = arr.length - 1, val = 1; i >= 0; i--) {
        decimalValue += ((val * arr[i]));
        val *= base;
    }

    return decimalValue;
}

print(solver());
// console.log(solver());


var x = readline().split(' ');
var n = parseInt(x[0]);
var bx = parseInt(x[1]);
x = readline().split(' ');
var a = []
for(var i = 0; i < n; i++) {
    a[i] = parseInt(x[i]);
}
x = readline().split(' ');
var m = parseInt(x[0]);
var by = parseInt(x[1]);
x = readline().split(' ');
var b = []
for(var i = 0; i<m;i ++) {
    b[i] = parseInt(x[i]);
}
var a1 = 0;
for(var i=0;i<n;i++) {
    a1 = a1 * bx + a[i];
}
var a2 = 0;
for(var i = 0; i < m; i ++) {
    a2 = a2 * by + b[i];
}
if(a1 < a2) print("<");
else if(a1 == a2) print("=");
else print(">");


var x ;
 var Arr , c ,v0 ,v1 ,a ,l ,sum , count ;

nextLine();
function nextLine(){
var x = readline()
if(x){
Arr = x.split(" ").map(function(x) { return parseInt(x); })
c= Arr[0]
v0 = Arr[1]
v1 = Arr[2]
a =Arr[3]
l = Arr[4]
sum = 0 ;
count=0 ;
sum = 0 ;
count = 0;

summer();
}
}

function summer (){
sum += (v0+count*a<v1)?v0+count*a:v1 ;
if(sum < c ){sum-= l ;count++; summer() }
else {print(count+1) ;nextLine() }

}


function main()
{
    var line = readline();
    var arr = line.split(' ');

    //print(arr);

    var c  = parseInt(arr[0]),
        v0 = parseInt(arr[1]),
        v1 = parseInt(arr[2]),
        a  = parseInt(arr[3]),
        l  = parseInt(arr[4]);

    var read = v0,
        days = 1;

    if (c === 0) {
        print(0);
        return 0;
    }
    while (read < c) {
        read += Math.min((v0 - l) + days * a, v1 - l);
        days++;
    }

    print(days);
    return 0;
}
main();


function ansa(c,v0,v1,a,l){

  var points = v0;
  var days = 1;
  var i = 1;

  if(c <= v0){
    print("1");
    return;
  }

  else{
    while(points < c){
      if((v0 + ( i * a) < v1)){
        points+= (v0 + ( i * a)) - l;
      }
      else{
        points += v1 - l;
      }
      days++;
      i++;
    }
  }
  print(days);
}

var line = readline().split(' ');
for(var i = 0 ; i < line.length ; i++) line[i] = parseInt(line[i]);

ansa(line[0],line[1],line[2],line[3],line[4]);


"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

var _readline$split$map = readline().split(' ').map(function (val) {
  return parseInt(val);
}),
    _readline$split$map2 = _slicedToArray(_readline$split$map, 5),
    c = _readline$split$map2[0],
    v0 = _readline$split$map2[1],
    v1 = _readline$split$map2[2],
    a = _readline$split$map2[3],
    l = _readline$split$map2[4];

var cur = 0;
var speed = v0;
var day = 0;

while (true) {
  day++;
  cur += speed;
  if (cur >= c) break;
  cur -= l;
  speed = Math.min(v1, speed + a);
}

print(day);


function main()
{
    var line = readline();
    var arr = line.split(' ');

    //print(arr);

    var c  = parseInt(arr[0]),
        v0 = parseInt(arr[1]),
        v1 = parseInt(arr[2]),
        a  = parseInt(arr[3]),
        l  = parseInt(arr[4]);

    var read = v0,
        days = 1;

    if (c === 0) {
        print(0);
        return 0;
    }
    while (read < c) {
        read += Math.min((v0 - l) + days * a, v1);
        days++;
    }

    print(days);
    return 0;
}
main();


function main()
{
    var line = readline();
    var arr = line.split(' ');

    //print(arr);

    var c  = parseInt(arr[0]),
        v0 = parseInt(arr[1]),
        v1 = parseInt(arr[2]),
        a  = parseInt(arr[3]),
        l  = parseInt(arr[4]);

    var read = v0,
        days = 1;

    while (read < c) {
        read += Math.min((v0 - l) + days * a, v1);
        days++;
    }

    print(days);
    return 0;
}
main();


var x ;
var Arr , c ,v0 ,v1 ,a ,l ,sum , count ;
nextLine();
function nextLine(){
   // var x = readLine()
    if(x.split(" ").length>3){
        Arr = readLine().split(" ").map(function(x) { return parseInt(x); })
        c= Arr[0]
        v0 = Arr[1]
        v1 = Arr[2]
        a =Arr[3]
        l = Arr[4]
        sum = 0 ;
        count=0 ;
        sum = 0 ;
        count = 0;
        summer();
    }
}

function summer (){
    sum += (v0+count*a<v1)?v0+count*a:v1 ;
    if(sum < c ){sum-= l ;count++; summer() }
    else {print(parseInt(count+1)) ;nextLine() }

}


var x ;
var Arr , c ,v0 ,v1 ,a ,l ,sum , count ;
nextLine();
function nextLine(){
  //  var x = readLine()
        Arr = readLine().split(" ").map(function(x) { return parseInt(x); })
        c= Arr[0]
        v0 = Arr[1]
        v1 = Arr[2]
        a =Arr[3]
        l = Arr[4]
        sum = 0 ;
        count=0 ;
        sum = 0 ;
        count = 0;
        summer();
}

function summer (){
    sum += (v0+count*a<v1)?v0+count*a:v1 ;
    if(sum < c ){sum-= l ;count++; summer() }
    else {print(count+1) ;nextLine() }

}


var x ;
 var Arr , c ,v0 ,v1 ,a ,l ,sum , count ;

nextLine();
function nextLine(){
var x = readline()
if(x.split(" ").length>3){
Arr = x.split(" ").map(function(x) { return parseInt(x); })
c= Arr[0]
v0 = Arr[1]
v1 = Arr[2]
a =Arr[3]
l = Arr[4]
sum = 0 ;
count=0 ;
sum = 0 ;
count = 0;

summer();
}
}

function summer (){
sum += (v0+count*a<v1)?v0+count*a:v1 ;
if(sum < c ){sum-= l ;count++; summer() }
else {print(count+1) ;nextLine() }

}


var x ;
 var Arr , c ,v0 ,v1 ,a ,l ,sum , count ;

nextLine();
function nextLine(){
var x = readLine()
if(x.split(" ").length>3){
Arr = x.split(" ").map(function(x) { return parseInt(x); })
c= Arr[0]
v0 = Arr[1]
v1 = Arr[2]
a =Arr[3]
l = Arr[4]
sum = 0 ;
count=0 ;
sum = 0 ;
count = 0;

summer();
}
}

function summer (){
sum += (v0+count*a<v1)?v0+count*a:v1 ;
if(sum < c ){sum-= l ;count++; summer() }
else {print(count+1) ;nextLine() }

}


var x ;
var Arr , c ,v0 ,v1 ,a ,l ,sum , count ;
nextLine();
function nextLine(){
   // var x = readLine()
    if(x.split(" ").length>3){
        Arr = readLine().split(" ").map(function(x) { return parseInt(x); })
        c= Arr[0]
        v0 = Arr[1]
        v1 = Arr[2]
        a =Arr[3]
        l = Arr[4]
        sum = 0 ;
        count=0 ;
        sum = 0 ;
        count = 0;
        summer();
    }
}

function summer (){
    sum += (v0+count*a<v1)?v0+count*a:v1 ;
    if(sum < c ){sum-= l ;count++; summer() }
    else {print(count+1) ;nextLine() }

}


readline();
var s = readline();
var ans = s.length;
for(var i = 1;i < s.length;i++)
    if(s.substr(0, i) == s.substr(0 + i, i)) {
        ans = s.length - i + 1;
    }
print(ans);


var x ;
 var n ,k,losers,dipl ,cert  ,sum , count ;

nextLine();
function nextLine(){
var x = readline()
if(x){
    Arr = x.split(" ").map(function(x) { return parseInt(x); })
    n= Arr[0]
    k = Arr[1]
    dipl = Math.floor((.5*n/(1+k)));
    cert=k*dipl ;
    var losers = n - cert - dipl ;
    sum = 0 ;
    console.log(dipl,cert,losers)
    write(dipl+' '+cert+' '+ losers+'\n')
nextLine()
    }
}


var x ;
 var n ,k,losers,dipl ,cert  ,sum , count ;

nextLine();
function nextLine(){
var x = readLine()
if(x){
    Arr = x.split(" ").map(function(x) { return parseInt(x); })
    n= Arr[0]
    k = Arr[1]
    dipl = Math.floor((.5*n/(1+k)));
    cert=k*dipl ;
    var losers = n - cert - dipl ;
    sum = 0 ;
    print(dipl+' '+cert+' '+ losers)
    nextLine()
    }
}

// function readline(){
//     return '18 2'
// }


var x ;
 var n ,k,losers,dipl ,cert  ,sum , count ;

nextLine();
function nextLine(){
var x = readLine()
if(x){
    Arr = x.split(" ").map(function(x) { return parseInt(x); })
    n= Arr[0]
    k = Arr[1]
    dipl = Math.floor((.5*n/(1+k)));
    cert=k*dipl ;
    var losers = n - cert - dipl ;
    sum = 0 ;
    console.log(dipl,cert,losers)
    write(dipl+' '+cert+' '+ losers+'\n')

    }
}


var x ;
 var n ,k,losers,dipl ,cert  ,sum , count ;

nextLine();
function nextLine(){
var x = readline()
if(x){
    Arr = x.split(" ").map(function(x) { return parseInt(x); })
    n= Arr[0]
    k = Arr[1]
    dipl = Math.floor((.5*n/(1+k)));
    cert=k*dipl ;
    var losers = n - cert - dipl ;
    sum = 0 ;
    console.log(dipl,cert,losers)
    print(dipl+' '+cert+' '+ losers)
    nextLine()
    }
}

// function readline(){
//     return '18 2'
// }


var x ;
 var n ,k,losers,dipl ,cert  ,sum , count ;

nextLine();
function nextLine(){
var x = readline()
if(x){
    Arr = x.split(" ").map(function(x) { return parseInt(x); })
    n= Arr[0]
    k = Arr[1]
    dipl = Math.floor((.5*n/(1+k)));
    cert=k*dipl ;
    var losers = n - cert - dipl ;
    sum = 0 ;
    console.log(dipl,cert,losers)
    write(dipl+' '+cert+' '+ losers+'\n')

    }
}


var x ;
 var n ,k,losers,dipl ,cert  ,sum , count ;

nextLine();
function nextLine(){
var x = readline()
if(x){
    Arr = x.split(" ").map(function(x) { return parseInt(x); })
    n= Arr[0]
    k = Arr[1]
    dipl = Math.floor((.5*n/(1+k)));
    cert=k*dipl ;
    var losers = n - cert - dipl ;
    sum = 0 ;
    console.log(dipl,cert,losers)
    write(dipl+' '+cert+' '+ losers)
    nextLine()
    }
}

// function readline(){
//     return '18 2'
// }


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

rl.on('line', (d) => {
  let [n, k] = d.split(' ').map(Number);

  let mid = Math.ceil(n / 2);
  let x = mid % (k + 1);
  let a = (mid - x) / (k + 1);
  let b = a * k;
  let c = n - a - b;

  console.log(`${a} ${b} ${c}`);
});


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

    var students = numbers[0];
    var ratio = numbers[1];
    var notWinners = '0 0 ' + students;

    if (ratio * 2 > students)
        return notWinners;

    for (var i = parseInt((students + 1) / 2); i >= 0; i--) {
        var ratio2 = ratio + 1;
        if (i % ratio2 == 0) {
            var numDiplomas = i / ratio2;
            return numDiplomas + " " + numDiplomas * ratio + " " + (students - (numDiplomas * ratio2));
        }
    }

    return notWinners;
}

print(main());


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

    const students = numbers[0];
    const ratio = numbers[1];
    const notWinners = '0 0 ' + students;

    if (ratio * 2 > students)
        return notWinners;

    for (let i = parseInt((students + 1) / 2); i >= 0; i--) {
        let ratio2 = ratio + 1;
        if (i % ratio2 == 0) {
            let numDiplomas = i / ratio2;
            return numDiplomas + " " + numDiplomas * ratio + " " + (students - (numDiplomas * ratio2));
        }
    }

    return notWinners;
}

print(main());


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

    var students = numbers[0];
    var ratio = numbers[1];
    var notWinners = '0 0 ' + students;

    if (ratio * 2 >= students)
        return notWinners;

    var max = parseInt(students / 2);
    var ratio2 = ratio + 1;
    max -= max % ratio2;
    var ndiplomas = max / ratio2;
    if(ndiplomas === 0)
        return notWinners;
    var ncert = ndiplomas * ratio;
    var nnotwinners = students - ncert - ndiplomas;

    return ndiplomas + ' ' + ncert + ' ' + nnotwinners;
}

print(main());


var data = readline().split(" ");
var cnt = parseInt(data[0]);
var mod = parseInt(data[1]);

var d = 0;
var g = 0;
var l = 0;
var p = parseInt(cnt/2); //9

d = parseInt(p / (mod + 1));
g = parseInt(d * mod);
l = parseInt(cnt - d - g);

if (mod > cnt) {
  d = 0;
  g = 0;
  l = cnt;
}

print(d + ' ' + g + ' ' + l)


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

rl.on('line', (d) => {
  let [n, k] = d.split(' ').map(Number);

  let mid = Math.floor(n / 2);
  let x = mid % (k + 1);
  let a = (mid - x) / (k + 1);
  let b = a * k;
  let c = n - a - b;

  console.log(`${a} ${b} ${c}`);
});


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

    var students = numbers[0];
    var ratio = numbers[1];
    var notWinners = '0 0 ' + students;

    if (ratio * 2 > students)
        return notWinners;

    for (var i = parseInt(students / 2); i >= 0; i--) {
        var ratio2 = ratio + 1;
        if (i % ratio2 == 0) {
            var numDiplomas = i / ratio2;
            return numDiplomas + " " + numDiplomas * ratio + " " + (students - (numDiplomas * ratio2));
        }
    }

    return notWinners;
}

print(main());


s=readline().split(' ')
n=+s[0]
m=+s[1]
if (n<m)
    t=n
    n=m
    m=t
print((n-1)+' '+m)


var l1 = readline().split(' ');
var k = +l1[0];

if(k == 0) {
    print("a");
}else {
    var ans = "";
    function nC2 (n) {
        return n*(n-1)/2;
    }
    for(var rep = 0; k > 0; rep++) {
        var low = 0, high = 1000, cnt = 0;
        while(low <= high) {
            var mid = (low + high) >> 1;
            if(nC2(mid) <= k) {
                cnt = mid;
                low = mid + 1;
            }else {
                high = mid - 1;
            }
        }
        k -= nC2(cnt);
        ans += String.fromCharCode(97 + rep).repeat(cnt);
    }
    print(ans);
}


var triangles=[0]
while(triangles[triangles.length-1]<=100000)
{
    triangles.push(triangles[triangles.length-1]+triangles.length);
}

var n=+readline()
var nows='qwertyuiopasdfghjklzxcvbnm'
var now=0
res=''
if (0==n)
{
    print("skorobogatova")
}
else if (0==n)
{
    print("danil")
}
else
{
    var i=triangles.length-1;
    while(n)
    {
        while(triangles[i]>n){i--;}
        n-=triangles[i]
        for (var j=0;j<=i;j++)
        {
            res+=nows[now];
        }
        now++;
    }
}
print(res)


var input = readline().split(' ').map((x) => Number(x));

// var input = "5 2 1 4 5".split(' ').map((x) => Number(x));

var d = input[0], k = input[1], a = input[2], b = input[3], t = input[4];

var cnt = Math.floor(d / k), o = d - cnt * k;

var a1 = (t / k + a);

var ans;

if (k >= d) {
  print(a * d);
}

if (a1 >= b) {
    ans = k * a + (d - k) * b;
}
else {
    var t1 = (cnt * k + o) * a + t * cnt, t2 = cnt * k * a + b * o + t * (cnt - 1);
    ans = Math.min(t1, t2);
}

print(ans);


var input = readline().split(' ').map((x) => Number(x));

// var input = "5 2 1 4 5".split(' ').map((x) => Number(x));

var d = input[0], k = input[1], a = input[2], b = input[3], t = input[4];

var cnt = Math.floor(d / k), o = d - cnt * k;

var a1 = (t / k + a);

var ans;

if (a1 >= b) {
    ans = k * a + (d - k) * b;
}
else {
    var t1 = (cnt * k + o) * a + t * cnt, t2 = cnt * k * a + b * o + t * (cnt - 1);
    ans = Math.min(t1, t2);
}
 print(Math.min(t1, t2));

//console.log(ans);


var input = readline().split(' ').map((x) => Number(x));

// var input = "5 2 1 4 5".split(' ').map((x) => Number(x));

var d = input[0], k = input[1], a = input[2], b = input[3], t = input[4];

var cnt = Math.floor(d / k), o = d - cnt * k;

var a1 = (t / k + a);

var ans;

if (a1 >= b) {
    ans = k * a + (d - k) * b;
}
else {
    var t1 = (cnt * k + o) * a + t * cnt, t2 = cnt * k * a + b * o + t * (cnt - 1);
    ans = Math.min(t1, t2);
}

print(ans);

//console.log(ans);


var input = readline().split(' ').map((x) => Number(x));

// var input = "5 2 1 4 5".split(' ').map((x) => Number(x));

var d = input[0], k = input[1], a = input[2], b = input[3], t = input[4];

var cnt = Math.floor(d / k), o = d - cnt * k;

var a1 = (t / k + a);

var ans;

if (a1 >= b) {
    ans = k * a + (d - k) * b;
}
else {
    var t1 = (cnt * k + o) * a + t * cnt, t2 = cnt * k * a + b * o + t * (cnt - 1);
    ans = Math.min(t1, t2);
}

if (k >= d) {
    ans = d * a;
}

print(ans);


var time = readline();
time = time.split(":");
time[0] = parseInt(time[0]);
time[1] = parseInt(time[1]);
if(time[0] > 12){time[0] -= 12;}
print((time[0]*30+time[1]*0.5).toFixed(9) + " " + (time[1]*6).tofixed(9));


const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  let [h, m] = ipt.split(EOL).slice(0, -1)[0].split(':').map(v => parseInt(v))
  if (h >= 12) h -= 12

  let y = m * 6
  let x = h * 30 + y / 12

  console.log(x, y)
})


var time = readline();
time = time.split(":");
time[0] = parseInt(time[0]);
time[1] = parseInt(time[1]);
if(time[0] > 12){time[0] -= 12;}
print((time[0]*30+time[1]*0.5).toFixed(9) + " " + (time[1]*6).toFixed(9));


var params = readline().split(/[.e]/);
var a = params[0]; var d = params[1]; var b = parseInt(params[2]);
print(params);

if(a === "0" || b === 0) {
    print(a + "." + d);
} else {

    var num = a + d;
    if(b < d.length) {
        var tmp = num.split('');
        tmp.splice(a.length + b, 0, '.');
        num = tmp.join('');
    } else if(b > d.length) {
        var zeros = b - d.length;
        for(var i = 0; i < zeros; i++)
            num += "0";
    }

    print(num);
}


var input = readline();
var match = input.match(/(\d*)\.(\d*)e(\d*)/);

var a = match[1];
var d = match[2];
var b = match[3];

for (var i = d.length; i < +b; ++i) {
  d += '0';
}

match = d.match(new RegExp('(.{' + b + '})(.*)'));

a = +(a + match[1]);
d = +match[2];

write(d === 0 ? a : a + '.' + d)


var params = readline().split(/[.e]/);
var a = params[0]; var d = params[1]; var b = parseInt(params[2]);

if(a === "0") {
    print(a + "." + d);
} else {

    var num = a + d;
    if(b < d.length) {
        var tmp = num.split('');
        tmp.splice(a.length + d.length - 1, 0, '.');
        num = tmp.join('');
    } else if(b > d.length) {
        var zeros = b - d.length;
        for(var i = 0; i < zeros; i++)
            num += "0";
    }

    print(num);
}


var params = readline().split(/[.e]/);
var a = params[0]; var d = params[1]; var b = parseInt(params[2]);

if(a === "0" && d === "0" && b === 0) {
    print("0");
} else if(a === "0" || b === 0) {
    print(a + "." + d);
} else {

    var num = a + d;
    if(b < d.length) {
        var tmp = num.split('');
        tmp.splice(a.length + b, 0, '.');
        num = tmp.join('');
    } else if(b > d.length) {
        var zeros = b - d.length;
        for(var i = 0; i < zeros; i++)
            num += "0";
    }

    print(num);
}


var params = readline().split(/[.e]/);
var a = params[0]; var d = params[1]; var b = params[2];

if(a === 0) {
    print(a + "." + d);
} else {

    var num = a + d;
    if(b < d.length) {
        num = num.split('').splice(a.length + d.length, 0, '.').join('');
    } else if(b > d.length) {
        var zeros = b - d.length;
        for(var i = 0; i < zeros; i++)
            num += "0";
    }

    print(num);
}


var input = readline();
var match = input.match(/(\d*)\.(\d*)e(\d*)/);

var a = match[1];
var d = match[2];
var b = match[3];

for (var i = d.length; i < +b; ++i) {
  d += '0';
}

match = d.match(new RegExp('(.{' + b + '})(.*)'));

a += match[1];
d = +match[2];

write(d === 0 ? a : a + '.' + d)


var input = readline();
var match = input.match(/(\d*)\.(\d*)e(\d*)/);

var a = match[1];
var d = match[2];
var b = match[3];

for (var i = d.length; i < +b; ++i) {
  d += '0';
}

match = d.match(new RegExp('(.{' + b + '})(.*)'));

a += match[1];
d = match[2];

write(+d === 0 ? a : a + '.' + d)


var s = readline();
  s = s.split('e');
  var nm = s[0].split('.');
  var a = nm[0];
  var b = nm[1];
  var c = parseInt(s[1]);
  var res = a;
  if(c >= b.length) {
    res += b;
    while(c > b.length) {
      c -= 1;
      res += '0';
    }
  } else {
    res += b.substr(0, c) + '.' + b.substr(c);
  }

  while(res[0] === '0') {
    res = res.substr(1);
  }
  if(res[0] === '.') {
    res = '0' + res;
  }
  if(res.indexOf('.') !== -1) {
    while(res[res.length - 1] === '0') {
      res = res.substr(0, res.length - 1);
    }
  }
  while(res[res.length - 1] === '.') {
    res = res.substr(0, res.length - 1);
  }
  print(res);


(function() {
  var count, lastItem, res, str;
  str = readline();
  lastItem = str[0];
  count = 0;
  res = [];
  str.split("").forEach(function(type) {
    if (type === lastItem) {
      return count++;
    } else {
      res.push(count);
      lastItem = type;
      return count = 1;
    }
  });
  res.push(count);
  count = 0;
  res.forEach(function(num) {
    return count += Math.ceil(num / 5);
  });
  write(count);
}).call(this);


;(function () {

	print((function () {
		for (var i = 1, str = readline(), l = str.length, ret = 0, p = 0; i < l; i++) {
			if (str[i] === str[i - 1]) {
				p++;
			} else {
				p = 0;
				ret++;
			}

			if (p >= 5) {
				ret++;
				p = 0;
			}
		}

		return ret + 1;
	}).apply(0));

}).call(this);


//137A
//Local attempts - 4
let arr = readline().split('');
let res = 0;
while(arr.length) {
    let curr = arr.shift();
    for(let i = 0; i < 4; i++) {
        if (arr[0] === curr) {
            arr.shift();
        } else {
            break;
        }
    }
    res++;
}
print(res);


var flowers = function(r, g, b){
	var count = 0;
	var colors = [r, g, b];
	for (var i in colors) {
		while (colors[i] > 3){
			colors[i] -= 3;
			count++;
		}
	}

	r = colors[0];
	g = colors[1];
	b = colors[2];

	if (r + g + b == 9){
		count += 3
	}
	else if (r + g + b >= 6){
		count += 2;
	}
	else{
		while (r >= 1 && g >= 1 && b >= 1){
			r -= 1;
			g -= 1;
			b -= 1;
			count++;
		}
	}

	return count;
};

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

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


var flowers = function(r, g, b){
	return Math.floor((r + g + b) / 3);
};

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

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


var flowers = function(r, g, b){
	var count = 0;
	var colors = [r, g, b];
	for (var i in colors) {
		while (colors[i] > 3){
			colors[i] -= 3;
			count++;
		}
	}

	r = colors[0];
	g = colors[1];
	b = colors[2];
	if (r + g + b >= 6){

		count += 2;
	}
	else{
		while (r >= 1 && g >= 1 && b >= 1){
			r -= 1;
			g -= 1;
			b -= 1;
			count++;
		}
	}

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

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


var flowers = function(r, g, b){
	var count = 0;
	var colors = [r, g, b];
	for (var i in colors) {
		while (colors[i] >= 3){
			colors[i] -= 3;
			count++;
		}
	}

	r = colors[0];
	g = colors[1];
	b = colors[2];
	while (r >= 1 && g >= 1 && b >= 1){
		r -= 1;
		g -= 1;
		b -= 1;
		count++;
	}

	return count;
};

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

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


var flowers = function(r, g, b){
	var count = 0;
	var colors = [r, g, b];
	for (var i in colors) {
		while (colors[i] > 3){
			colors[i] -= 3;
			count++;
		}
	}

	r = colors[0];
	g = colors[1];
	b = colors[2];
	while (r >= 1 && g >= 1 && b >= 1){
		r -= 1;
		g -= 1;
		b -= 1;
		count++;
	}

	return count;
};

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

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


var flowers = function(r, g, b){
	var count = 0;
	var colors = [r, g, b];
	for (var i in colors) {
		while (colors[i] > 3){
			colors[i] -= 3;
			count++;
		}
	}

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

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

	return count;
};

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

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


var flowers = function(r, g, b){
	var count = 0;
	var colors = [r, g, b];
	for (var i in colors) {
		while (colors[i] > 3){
			colors[i] -= 3;
			count++;
		}
	}

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

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

	return count;
};

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

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


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

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

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

	return count;
};

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

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


'use strict'

const {EOL} = require('os')

let ipt = ''
process.stdin.on('data', s => ipt += s)
process.stdin.on('end', () => {
  let [p1, p2, p3, p4, a, b] = ipt.split(EOL)[0].split(' ').map(v => parseInt(v))
  let c = 0
  for (let i = a; i <= b; i++) {
    i % p4 % p3 % p2 % p1 == i && c++
  }

  console.log(c)
})


print(Math.ceil((-1 + Math.sqrt(1 + 8*+readline()))/2));


const https = require('https');

// Get process.stdin as the standard input object.
var standard_input = process.stdin;

// Set input character encoding.
standard_input.setEncoding('utf-8');

// Prompt user to input data in console.

// When user input data and click enter key.
standard_input.on('data', function (data) {

    // User input exit.
    if(data === 'exit\n'){
        // Program exit.
        console.log("User input complete, program exit.");
        process.exit();
    }else
    {
        // Print user input in console.
        console.log('User Input Data : ' + data);
    }
});


Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
//atcoderのサンプルは最後に改行入れること
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    myout("1");
}


// Get process.stdin as the standard input object.
var standard_input = process.stdin;

// Set input character encoding.
standard_input.setEncoding('utf-8');

// Prompt user to input data in console.

// When user input data and click enter key.
standard_input.on('data', function (data) {

    // User input exit.
    if(data === 'exit\n'){
        // Program exit.
        console.log("User input complete, program exit.");
        process.exit();
    }else
    {
		//variable: data
		var url = "https://oeis.org/search?fmt=json&q=id:" + data;
		console.log(url);
		    }
});


Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
//atcoderのサンプルは最後に改行入れること
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
    myout("0");
}


const https = require('https');

// Get process.stdin as the standard input object.
var standard_input = process.stdin;

// Set input character encoding.
standard_input.setEncoding('utf-8');

// Prompt user to input data in console.

// When user input data and click enter key.
standard_input.on('data', function (data) {

    // User input exit.
    if(data === 'exit\n'){
        // Program exit.
        console.log("User input complete, program exit.");
        process.exit();
    }else
    {
		//variable: data
		var url = "https://oeis.org/search?fmt=json&q=1:" + data;
		console.log(url)
    }
});


const request = require("request");
// Get process.stdin as the standard input object.
var standard_input = process.stdin;

// Set input character encoding.
standard_input.setEncoding('utf-8');

// Prompt user to input data in console.

// When user input data and click enter key.
standard_input.on('data', function (data) {

    // User input exit.
    if(data === 'exit\n'){
        // Program exit.
        console.log("User input complete, program exit.");
        process.exit();
    }else
    {
		//variable: data
		var url = "https://oeis.org/search?fmt=json&q=id:" + data;
		https.get(url, (resp) => {
			console.log(resp);
		});

    }
});


const request = require("request");
// Get process.stdin as the standard input object.
var standard_input = process.stdin;

// Set input character encoding.
standard_input.setEncoding('utf-8');

// Prompt user to input data in console.

// When user input data and click enter key.
standard_input.on('data', function (data) {

    // User input exit.
    if(data === 'exit\n'){
        // Program exit.
        console.log("User input complete, program exit.");
        process.exit();
    }else
    {
		//variable: data
		var url = "https://oeis.org/search?fmt=json&q=id:" + data;
		request.get(url, (error, response, body) => {
			let json = JSON.parse(body);
	  		console.log(json);
		});
    }
});


var input = readline();

var s = readline();
var k = s.slice(s.length - 1);
print(k % 2 == 0 ? 0 : 1);


const https = require('https');

https.get('https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY', (resp) => {
  let data = '';

  // A chunk of data has been recieved.
  resp.on('data', (chunk) => {
    data += chunk;
  });

  // The whole response has been received. Print out the result.
  resp.on('end', () => {
    console.log(JSON.parse(data).explanation);
  });

}).on("error", (err) => {
  console.log("Error: " + err.message);
});


// Get process.stdin as the standard input object.
const https = require("https");
var standard_input = process.stdin;

// Set input character encoding.
standard_input.setEncoding('utf-8');

// Prompt user to input data in console.

// When user input data and click enter key.
standard_input.on('data', function (data) {

    // User input exit.
    if(data === 'exit\n'){
        // Program exit.
        console.log("User input complete, program exit.");
        process.exit();
    }else
    {
		//variable: data
		var url = "https://oeis.org/search?fmt=json&q=id:" + data;
		console.log(url);
		https.get(url, res => {
  res.setEncoding("utf8");
  let body = "";
  res.on("data", data => {
    body += data;
  });
  res.on("end", () => {
    body = JSON.parse(body);
    console.log(body);
  });
});
	}
});


const https = require('https');

// Get process.stdin as the standard input object.
var standard_input = process.stdin;

// Set input character encoding.
standard_input.setEncoding('utf-8');

// Prompt user to input data in console.

// When user input data and click enter key.
standard_input.on('data', function (data) {

    // User input exit.
    if(data === 'exit\n'){
        // Program exit.
        console.log("User input complete, program exit.");
        process.exit();
    }else
    {
		//variable: data
		var url = "https://oeis.org/search?fmt=json&q=id:" + data;
		https.get(url, (resp) => {
			console.log(resp);
		});

    }
});


// Get process.stdin as the standard input object.
const https = require("https");
var standard_input = process.stdin;

// Set input character encoding.
standard_input.setEncoding('utf-8');

// Prompt user to input data in console.

// When user input data and click enter key.
standard_input.on('data', function (data) {

    // User input exit.
    if(data === 'exit\n'){
        // Program exit.
        console.log("User input complete, program exit.");
        process.exit();
    }else{
		var r = int(data[6])
		console.log(r % 2);
	}
});


'use strict';

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

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
  inputString += inputStdin;
});

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

  main();
});

function readline() {
  return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  const x = readline();
  let z = parseInt(x, 16) % 2;
  process.stdout.write(z.toString()); // without auto '\n' (newline)

  // console.log(z); // with auto '\n' (newline)
}


var input = readline();

var numbers = parseInt(input.split("A").join(""));
print(numbers % 2 === 0 ?  0: 1);


// Get process.stdin as the standard input object.
var standard_input = process.stdin;

// Set input character encoding.
standard_input.setEncoding('utf-8');

// Prompt user to input data in console.

// When user input data and click enter key.
standard_input.on('data', function (data) {

    // User input exit.
    if(data === 'exit\n'){
        // Program exit.
        console.log("User input complete, program exit.");
        process.exit();
    }else{
		var r = data[6] - '0'
		console.log(r % 2);
	}
});


//var input = readline();
var s = readline();
var k = s.slice(s.length - 1);
print(k % 2 == 0 ? 0 : 1);


function ansa(h,m){

    var t = 0;
    while(true){
      if(((h % 10) === (m / 10)) && ((h / 10) === (m % 10))){
        print(t);
        return;
      }
      m++;
      if(m === 60){
        h++;
        m = 0;
        if(h === 24) h = 0;
      }
      t++;
    }
}

//ansa(6,[1,1,1,1,1,1],[5,5,5,5,5,5])

var line = readline();

var h = parseInt(line[0] + line[1]);
var m = parseInt(line[3] + line[4]);
// var a = readline().split(" ");
// for(var i = 0 ; i < a.length ; i++) a[i] = parseInt(a[i]);
// var b = readline().split(' ');
// for(var i = 0 ; i < b.length ; i++) b[i] = parseInt(b[i]);

ansa(h,m);


function ansa(h,m){

    var t = 0;
    while(true){
      if((h % 10 === m / 10) && (a / 10 === b % 10)){
        print(t);
        return;
      }
      m++;
      if(b === 60){
        h++;
        if(h === 24) h = 0;
      }
      t++;
    }
}

//ansa(6,[1,1,1,1,1,1],[5,5,5,5,5,5])

var line = readline();

var h = parseInt(parseInt(line[0]) + "" + parseInt(line[1]));
var m = parseInt(parseInt(line[3]) + "" + parseInt(line[4]));
// var a = readline().split(" ");
// for(var i = 0 ; i < a.length ; i++) a[i] = parseInt(a[i]);
// var b = readline().split(' ');
// for(var i = 0 ; i < b.length ; i++) b[i] = parseInt(b[i]);

ansa(h,m);


function ansa(h,m){

    var t = 0;
    while(true){
      if(((h % 10) === (m / 10)) && ((h / 10) === (m % 10))){
        print(t);
        return;
      }
      m++;
      if(m === 60){
        h++;
        if(h === 24) h = 0;
      }
      t++;
    }
}

//ansa(6,[1,1,1,1,1,1],[5,5,5,5,5,5])

var line = readline();

var h = parseInt(parseInt(line[0]) + "" + parseInt(line[1]));
var m = parseInt(parseInt(line[3]) + "" + parseInt(line[4]));
// var a = readline().split(" ");
// for(var i = 0 ; i < a.length ; i++) a[i] = parseInt(a[i]);
// var b = readline().split(' ');
// for(var i = 0 ; i < b.length ; i++) b[i] = parseInt(b[i]);

ansa(h,m);


function ansa(h,m){

    var t = 0;
    while(true){
      if((h % 10 === m / 10) && (h / 10 === m % 10)){
        print(t);
        return;
      }
      m++;
      if(m === 60){
        h++;
        if(h === 24) h = 0;
      }
      t++;
    }
}

//ansa(6,[1,1,1,1,1,1],[5,5,5,5,5,5])

var line = readline();

var h = parseInt(parseInt(line[0]) + "" + parseInt(line[1]));
var m = parseInt(parseInt(line[3]) + "" + parseInt(line[4]));
// var a = readline().split(" ");
// for(var i = 0 ; i < a.length ; i++) a[i] = parseInt(a[i]);
// var b = readline().split(' ');
// for(var i = 0 ; i < b.length ; i++) b[i] = parseInt(b[i]);

ansa(h,m);


var arr = readline().split(':');
var h = parseInt(arr[0]);
var m = parseInt(arr[1]);

var isP = function (s)
{
    for (var i = 0; i < s.length / 2; i ++)
    {
        if (s.charAt(i) != s.charAt(s.length - i - 1))
        {
            return false;
        }
    }
    return true;
}
var zeroPad = function (num, places)
{
    var zero = places - num.toString().length + 1;
    return Array(+(zero > 0 && zero)).join("0") + num;
}

var i = 0;
while(true)
{
    var str = zeroPad(h, 2)+zeroPad(m, 2);
    // print(str);
    if (isP(str))
    {
        break;
    }
    m ++;
    if (m >= 60)
    {
        m %= 60;
        h ++;
        h %= 24;
    }
    i ++;
}
print(i);


function ansa(h,m){

    var t = 0;
    while(true){
      if(((Math.floor(h % 10)) === (Math.floor(m / 10))) && (Math.floor((h / 10)) === (Math.floor(m % 10)))){
        print(t);
        return;
      }
      m++;
      if(m === 60){
        h++;
        m = 0;
        if(h === 24) h = 0;
      }
      t++;
    }
}

//ansa(6,[1,1,1,1,1,1],[5,5,5,5,5,5])

var line = readline();

var h = parseInt(line[0] + line[1]);
var m = parseInt(line[3] + line[4]);
// var a = readline().split(" ");
// for(var i = 0 ; i < a.length ; i++) a[i] = parseInt(a[i]);
// var b = readline().split(' ');
// for(var i = 0 ; i < b.length ; i++) b[i] = parseInt(b[i]);

ansa(h,m);


const rd = readline;
const wr = write;
const pr = print;

var parties = 0;
var pi = [];
parties = +rd();
pi = rd().split(' ').map(v => +v);
var cannot = true;
var curr = pi[0];
var i = 1;
var k = 1, ki = [1];
var total = pi.reduce((sum, curr) => {return sum + curr;}, 0);
while(cannot && i < pi.length) {
	if ((pi[0] >> 1) >= pi[i]) {
        ki.push(i + 1);
        k++;
		curr+= pi[i];
	}
	i++;
	if ((curr << 1) > total) {
	   cannot = false;
	}
}
if (cannot) {
	wr('0');
} else {
    pr(k);
	wr(ki.join(' '));
}


"use strict";

var main = function() {
    var n = +rd();
    var A = rdAr().map((v, i) => [v, i+1]);
    var B = [A[0]].concat(A.slice(1).sort((a, b) => a[0] - b[0]));
    var S = A.reduce((a, v) => v[0] + a, 0);
   //pr(S);
    var pA = A[0][0];
    var H = S/2.0;
    var s = 0;
    var res = [];
    for (var i = 0; i < B.length; ++i) {
        if (s> 0 && pA < 2*B[i][0]) {
            break;
        }
        s += B[i][0];
        res.push(B[i][1]);
        if (s > H) {
            pr(res.length);
            prAr(res);
            return;
        }
    }
    wr(0);
};

const rd = readline;
const wr = write;
const pr = print;
const rdAr = () => rd().split(' ').map(v => +v);
const prAr = (a) => pr(a.join(' '));
const cmpLt = (a, b) => a - b;
const cmpGt = (a, b) => b - a;
Array.prototype.sortLt = function() { return this.sort(cmpLt); };
Array.prototype.sortGt = function() { return this.sort(cmpGt); };
const crAr = function(length, ...fillArgs) { return new Array(length).fill(...fillArgs); };

main();


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);
  let a = arr[0];
  let b = 0;
  let mid = Math.floor(a / 2);
  const ans = [1];

  for (let i = 1; i < arr.length; i++) {
    if (arr[i] > mid) {
      b += arr[i];
    }
    else {
      a += arr[i];
      ans.push(i + 1);
    }
  }

  if (a <= b) {
    console.log(0);
  }
  else {
    console.log(ans.length);
    console.log(ans.join(' '));
  }

  c++;
});


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);
  let a = arr[0];
  let b = 0;
  let mid = Math.floor(a / 2);
  const ans = [1];

  for (let i = 1; i < arr.length; i++) {
    if (arr[i] > mid) {
      b += arr[i];
    }
    else {
      a += arr[i];
      ans.push(i + 1);
    }
  }

  if (a <= b) {
    console.log(0);
  }
  else {
    console.log(ans.join(' '));
  }

  c++;
});


function readArr()
{
    return readline().split(' ').map(function(x){return +x;})
}

function readArr1()
{
    return readline().split(' ')
}

n=+readline()
c=new Array(n)
for (i=0;i<n;i++)
{
    c[i]=readArr1()
}
res=[]
for (i=0;i<n;i++)
{
    for (i1=0;i1<6;i1++)
    {
        res.push(c[i][i1])
        if (n>1)
        for (j=0;j<n;j++)
        {
            if (j==i)
                continue
            for (j1=0;j1<6;j1++)
            {
                res.push(c[i][i1]+c[j][j1])
                if (n>2)
                for (k=0;k<n;k++)
                {
                    if (k==j||k==i)
                        continue
                    for (k1=0;k1<6;k1++)
                    {
                        res.push(c[i][i1]+c[j][j1]+c[k][k1])
                    }
                }
            }
        }
    }
}
res=res.map(function(x){return(+x);})
function cmp(a,b){return a-b;}
res.sort(cmp)
ans=0
for (i=0;i<res.length-1;i++)
{
    if (res[i+1]-res[i]>1)
    {
        ans=res[i]
        break
    }
}
print(ans)


function readArr()
{
    return readline().split(' ').map(function(x){return +x;})
}

function readArr1()
{
    return readline().split(' ')
}

n=+readline()
c=new Array(n)
for (i=0;i<n;i++)
{
    c[i]=readArr1()
}
res=[]
for (i=0;i<n;i++)
{
    for (i1=0;i1<6;i1++)
    {
        res.push(c[i][i1])
        if (n>1)
        for (j=0;j<n;j++)
        {
            if (j==i)
                continue
            for (j1=0;j1<6;j1++)
            {
                res.push(c[i][i1]+c[j][j1])
                if (n>2)
                for (k=0;k<n;k++)
                {
                    if (k==j||k==i)
                        continue
                    for (k1=0;k1<6;k1++)
                    {
                        res.push(c[i][i1]+c[j][j1]+c[k][k1])
                    }
                }
            }
        }
    }
}
res=res.map(function(x){return(+x);})
function cmp(a,b){return a-b;}
res.sort(cmp)
ans=res[res.length-1]
for (i=0;i<res.length-1;i++)
{
    if (res[i+1]-res[i]>1)
    {
        ans=res[i]
        break
    }
}
print(ans)


function readArr()
{
    return readline().split(' ').map(function(x){return +x;})
}

function readArr1()
{
    return readline().split(' ')
}

n=+readline()
c=new Array(n)
for (i=0;i<n;i++)
{
    c[i]=readArr1()
}
res=[]
for (i=0;i<n;i++)
{
    for (i1=0;i1<6;i1++)
    {
        res.push(c[i][i1])
        if (n>1)
        for (j=0;j<n;j++)
        {
            if (j==i)
                continue
            for (j1=0;j1<6;j1++)
            {
                res.push(c[i][i1]+c[j][j1])
                if (n>2)
                for (k=0;k<n;k++)
                {
                    if (k==j||k==i)
                        continue
                    for (k1=0;k1<6;k1++)
                    {
                        res.push(c[i][i1]+c[j][j1]+c[k][k1])
                    }
                }
            }
        }
    }
}
res=res.map(function(x){return(+x);})
function cmp(a,b){return a-b;}
res.sort(cmp)
ans=0
for (i=0;i<res.length;i++)
{
    if (i)
    if (res[i]-res[i-1]>1)
    {
        ans=res[i]
        break
    }
    if (!i)
    {
        if (res[i]>1)
        {
            ans=0
            break
        }
    }
}
print(ans)


var triangles = readline().split(' '),
    a = parseInt(triangles[0]),
    b = parseInt(triangles[1]),
    curr = [a, a, b],
    step = 1,
    i = 0,
    j = 0;

while (curr[0] !== b && curr[1] !== b) {
    i = Math.abs(1 - i);
    j = Math.abs(1 - i);
    curr[i] = Math.abs(curr[j] - b) + 1;
    while (curr[0] + curr[1] <= b || Math.abs(curr[0] - curr[1]) >= b) {
        curr[i]++;
    }
    step++;
}

print(step);


var triangles = readline().split(' '),
	a = parseInt(triangles[0]),
	b = parseInt(triangles[1]),
	bottomUp = [b, b, b],
	step = 0,
	i = 0,
	j = 0,
	k = 0;

while(bottomUp[0] < a || bottomUp[1] < a || bottomUp[2] < a) {
	for (i = 0; i < 3; i++) {
		j = (i + 1) % 3;
		k = (i + 2) % 3;
		bottomUp[i] = Math.min(a, bottomUp[j] + bottomUp[k] - 1);
		step++;
		if (Math.abs(a - bottomUp[j]) < bottomUp[k] && bottomUp[k] < a + bottomUp[j]) {
			bottomUp[i] = a;
			if (bottomUp[j] < a) {
				bottomUp[j] = a;
				step++;
			}
			if (bottomUp[k] < a) {
				bottomUp[k] = a;
				step++;
			}
			break;
		}
	}
}
print(step);


let i = ''

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

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

    let a = parseInt(lines[0].split(" ")[0])
    let ta = parseInt(lines[0].split(" ")[1])

    let b = parseInt(lines[1].split(" ")[0])
    let tb = parseInt(lines[1].split(" ")[1])

    let startingHour = parseInt(lines[2].split(":")[0])
    let startingMinute = parseInt(lines[2].split(":")[1])
    let startingTime = (startingHour * 60) + startingMinute

    let startOfShift = 5 * 60
    let endOfShift = 23 * 60 + 59

    let count = 0

    for (i = startOfShift; i <= endOfShift; i = i+b) {
        if ( i < startingTime + ta && i + tb > startingTime ) {
            count ++
        }
    }

    console.log(count)
 })


function getInput() {
    var line = readline();
    var lines = [line];
    while (line = readline()) {
        lines.push(line);
    }
    return lines;
}

function main() {
    var lines = getInput().map(item => item.split(' '));
    var durationA = Number(lines[0][1]);
    var durationB = Number(lines[1][1]);
    var repeatB = Number(lines[1][0]);

    // first bus run at 5:00.
    var firstBusTime = 5 * 60;
    // start time in minutes.
    var startTime = lines[2][0].split(':').map(Number);
    // after 00
    if (startTime[0] < 5) {
        startTime[0] *= 24;
    }
    startTime = startTime[0] * 60 + startTime[1];

    var count = 0;
    var firstBBusTime = firstBusTime;
    while((firstBBusTime + durationB) <= startTime) {
        firstBBusTime += repeatB;
    }

    while(firstBBusTime < (startTime + durationA)) {
        firstBBusTime += repeatB;
        count++;
    }

    print(count);
}

main();


function getInput() {
    var line = readline();
    var lines = [line];
    while (line = readline()) {
        lines.push(line);
    }
    return lines;
}

function main() {
    var lines = getInput().map(item => item.split(' '));
    var durationA = Number(lines[0][1]);
    var durationB = Number(lines[1][1]);
    var repeatB = Number(lines[1][0]);

    // first bus run at 5:00.
    var firstBusTime = 5 * 60;
    // start time in minutes.
    var startTime = lines[2][0].split(':').map(Number);
    startTime = startTime[0] * 60 + startTime[1];

    var count = 0;
    var firstBBusTime = firstBusTime;
    while((firstBBusTime + durationB) < startTime) {
        firstBBusTime += repeatB;
    }

    while(firstBBusTime < (startTime + durationA)) {
        firstBBusTime += repeatB;
        count++;
    }

    print(count);
}

main();


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

var n = str[0], a = str[1], b = str[2], i = 0, j = 0, arr = [], count = 1, x = false;

while (i !== n) {
	i++;
	arr.push(i);
};

while (x !== true) {
	if ((arr[j] == a && arr[j + 1] == b) || (arr[j] == b && arr[j + 1] == a)) {
		if (arr.length == 2) {
			print('Final!');
		} else {
			print(count);
		};

		x = true;
		break;
	} else if ((arr[j] == a && arr[j + 1] !== b) || (arr[j] == b && arr[j + 1] !== a)) {
		arr.splice(j + 1, 1);
	} else if ((arr[j + 1] == a && arr[j] !== b) || (arr[j + 1] == b && arr[j] !== a)) {
		arr.splice(j, 1);
	} else {
		arr.splice(j + 1, 1);
	};

	if (j == arr.length - 1) {
		j = 0;
		count++;
	} else {
		j++;
	};
};


a b 3 4

1 a 3 4 5 b 7 8
a 3 b 7
a b

1 2 3 4 b 6 a 8
1 3 b a

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

var n = str[0], a = str[1], b = str[2], i = 0, j = 0, arr = [], count = 1, x = false;

while (i !== n) {
	i++;
	arr.push(i);
};

while (x !== true) {
	if ((arr[j] == a && arr[j + 1] == b) || (arr[j] == b && arr[j + 1] == a)) {
		if (arr.length == 2) {
			print('Final!');
		} else {
			print(count);
		};

		x = true;
		break;
	} else if ((arr[j] == a && arr[j + 1] !== b) || (arr[j] == b && arr[j + 1] !== a)) {
		arr.splice(j + 1, 1);
	} else if ((arr[j + 1] == a && arr[j] !== b) || (arr[j + 1] == b && arr[j] !== a)) {
		arr.splice(j, 1);
	} else {
		arr.splice(j + 1, 1);
	};

	if (j == arr.length - 1) {
		j = 0;
		count++;
	} else {
		j++;
	};
};


function gcd(a, b) {
    return b == 0 ? a : gcd(b, a % b);
}
var inp = readline().split(' ').map(Number);
var x = inp[0], y = inp[1], a = inp[2], b = inp[3];
var i = 1, g = gcd(Math.max(x, y), Math.min(x, y)), lcm = (x / g) * y;
print(Math.floor(b / lcm) - Math.floor((a - 1) / lcm));


function gcd(a, b){
	return b===0 ? a : gcd(b, a%b);
}
print(function(x, y, a, b){
	var ans = x*y/gcd(x, y);
	return Math.floor(b/ans)-Math.floor((a-1)/ans);
}.apply(0, readline().split(' ').map(Number)));


var input = readline().split(' ').map(Number);
var x = input[0], y = input[1], a = input[2], b = input[3];
var i = 1, lcm = 0;
while (true) {
    if (x * i % y == 0) {
        lcm = x * i;
        break;
    }
    i++;
}
var cm = 0;
for (var i = a; i <= b; i++) {
    if (i % lcm === 0) {
        cm = i;
        break;
    }
}
print(cm == 0 ? 0 : Math.floor((b - Math.max(cm, a)) / lcm + 1));


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

;(function () {

	var x = readline().split(' ');
	var y = +x[1];
	var a = +x[2];
	var b = +x[3];
	x = +x[0];

	var l = lcm(x, y);

	print( Math.floor( b / l) - Math.floor( (a - 1) / l) );

}).call(this);


function gcd(a, b){
	return a%b===0 ? b : gcd(b, a%b);
}
print(function(x, y, a, b){
	var ans = x*y/gcd(x, y);
	return Math.floor(b/ans)-Math.floor((a-1)/ans);
}.apply(0, readline().split(' ').map(Number)));


var input = readline().split(' ').map(Number);
var x = input[0], y = input[1], a = input[2], b = input[3];
var i = 1, lcm = 0;
while (true) {
    if (x * i % y == 0) {
        lcm = x * i;
        break;
    }
    i++;
}
var cm = lcm;
for (var i = a; i < b; i++) {
    if (i % lcm == 0) {
        cm = i;
        break;
    }
}
print(Math.floor((b - Math.max(cm, a)) / lcm + 1));


var input = readline().split(' ').map(Number);
var x = input[0], y = input[1], a = input[2], b = input[3];
var i = 1, lcm = 0;
while (true) {
    if (x * i % y == 0) {
        lcm = x * i;
        break;
    }
    i++;
}
var cm = 0;
for (var i = a; i < b; i++) {
    if (i % lcm == 0) {
        cm = i;
        break;
    }
}
print(cm == 0 || (b - cm) / lcm + 1);


var input = readline().split(' ').map(Number);
var x = input[0], y = input[1], a = input[2], b = input[3];
var i = 1, lcm = 0;
while (true) {
    if (x * i % y == 0) {
        lcm = x * i;
        break;
    }
    i++;
}
var cm = 0;
for (var i = a; i < b; i++) {
    if (i % lcm == 0) {
        cm = i;
        break;
    }
}
print(cm == 0 || Math.floor((b - cm) / lcm + 1));


var input = readline().split(' ').map(Number);
var x = input[0], y = input[1], a = input[2], b = input[3];
var i = 1, lcm = 0;
while (true) {
    if (x * i % y == 0) {
        lcm = x * i;
        break;
    }
    i++;
}
var cm = 0;
for (var i = a; i < b; i++) {
    if (i % lcm == 0) {
        cm = i;
        break;
    }
}
print(cm == 0 ? 0 : Math.floor((b - cm) / lcm + 1));


;(function () {

	var x = readline().split(' ');
	var y = +x[1];
	var a = +x[2];
	var b = +x[3];
	x = +x[0];

	var t = 0;
	for (var i = a; i <= b; i++) {
		if (i % x == 0 && i % y == 0) t++;
	}

	print(t);

}).call(this);


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

function phi(n)
{
    var res=1;
    for (var i=2; i*i<=n; i++)
    {
        if (n%i==0)
        {
            var z1=1;
            while(n%i==0)
            {
                z1*=i;
                n/=i;
            }
            res*=(z1-z1/i);
        }
    }
    if (n>1)
    {
        res*=(n-1);
    }
    return res;
}

function f(n,k)
{
    if (k==0){return n;}
    if (n==1){return 1;}
    if (k%2==0){return f (n,k-1);}
    return f(phi(n),k-1);
}

print(f(n,k)%1000000007)


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

function phi(n)
{
    var res=1;
    for (var i=2; i*i<=n; i++)
    {
        if (n%i==0)
        {
            var z1=1;
            while(n%i==0)
            {
                z1*=i;
                n/=i;
            }
            res*=(z1-z1/i);
        }
    }
    if (n>1)
    {
        res*=(n-1);
    }
    return res;
}

function f(n,k)
{
    if (k==0){return n;}
    if (n==1){return 1;}
    if (k%2==0){return f (n,k-1);}
    return f(phi(n),k-1);
}

print(f(n,k))


const fs = require("fs");

const input = fs.readFileSync(0, "utf8").trim().split("\n");

const testCases = [];

function parseInput() {
  // T = parseInt(input[0]);
  // let index = 0;

  // for (let i = 0; i < T; i++) {
  //   index++;
  const [n, m] = input[index].split(" ").map((item) => BigInt(item));
  const testCase = {
    n,
    m,
  };
  testCases.push(testCase);
  // }
}

function solution(testCase) {
  const { n, m } = testCase;

  const modulo = 998244353n;

  let result = 0n;
  let toRemove = m;
  const primes = [];
  let primeProd = 1n;

  result = ((m ** (n + 1n) - 1n) / (m - 1n) - m - 1n) % modulo;

  for (let l = 2n; l <= n; l++) {
    if (!primes.find((p) => l % p == 0)) {
      primes.push(l);
      primeProd *= l;
    }
    if (toRemove) {
      toRemove *= m / primeProd;
    }
    if (toRemove == 0) break;
    result = (result - toRemove) % modulo;
  }

  console.log(((result + modulo) % modulo).toString());
}

parseInput();

testCases.forEach(solution);


const fs = require("fs");

const input = fs.readFileSync(0, "utf8").trim().split("\n");

const testCases = [];

function parseInput() {
  let index = 0;

  // T = parseInt(input[0]);

  // for (let i = 0; i < T; i++) {
  //   index++;
  const [n, m] = input[index].split(" ").map((item) => BigInt(item));
  const testCase = {
    n,
    m,
  };
  testCases.push(testCase);
  // }
}

function solution(testCase) {
  const { n, m } = testCase;

  const modulo = 998244353n;

  let result = 0n;
  let toRemove = m;
  const primes = [];
  let primeProd = 1n;

  let exp = m;
  for (let l = 2n; l <= n; l++) {
    exp = (exp * m) % modulo;
    result = (result + exp) % modulo;
  }

  for (let l = 2n; l <= n; l++) {
    if (!primes.find((p) => l % p == 0)) {
      primes.push(l);
      primeProd *= l;
    }
    if (toRemove) {
      toRemove *= m / primeProd;
    }
    if (toRemove == 0) break;
    result = (result - toRemove) % modulo;
  }

  console.log(((result + modulo) % modulo).toString());
}

parseInput();

testCases.forEach(solution);


'use strict';

var fs = require('fs');

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

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const [n, m] = rns();
  let pre = 1,
      M = mod(m),
      res = 0,
      ans = M,
      ans1 = M;
  const p = getPrimes(n + 10);
  for (let i = 2; i <= n; i++) {
    if (pre <= m && p[i]) pre = pre * i;
    if (pre > m) {
      ans = 0;
    } else {
      ans = mul(ans, Math.floor(m / pre));
    }
    ans1 = mul(ans1, M);
    res = mod(res + ans1 - ans);
  }
  return res;
}
function getPrimes(n) {
  const nums = new Array(n + 1).fill(1);
  nums[0] = nums[1] = 0;
  const primes = [];
  for (let i = 2; i <= n; i++) {
    if (nums[i]) primes.push(i);
    for (let j = 0; primes[j] <= n / i; j++) {
      nums[primes[j] * i] = 0;
      if (i % primes[j] === 0) break;
    }
  }
  return nums;
}
const MOD = 998244353;
function mod(num) {
  if (num >= MOD) return num % MOD;else if (num < 0) return (num % MOD + MOD) % MOD;
  return num;
}
function mul(...args) {
  if (args.length === 0) throw new Error('参数不能为空');
  if (args.length === 1) return args[0];
  const [a, b] = args;
  if (args.length > 2) return mul(mul(a, b), ...args.slice(2));
  return (Math.floor(a / 65536) * b % MOD * 65536 + (a & 65535) * b) % MOD;
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = 1;
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) ; else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\r?\n/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();


const fs = require("fs");

const input = fs.readFileSync(0, "utf8").trim().split("\n");

const testCases = [];

function parseInput() {
  let index = 0;

  const [n, m] = input[index].split(" ").map((item) => BigInt(item));
  const testCase = {
    n,
    m,
  };

  testCases.push(testCase);
}

function solution(testCase) {
  const { n, m } = testCase;

  const modulo = 998244353n;

  let result = 0n;
  let toRemove = m;
  const primes = [];
  let primeProd = 1n;
  let exp = m;

  for (let l = 2n; l <= n; l++) {
    if (!primes.find((p) => l % p == 0)) {
      primes.push(l);
      primeProd *= l;
    }
    if (toRemove) {
      toRemove *= m / primeProd;
    }
    exp = exp * m;
    result = (result + exp - toRemove + modulo) % modulo;
  }

  console.log((result % modulo).toString());
}

parseInput();

testCases.forEach(solution);


const fs = require("fs");

const input = fs.readFileSync(0, "utf8").trim().split("\n");

const testCases = [];

function parseInput() {
  // T = parseInt(input[0]);
  let index = 0;

  // for (let i = 0; i < T; i++) {
  //   index++;
  const [n, m] = input[index].split(" ").map((item) => BigInt(item));
  const testCase = {
    n,
    m,
  };
  testCases.push(testCase);
  // }
}

function solution(testCase) {
  const { n, m } = testCase;

  const modulo = 998244353n;

  let result = 0n;
  let toRemove = m;
  const primes = [];
  let primeProd = 1n;

  result = ((m ** (n + 1n) - 1n) / (m - 1n) - m - 1n) % modulo;

  for (let l = 2n; l <= n; l++) {
    if (!primes.find((p) => l % p == 0)) {
      primes.push(l);
      primeProd *= l;
    }
    if (toRemove) {
      toRemove *= m / primeProd;
    }
    if (toRemove == 0) break;
    result = (result - toRemove) % modulo;
  }

  console.log(((result + modulo) % modulo).toString());
}

parseInput();

testCases.forEach(solution);


function cmp(a,b)
{
    return a-b;
}

var s=readline().split(' ')
var n=+s[0]
var k=+s[1]
var m=+s[2]
var t=readline().split(' ').map(function(v){return +v;})
t.sort(cmp)
var sum=0;
for (var i=0;i<k;i++){sum+=t[i];}
var res=0;
for (var i=0;i<=n;i++)
{
    var kol=i*(k+1);
    var ti=sum*i;
    if (ti>m){break;}
    for (var j=0;j<k;j++)
    {
        for (var x=i;x<n;x++)
        {
            if (ti+t[j]<=m){ti+=t[j];kol++;}
        }
    }
    if (kol>res){res=kol;}
}
print(res)


const golorp = readline().match(/^\?\((.+)\):-(.+)\.$/);
const expression = golorp[1];
const conditions = golorp[2].split(",").map(condition => {
  const match = condition.match(/[<>]/);
  const index = match.index;
  const left = condition.substring(0, index);
  const right = condition.substring(index + 1);
  return match[0] === ">" ? [right, left] : [left, right];
});
const sequence = expression.match(/_+/g);
const variables = Array.from(new Set(sequence));
const nodes = new Map;
const values = new Map;
for (var variable of variables) {
  nodes.set(variable, [variable, new Set, new Set]);
  values.set(variable, -1);
}
for (var condition of conditions) {
  var less = condition[0];
  var greater = condition[1];
  nodes.get(less)[1].add(greater);
  nodes.get(greater)[2].add(less);
}
const seen = new Set;
for (var i = 10; i; i--)
  for (var from of variables) {
    if (seen.has(from)) continue;
    var fromNode = nodes.get(from);
    if (!fromNode[2].size) {
      seen.add(from);
      var newValue = values.get(from) + 1;
      values.set(from, newValue);
      for (var to of fromNode[1]) {
        if (newValue > values.get(to)) values.set(to, newValue);
        nodes.get(to)[2].delete(from);
      }
    }
  }
var found = true;
for (var variable of variables)
  if (!seen.has(variable) || values.get(variable) >= 10) {
    found = false;
    break;
  }
print(found ? sequence.map(variable => values.get(variable)).join("") : "false");


var text = readline().split(':-'), i;
var left = text[0].split(/[^_]/).filter(function(x){return x.length != 0;});
var right = text[1].split(/[^_<>]/).filter(function(x){return x.length != 0;});
var top = 0, nxt = new Array(), to = new Array(), head = new Array(), dgree = new Array(), as = new Array();
for(i = 0; i < 1024; ++i) nxt[i] = to[i] = head[i] = dgree[i] = as[i] = 0;
function addedge(te, sym)
{
	var val = te.split(sym);
	if(sym === '>') val = [val[1].length, val[0].length];
	else val = [val[0].length, val[1].length];
	top++;
	nxt[top] = head[val[0]];
	to[top] = val[1];
	head[val[0]] = top;
	++dgree[val[1]];
}
function solve(okback, nsback)
{
	var que = new Array(), lead = 1, tail = 0, now;
	for(i = 1; i < 1024; ++i) if(!dgree[i]) que[++tail] = i;
	for(; lead <= tail; ++lead)
	{
		now = que[lead];
		for(i = head[now]; i; i = nxt[i])
		{
			as[to[i]] = Math.max(as[to[i]], as[now] + 1);
			if(!--dgree[to[i]]) que[++tail] = to[i];
		}
	}
	if(dgree.reduce(function(l, r){return l || (r != 0);}) || as.reduce(function(l, r){return l || (r > 9);}))	nsback();
	else okback();
}
for(i = 0; i < right.length; ++i)
	if(right[i].indexOf('>') != -1) addedge(right[i], '>');
	else addedge(right[i], '<');
var ans = "";
solve(function(){for(i = 0; i < left.length; ++i) ans = ans + as[left[i].length];},function(){ans = 'false'});
write(ans, '\n');


const golorp = readline().match(/^\?\((.+)\):-(.+)\.$/);
const expression = golorp[1];
const conditions = golorp[2].split(",");
const sequence = expression.match(/_+/g);
const variables = Array.from(new Set(sequence));
const variableCount = variables.length;
const values = new Map;
const expressionFunction = new Function(...variables, `return ${expression};`);
const conditionToString = condition => " && " + condition[2];
const conditionsFunctions = variables.reduceRight((previous, current, index) => {
  previous[index] = previous[index + 1].filter(condition => condition[0] != current && condition[1] != current);
  return previous;
}, (() => {
  const result = new Array(variableCount + 1);
  result[variableCount] = conditions.map(condition => {
    const index = condition.match(/[<>]/).index;
    return [condition.substring(0, index), condition.substring(index + 1), condition];
  });
  return result;
})()).map(conditions => new Function(...variables, `return true${conditions.map(conditionToString).join("")};`));

function toValues(variables) {
  return variables.map(variable => values.get(variable));
}

(() => {
  try {
    (function search(depth) {
      const args = toValues(variables);
      if (!conditionsFunctions[depth](...args)) return;
      if (depth == variableCount) {
        if (Number.isFinite(expressionFunction(...args))) throw undefined;
        return;
      }
      const variable = variables[depth++];
      for (var i = 0; i <= 9; i++) {
        values.set(variable, i);
        search(depth);
      }
    })(0);
  } catch (e) {
    print(toValues(sequence).join(""));
    return;
  }
  print("false");
})();


function main() {

    var nm = readline().split(' ').map(Number);
    var n = nm[0];
    var m = nm[1];
    var horizontal = readline();
    var vertical = readline();

    if (horizontal[0] === "<" && horizontal[n - 1] === ">" && vertical[0] === "v" && vertical[m - 1] === "^") {
        print("YES");
    } else if (horizontal[0] === ">" && horizontal[n - 1] === "<" && vertical[m - 1] === "v" && vertical[0] === "^") {
        print("YES");
    } else {
        print("NO");
    }

}

main();


function ProblemSolver() {

    this.dfs = function( x , y ) {
        var nx , ny , i , j;
        this.vis[ x ][ y ] = 1;
        i = this.arr[ x ];
        j = this.brr[ y ];
        nx = x + this.dx[ i ];
        ny = y + this.dy[ i ];
        if( nx >= 0 && nx < this.n && ny >= 0 && ny < this.m ) {
            if( this.vis[ nx ][ ny ] == 0 ) {
                this.dfs( nx , ny );
            }
        }
        nx = x + this.dx[ j ];
        ny = y + this.dy[ j ];
        if( nx >= 0 && nx < this.n && ny >= 0 && ny < this.m ) {
            if( this.vis[ nx ][ ny ] == 0 ) {
                this.dfs( nx , ny );
            }
        }
    };

    this.solveCase = function() {
        var res , i , j , k , l;
        res = "YES";
        for( i = 0 ; i < this.n ; i++ ) {
            if( this.s.charAt( i ) == '<' ) {
                this.arr[ i ] = 1;
            }
            else {
                this.arr[ i ] = 0;
            }
        }
        for( i = 0 ; i < this.m ; i++ ) {
            if( this.t.charAt( i ) == '^' ) {
                this.brr[ i ] = 3;
            }
            else {
                this.brr[ i ] = 2;
            }
        }
        for( i = 0 ; i < this.n ; i++ ) {
            for( j = 0 ; j < this.m ; j++ ) {
                this.vis = new Array();
                for( k = 0 ; k < this.n ; k++ ) {
                    this.vis.push( new Array() );
                    for( l = 0 ; l < this.m ; l++ ) {
                        this.vis[ k ].push( 0 );
                    }
                }
                this.dfs( i , j );
                for( k = 0 ; k < this.n ; k++ ) {
                    for( l = 0 ; l < this.m ; l++ ) {
                        if( this.vis[ k ][ l ] == 0 ) {
                            res = "NO";
                        }
                    }
                }
            }
        }
        print( res );
    };

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

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

    this.clearPerCase = function() {
        this.cn = 0;
        this.cc++;
        //this.clearArraysPerCase() ;
    };

    this.HAS_TEST_CASES = false;
    this.INPUT_FILE_NAME = "test.in";
    this.OUTPUT_FILE_NAME = "out.txt";
    this.DO_OUTPUT_TO_FILE = false;

    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();
        this.dx = new Array( 0 , 0 , +1 , -1 );
        this.dy = new Array( +1 , -1 , 0 , 0 );
        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() {
        this.lim1 = 100010;
        this.lim2 = 110;
        this.cc = 1;
        this.ind = 1;
        this.n = 0;
        this.cn = 0;
        this.declareAndFillArrays();
    };

    this.memsetArray1D = function( arrParam , val ) {
        var i;
        if( arrParam == null ) {
            throw new Error( "No array supplied in the parameter!" );
        }
        if( val == null ) {
            throw new Error( "No value for memset has been supplied in the parameter!" );
        }
        arrParam = new Array();
        for( i = 0 ; i < this.lim1 ; i++ ) {
            arrParam.push( val );
        }
        return arrParam;
    };

    this.getStringLength = function( stringData ) {
        var len , lengthType;
        len = stringData.length;
        lengthType = typeof len;
        if( lengthType == "function" ) {
            len = stringData.length();
        }
        else {
            len = stringData.length;
        }
        return len;
    };

    this.init();
}

function InputReader() {
    this.allLines = new Array();
    this.currrentLineNumber = 0;
    this.currrentCharacterIndex = 0;

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

    this.readAllLinesFromRhinoStdin = function() {
        importPackage( java.io );
        importPackage( java.lang );
        var singleLine , reader;
        reader = new BufferedReader( new InputStreamReader( System[ "in" ] ) );
        this.allLines = [];
        while( true ) {
            singleLine = reader.readLine();
            if( singleLine != null ) {
                this.allLines.push( singleLine );
            }
            else {
                break;
            }
        }
    };

    this.readAllLinesFromNodeStdin = function() {
        var fsObj , size , rawData;
        process.stdin.setEncoding( 'ascii' );
        fsObj = require( 'fs' );
        size = fsObj.fstatSync( process.stdin.fd ).size;
        rawData = fsObj.readSync( process.stdin.fd , size )[ 0 ];
        this.parseRawData( rawData );
    };

    this.parseRawData = function( data ) {
        var len , i , currentString;
        len = data.length;
        currentString = "";
        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 , lengthType;
        len = this.allLines[ this.currrentLineNumber ].length;
        lengthType = typeof len;
        if( lengthType == "function" ) {
            len = this.allLines[ this.currrentLineNumber ].length();
        }
        if( flag == 0 ) {
            res = "";
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                res += String.fromCharCode( this.allLines[ this.currrentLineNumber ].charCodeAt( 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;
            for( i = this.currrentCharacterIndex ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != ' '.charCodeAt( 0 ) && this.allLines[ this.currrentLineNumber ].charCodeAt( i ) != '\t'.charCodeAt( 0 ) ) {
                    startIdx = i;
                    break;
                }
            }
            if( startIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
                continue;
            }
            res = "";
            endIdx = -1;
            for( i = startIdx ; i < len ; i++ ) {
                if( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == ' '.charCodeAt( 0 ) || this.allLines[ this.currrentLineNumber ].charCodeAt( i ) == '\t'.charCodeAt( 0 ) ) {
                    endIdx = i;
                    break;
                }
                res += String.fromCharCode( this.allLines[ this.currrentLineNumber ].charCodeAt( i ) );
            }
            if( endIdx == -1 ) {
                this.currrentLineNumber++;
                this.currrentCharacterIndex = 0;
            }
            else {
                this.currrentCharacterIndex = endIdx;
            }
            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() {
        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;
        if( currentDirectory.charAt( 1 ) != ":" ) {
            //not local machine/windows
            outputFilePath = outputFileName;
        }
        fsObj.writeFileSync( outputFilePath , res );
        this.clearPercase();
    };
}

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

    this.runCode = function() {
        var testCases , i , hasMoreTestCases , isLocalMachine , localContext;
        isLocalMachine = false;
        try {
            if( __dirname != null && __dirname.charAt( 1 ) == ':' ) {
                //only on windows
                isLocalMachine = true;
            }
        }
        catch( ex ) {
            isLocalMachine = false;
        }
        if( isLocalMachine == true ) {
            //local machine runs on node and relies on file i/o
            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 );
        }
        else {
            //server machine
            try {
                var rlObj = readline;
                //server runs on javasctipt v8 distribution and has readline method on global context
                this.irObj.readAllLines();
            }
            catch( ex ) {
                try {
                    var pObj = process;
                    //server runs on node
                    print = console.log;
                    this.irObj.readAllLinesFromNodeStdin();
                }
                catch( ex ) {
                    try {
                        var ipObj = importPackage;
                        //server runs on rhino
                        this.irObj.readAllLinesFromRhinoStdin();
                    }
                    catch( ex ) {
                        throw new Error( "Unknown javasctipt distribution!" );
                    }
                }
            }
        }
        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 ) {
            //only works for local machine(tested)
            this.fohObj.flushOutOutputToFile( this.psObj.OUTPUT_FILE_NAME );
        }
    };

    this.runCode();
}

new CodeExecutioner();


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

var a = parseInt(line[0]);
var m = parseInt(line[1]);
var dat = {};

var current = a;

while(!dat[current] && current<=m)
{
    dat[current] = true;
    current = current + a%m;
}

print((dat[0] || dat[m]) ? "Yes" : "No");


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

//var line = "3 6".split(' ');

var a = parseInt(line[0]);
var m = parseInt(line[1]);
var dat = {};

var current = a;
var firstIt = true;

while(!dat[current] && (current<=m || firstIt))
{
    dat[current] = true;
    current = current + current%m;
    firstIt = false;
}

print((dat[0] || dat[m]) ? "Yes" : "No");
//console.log((dat[0] || dat[m]) ? "Yes" : "No");


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

//var line = "3 6".split(' ');

var a = parseInt(line[0]);
var m = parseInt(line[1]);
var dat = {};

var current = a;

while(!dat[current] && current<=m*3)
{
    dat[current] = true;
    current = current + current%m;
}

print((dat[0] || dat[m] || a%m == 0) ? "Yes" : "No");
//console.log((dat[0] || dat[m]) ? "Yes" : "No");


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

var a = parseInt(line[0]);
var m = parseInt(line[1]);
var dat = {};

var result = "No";

a = a%m;

while(!dat[a])
{
    if (a)
    {
          a = a * 2;
          a = a % m;
          dat[a] = true;
    }
    else
    {
        result = "Yes";
    }
}

print(result);


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

//var line = "3 6".split(' ');

var a = parseInt(line[0]);
var m = parseInt(line[1]);
var dat = {};

var current = a;

while(!dat[current] && current<=m)
{
    dat[current] = true;
    current = current + current%m;
}

print((dat[0] || dat[m] || a%m == 0) ? "Yes" : "No");
//console.log((dat[0] || dat[m]) ? "Yes" : "No");


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

var a = parseInt(line[0]);
var m = parseInt(line[1]);
var dat = {};

var result = "No";

a = a%m;

while(!dat[a])
{
    if (a)
    {
        dat[a] = true;
        a = a * 2;
        a = a % m;
    }
    else
    {
        result = "Yes";
    }
}

print(result);


var line = readline();
var rb = 0, rs = 0, rc = 0;
var i;
for (i = 0; i < line.length; i++) {
  switch (line[i]) {
    case 'B': rb++; break;
    case 'S': rs++; break;
    case 'C': rc++; break;
  }
}

line = readline().split(' ');
var nb = +line[0];
var ns = +line[1];
var nc = +line[2];

line = readline().split(' ');
var pb = +line[0];
var ps = +line[1];
var pc = +line[2];

var pr = pb*rb + ps*rs + pc*rc;

line = readline();
var r = +line;

var rMakingN = function (n) {
  if (n < 1) {
    return 0;
  }

  var costb = (n*rb-nb)*pb;
  if (costb < 0) {
    costb = 0;
  }
  var costs = (n*rs-ns)*ps;
  if (costs < 0) {
    costs = 0;
  }
  var costc = (n*rc-nc)*pc;
  if (costc < 0) {
    costc = 0;
  }

  return costb + costs + costc;
};

var min = 0;
var max = 2e12;
var mid = 0;
var cost = 0;

while (min < max) {
  mid = Math.ceil((min+max)/2);
  cost = rMakingN(mid);
  if (cost > r) {
    if (max === mid) mid--;
    max = mid;
  } else if (cost < r) {
    min = mid;
  } else {
    break;
  }
}

write(mid);


var line = readline();
var rb = 0, rs = 0, rc = 0;
var i;
for (i = 0; i < line.length; i++) {
  switch (line[i]) {
    case 'B': rb++; break;
    case 'S': rs++; break;
    case 'C': rc++; break;
  }
}

line = readline().split(' ');
var nb = +line[0];
var ns = +line[1];
var nc = +line[2];

line = readline().split(' ');
var pb = +line[0];
var ps = +line[1];
var pc = +line[2];

var pr = pb*rb + ps*rs + pc*rc;

line = readline();
var r = +line;

var total = 0;
var subtotal = 0;

var maxb = 0;
var maxs = 0;
var maxc = 0;
var max = 0;

var rMakingN = function (n) {
  if (n < 1) {
    return 0;
  }

  var costb = (n*rb-nb)*pb;
  if (costb < 0) {
    costb = 0;
  }
  var costs = (n*rs-ns)*ps;
  if (costs < 0) {
    costs = 0;
  }
  var costc = (n*rc-nc)*pc;
  if (costc < 0) {
    costc = 0;
  }

  return costb + costs + costc;
}

maxb = Math.floor(nb/rb);
maxs = Math.floor(ns/rs);
maxc = Math.floor(nc/rc);

max = Math.min(maxb, maxs, maxc);

total += max;
nb -= rb * max;
ns -= rs * max;
nc -= rc * max;

while (true) {
  if (nb === 0 && ns === 0 && nc === 0) {
    total += Math.floor(r/pr);
    r %= pr;
    break;
  }

  if (nb < rb) {
    r -= pb*(rb-nb);
    nb = rb;
  }
  if (ns < rs) {
    r -= ps*(rs-ns);
    ns = rs;
  }
  if (nc < rc) {
    r -= pc*(rc-nc);
    nc = rc;
  }
  if (r < 0) {
    break;
  }
  total++;
  nb -= rb;
  ns -= rs;
  nc -= rc;

  maxb = Math.floor(nb/rb);
  maxs = Math.floor(ns/rs);
  maxc = Math.floor(nc/rc);

  max = 0;
  if (maxb > 0) {
    max = maxb;
  }
  if (maxs > 0 && maxs < max) {
    max = maxs;
  }
  if (maxc > 0 && maxc < max) {
    max = maxc;
  }

  var rCostMax = rMakingN(max);
  if (rCostMax <= r) {
    total += max;
    nb -= rb * max;
    ns -= rs * max;
    nc -= rc * max;
  }
}

write(total);


var line = readline();
var rb = 0, rs = 0, rc = 0;
var i;
for (i = 0; i < line.length; i++) {
  switch (line[i]) {
    case 'B': rb++; break;
    case 'S': rs++; break;
    case 'C': rc++; break;
  }
}

line = readline().split(' ');
var nb = +line[0];
var ns = +line[1];
var nc = +line[2];

line = readline().split(' ');
var pb = +line[0];
var ps = +line[1];
var pc = +line[2];

var pr = pb*rb + ps*rs + pc*rc;

line = readline();
var r = +line;

var total = 0;
var subtotal = 0;

var maxb = 0;
var maxs = 0;
var maxc = 0;
var max = 0;

var rMakingN = function (n) {
  if (n < 1) {
    return 0;
  }

  var costb = (n*rb-nb)*pb;
  if (costb < 0) {
    costb = 0;
  }
  var costs = (n*rs-ns)*ps;
  if (costs < 0) {
    costs = 0;
  }
  var costc = (n*rc-nc)*pc;
  if (costc < 0) {
    costc = 0;
  }

  return costb + costs + costc;
}

maxb = Math.floor(nb/rb);
maxs = Math.floor(ns/rs);
maxc = Math.floor(nc/rc);

max = Math.min(maxb, maxs, maxc);

total += max;
nb -= rb * max;
ns -= rs * max;
nc -= rc * max;

while (true) {
  if (nb === 0 && ns === 0 && nc === 0) {
    total += Math.floor(r/pr);
    r %= pr;
    break;
  }

  if (nb < rb) {
    r -= pb*(rb-nb);
    nb = rb;
  }
  if (ns < rs) {
    r -= ps*(rs-ns);
    ns = rs;
  }
  if (nc < rc) {
    r -= pc*(rc-nc);
    nc = rc;
  }
  if (r < 0) {
    break;
  }
  total++;
  nb -= rb;
  ns -= rs;
  nc -= rc;

  maxb = nb/rb | 0;
  maxs = ns/rs | 0;
  maxc = nc/rc | 0;

  max = 0;
  if (maxb > 0) {
    max = maxb;
  }
  if (maxs > 0 && maxs < max) {
    max = maxs;
  }
  if (maxc > 0 && maxc < max) {
    max = maxc;
  }

  if (max === 0) {
    total += Math.floor(r/pr);
    r %= pr;
  }

  var rCostMax = rMakingN(max);
  if (rCostMax <= r) {
    total += max;
    nb -= rb * max;
    ns -= rs * max;
    nc -= rc * max;
  } else {

  }
}

write(total);


let table = [0];
let j = "";
for(let i=0;i<55;i++)
{
    j+= "1"
    table[i+1] = BigInt(j);
}

let dp = {};

let i = ''
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL)
    console.log(calc(BigInt(lines[0])));
});

function abs(x)
{
    return (x>=0)?x:0n-x;
}

function max(v1,v2)
{
    return (v1>v2)?v1:v2;
}

function min(v1,v2)
{
    return (v1>v2)?v2:v1;
}

function calc(x)
{
    if (x==0) return 0;

    let str = x.toString();
    if (dp[str]) return dp[str];
    let n = str.length;

    let v1 = abs(table[n+1]-x);
    let v2 = abs(table[n]-x);

    let ret;

    let diff = abs(v1-v2);
    let mx = max(v1,v2);
    let ratio = Number(diff * 100n / mx) / 100;
    if (ratio<=0.1)
    {
        ret = min(n+1+calc(v1),n+calc(v2));
    }
    else
    {
        if (v1<v2)
        {
            ret = n+1+calc(v1);
        }
        else
        {
            ret = n+calc(v2);
        }
    }

    dp[str] = ret;
    return ret;
}


let i = ''
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    run(BigInt(lines[0]),lines[0].length);
});

function abs(x)
{
    return (x>=0)?x:0n-x;
}

function run(x,n)
{
    let table = [0];
    let j = "";
    for(let i=0;i<n+1;i++)
    {
        j+= "1"
        table[i+1] = BigInt(j);
    }

    let ret = 0;

    while(x>0)
    {
        n = x.toString().length;
        let s = -1n;
        let c = 0;
        for(let i=1;i<=n+1;i++)
        {
            let v = abs(table[i]-x);
            if ((s==-1n) || (v<s))
            {
                s = v;
                c = i;
            }
        }
        x = s;
        ret+= c;
    }

    console.log(ret);
}


let i = ''
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    run(parseInt(lines[0]),lines[0].length);
});

function run(x,n)
{
    let table = [0];
    let j = "";
    for(let i=0;i<n+1;i++)
    {
        j+= "1";
        table.push(parseInt(j));
    }
    let ret = 0;

    while(x>0)
    {
        n = x.toString().length;
        let v1 = Math.abs(table[n+1]-x);
        let v2 = Math.abs(table[n]-x);
        if (v1<v2)
        {
            ret+= n+1;
            x = v1;
        }
        else
        {
            ret+= n;
            x = v2;
        }
    }

    console.log(ret);
}


'use strict'

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

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


'use strict'

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


'use strict'

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


'use strict'

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

const MOD = 1000000007;

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

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

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

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


'use strict'

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

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


var nums = readline().split(" ").map(function(x) { return parseInt(x); });
var n = nums[0], m = nums[1];
var s = readline().split(" ").map(function(x) { return parseInt(x); });

//var sum = 0;
//for (var i=0; i<n; i++) sum += s[i];
s.sort(function(a,b) {return a-b;});

var down = 1, up = Math.min(m, n) + 1;
while (up>down) {
//write(" down = ", down, "\n");
//write(" up = ", up, "\n\n");
	var mid = Math.floor((up+down)/2);
	//var res = sum;
	var dvv = Math.floor(n/mid);
	var rem = n % mid;

	var res = 0;
	var fr = 0;
	if (rem > 0) {
		for (var i=0; i<rem; i++) res += Math.max(0, s[i] - dvv);
		fr = rem;
	}
	for (var i=fr; i<n; i+=mid) {
		dvv--;
		for (var j=0; j<mid; j++) res += Math.max(0, s[i+j] - dvv);
	}

	//0...dvv-1
	//res -= Math.floor(dvv*(dvv-1)/2);
	//var rem = n % mid;
	//if (rem > 0)
	//	res -= rem * dvv;

	if (res >= m) up = mid;
	else down = mid + 1;
}
if (down > Math.min(n,m)) write("-1");
else write(down);


var str1 =readline().split(" ");
var answer = [0,0,0];
var x;
var y;
var z;
x = Math.abs(str1[0]-str1[2]);
y = Math.abs(str1[1]-str1[3]);
if (x==0&&y==0) answer[0]=0;
	else if (x==0||y==0) answer[0]=1;
			else answer[0]=2;
if (x==0&&y==0) answer[1]=0;
	else{ z = Math.abs(x-y);
		if (z==1||z==3||z==5||z==7) answer[1]=0;
			else if (x==y) answer[1]=1;
					else answer[1]=2;}
if (x==0&&y==0) answer[2]=0;
else if (x==0||y==0) {z = Math.abs(x-y);answer[2]=z;}
		else {z = Math.max(x,y); answer[2]=z;}
print(answer);


var str1 =readline().split(" ");
var answer = [0,0,0];
var x;
var y;
var z;
var answer1 = "";
x = Math.abs(str1[0]-str1[2]);
y = Math.abs(str1[1]-str1[3]);
if (x==0&&y==0) answer[0]=0;
	else if (x==0||y==0) answer[0]=1;
			else answer[0]=2;
if (x==0&&y==0) answer[1]=0;
	else{ z = Math.abs(x-y);
		if (z==1||z==3||z==5||z==7) answer[1]=0;
			else if (x==y) answer[1]=1;
					else answer[1]=2;}
if (x==0&&y==0) answer[2]=0;
else if (x==0||y==0) {z = Math.abs(x-y);answer[2]=z;}
		else {z = Math.max(x,y); answer[2]=z;}
for (i=0;i<3;i++)
	answer1 = answer1 +" " + answer[i];
print(answer1);


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

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

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

function main() {
	var integers = tokenizeIntegers(readline());
	var fromR = integers[0], fromC = integers[1];
	var toR = integers[2], toC = integers[3];

	var rook = (fromR == toR || fromC == toC ? 1 : 2);

	if ((fromR+fromC)%2 != (toR+toC)%2) {
		var bishop = 0;
	}
	else {
		var bishop = (Math.abs(fromR - toR) == Math.abs(fromC - toC) ? 1 : 2);
	}

	var dr = Math.abs(fromR - toR), dc = Math.abs(fromC - toC);
	var king = dr + dc - Math.min(dr, dc);

	print(rook, bishop, king);
}

main();


(function() {
    'use strict';
    let n = readline().split(' ').map(Number);
    let x = readline().split(' ').map(Number);
    let y = 0;
    let i = 0;
    while(x[i] <= n[1]) {
            y++;
            i++;
    }
    let m = x.length - 1;
    while(x[m] <= n[1]) {
        y++;
        m--;
    }
    print(y);
}());


var s1=readline().split(" ");
var s2=readline().split(" ");
var n=s1[0],k=s1[1],t=0;
for(var i=0;i<n;i++){
	if(s2[i]<=k){t++;}
	else{
		for(var y=n-1;y>=0;y--){
			if(s2[i]<=k){t++;}
			else{break;}
		}
	}
}print(t);


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

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

  const arr = d.split(' ').map(Number);
  let ans = 0;
  let stopIndex = 0;

  for (let i = 0; i < arr.length; i++) {
    if (arr[i] <= k) {
      ans++;
    }
    else {
      stopIndex = i;
      break;
    }
  }

  if (stopIndex !== 0) {
    for (let j = arr.length - 1; j > stopIndex; j--) {
      if (arr[j] <= k) {
        ans++;
      }
      else {
        break;
      }
    }
  }

  console.log(ans);

  c++;
});


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

function main()
{
    const [n,k]=readLine().trim().split(' ').map(a=>{return +(a.trim());});
    let arr=readLine().trim().split(' ').map(a=>{return +(a.trim());});
    let ans=0;
    for(let i=0;i<n;++i)
    {
        if(arr[i]>k)
        {
            break;
        }
        ans++;
        if(i==n-1)
        {
            console.log(ans);
            return;
        }
    }
    for(let i=n-1;i>=0;--i)
    {
        if(arr[i]>k)
        {
            break;
        }
        ans++;
    }
    console.log(ans);
}


var n, k, aa = [ ];
var line = readline ();
var one = line.trim ().split ( ' ' ); // method chaining
n = (+ one [ 0 ]); // convert words to numbers
k = (+ one [ 1 ]); //
line = readline ();
aa = line.trim ().split ( ' ' );
var cnt = 0;
la: while ( aa.length > 0 && aa [ 0 ] <= k && ++ cnt ) { aa.shift (); }
lb: while ( aa.length > 0 && aa [ aa.length - 1 ] <= k && ++ cnt  ) { aa.pop (); }
print ( cnt );


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

//Don't have to see. end------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var K = one[1];
	var list = nextIntArray();
	var count = 0;
	while(list.length > 0){
		var L = list[0];
		if(L <= K){
			count++;
			list.shift();
			continue;
		}
		var R = list[list.length - 1];
		if(R <= K){
			count++;
			list.pop();
			continue;
		}
		break;
	}

	myout(count);
}


function processData(input) {
    //Enter your code here
     let  res=input.split("\n"),   [n,k]=res[0].split(" ").map(Number),
      arr=res[1].split(" ").filter((x)=>x!=="").map(Number);
  while(arr.length>0){
    if(arr[0]<=k){
      arr.shift()
    }else if(arr[arr.length-1]<=k){
      arr.pop()
    }else{
      break;
    }
  }
  console.log(n-arr.length)
}

process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
    _input += input;
});

process.stdin.on("end", function () {
   processData(_input);
});


var nk = readline().split(' ').map(Number);
var n = nk[0];
var k = nk[1];
var test = readline().split(' ').map(Number);
var count = 0;
for (var i=0; i<n; i++){
	if (test[i] <= k) count++;
	else break;
}
if (count < n-1){
	for (var i=n-1; i>=0; i--){
	if (test[i] <= k) count++;
	else break;
}
}
print(count);