#include<stdio.h>
#define m 10*hundreds+tens

int main()
{
    int hundreds, tens, i, x, y;
    scanf("%d %d", &hundreds, &tens);
    for(i=1; (tens>=22) || (hundreds>0 && tens>=12) || (hundreds>=2 && tens>=2); i++)
    {
        if(i%2)
        {
            if(hundreds>=2)
            {
                hundreds-=2;
                tens-=2;
            }
            else if(hundreds>=1)
            {
                hundreds-=1;
                tens-=12;
            }
            else
            {
                tens-=22;
            }
        }
        else
        {
            if(tens>=22)
            {
                tens-=22;
            }
            else if(tens>=12)
            {
                tens-=12;
                hundreds-=1;
            }
            else
            {
                tens-=2;
                hundreds-=2;
            }
        }
    }
    if(i%2) printf("Hanako");
    else printf("Ciel");
    return 0;
}


#include<ctype.h>
#include<limits.h>
#include<math.h>
#include<stdbool.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void)
{
    long long x, y, z, k;

    scanf("%I64d%I64d%I64d%I64d", &x, &y, &z, &k);

    long long a = 1, b = 1, c = 1;
    int i = 0;
    while(i < k)
    {
        if(i < k && x > 1)
        {
            x--;
            a++;
            i++;
        }
        if(i < k && y > 1)
        {
            y--;
            b++;
            i++;
        }
        if(i < k && z > 1)
        {
            z--;
            c++;
            i++;
        }
        if(x == 1 && y == 1 && z == 1)
            i = k;
    }

    printf("%I64d", a * b * c);

    return 0;
}


#include <stdio.h>
#include <string.h>

#define LMT 105

char work[LMT];
int len, n, dp[2][LMT << 1][LMT][52];

int
max (int x, int y)
{
  return x > y ? x : y;
}

int
dfs (int dre, int pos, int i, int cn)
{
  if (cn < 0)
    return 0;

  if (!work[i])
    return cn > 0 ? 0 : abs (pos);

  if (dp[dre][pos + 100][i][cn] != -1)
    return dp[dre][pos + 100][i][cn];

  int mv = dre ? 1 : -1;
  int x = dfs (dre, pos + mv, i + 1, cn - (work[i] != 'F'));
  int y = dfs (!dre, pos, i + 1, cn - (work[i] != 'T'));
  dp[dre][pos + 100][i][cn] = max (x, y);
  return dp[dre][pos + 100][i][cn];
}

int
main ()
{
  int ans = 0;
  scanf ("%s%d", work, &n);
  memset (dp, -1, sizeof (dp));
  for (; n >= 0; n -= 2)
    ans = max (ans, dfs (1, 0, 0, n));
  printf ("%d\n", ans);
  return 0;
}


#include<stdio.h>

int determine(int set1, int set2, int set4,int n)
{
	int temp = set2 - 2 * n;
	int x;
	if (temp > set1)
		x = set4 + set1 + (temp - set1 + 1) * 2 / 3;
	else
		x = set4 + temp + (set1 - temp + 1) / 2;
	if (x <= n)
		return 1;
	else
		return 0;
}

int main()
{
	int n, k, i, set1, set2, set4, temp;
	scanf("%d %d", &n, &k);
	set1 = 0;
	set2 = 0;
	set4 = 0;
	for (i = 0; i < k; i++) {
		scanf("%d", &temp);
		set4 += temp / 4;
		temp %= 4;
		set2 += temp / 2;
		temp %= 2;
		set1 += temp;
	}
	if (set1 * 2 + set2 * 2 + set4 * 4 <= n * 8 && determine(set1, set2, set4, n))
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define NUMSIZE 15

int cmp (const void *a, const void *b)
{
	return *(char *)b - *(char *)a;
}

int main()
{
	/* 4 -- ����� ����� ������� ������ ������ (��� 8 � 9) */
	char a[NUMSIZE + 1], x[4 * NUMSIZE + 1] = "", strchg[][8] = {"", "", "2", "3", "322", "5", "53", "7", "7222", "7332"};
	int i;

	scanf ("%*d\n");
	gets (a);

	for (i = 0; a[i]; i++)
		strcat (x, strchg[a[i] - '0']);

	qsort (x, strlen(x), 1, cmp);

	puts (x);

	return 0;
}


#include <stdio.h>

enum {
    M = 4,
    D = 13,
    MAX = M * D + 2
};

typedef struct Card {
    int d, m;
} Card;

Card a[MAX][MAX];
char n2m[M] = {'C', 'D', 'H', 'S'};
char n2d[D] = {'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'};

int
m2n(char m)
{
    switch (m) {
    case 'C':
        return 0;
    case 'D':
        return 1;
    case 'H':
        return 2;
    case 'S':
        return 3;
    default:
        return -1;
    }
}

int
d2n(char d)
{
    switch (d) {
    case 'T':
        return 8;
    case 'J':
        return 9;
    case 'Q':
        return 10;
    case 'K':
        return 11;
    case 'A':
        return 12;
    default:
        return d - '2';
    }
}

int
good(int r, int c)
{
    int m = a[r][c].m;
    int goodm = 1;
    int ud[D] = {};
    int goodd = 1;
    int i, j;
    for (i = r; i < r + 3; ++i) {
        for (j = c; j < c + 3; ++j) {
            goodm &= (a[i][j].m == m);
            goodd &= (ud[a[i][j].d] == 0);
            ud[a[i][j].d] = 1;
        }
    }
    return goodm || goodd;
}

int
main(void)
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, m, i, j;
    char s[MAX];
    int j1r, j1c, j2r, j2c;
    j1r = j1c = j2r = j2c = -1;
    int used[M][D] = {};
    scanf("%d %d", &n, &m);
    for (i = 0; i < n; ++i) {
        for (j = 0; j < m; ++j) {
            scanf("%s", s);
            a[i][j].d = d2n(s[0]);
            a[i][j].m = m2n(s[1]);
            if (s[1] == '1') {
                j1r = i;
                j1c = j;
            } else if (s[1] == '2') {
                j2r = i;
                j2c = j;
            } else {
                used[a[i][j].m][a[i][j].d] = 1;
            }
        }
    }

    int m1, d1, m2, d2, r1, c1, r2, c2;
    for (m1 = 0; m1 < M; ++m1) {
        for (d1 = 0; d1 < D; ++d1) {
            if (used[m1][d1]) continue;
            used[m1][d1] = 1;
            if (j1r > -1) {
                a[j1r][j1c].d = d1;
                a[j1r][j1c].m = m1;
            }
            for (m2 = 0; m2 < M; ++m2) {
                for (d2 = 0; d2 < D; ++d2) {
                    if (used[m2][d2]) continue;
                    used[m2][d2] = 1;
                    if (j2r > -1) {
                        a[j2r][j2c].d = d2;
                        a[j2r][j2c].m = m2;
                    }

                    for (r1 = 0; r1 < n - 2; ++r1) {
                        for (c1 = 0; c1 < m - 2; ++c1) {
                            for (r2 = r1; r2 < n - 2; ++r2) {
                                for (c2 = 0; c2 < m - 2; ++c2) {
                                    if ((r2 < r1 + 3) && ((c2 >= c1 && c2 < c1 + 3) || (c2 + 2 >= c1 && c2 + 2 < c1 + 3))) continue;
                                    if (good(r1, c1) && good(r2, c2)) {
                                        printf("Solution exists.\n");
                                        if (j1r == -1 && j2r == -1) {
                                            printf("There are no jokers.\n");
                                        } else if (j1r == -1) {
                                            printf("Replace J2 with %c%c.\n", n2d[d2], n2m[m2]);
                                        } else if (j2r == -1) {
                                            printf("Replace J1 with %c%c.\n", n2d[d1], n2m[m1]);
                                        } else {
                                            printf("Replace J1 with %c%C and J2 with %c%c.\n", n2d[d1], n2m[m1], n2d[d2], n2m[m2]);
                                        }
                                        printf("Put the first square to (%d, %d).\n", r1 + 1, c1 + 1);
                                        printf("Put the second square to (%d, %d).\n", r2 + 1, c2 + 1);
                                        return 0;
                                    }
                                }
                            }
                        }
                    }
                    used[m2][d2] = 0;
                }
            }
            used[m1][d1] = 0;
        }
    }
    printf("No solution.\n");

    return 0;
}


#include <stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    int log2Value = 0;
    while(n >0){
        log2Value++;
	n >>= 1;
	// printf("n: %d\n", n);
    }
    printf("%d\n", log2Value);
    return 0;
}


#include <stdio.h>
const int N=1000000007;
long long int x, i, n, a = 1;
long long int k (long long int x, long long int p)
{
	long long int s = 1;
	while (p)
	{
		if (p % 2)
			s = s * x % N;
		p /= 2;
		x = x * x % N;
	}
    return s;
}
long long int d (long long int p)
{
	long long int m = n, sum = 0;
	while (m)
		sum += m /= p;
	return k(p, sum);
}
int main()
{
	scanf("%lld%lld", &x, &n);
	for (i = 2; i * i <= x; i++)
		if (x % i == 0)
		{
			a = a * d(i) % N;
			while (x % i == 0)
				x /= i;
		}
	if (x != 1)
		a = a * d(x) % N;
	printf("%lld", a);
}


#include <stdio.h>
#include <stdlib.h>

int n,m,k;

int modpow(int x,int y){
    int ret,MOD=1e9+7;
    long long temp=1;
    while(y--){
        temp*=x;
        temp%=MOD;
    }
    return (int)temp;
}

void print(int x){printf("%d\n",x);exit(0);}

main(){
    scanf("%d%d%d",&n,&m,&k);
    if(n<k||k==1) print(modpow(m,n));
    if(n==k)      print(modpow(m,-~n/2));
    if(k&1)       print(m*m);
    print (m);
}


#include<stdio.h>
#include<string.h>
char a[22],b[22];
void f1(char a[22])
{
	int i,j;char m;
	for(i=0;a[i];i++)
	{	for(j=i+1;a[j];j++)
			if(a[i]<a[j])
			{
				m=a[i];a[i]=a[j];a[j]=m;
			}
	}
}
void f2(char a[22],char b[22])
{
	int i,j;char c[22],k;
    for(i=0;a[i];i++)
	{	for(j=i+1;a[j];j++)
		{
			strcpy(c,a);
			k=c[i];c[i]=c[j];c[j]=k;
			if(strcmp(c,a)>0&&strcmp(c,b)<=0)
			{k=a[i];a[i]=a[j];a[j]=k;}
		}
	}
	puts(a);
}
void f3(char a[22])
{
	int i,j;char m;
	for(i=0;a[i];i++)
		for(j=i+1;a[j];j++)
			if(a[i]>a[j])
			{
				m=a[i];a[i]=a[j];a[j]=m;
			}
}
int main()
{
    int i,j,alen,blen;
	scanf("%s%s",a,b);
	alen=strlen(a);blen=strlen(b);
    f1(a);
	if(alen<blen)
		puts(a);
	else
	{	f3(a);
        f2(a,b);
	}
}


#include<stdio.h>
#include<string.h>

 int luckyNo(int x)
 {
    int n=x;
    int r,sum=0,m=1;
    while(n)
    {
        r=n%10;
        n=n/10;
        if(r==4||r==7)
        {
            sum=sum+r*m;
            m=m*10;
        }
    }
  return sum;
 }
int main()
{
    int a,b;

    scanf("%d %d",&a,&b);
    a++;
    if(a<b)
        a=b;
    else
    while(b!=luckyNo(a))
    {
        a++;
    }
    printf("%d\n",a);

 return 0;
 }


#include <stdio.h>
#include <string.h>

char buf[200];

int main()
{
    int i,len,flag=0;

    scanf("%s",buf);

    len =strlen(buf);

    for(i=0;i<len;i++)
    {
        if(buf[i]=='/')
        {
            while(buf[i+1]=='/')
              i++;
            if(buf[i+1])  /*not null*/
            {
                putchar('/');
                flag=1;
            }
        }
        else
        {
            putchar(buf[i]);
            flag=1;
        }
    }

    if(flag==0)
      putchar('/');

    puts("");

    return 0;
}
/****** PCCA -Wed Aug 24 04:05:43 GMT 2011 *******/


#include <stdio.h>

void solve(long long j, long long i){
    int l, r;
    char ar[11] = "codeforces";
    for( l = 0; l < j; l ++ )
        for(r = 0; r < i; r++ )
            printf("%c", ar[l] );

    for( l = j; l < 10; l ++ )
        for(r = 0; r < i-1; r++ )
            printf("%c", ar[l] );

    printf("\n");
    return;
}

int main (){
    long long k, i, j, prod, sol;
    scanf("%lld", &k );

    if( k == 3 || k == 1){
        if( k == 3 )
            printf("codeforcesss\n");
        else
            printf("codeforces\n");
    }else{

    i = 1;
    prod = 1;
    while( prod < k ){
        i++;
        prod = 1;
        for( j = 0; j < 10; j++ )
            prod = prod * i;
    }
    sol = 1;
    for( j = 0; j < 10; j++ )
        sol = sol * (i-1);
    j = 0;
    while( sol < k ){
        sol = i * (sol/(i-1));
        j++;
    }
    solve(j,i);
    }
    return 0;
}


#include <stdio.h>

int main(void) {
	int n, a[100+5], non_zero = 0;
	scanf("%d", &n);
	for(int i=1;i<n+1;i++) scanf("%d", &a[i]), non_zero += a[i]!=0?1:0;
	if(non_zero<1) {printf("NO");return 0;}
	printf("YES\n%d\n", non_zero);
	int l=1; non_zero=0;
	for(int i=1;i<n+1;i++)
	{
		non_zero += a[i]!=0?1:0;
		if(non_zero>1)
		{
			printf("%d %d\n", l, i-1);
			l=i; non_zero=0; i--;
		}
		else if(i==n)
			printf("%d %d\n", l, n);
	}
	return 0;
}


#include<stdio.h>
#include<string.h>

int main()
{
	int n;
	scanf("%d",&n);
	char s1[n+1];
	int s[n+1];
	scanf("%s",s1);
	int length=strlen(s1),total_sum=0,sum=0,temp=0,k=0,j,flag=0;
	for(int i=0;i<length;i++){
		if(s1[i]-'0'!=0){
			s[k++]=s1[i]-'0';
		}
	}
	length=k;
	for(int i=0;i<length;i++)total_sum+=s[i];
	for(j=2;j<=length;j++){
		flag=0;
		if(total_sum%j!=0) continue;
		sum=total_sum/j;
		k=0;
		while(k<length){
			temp=0;
			while(temp<sum && k<length){
				temp+=s[k];
				k++;
			}
			if(temp!=sum){flag=1;break;}
		}
		if(!flag)break;
	}
	if(length==0) printf("YES\n");
	else if(!flag && j <=length)printf("YES\n");
	else printf("NO\n");
	return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SORT(a,n) qsort(a,n,sizeof(int),intcmp)
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define fill(a,v)                   memset(a, v, sizeof(a))
int intcmp(const void *f,const void *s)
{
   return (*(int *)f -*(int *)s);
}
int gcd(int a,int b){ return ((b==0)?a:gcd(b,a%b));}

#define MAX
#define MODBY 1000000007

typedef long long int lld;
typedef long double Lf;
#define LOGMAX 12
lld cnt[LOGMAX][LOGMAX];//cnt[i][j] contains no of lucky numbers with i digits, of which j are lucky
lld cum_cnt[LOGMAX][LOGMAX];//cum_cnt[i][j] contains no of lucky numbers with <= i digits, of which j are lucky
int count_lucky(char *a,int rt)
{
   int ans=0,i;
   for(i=0;a[i];++i)
      if(a[i]=='4') ans++;
      else if(a[i]=='7') ans++;
   while(rt--){
      --i;
      if(a[i]=='4') --ans;
      else if(a[i]=='7') --ans;
   }
   return ans;
}
int isl[100];
lld real_cnt[LOGMAX]={};
void discount(lld n)
{
   char a[20];
   lld upper=1;
   int dig=0;
   for(upper=1;upper<n;upper*=10)
      dig++;
   //printf("dig is %lld\n",(lld)dig);
   //if(n!=upper)//think
   lld mult=1;
   int rt=0,i,j;
   lld inv_cnt[LOGMAX]={};
   while(n<upper){
      //  printf("n is now %lld\n",n);
      int low=(n/mult)%10;
      sprintf(a,"%lld",n);
      int carry=count_lucky(a,rt+1);
      // printf("carry is %d, low is %d\n",carry,low);
      for(i=low;i<=9;++i){
         ++inv_cnt[carry+isl[i]];//followed by all zeroes
         for(j=0; carry+isl[i]+j < LOGMAX;++j)
            inv_cnt[carry+isl[i]+j]+=cum_cnt[rt][j];
      }
      mult*=10;
      n=((n/mult)+1)*mult;
      rt++;
   }
   for(i=0;i<LOGMAX;++i){
      real_cnt[i]=0;
      real_cnt[i]+=cum_cnt[dig][i];
      //   printf("%lld ",real_cnt[i]);
      real_cnt[i]-=(inv_cnt[i]%MODBY);
      real_cnt[i]=(real_cnt[i]+MODBY)%MODBY;
   //      printf("%lld\n",real_cnt[i]);
   }
//   printf("\n");
}
void init()
{
   int i,j;
   isl[4]=isl[7]=1;
   cum_cnt[1][0]=cnt[1][0]=7;//not including zero
   cum_cnt[1][1]=cnt[1][1]=2;
   for(i=2;i<LOGMAX;++i){
      cnt[i][0]=(cnt[i-1][0]*8)%MODBY;
      cum_cnt[i][0]=cnt[i][0]+cum_cnt[i-1][0];
      //   printf("%lld\t",cum_cnt[i][0]);
      for(j=1;j<=i;++j){
         cnt[i][j]=(cnt[i-1][j]*8+cnt[i-1][j-1]*2)%MODBY;
         cum_cnt[i][j]=cnt[i][j]+cum_cnt[i-1][j];
         //    printf("%lld\t",cum_cnt[i][j]);
      }
      //   printf("\n");
   }
}
int get_cnt(int left,int sum,int *carry)
{
   int i;
   lld ans=0;
   if(left==0) return 1;
   for(i=sum;i>=0;--i){
      carry[i]++;
      ans+=(real_cnt[i]-carry[i]+1)*get_cnt(left-1,sum-i,carry);
      carry[i]--;
   }
   return (int)(ans%MODBY);
}

int main()
{
   int n,i;
   //system("clear");
   init();
   //n=8;
   scanf("%d",&n);
   discount((lld)(n+1));
   //return 0;
   int carry[LOGMAX]={};
   lld ans=0;
   for(i=0;i<LOGMAX;++i)
      if(real_cnt[i]){
         carry[i]++;
         ans+=(real_cnt[i]*get_cnt(6,i-1,carry))%MODBY;
         carry[i]--;
      }
   printf("%d\n",(int)(ans%MODBY));
   return 0;
}


#include<stdio.h>
int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
int main()
{
    int a,b,n,t,flag;
    while(scanf("%d%d%d",&a,&b,&n)!=EOF)
    {
        while(1)
        {
            t=gcd(a,n);
            n-=t;
            if(n<0)
            {
                flag=1;
                break;
            }
            t=gcd(b,n);
            n-=t;
            if(n<0)
            {
                flag=0;
                break;
            }
        }
        printf("%d\n",flag);
    }
    return 0;
}


#include <stdio.h>
#include<math.h>
int main(void) {
    // your code goes here
    int r,h,n,temp;
    float t;
    scanf("%d %d",&r,&h);
    temp=h/r;
    n=2*temp;
    t=h%r;
    if(t<0.5*r){
        n++;
    }
    else if(t>=0.5*r&&t<sqrt(3)*0.5*r){
        n+=2;
    }
    else{
        n+=3;
    }
    printf("%d",n);
    return 0;
}


/*interface*/
#include<stdio.h>
int max(int a,int b) {
    if(a>b) return a;
    else return b;
}
/*interface implementation*/
/*client*/
int main() {
    int a1,b1;
    scanf("%d%d",&a1,&b1);
    int a2,b2;
    scanf("%d%d",&a2,&b2);
    int a3,b3;
    scanf("%d%d",&a3,&b3);
    int is_ok=0;
    if(b2+b3<=b1 && max(a2,a3)<=a1) {
        is_ok=1;
    } else if(b2+a3<=b1 && max(a2,b3)<=a1) {
        is_ok=1;
    } else if(a2+b3<=b1 && max(b2,a3)<=a1) {
        is_ok=1;
    } else if(a2+a3<=b1 && max(b2,b3)<=a1) {
        is_ok=1;
    } else if(a2+a3<=a1 && max(b2,b3)<=b1) {
        is_ok=1;
    } else if(a2+b3<=a1 && max(b2,a3)<=b1) {
        is_ok=1;
    } else if(b2+a3<=a1 && max(a2,b3)<=b1) {
        is_ok=1;
    } else if(b2+b3<=a1 && max(a2,a3)<=b1) {
        is_ok=1;
    } else {
        is_ok=0;
    }
    if(is_ok) printf("YES\n");
    else printf("NO\n");

    return 0;
}


#include<stdio.h>
int main()
{
   char a[20];
   int i,sum;
   while(gets(a))
   {
      sum=0;
      for(i=0;a[i]!='\0';i++)
      {
         if(a[i]=='4' || a[i]=='7')
         {
            sum++;
         }
      }
      if(sum==4 ||sum==7)
      {
          printf("YES\n");
      }
      else
        {
            printf("NO\n");
            }
   }
    return 0;
}


#include <stdio.h>

int main(void) {
	// your code goes here

	int n,m,k,temp;
	scanf("%d %d %d",&n,&m,&k);
	if(k%(2*m)==0) printf("%d ", k/(2*m)); else printf("%d ",k/(2*m)+1);

	temp=k%(2*m);
	if(temp==0) printf("%d ",m);
	else{
	if(temp%2==0) printf("%d ",temp/2);
	else printf("%d ",temp/2+1);
	}

	if(k%2!=0) printf("L"); else printf("R");

	return 0;
}


#include <stdio.h>

int main() {
	int s;
	scanf("%d", &s);
	switch(s/10)
	{
	case 2:printf("twenty"); break;
	case 3:printf("thirty"); break;
	case 4:printf("forty"); break;
	case 5:printf("fifty"); break;
	case 6:printf("sixty"); break;
	case 7:printf("seventy"); break;
	case 8:printf("eighty"); break;
	case 9:printf("ninety"); break;
	}
	if( s % 10 != 0 && s > 20 ) {
		printf("-");
		s %= 10;
	}
	switch(s)
	{
	case 0: printf("zero"); break;
	case 1: printf("one"); break;
	case 2: printf("two"); break;
	case 3: printf("three"); break;
	case 4: printf("four"); break;
	case 5: printf("five"); break;
	case 6: printf("six"); break;
	case 7: printf("seven"); break;
	case 8: printf("eight"); break;
	case 9: printf("nine"); break;
	case 10: printf("ten"); break;
	case 11: printf("eleven"); break;
	case 12: printf("twelve"); break;
	case 13: printf("thirteen"); break;
	case 14: printf("fourteen"); break;
	case 15: printf("fifteen"); break;
	case 16: printf("sixteen"); break;
	case 17: printf("seventeen"); break;
	case 18: printf("eighteen"); break;
	case 19: printf("nineteen"); break;
	}
	return 0;
}


#include<stdio.h>
#include<math.h>

int main()
{
    unsigned int n,a,b,x,i=0;
    scanf("%u",&n);

    x = sqrt(n);

    if(x*x == n)
        printf("%u %u\n",x,x);
    else
    {
        for(i = x + 1;;i++)
        {
            if(x * i > n)
                x--;
            else if(x * i == n)
                break;
        }
        printf("%u %u\n",x,i);
    }

    return 0;
}


#include <stdio.h>
#include <string.h>

char Visit[256];

int Val(char *a)
{
    return (a[0] - 'A') * 64 + (a[1] - 'A') * 16 + (a[2] - 'A') * 4 + (a[3] - 'A');
}

void Change(char *str)
{
    if(str[0] == 'X') {
        str[0] = 'D';
    }
    if(str[1] == 'X') {
        str[1] = 'D';
    }
}

int main()
{
    char a[4];
    for(int i = 0; i < 2; ++i) {
        scanf("%s", a + 2 * i);
        Change(a + 2 * i);
    }
    int change[4][2] = {{1, 2}, {0, 3}, {0, 3}, {1, 2}};
    Visit[Val(a)] = 1;
    char queue[256][4];
    int head = 0, tail = 1;
    for(int i = 0; i < 4; ++i) {
        queue[0][i] = a[i];
    }
    while(head < tail) {
        for(int i = 0; i < 4; ++i) {
            if(queue[head][i] == 'D') {
                char update[4];
                for(int j = 0; j < 2; ++j) {
                    for(int k = 0; k < 4; ++k) {
                        update[k] = queue[head][k];
                    }
                    char temp = update[change[i][j]];
                    update[change[i][j]] = update[i];
                    update[i] = temp;
                    if(!Visit[Val(update)]) {
                        Visit[Val(update)] = 1;
                        memcpy(queue[tail], update, sizeof(update));
                        ++tail;
                    }
                }
            }
        }
        ++head;
    }
    for(int i = 0; i < 2; ++i) {
        scanf("%s", a + 2 * i);
        Change(a + 2 * i);
    }
    puts(Visit[Val(a)] ? "YES" : "NO");
    return 0;
}


#include<stdio.h>

int main(){
	long long res,a,b,w,x,c;
	scanf("%I64d%I64d%I64d%I64d%I64d",&a,&b,&w,&x,&c);
	if (a<c){
		res=(long long)(((double)(a-c)*w+b)/(x-w));
		if (res<(((double)(a-c)*w+b)/(x-w))) res+=1;
		printf("%I64d\n",res);
	}
	else printf("0\n");
	return 0;
}


#include <stdio.h>

typedef struct mk
{
	int day,type;
}roy;

int n,m,a[200010],l,r,tot=0;
roy off[200010],tmp[200020];

int ok(int days){
	int t[n+1];
	int need = 0,collect = days;
	for(int i = 0;i<n;i++) t[i] = a[i];
	for(int i = m-1;i>=0;i--){
		if(off[i].day>days) continue;
		collect = (collect<=off[i].day)?collect:off[i].day;
		int tp = (collect<=t[off[i].type-1])?collect:t[off[i].type-1];
		need += tp;
		t[off[i].type-1]-= tp;
		collect-=tp;
	}
	need += (tot - need)*2;
	return (need<=days);
}
void merge(roy *of, int s,int m,int e){
	int i = s,j = m+1,k = 0;
	while (i<=m && j<=e){
		if(of[i].day==of[j].day){
			tmp[k++] = (a[of[i].type-1]<a[of[j].type-1])?of[i++]:of[j++];
		}
		else tmp[k++] = (of[i].day<of[j].day)?of[i++]:of[j++];
	}
	while (i<=m) tmp[k++] = of[i++];
	while (j<=e) tmp[k++] = of[j++];
	for(int i = s;i<=e;i++) {
		of[i] = tmp[i-s];
	}
}
void sort(roy *of, int s,int e){
	if(s<e){
		int m = (e+s)/2;
		sort(of,s,m);
		sort(of,m+1,e);
		merge(of,s,m,e);
	}
}
void solve(){
	scanf("%d%d",&n,&m);
	for(int i = 0;i<n;i++){
		scanf("%d",a+i);
		tot += a[i];
	}
	for(int i = 0;i<m;i++){
		scanf("%d%d",&off[i].day,&off[i].type);
	}
	sort(off, 0, m-1);
	l = 1;r = tot*2+1;
	int Ans;
	while (l<=r)
	{
		int m = (l+r)/2;
		if(ok(m)){
			Ans  = m;
			r = m-1;
		}
		else l = m+1;
	}
	for(int i = l;i<=r;i++){
		if(ok(i)){
			Ans = i;
			break;
		}
	}
	printf("%d\n",Ans);
}
int main(){
	solve();
	return 0;
}


#include<stdio.h>
int main()
{
    int k,n,w,c,i;
    scanf("%d%d%d",&k,&n,&w);
    c=0;
    for(i=1;i<=w;i++)
    {
        c=c+(k*i);
    }
    if(c>=n)
    {
    printf("%d",(c-n));
    }
    else
    {
    printf("0");
    }
    return 0;
}


#include<stdio.h>

int main()
{
    int n,i,c=0;
    scanf("%d",&n);
    for(i=1; i<n; i++)
    {
        if((n-i)%i==0)
        {
            c++;
        }
    }
    printf("%d",c);
    return 0;
}


#include<stdio.h>

int main(void){
  int check,i,l,d,v,g,r,sum=0,roop;
  double t1,t2,t;
  scanf("%d %d %d %d %d",&l,&d,&v,&g,&r);
  roop=g+r;
  t1=(double)d/v;
  //printf("t1:%f\n",t1);
  i=1;
  while(sum<t1){
    if(i%2){
      sum+=g;
      if(sum>t1) check=2;
      else if(sum==t1) check=3;
    }else{
      sum+=r;
      if(sum>t1) check=1;
      else if(sum==t1) check=2;
    }
    i++;
  }
  if(check==1) t1=sum;
  else if(check==3) t1+=r;
  //printf("t1:%f\n",t1);
  t2=((double)l-(double)d)/v;
  //printf("t2:%f\n",t2);
  t=t1+t2;
  printf("%f\n",t);
  return 0;
}


#include <stdio.h>

long long zcy(long long m)
{
    long long ans = m;
    while (m > 0)
    {
        ans = ans * 10 + m % 10;
        m /= 10;
    }
    return ans;
}

int main()
{
    int k, p,i;

    scanf("%d %d", &k, &p);
    long long sum = 0;

    for (i = 1; i <= k; i++)

        sum = (sum + zcy(i)) % p;

    printf("%I64d\n", sum);

    return 0;
}


#include <stdbool.h>
#include <stdio.h>

int main() {
    int n, m;
    scanf("%d %d", &n, &m);

    int digits[14] = {0};
    bool dup = true;
    while (n) {
        int d = n % m;
        if (digits[d]) {
            dup = false;
            break;
        } else {
            digits[d] = 1;
        }

        n /= m;
    }

    if (dup) {
        puts("YES");
    } else {
        puts("NO");
    }
}


#include <stdio.h>

int main()
{
	int ibit;
	unsigned long long l, r, x, res, bit;
	scanf("%I64d%I64d", &l, &r);
	x = l ^ r;
	res = 0;
	for ( ibit = 63; --ibit >= 0; )
	{
		bit = (unsigned long long) 1 << ibit;
		if ( x & bit )
		{
			res |= bit;
			if ( r & bit )
			{
				res |= bit - 1;
				break;
			}
		}
		else if ( (l >> ibit) == (r >> ibit) )
			continue;
		else if ( !(l & bit) )
		{
			res |= bit | bit - 1;
			break;
		}
		else if ( r & bit )
		{
			res |= bit | bit - 1;
			break;
		}
	}
	printf("%I64d\n", res);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
    char ch[101];
    gets(ch);
    int i,count[100] = {0},s=0,sum=0;
    if(ch[strlen(ch)-1] != 'n'&&ch[strlen(ch)-1] != 'a'&&ch[strlen(ch)-1] != 'e'&&ch[strlen(ch)-1] != 'i'&&ch[strlen(ch)-1] != 'o'&&ch[strlen(ch)-1] != 'u'){
        printf("NO\n");
        return 0;
    }
    if(strcmp(ch,"nn")==0){
        printf("YES\n");
        return 0;
    }
    if(strlen(ch)==1){
        if(ch[0] == 'a'||ch[0] =='e'||ch[0] =='i'||ch[0] =='o'||ch[0] =='u'||ch[0] == 'n')
            printf("YES\n");

        else
            printf("NO\n");
        return 0;
    }
    if(strlen(ch)==2){
        if(ch[1] == 'a'||ch[1] =='e'||ch[1] =='i'||ch[1] =='o'||ch[1] =='u')
            printf("YES\n");

        else
            printf("NO\n");
        return 0;
    }
    for(i=0; i<strlen(ch); i++){
        if(ch[i] == 'a'||ch[i] =='e'||ch[i] =='i'||ch[i] =='o'||ch[i] =='u')continue;
        else if(ch[i] == 'n')count[i]+=2;
        else
            count[i]++;
    }
    for(i=0; i<strlen(ch); i++){
        if(count[i]==1&&count[i+1]==1){
            printf("NO\n");
            s++;
            break;
        }
        if(count[i]==2&&count[i-1]==1){
            printf("NO\n");
            s++;
            break;
        }

    }
    for(i=0; i<strlen(ch); i++){
        sum+=count[i];
    }
    if(sum==1&&count[strlen(ch)-1]==1){
            printf("NO\n");
            return 0;
    }
    if(s==0)printf("YES\n");

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

long long int XY(int A, int B, int C, int X_plus_Y)
{
	long long int x = 0;
	int i;
	int j1, j2;

	i = A;
	j1 = X_plus_Y - i;

	if(j1>C)
	{
		j1 = C;
	}

	i = B;
	j2 = X_plus_Y - i;

	if(j2<B)
	{
		j2 = B;
	}

	return j1-j2+1;
}

long long int Z(int C, int D, int X_plus_Y)
{
	int min;
	long long int z;
	if( X_plus_Y-1 <= D)
	{
		min = X_plus_Y-1;
	}
	else
	{
		min = D;
	}

	z = min - C + 1;
	if(z<0)
	{
		return 0;
	}

	return z;
}

int main()
{
	// variable in description
	int T;
	int A, B, C, D;
	// variable to support
	long long int ans;
	long long int XY_num;
	long long int Z_num;
	// variable to judge
	int i;
	int j;
	int k;

		scanf("%d %d %d %d",&A,&B,&C,&D);

		ans = 0;

		for(j=A+B;j<=B+C;j++)
		{
			XY_num = XY(A,B,C,j);
			Z_num = Z(C,D,j);
			ans += XY_num*Z_num;
			//printf("%d %d\n",XY_num,Z_num);
		}

		printf("%lld\n",ans);

	return 0;
}


#include<stdio.h>
#include<string.h>

int main()
{
    int n,i,l,k,j;
    char a[8][10] = {"vaporeon","jolteon","flareon","espeon","umbreon","leafeon","glaceon","sylveon"};
    char b[10];
    scanf("%d %s",&n,b);
    for(i=0; i<8; i++)
    {
        if(strlen(a[i])==n)
        {
            l = 0,k = 0;
            for(j=0; b[j]; j++)
            {
                if(b[j]=='.')   l++;
                else if(b[j]==a[i][j])  k++;
                else    break;
            }
        }
        if(l+k==strlen(b))
        {
            printf("%s\n",a[i]);
            return 0;
        }
    }
}


#include <stdio.h>

int main() {
    int i, n, winner[100], spectator[100] = {3};
    scanf("%d", &n);
    for(i = 0; i < n; i++) {
        scanf("%d", &winner[i]);
        if (i)
            spectator[i] = 6 - winner[i - 1] - spectator[i - 1];
    }
    for(i = 0; i < n; i++) {
        if (winner[i] == spectator[i]) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int i,j,n,max=-1,count,a;
    char c1,c2;
    scanf("%d",&n);
    char s[n];
    scanf("%s",s);
    for(i=0;i<n-1;i++)
    {
        count=0;
        for(j=i+1;j<n-1;j++)
        {
            if(s[j]==s[i])
            {
                if(s[j+1]==s[i+1])
                    count++;
            }
        }
        if(count>max)
        {
            max=count;
            c1=s[i];
            c2=s[i+1];
        }
    }
    printf("%c%c\n",c1,c2);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    char str[200],c1,c2;
    scanf("%s", str);
    int i, s1, s2, sum=0;
    for(i=0; i<strlen(str); i++){
        if(i==0){
            s1=str[i]-'a';
            s2='a'-str[i]+26;
            if(s1<s2){
                sum=sum+s1;
            }
            else{
                sum=sum+s2;
            }
        }
        else{
            if(str[i]>str[i-1]){
                c1=str[i-1];
                c2=str[i];
            }
            else{
                c1=str[i];
                c2=str[i-1];
            }
            s1=c2-c1;
            s2=c1-c2+26;
            if(s1<s2){
                sum=sum+s1;
            }
            else{
                sum=sum+s2;
            }
        }

    }
    printf("%d\n", sum);
}


#include <stdio.h>
#include <string.h>
int ar[9];
int main()
{
	char s[60];
	int i,j,len;
	scanf("%s",s);
	len=strlen(s);
	for (i=0; i<len; i++)
	{
		if (s[i]=='4') ar[4]++;
		else if (s[i]=='7') ar[7]++;
	}
	if (ar[4]==0 && ar[7]==0) printf("-1\n");
	else if (ar[4]==ar[7]) printf("4\n");
	else if (ar[4]>ar[7]) printf("4\n");
	else printf("7\n");

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <conio.h>

int main()
{
    int n,i,j,k,l,min;
    scanf("%d",&n);

    int len=1,num=n;

    while(1){
        num=num/10;
        if(num==0){
            break;
        }
        else{
            len++;
        }
    }

    min=len;

    for(i=1;i*i<=n;i++){
        j=i*i;
        num=j;
        k=1;

        while(1){
            num=num/10;
            if(num==0){
                break;
            }
            else{
                k++;
            }
        }

        num=n;
        l=k;

        while(1){
            while(1){
                if(num%10==j%10){
                    num=num/10;
                    l--;
                    break;
                }
                else{
                    num=num/10;
                    if(num==0){
                        break;
                    }
                }
            }
            if(l==0){
                if((len-k)<min){
                    min=len-k;
                }
                break;
            }
            else if(num==0){
                break;
            }
            j=j/10;
        }
    }

    if(min==len){
        printf("%d\n",-1);
    }
    else{
        printf("%d\n",min);
    }

    return 0;
}


#ifndef _TJYTLXWXHYZQFW_COMMON_H
#define _TJYTLXWXHYZQFW_COMMON_H
#include <assert.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define offset(t,m) ((unsigned long)&(((t*)0)->m))
#define container_of(a,t,m) ((t*)((unsigned long)a-offset(t,m)))
#define ULL1 ((unsigned long long )1)
#define LL(x) ((long long)(x))
#define SWP(a, b) if ((a) != (b)) do {(a) ^= (b); (b) ^= (a); (a) ^= (b);} while(0)
#define IOF(p) ((p) = ((p) < 0 ? INT_MAX : (p)))
#define LLOF(p) ((p) = ((p) < 0 ? LLONG_MAX :(p)))
#define ir(x, start, end) ((x) >= (start) && (x) < (end))
#define ire(x, start, end) ((x) >= (start) && (x) <= (end))
#define max(x,y) ((x) < (y) ? (y) : (x))
#define min(x, y) ((x) < (y) ? (x) : (y))
#define abv(x) ((x) < 0 ? (x) * (-1) : (x))
#define forn(i, n) for ((i) = 0; (i) < (n); (i) += 1)
#define fore(i, n) for ((i) = 0; (i) <= (n); (i) += 1)
#define forr(i, s, e) for((i) = (s); (i) < (e); (i) += 1)
#define forre(i, s, e) for((i) = (s); (i) <= (e); (i) += 1)
#endif
#ifndef _WCC_NUMTH_H
#define _WCC_NUMTH_H
#include <assert.h>
#define NUMTH_ENS (-1)
#define NUMTH_MODPLS(x, y, p) ((((x) % (p)) + ((y) % (p))) % p)
#define NUMTH_MODMUL(x, y, p) ((((X) % (P)) * ((y) % (p))) % p)
#define NUMTH_CORRECT(x, mod) ((x) += ((x) < 0 ? (mod) : 0))
long long numth_modexp(long long a, long long b, long long n);
long long numth_gcd(long long a, long long b);
void numth_gcd_e(long long a, long long b, long long *d, long long *x, long long *y);
int numth_mle(long long a, long long b, long long n, long long *x, long long *gcd);
#define numth_for_each_solution(i, x, n, d) \
	for ((i) = 0; (i) < (d); (i) += 1, (x) = ((x) + (n) / (d)) % (n))
int numth_divisors(long long k, long long divs[], long long *ndivs);
#endif
#define M 1000000007
#define T 100
#define K 1000
#define pls(a, b) NUMTH_MODPLS((a), (b), M)
int dp[2*T][4*T*K+1];
int a, b, t, k;
int delta, delta_min, delta_max, offset, index_max;
int dp_fill(int i, int j)
{
	int x;
	if (j == index_max-k) {
		dp[i][j] = 0;
		forre(x, j-k, j+k) dp[i][j] = pls(dp[i][j], dp[i+1][x]);
	} else {
		dp[i][j] = pls(pls(dp[i+1][j-k], dp[i][j+1]), -1*dp[i+1][j+k+1]);
		NUMTH_CORRECT(dp[i][j], M);
	}
	return dp[i][j];
}
int main(void)
{
	int i, j;
	scanf("%d%d%d%d", &a, &b, &k, &t);
	t <<= 1;
	delta = a - b;
	delta_min = delta - t * k;
	delta_max = delta + t * k;
	offset = -1 * delta_min;
	index_max = delta_max + offset;
	forre(i, 0, index_max) dp[t-1][i] = max(0, k-max(-1*k, offset-i+1)+1);
	for (i = t-2; i >= 0; --i)
		for (j = index_max-k; j >= k; --j)
			dp_fill(i, j);
	printf("%d\n", dp[0][delta+offset]);
	return 0;
}


#include <stdio.h>
#define ll long long
int main()
{
	ll n,k;
	scanf("%lld %lld", &n,&k);
	if(k>50){
		printf("No");
		return 0;
	}
	for(int i=1;i<=k;i++)
		for(int j=i+1;j<=k;j++){
			if(n%i==n%j){
				printf("No");
				return 0;
			}
		}
		printf("Yes");
}


#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int64_t i64;
typedef int32_t i32;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

#define MAX(a,b) ((a)>(b)?(a):(b))
#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

#define POS(i, j, k) ((((i) & 1) * (n + 1) + (j)) * (n + 1) + (k))

void run (void) {
  const i32 n = read_int();
  const i32 m = read_int();
  const i32 mod = 998244353;
  i64 *dp = ALLOC (2 * (n + 1) * (n + 1), i64);
  dp[POS(1, 1, 1)] = 1;
  for (i32 i = 1; i < n; ++i) {
    memset (dp + POS(i + 1, 0, 0), 0, sizeof (*dp) * (n + 1) * (n + 1));
    for (i32 j = 1; j <= i; ++j) {
      for (i32 k = 1; k <= i; ++k) {
        dp[POS(i, j, k)] %= mod;
        dp[POS(i + 1, MAX (j, k + 1), k + 1)] += dp[POS(i, j, k)];
        dp[POS(i + 1, j, 1)] += dp[POS(i, j, k)];
      }
    }
  }
  i64 *way = ALLOC (n + 1, i64);
  for (i32 j = 1; j <= n; ++j) {
    for (i32 k = 1; k <= j; ++k) {
      way[j] += dp[POS(n, j, k)] % mod;
    }
  }
  for (i32 i = 1; i <= n; ++i) {
    way[i] %= mod;
  }
  i64 ans = 0;
  for (i32 i = 1; i <= n; ++i) {
    for (i32 j = 1; j <= n; ++j) {
      if (i * j < m) {
        ans += way[i] * way[j] % mod;
      }
    }
  }
  ans = 2 * ans % mod;
  print_int (ans);
  puts ("");
}

int main (void) {
  run ();
  return 0;
}


#include <stdio.h>
#include <stdlib.h>

#define N	200000
#define L_	19	/* L_ = ceil(log2(N * 2 + 1)) */
#define N_	(1 << L_)
#define MD	998244353

int min(int a, int b) { return a < b ? a : b; }

long long power(long long a, int k) {
	long long p = 1;

	while (k) {
		if (k & 1)
			p = p * a % MD;
		a = a * a % MD;
		k >>= 1;
	}
	return p;
}

int vv[N + 1], ff[N + 1], gg[N + 1], mobius[N + 1];
int *wwu[L_ + 1], *wwv[L_ + 1], vv_[L_ + 1];

void init() {
	int i, j, l, u, v;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;
		ff[i] = (long long) ff[i - 1] * i % MD;
		gg[i] = (long long) gg[i - 1] * vv[i] % MD;
	}
	for (i = 2; i <= N; i++) {
		if (mobius[i])
			continue;
		for (j = i; j <= N; j += i)
			mobius[j]++;
	}
	for (i = 2; i <= N / i; i++)
		for (j = i * i; j <= N; j += i * i)
			mobius[j] = -1;
	for (i = 1; i <= N; i++)
		mobius[i] = mobius[i] == -1 ? 0 : (mobius[i] % 2 == 0 ? 1 : -1);
	u = power(3, MD - 1 >> L_), v = power(u, MD - 2);
	for (l = L_; l > 0; l--) {
		int n = 1 << l, m = n >> 1;

		wwu[l] = (int *) malloc(m * sizeof *wwu[l]);
		wwv[l] = (int *) malloc(m * sizeof *wwv[l]);
		wwu[l][0] = wwv[l][0] = 1;
		for (i = 1; i < m; i++) {
			wwu[l][i] = (long long) wwu[l][i - 1] * u % MD;
			wwv[l][i] = (long long) wwv[l][i - 1] * v % MD;
		}
		vv_[l] = power(1 << l, MD - 2);
		u = (long long) u * u % MD, v = (long long) v * v % MD;
	}
	vv_[0] = 1;
}

int choose(int n, int k) {
	return (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

void ntt_(int *aa, int l, int inverse) {
	if (l) {
		int n = 1 << l, m = n >> 1, *ww = inverse ? wwv[l] : wwu[l], i, j;

		ntt_(aa, l - 1, inverse), ntt_(aa + m, l - 1, inverse);
		for (i = 0; (j = i + m) < n; i++) {
			int a = aa[i], b = (long long) aa[j] * ww[i] % MD;

			if ((aa[i] = a + b) >= MD)
				aa[i] -= MD;
			if ((aa[j] = a - b) < 0)
				aa[j] += MD;
		}
	}
}

void ntt(int *aa, int l, int inverse) {
	int n = 1 << l, i, j;

	for (i = 1, j = 0; i < n; i++) {
		int b = n >> 1, tmp;

		while ((j ^= b) < b)
			b >>= 1;
		if (i < j)
			tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
	}
	ntt_(aa, l, inverse);
}

void multiply(int *aa, int *bb, int n) {
	static int aa_[N_], bb_[N_];
	int n_, l_, i;

	l_ = 0;
	while (1 << l_ < n + n - 1)
		l_++;
	n_ = 1 << l_;
	for (i = 0; i < n_; i++) {
		aa_[i] = i < n ? aa[i] : 0;
		bb_[i] = i < n ? bb[i] : 0;
	}
	ntt(aa_, l_, 0), ntt(bb_, l_, 0);
	for (i = 0; i < n_; i++)
		aa_[i] = (long long) aa_[i] * bb_[i] % MD;
	ntt(aa_, l_, 1);
	for (i = 0; i < n; i++)
		aa[i] = (long long) aa_[i] * vv_[l_] % MD;
}

void inv(int *aa, int *bb, int n) {
	static int aa_[N_], bb_[N_];
	int m, n_, l_, i;

	if (n == 1) {
		bb[0] = 1;
		return;
	}
	m = (n + 1) / 2;
	inv(aa, bb, m);
	l_ = 0;
	while (1 << l_ < n * 2)
		l_++;
	n_ = 1 << l_;
	for (i = 0; i < n_; i++) {
		aa_[i] = i < n ? aa[i] : 0;
		bb_[i] = i < m ? bb[i] : 0;
	}
	ntt(aa_, l_, 0), ntt(bb_, l_, 0);
	for (i = 0; i < n_; i++)
		aa_[i] = bb_[i] * (MD + 2 - (long long) aa_[i] * bb_[i] % MD) % MD;
	ntt(aa_, l_, 1);
	for (i = 0; i < n; i++)
		bb[i] = (long long) aa_[i] * vv_[l_] % MD;
}

void log_(int *aa, int *bb, int n) {
	static int pp[N + 1], qq[N + 1];
	int i;

	for (i = 0; i < n; i++)
		pp[i] = i + 1 == n ? 0 : (long long) aa[i + 1] * (i + 1) % MD;
	inv(aa, qq, n);
	multiply(pp, qq, n);
	for (i = 0; i < n; i++)
		bb[i] = i == 0 ? 0 : (long long) pp[i - 1] * vv[i] % MD;
}

void exp_(int *aa, int *bb, int n) {
	static int aa_[N + 1], bb_[N + 1], cc_[N + 1];
	int m, i;

	if (n == 1) {
		bb[0] = 1;
		return;
	}
	m = (n + 1) / 2;
	exp_(aa, bb, m);
	for (i = 0; i < n; i++)
		bb_[i] = i < m ? bb[i] : 0;
	log_(bb_, cc_, n);
	for (i = 0; i < n; i++)
		aa_[i] = (aa[i] - cc_[i] + MD) % MD;
	aa_[0] = (aa_[0] + 1) % MD;
	multiply(aa_, bb_, n);
	for (i = 0; i < n; i++)
		bb[i] = aa_[i];
}

int bell[N + 1];

void compute_bell() {
	static int aa[N + 1];
	int i;

	for (i = 1; i <= N; i++)
		aa[i] = gg[i];
	exp_(aa, bell, N + 1);
	for (i = 0; i <= N; i++)
		bell[i] = (long long) bell[i] * ff[i] % MD;
}

int sum(int n, int k) {
	static int aa[N + 1], bb[N + 1];
	int i, ans;

	if (k > n)
		return (bell[n] - 1 + MD) % MD;
	for (i = 0; i <= k; i++)
		aa[i] = power(i, n) * gg[i] % MD;
	for (i = 0; i <= k; i++)
		bb[i] = (long long) (i % 2 == 0 ? 1 : MD - 1) * gg[i] % MD;
	multiply(aa, bb, k + 1);
	ans = MD - 1;
	for (i = 0; i <= k; i++)
		ans = (ans + aa[i]) % MD;
	return ans;
}

int main() {
	int n, k, d, ans;

	init();
	scanf("%d%d", &n, &k);
	if (k == 1 || n == 1) {
		printf("1\n");
		return 0;
	}
	compute_bell();
	ans = 0;
	for (d = 1; d < n; d++)
		if (mobius[d])
			ans = (ans + sum((n + d - 1) / d, k) * mobius[d]) % MD;
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,i=0,k=0,l=0;
    scanf("%d",&n);
    char *a=(char*)malloc(sizeof(char)*(n+1));
    int *c=(int*)malloc(sizeof(int)*n);
    scanf("%s",a);
    for(i=0;i<n;i++)
    {
        c[i]=0;
    }
    i=0;
    while(i<n)
    {
        while(i<n&&a[i]=='B')
        {
           c[k]=c[k]+1;
           if(i<n-1&&a[i+1]=='W')
           {
            k++;
           }
             i++;
        }
        i++;
    }
    i=0;
    while(i<n&&c[i]!=0)
    {
        l=l+1;
        i++;
    }
    printf("%d\n",l);
    for(i=0;i<n;i++)
    {   if(c[i]!=0)
        printf("%d\t",c[i]);
    }
    return 0;
}


#include <stdio.h>
int main()
{
     int n,i,j,m=0;
     char pass[3],kash[100][2];
     scanf("%s",pass);
     scanf("%d",&n);
     for(i=0;i<n;i++)
     {
         scanf("%s",kash[i]);
     }
    for(i=0;i<n;i++)
    {
        if(pass[0]==kash[i][0])
            {
                if(pass[1]==kash[i][1])
                m=2;
            }
    }
    for(i=0;i<n;i++)
    {
        if(pass[0]==kash[i][1])
             for(j=0;j<n;j++)
            {
                if(pass[1]==kash[j][0])
                m=2;
            }
    }
    if(m==2)
        printf("YES");
    else printf("NO");
    return 0;
}


#include<stdio.h>
#include<conio.h>
int main()
{
  int n, a[10000],p=0,q=0, i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
     scanf("%d",&a[i]) ;
     if(a[i] >0)
          p++;
     else if(a[i] <0)
           q++;
  }
  float f=n/2.0;
  if(p>=f)
     printf("1\n");
  else if(q>=f)
     printf("-1\n");
  else
      printf("0");
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int comp(const void* a, const void* b) {
    return(*(int*)a - *(int*)b);
}

int main() {
    int n, k, p[50], s1 = 0, s2 = 0, res;
    scanf("%d", &n);
    k = n/2;
    for (int i=0; i<k; ++i)
        scanf("%d", &p[i]);
    qsort(p, k, sizeof(int), comp);
    for (int i=0; i<k; ++i) {
        s1 += abs(p[i] - (2*i + 1));
        s2 += abs(p[i] - (2*i + 2));
    }
    if (s1 < s2) res = s1;
    else res = s2;
    printf("%d", res);
    return 0;
}


#include <stdio.h>
#include <stdint.h>
#define ll int64_t

struct pr
{
    ll f, s;
} a[100001], b[100001];

int cmp(const void* p1, const void* p2)
{
    ll d = - ((const struct pr*)p1)->f + ((const struct pr*)p2)->f;
    if (d) return d < 0 ? -1 : 1;
    return ((const struct pr*)p1)->s - ((const struct pr*)p2)->s > 0 ? 1 : -1;
}

int main()
{
    int n, m; ll d;
    scanf("%d%d%I64d", &n, &m, &d);
    for(int i = 0; i < n; ++i)
    {
        scanf("%I64d%I64d", &(a[i].f), &(a[i].s));
    }
    for(int i = 0; i < m; ++i)
    {
        scanf("%I64d%I64d", &(b[i].f), &(b[i].s));
    }
    qsort(a, n, sizeof(struct pr), cmp);
    qsort(b, m, sizeof(struct pr), cmp);
    for(int i = 1; i < n; ++i)
    {
        a[i].f += a[i-1].f;
        a[i].s += a[i-1].s;
    }
    for(int i = 1; i < m; ++i)
    {
        b[i].f += b[i-1].f;
        b[i].s += b[i-1].s;
    }
    int i = 0, j = 0;
    if (a[0].s + b[0].s > d)
    {
        printf("0");
        return 0;
    }
    while(i < n && a[i].s + b[0].s <= d) ++i;
    ll ans = 0;
    while(j < m && i >= 0)
    {
        if (i < n && a[i].s + b[j].s <= d)
        {
            if (a[i].f + b[j].f > ans) ans = a[i].f + b[j].f;
            ++j;
        }
        else --i;
    }
    printf("%I64d", ans);
    return 0;
}


/* https://codeforces.com/contest/1185/submission/55797221 (Dukkha) */
#include <stdio.h>

#define N	50
#define T	2500
#define MD	1000000007

int dp[N + 1][N + 1][N + 1], dq[N + 1][N + 1][N + 1][3];

void init(int na, int nb, int nc) {
	int ma, mb, mc, x0, x1, x2;

	for (ma = 0; ma <= na; ma++)
		for (mb = 0; mb <= nb; mb++)
			for (mc = 0; mc <= nc; mc++) {
				x0 = ma > 0 ? (long long) dq[ma - 1][mb][mc][0] * ma % MD : 0;
				x1 = mb > 0 ? (long long) dq[ma][mb - 1][mc][1] * mb % MD : 0;
				x2 = mc > 0 ? (long long) dq[ma][mb][mc - 1][2] * mc % MD : 0;
				if (ma == 0 && mb == 0 && mc == 0) {
					dp[ma][mb][mc] = 1;
					dq[ma][mb][mc][0] = dq[ma][mb][mc][1] = dq[ma][mb][mc][2] = 1;
				} else {
					dp[ma][mb][mc] = ((long long) x0 + x1 + x2) % MD;
					dq[ma][mb][mc][0] = (x1 + x2) % MD;
					dq[ma][mb][mc][1] = (x0 + x2) % MD;
					dq[ma][mb][mc][2] = (x0 + x1) % MD;
				}
			}
}

void solve1(int *aa, int t, int n, int da[][N + 1]) {
	int i, s, m, a;

	for (s = 0; s <= t; s++)
		for (m = 0; m <= n; m++)
			da[0][0] = 0;
	da[0][0] = 1;
	for (i = 0; i < n; i++) {
		a = aa[i];
		for (s = t; s >= a; s--)
			for (m = 1; m <= n; m++)
				da[s][m] = (da[s][m] + da[s - a][m - 1]) % MD;
	}
}

void solve2(int *aa, int *bb, int t, int na, int nb, int dab[][N + 1][N + 1]) {
	static int da[T + 1][N + 1];
	int i, b, s, ma, mb;

	solve1(aa, t, na, da);
	for (s = 0; s <= t; s++)
		for (ma = 0; ma <= na; ma++) {
			dab[s][ma][0] = da[s][ma];
			for (mb = 1; mb <= nb; mb++)
				dab[s][ma][mb] = 0;
		}
	for (i = 0; i < nb; i++) {
		b = bb[i];
		for (s = t; s >= b; s--)
			for (ma = 0; ma <= na; ma++)
				for (mb = 1; mb <= nb; mb++)
					dab[s][ma][mb] = (dab[s][ma][mb] + dab[s - b][ma][mb - 1]) % MD;
	}
}

int main() {
	static int aa[N], bb[N], cc[N], dab[T + 1][N + 1][N + 1], dc[T + 1][N + 1];
	int n, na, nb, nc, t, tab, tc, ma, mb, mc, xab, xc, ans;

	scanf("%d%d", &n, &t);
	na = nb = nc = 0;
	while (n--) {
		int a, g;

		scanf("%d%d", &a, &g);
		if (g == 1)
			aa[na++] = a;
		else if (g == 2)
			bb[nb++] = a;
		else
			cc[nc++] = a;
	}
	init(na, nb, nc);
	solve1(cc, t, nc, dc);
	solve2(aa, bb, t, na, nb, dab);
	ans = 0;
	for (tab = 0; tab <= t; tab++) {
		tc = t - tab;
		for (ma = 0; ma <= na; ma++)
			for (mb = 0; mb <= nb; mb++)
				if ((xab = dab[tab][ma][mb]))
					for (mc = 0; mc <= nc; mc++)
						if ((xc = dc[tc][mc]))
							ans = (ans + (long long) xab * xc % MD * dp[ma][mb][mc]) % MD;
	}
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>
int main()
{
    int n,a=0;
    scanf("%d",&n);
    int i,w;
    for(i=0;i<n;i++)
    {
        scanf("%d",&w);
        if(w==100)a++;
    }
    if(a%2==1||(n%2==1&&a==0))printf("NO");
    else printf("YES");
    return 0;
}


#include <stdio.h>

int main()
{
    puts("Karen");
    return 0;
}


#include <stdio.h>
#include <math.h>

struct table
{
    int arr[10];
};

void fillt(struct table *t, int n)
{
    int x;
    for(x = 0; x < 10; x++)
    {
        t->arr[x] = 0;
    }
    while(n)
    {
        t->arr[n % 10] = 1;
        n /= 10;
    }
}

int compt(struct table *a, struct table *b)
{
    int x;
    for(x = 0; x < 10; x++)
    {
        if(a->arr[x] == 1 && b->arr[x] == 1)
        {
            return 1;
        }
    }
    return 0;
}

int main()
{
    int n;
    scanf("%d", &n);
    int x;
    struct table nt, xt;
    fillt(&nt, n);
    int ans = 0;
    for(x = 1; x <= sqrt(n); x++)
    {
        if(n % x == 0)
        {
            fillt(&xt, x);
            ans += compt(&xt, &nt);
            if(n / x != x)
            {
                fillt(&xt, n / x);
                ans += compt(&xt, &nt);
            }
        }
    }
    printf("%d", ans);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define maximun 50

int cambia_letra(char x)
{
    switch(x)
    {
    case 'a':
        return 1;
    case 'b':
        return 2;
    case 'c':
        return 3;
    case 'd':
        return 4;
    case 'e':
        return 5;
    case 'f':
        return 6;
    case 'g':
        return 7;
    case 'h':
        return 8;
    }
    return 0;
}

int main()
{
    char coordenada[3];
    int resptorre[9][2], respcaballo[9][2],i,j;
    int pasos_caballo[8][2]={{-2,1},{-1,2},{1,2},{2,1},{2,-1},{1,-2},{-1,-2},{-2,-1}};

    gets(coordenada);
    resptorre[0][0]=atoi(&coordenada[1]);
    resptorre[0][1]=cambia_letra(coordenada[0]);

    gets(coordenada);
    respcaballo[0][0]=atoi(&coordenada[1]);
    respcaballo[0][1]=cambia_letra(coordenada[0]);

    for(i=0;i<=7;i++)
    {
        if(resptorre[0][0]+pasos_caballo[i][0]>=1 && resptorre[0][0]+pasos_caballo[i][0]<=8 && resptorre[0][1]+pasos_caballo[i][1]>=1 && resptorre[0][1]+pasos_caballo[i][1]<=8)
        {
            resptorre[i+1][0]=resptorre[0][0]+pasos_caballo[i][0];
            resptorre[i+1][1]=resptorre[0][1]+pasos_caballo[i][1];
        }
        else
        {
            resptorre[i+1][0]=0;
            resptorre[i+1][1]=0;
        }

    }

        for(i=0;i<=7;i++)
    {
        if(respcaballo[0][0]+pasos_caballo[i][0]>=1 && respcaballo[0][0]+pasos_caballo[i][0]<=8 && respcaballo[0][1]+pasos_caballo[i][1]>=1 && respcaballo[0][1]+pasos_caballo[i][1]<=8)
        {
            respcaballo[i+1][0]=respcaballo[0][0]+pasos_caballo[i][0];
            respcaballo[i+1][1]=respcaballo[0][1]+pasos_caballo[i][1];
        }
        else
        {
            respcaballo[i+1][0]=0;
            respcaballo[i+1][1]=0;
        }

    }

    for(i=1;i<=8;i++)
    {

        if(resptorre[i][0]!=0)
        {
            for(j=1;j<=8;j++)
            {
                if((resptorre[i][0]==respcaballo[j][0] && resptorre[i][1]==respcaballo[j][1]) || resptorre[0][0]==respcaballo[j][0] || resptorre[0][1]==respcaballo[j][1])
                {
                    respcaballo[j][0]=0;
                    respcaballo[j][1]=0;
                }
            }
        }
    }
    j=0;
    for(i=0;i<=8;i++)
    {
        if(resptorre[i][0]!=0) j++;
        if(respcaballo[i][0]!=0) j++;
    }
    printf("%d",maximun-j);
    return 0;
}


#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
	char minutes[102];
	scanf("%s", minutes);

	unsigned short nMissedTrains = 0;
	unsigned long nDigits = strlen(minutes);
	if(nDigits % 2 == 0)
	{
		printf("%ld", (strlen(minutes) / 2));
		return 0;
	}
	else
	{
		nMissedTrains = (strlen(minutes) / 2);
	}

	unsigned short nOnes, i;
	nOnes = i = 0;
	while(nOnes <= 1 && minutes[i] != '\0')
	{
		if(minutes[i] == '1')
			nOnes++;
		i++;
	}

	if(nOnes > 1)
		nMissedTrains++;

	printf("%d", nMissedTrains);

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int
main (int ac, char *av[])
{
	int i, j, k, len;
	char num[32];
	char x;
	int	sw1 = -1;
	int	sw2 = -1;

	scanf ("%s", num);

	len = strlen(num)-1;

	for (i = len; i >= 0; --i) {

		if (num[i] == '5') {
			int xx = 0;
			if (i == 0 && num[1] == '0') {
				for (k = 1; k < len; k++) {
					if (num[k] != '0') break;
					++xx;
				}
				if (k == len) continue;
			}

			for (j=len; j>=0; --j) {
				x = num[j];
				if (j == 0 && num[1] == '0') {
					for (k = 1; k < len; k++) {
						if (num[k] != '0') break;
						++xx;
					}
					if (k == len) continue;
				}

				if (x == '2' || x == '7') {
					sw1 = (len-i) + (len-j)+xx;
                                        if (j < i) --sw1;
					break;
				}
			}
			break;
		}
	}

	for (i = len; i >= 0; --i) {
		if (num[i] == '0') {
                        num[i] = '9';
			for (j=len; j>=0; --j) {
				x = num[j];
				if (x == '0' || x == '5') {
					sw2 = (len-i)+(len-j);
                                        if (j < i) --sw2;
					break;
				}
			}
			break;
		}
	}
	if (sw1 != -1) {
		if (sw2 != -1) {
			printf ("%d\n", (sw1>sw2) ? sw2:sw1);
		} else {
			printf ("%d\n", sw1);
		}
	} else {
		printf ("%d\n", sw2);
	}

	return 0;
}


#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>

static bool has_duplicates (int arr[], size_t sz);
static void decrease_duplicates (int arr[], size_t sz);
static unsigned long long sum_positive (int arr[], size_t sz);

int main (void) {
	size_t letter_count;
	scanf("%I64u", &letter_count);

	int max_letter_freq[letter_count];
	for (size_t i = 0; i < letter_count; ++i) {
		scanf("%d", &max_letter_freq[i]);
	}

	while (has_duplicates(max_letter_freq, letter_count)){
		for (size_t i = 0; i < letter_count; ++i) {
			decrease_duplicates(max_letter_freq + i, letter_count - i);
		}
	}

	printf("%llu\n", sum_positive(max_letter_freq, letter_count));

	return 0;
}

static bool has_duplicates (int arr[], size_t sz) {
	if (sz == 1)
		return false;
	for (size_t i = 0; i < sz - 1; ++i)
		for (size_t j = i + 1; j < sz; ++j)
			if (arr[i] == arr[j])
				return true;

	return false;
}

static void decrease_duplicates (int arr[], size_t sz) {
	if (sz == 1)
		return;

	int elem = arr[0];
	int decrease_by = 1;
	for (size_t i = 1; i < sz; ++i) {
		if (arr[i] == elem) {
			arr[i] -= decrease_by;
			decrease_by++;
		}
	}
}

static unsigned long long sum_positive (int arr[], size_t sz) {
	unsigned long long sum = 0;
	for (size_t i = 0; i < sz; ++i)
		if (arr[i] > 0)
			sum += arr[i];

	return sum;
}


#include<stdio.h>

int dias_ano(int ano){
	if(ano%400==0){
		return 366;
	}
	if(ano%4==0){
		if(ano%100==0){
			return 365;
		}
		return 366;
	}
	return 365;
}

int main(void){
	int ano;
	int dias=0;
	int parada;
	int dia=0;
	scanf("%d", &ano);
	parada = dias_ano(ano);
	while(1){
		dia = dias_ano(ano);
		dias += dia;
		if(dias%7==0 && dias_ano(ano+1)==parada){break;}
		ano++;
	}
	printf("%d\n", ano+1);
	return 0;
}


#include<stdio.h>
long long int min(long long int n,long long int k)
{
	if(n<k)
		return n;
	else
		return k;
}
long long int value(long long int n,long long int k)
{
	long long int x=0;
	while(n!=0)
	{
		x+=min(n,k);
		n-=min(n,k);
		n-=(n/10);
	}
	return x;
}
int main()
{
	long long int x,m,n,k,l=1,ans,r;
	scanf("%lld",&n);
	r=n;
	ans=r;
	while(l<=r)
	{
		k=(l+r)/2;
		x=value(n,k);
		if(x*2>=n)
		{
			ans=k;
			r=k-1;
		}
		else
			l=k+1;
	}
	printf("%lld\n",ans);
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int qsort_compare (const void *a, const void *b)
{
    char strA = *(char*)a;
    char strB = *(char*)b;
    return strA - strB;
}

int main()
{
    char n[100];
    char n2[100];
    int i;

    scanf (" %s", n);
    scanf (" %s", n2);

    qsort (n, strlen (n), 1, qsort_compare);

    for (i = 0; n[i] == '0'; i++);

    if (n[i] != '\0')
    {
        char c = n[i];
        n[i] = n[0];
        n[0] = c;
    }

    for (i = 0; n[i] == n2[i] && n[i] && n2[i]; i++);

    if (!n[i] && !n2[i])
        printf("OK");
    else
        printf("WRONG_ANSWER");

    return 0;
}


#include<stdio.h>
int main(void)
{
    long long int n,k,t;
    scanf("%lld %lld %lld",&n,&k,&t);
    if(t>=(n+k))
        t%=(n+k);
    if(t<=k)
        printf("%lld\n",t);
    else if(t>k&&t<=n)
        printf("%lld\n",k);
    else if(t<(n+k)&&t>n)
        printf("%lld\n",((n+k)-t));
    return 0;
}


#include<stdio.h>

long long perm(int n, int i) {
	long long sum = 1;
	while (i--) sum = sum * n--;
	return sum;
}

long long comb(int n, int i) {
	return perm(n, i) / perm(i, i);
}

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	long long dp[5], sum, tt, temp;
	dp[0] = 1;
	dp[1] = 1;

	for (int i = 2; i <= k; i++) {
		sum = comb(n, i) * perm(i, i);
		temp = 0;
		for (int j = i - 1; j >= 0; j--) {
			tt = comb(n - j, i - j) - 1;
			sum -= (tt - temp) * dp[j];
			temp += tt - temp;
		}
		dp[i] = sum;
	}

	printf("%lld", dp[k]);
}


#include<stdio.h>
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        if(n<=10||n>21)  printf("0\n");
        else if(n>=12&&n<=19)  printf("4\n");
        else if(n==20)  printf("15\n");
        else if(n==11||n==21)  printf("4\n");
    }
    return 0;
}


/**
 * Recently, a chaotic virus Hexadecimal advanced a new theorem which will shake the Universe.
 * She thinks that each Fibonacci number can be represented as sum of three not necessary different
 * Fibonacci numbers.
 *
 * Let's remember how Fibonacci numbers can be calculated. F0 =0, F1 = 1, and all the next numbers are Fi = F(i-2) + F(i-1).
 *
 * So, Fibonacci numbers make a sequence of numbers: 0, 1, 1, 2, 3, 5, 8, 13, ...
 *
 * If you haven't run away from the PC in fear, you have to help the virus. Your task is to divide given Fibonacci number
 * n by three not necessary different Fibonacci numbers or say that it is impossible.
 *
 * Input
 * The input contains of a single integer n (0 ≤ n < 10^9) — the number that should be represented by the rules described
 * Auto-Indent : Ctrl + K + D
 * Output
 * Output three required numbers: a, b and c. If there is no answer for the test you have to print "I'm too stupid to solve
 * this problem" without the quotes.
 *
 * If there are multiple answers, print any of them.
 *
 * Examples
 *
 * Input
 * 3
 *
 * Output
 * 1 1 1
 *
 * Input
 * 13
 *
 * Output
 * 2 3 8
 */

#include <stdio.h>
#include <stdlib.h>

int main(void) {

	// User input
	int n = 0;

	// Current term
	int t1 = 0;

	// Next term
	int t2 = 1;

	// Array to store squence
	long F[10000];

	// Next next successive term
	int nextTerm = 0;

	/* F[i] = F[i-1] + F[i-2]
	   F[i-2] = F[i-3] + F[i-4]
	   F[i] = F[i-1] + F[i-3] + F[i-4]

	   F[i] = F[i-2]+F[i-3] + F[i-2]
	*/

	// nextTerm is sum of current and successive term
		nextTerm = t1 + t2;

	//Read user input ('n')
	scanf("%d", &n);

	F[0] = 0;
	F[1] = 1;
	F[2] = 1;

	//Calculate the fibonacci sequence and store it of later use
	for (int i = 3; F[i] <= n; i++) {

		//printf("%d ", t1);
		F[i] = F[i-1]+F[i-2];

		if(n==F[i])
		{
			printf("%d %d %d",F[i-3],F[i-2],F[i-2]);
			return EXIT_SUCCESS;
		}
	}

	printf("0 0 %d",n);

	return EXIT_SUCCESS;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main()
{
    long long int i,j=0,k=0,n,t_h,h,t_m,m;
    char ch[1005],previous='z';
    scanf("%lld ",&n);
    gets(ch);

    if(n==1){
        if(ch[0]=='0') printf("No\n");
        else printf("Yes\n");

        return 0;
    }

    if((ch[0]==ch[1] && ch[0]=='0') || (ch[n-1]==ch[n-2] && ch[n-1]=='0'))
       {
           printf("No\n");
           return 0;
       }
    for(i=0;i<n;i++){

        if(ch[i]=='0'){
            j++;
            k=0;
        }

        else{               //if ch[i]=='1'//
            k++;
            j=0;
        }
        if(j>2 || k>1)
        {
            printf("No\n");
            return 0;
        }
    }

    printf("Yes\n");

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define LL long long
long num[1000000];
long num2[1000000];
long shit[1000000];
long ans[1000000];
long ms[1000000];
int compare(long a,long b)
{
	return num[a]-num[b];
}
void mergesort(long *ds,int (*compare)(long a,long b),long size)
{
	long i,j,k,s,b,e;
	for (k=1;k<=size;k=k<<1)
	{
		for (i=1;i+k<=size;i+=k<<1)
		{
			s=i;b=i+k;e=b+k-1;
			if (e>size) {e=size;}
			for (j=1;(s<i+k)&&(b<=e);j++)
			{
				if (compare(ds[s],ds[b])<=0)
				{
					ms[j]=ds[s++];
				}
				else
				{
					ms[j]=ds[b++];
				}
			}
			for (b=i+k-1;b>=s;b--)
			{
				ds[e--]=ds[b];
			}
			for (b=1;b<j;b++)
			{
				ds[i+b-1]=ms[b];
			}
		}
	}
}
int main()
{
//	freopen("in.in","r",stdin);
	long i,j,k,n,l,r,a,b,c;
	LL ans1,ans2;
	scanf("%ld",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%ld",&num[i]);
		shit[i]=i;
	}
	mergesort(shit,&compare,n);
	for (i=1;i<=n;i++)
	{
		if (num[shit[i]]==num[shit[i+1]]) {goto FAIL;}
	}
	for (i=1;i<=n;i++)
	{
		num2[shit[i]]=i;
	}
	for (i=1;i<=n;i++)
	{
		ans[i]=num[shit[num2[i]%n+1]];
	}
	for (i=1;i<n;i++)
	{
		printf("%ld ",ans[i]);
	}
	printf("%ld\n",ans[i]);
	goto EXIT;
FAIL:
	printf("-1\n");
EXIT:
	return 0;
}


#include<stdio.h>
int dist_square(int x1,int y1, int x2, int y2)
{
	int dist=(x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
	return dist;
}
int check_right(int x1,int y1,int x2,int y2,int x3,int y3)
{
	int a=dist_square(x2,y2,x3,y3);
	int b=dist_square(x1,y1,x3,y3);
	int c=dist_square(x1,y1,x2,y2);
	if(a==(b+c) || (b==(a+c)) || (c==(a+b)))
	return 1;
	else
	return 0;
}
int check_tria(int x1,int y1, int x2, int y2, int x3,int y3)
{
	if(x1==x2 && y1==y2)
	return 0;
	if(x1==x3 && y1==y3)
	return 0;
	if(x2==x3 && y2==y3)
	return 0;
	return 1;
}
int main()
{
	int x1,y1,x2,y2,x3,y3;
	scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3);
	if(check_right(x1,y1,x2,y2,x3,y3)==1 && check_tria(x1,y1,x2,y2,x3,y3)==1)
	{

		printf("RIGHT");
		return 0;
	}
	if(check_right(x1-1,y1,x2,y2,x3,y3)==1 && check_tria(x1-1,y2,x2,y2,x3,y3)==1)
	{
		printf("ALMOST");
		return 0;
	}
	if(check_right(x1+1,y1,x2,y2,x3,y3)==1 && check_tria(x1+1,y1,x2,y2,x3,y3)==1)
	{
		printf("ALMOST");
		return 0;
	}
	if(check_right(x1,y1-1,x2,y2,x3,y3)==1 && check_tria(x1,y1-1,x2,y2,x3,y3)==1)
	{
		printf("ALMOST");
		return 0;
	}
	if(check_right(x1,y1+1,x2,y2,x3,y3)==1 && check_tria(x1,y1+1,x2,y2,x3,y3)==1)
	{
		printf("ALMOST");
		return 0;
	}
	if(check_right(x1,y1,x2-1,y2,x3,y3)==1 && check_tria(x1,y1,x2-1,y2,x3,y3)==1)
	{
		printf("ALMOST");
		return 0;
	}
	if(check_right(x1,y1,x2+1,y2,x3,y3)==1 && check_tria(x1,y1,x2+1,y2,x3,y3)==1)
	{
		printf("ALMOST");
		return 0;
	}
	if(check_right(x1,y1,x2,y2-1,x3,y3)==1 && check_tria(x1,y1,x2,y2-1,x3,y3)==1)
	{
		printf("ALMOST");
		return 0;
	}
	if(check_right(x1,y1,x2,y2+1,x3,y3)==1 && check_tria(x1,y1,x2,y2+1,x3,y3)==1)
	{
		printf("ALMOST");
		return 0;
	}
	if(check_right(x1,y1,x2,y2,x3-1,y3)==1 && check_tria(x1,y1,x2,y2,x3-1,y3)==1)
	{
		printf("ALMOST");
		return 0;
	}
	if(check_right(x1,y1,x2,y2,x3+1,y3)==1 && check_tria(x1,y1,x2,y2,x3+1,y3)==1)
	{
		printf("ALMOST");
		return 0;
	}
	if(check_right(x1,y1,x2,y2,x3,y3-1)==1 && check_tria(x1,y1,x2,y2,x3,y3-1)==1)
	{
		printf("ALMOST");
		return 0;
	}
	if(check_right(x1,y1,x2,y2,x3,y3+1)==1 && check_tria(x1,y1,x2,y2,x3,y3+1)==1)
	{
		printf("ALMOST");
		return 0;
	}
	printf("NEITHER");
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define bool int
#define true 1
#define false 0

#define swap(a,b) {*(a)=*(a)^*(b);*(b)=*(a)^*(b);*(a)=*(a)^*(b);}

bool next_permutation(int *a,int len)
{
    if(len == 1)
        return false;
    int i,j;
    int left;
    i = len - 1;
    left = len;
    for(i; i>0; i--)
        if(a[i] > a[i-1])
        {
            left = i - 1;
            break;
        }
    if(left == len)
        return false;
    if(left == len - 2)
    {
        swap(&a[left],&a[left+1]);
        return true;
    }
    i = len - 1;
    for(i; i>left; i--)
        if(a[i] > a[left])
        {
            swap(&a[i],&a[left]);
            break;
        }
    i = len - 1;
    j = left + 1;
    for(i,j; i>j; i--,j++)
        swap(&a[i],&a[j]);
    return true;
}

int diff(char **a,int len)
{
    int *num;
    num = (int*)malloc(sizeof(int) * len);
    int i,max,min;
    for(i=0; i<len; i++)
    {
        num[i] = atoi((const char*)a[i]);
    }
    max=min=num[0];
    for(i=0; i<len; i++)
    {
        if(num[i]>max)
            max=num[i];
        else if(num[i]<min)
            min=num[i];
    }
    free(num);
    num = NULL;
    return max-min;
}

void exchange(char** a,int* b,int n,int l)
{
    int i,j;
    char *temp;
    temp = (char*)malloc(l+1);

    for(i=0; i<n; i++)
    {
        memset(temp,0,l+1);
        for(j=0; j<l; j++)
        {
            temp[j]=a[i][b[j]];
        }
        memcpy(a[i],temp,l+1);
    }
    free(temp);
    temp=NULL;
}

int main(void)
{
    int n,m;
    int i,j;
    int mini;
    scanf("%d%d",&n,&m);
    int line[8];
    for(j=0; j<8; j++)
        line[j] = j;
    char *num[8];
    char *numbat[8];

    for(i=0; i<n; i++)
    {
        num[i] = (char*)malloc(m+1);
        numbat[i] = (char*)malloc(m+1);
        memset(num[i],0,m+1);
        scanf("%s",num[i]);
        memcpy(numbat[i],num[i],m+1);
    }
    int dif;
    dif = diff(num,n);
    mini = dif;
    while(next_permutation(line,m))
    {
        for(i=0; i<n; i++)
        {
            memcpy(num[i],numbat[i],m+1);
        }
        exchange(num,line,n,m);
        dif = diff(num,n);
        if(dif < mini)
            mini = dif;
    }
    printf("%d\n",mini);
    for(i=0; i<n; i++)
    {
        free(num[i]);
        num[i]=NULL;
        free(numbat[i]);
        numbat[i]=NULL;
    }
    return 0;
}


#include <stdio.h>

#define MOD 998244353LL

long long f[200001];

long long power(long long x, long long n){
    long long res;
    if(n==0){
        return 1;
    }
    if(n==1){
        return x%MOD;
    }

    res=power(x, n/2);
    res%=MOD;
    res*=res;
    res%=MOD;
    if(n & 1LL){
        res*=x;
        res%=MOD;
    }
    return res%MOD;
}

long long fibo(){
    int i;
    for(i=3; i<=200000; ++i){
        f[i]=f[i-2]+f[i-1];
        f[i]%=MOD;
    }
}

int main(void){
    long long N, res;

    scanf("%lld", &N);
    if(N==1){
        printf("%lld", power(2, MOD-2)%MOD);
        return 0;
    }
    else if(N==2){
        printf("%lld", power(4, MOD-2)%MOD);
        return 0;
    }
    f[1]=f[2]=1;
    fibo();

    res=((f[N]%MOD)*(power(power(2, N)%MOD, MOD-2)%MOD))%MOD;
    //(2*N-5)/2^N
    printf("%lld", res);

    return 0;
}

/*
x^MOD == x (mod MOD)
x^(MOD-1) == 1 (mod MOD)
x * x^(MOD-2) == 1 (mod MOD)

2*N-5 mod MOD * (2^N)^-1 mod MOD
*/


/***********************************************
 * Program Name: ex1
 * OS:           Linus 8
 * Compiler:     GCC
 * Author:       KlareH <klare0216@gmail.com>
 * Description:
 *
 * ********************************************/

#include <stdio.h>
#define t_mol     1000000007

int main(void){
  int n = 0;
  int i, c1, c2;
  long long all_kind, six_kind;

  all_kind = six_kind = 1;
  c1 = c2 = 0;

  scanf("%d", &n);

  for(i = (3 * n);i > 0;i--){
    all_kind *= 3;
   // c1 += all_kind / t_mol;
    all_kind = ( all_kind % t_mol );
  }

  //printf("all = %d + %d\n", c1, all_kind);

  for(i = n;i > 0;i--){
    six_kind *= 7;
  //  c2 += six_kind / t_mol;
    six_kind = ( six_kind % t_mol );
  }

  //printf("six = %d + %d\n", c2, six_kind);

  //c1 -= c2;

  all_kind = all_kind - six_kind;
  if (all_kind < 0 ){
  //  c1 -= 1;
    all_kind += t_mol;
  }
  printf("%d\n", all_kind);

  return 0;
}


#include <stdio.h>
int main(void)
{
    int *a;
    int b,i,k=100,x=0;
    scanf("%d",&b);
    a = malloc(b*sizeof(int));
    for(i=0;i<b;i++)
    {
        scanf("%d", &a[i]);
        if(a[i]<k)k=a[i];
    }
    for(i=0; i<b; i++)
        if(a[i]==k)x++;
    if(x>b/2)printf("Bob\n");
    else printf("Alice\n");

    return 0;
}


#include <ctype.h>
#include <stdio.h>
#include <string.h>

int main() {
	static char s[256], used[26];
	int n, i, max, cnt;

	scanf("%d%s", &n, s);
	max = cnt = 0;
	for (i = 0; i < n; i++)
		if (isupper(s[i])) {
			memset(used, 0, sizeof used);
			cnt = 0;
		} else {
			if (!used[s[i] - 'a']) {
				used[s[i] - 'a'] = 1;
				cnt++;
			}
			if (max < cnt)
				max = cnt;
		}
	printf("%d\n", max);
	return 0;
}


#include <stdio.h>
typedef long long int i64;
i64 min(i64 a, i64 b) {
    return a < b ? a : b;
}
int main(void) {
    i64 a, b, c, d, ans = 0;
    scanf("%I64d%I64d%I64d%I64d", &a, &b, &c, &d);
    for (int i = 0; i <= 100; i++) {
		for (int j = 0; j <= 100; j++) {
			if (b + a*i == d + c*j) {
				ans = ans == 0 ? b + a * i : min(b + a*i, ans);
			}
		}
	}
	printf("%I64d", ans ? ans : -1);
	return 0;
}


#include<stdio.h>
#include<string.h>
void zidian(char str[]);
int main()
{
	int i,len;
	char str[11];
	char s1[11],s2[11];
	scanf("%s",str);
	len=strlen(str);
	if(len%2==0)
	{
		for(i=0;i<len;i++)
		{
			if(i<len/2)
				s1[i]='4';
			else
				s1[i]='7';
		}
		s1[i]=0;
		for(i=0;i<len;i++)
		{
			if(i<len/2)
				s2[i]='7';
			else
				s2[i]='4';
		}
		s2[i]=0;
		if(strcmp(s2,str)<0)
		{
			len=len+2;
			for(i=0;i<len/2;i++)
				str[i]='4';
			for(i=len/2;i<len;i++)
				str[i]='7';
			str[i]=0;
		}
		else
		{
			while(1)
			{
				if(strcmp(s1,str)>=0)
				{
					strcpy(str,s1);
					break;
				}
				zidian(s1);
			}
		}

	}
	else
	{

			len+=1;
			for(i=0;i<len/2;i++)
				str[i]='4';
			for(i=len/2;i<len;i++)
				str[i]='7';
			str[i]=0;
	}
	puts(str);
	return 0;
}

void zidian(char str[])
{
	int i,l,j,t,k,len;
	char c;
	len=strlen(str);
	for(j=1;j<len;j++)
		if(str[j-1]<str[j])
			i=j;
	for(k=0;k<len;k++)
		if(str[i-1]<str[k])
			l=k;
	c=str[i-1];str[i-1]=str[l];str[l]=c;
	for(j=i,t=len-1;j<=t;j++,t--)
	{
		c=str[j];
		str[j]=str[t];
		str[t]=c;
	}
}


#include <stdio.h>
int main()
{
	int a,b,y,i=0;
	scanf("%d%d",&a,&b);
	while(a<=b)
	{
		a=a*3;
		b=b*2;
		i++;
	}
	printf("%d\n",i);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int Abs(int a){return a>=0?a:-a;}
int main()
{ int tab[5][2],i,j,stop=0,res,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){scanf("%d%d",&tab[i][0],&tab[i][1]);}
  if(n!=1)
  {
  for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
           {
           if(tab[i][0]!=tab[j][0] && tab[i][1]!=tab[j][1] )
              {
                    res=Abs(tab[i][0]-tab[j][0]) * Abs(tab[i][1]-tab[j][1]);
                    printf("%d",res);
                    return 0;
              }
           }
    }
    }
printf("-1");

return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main () {

	double x, y, z;

	double max;
	int ind = 0;

	scanf("%lf %lf %lf", &x, &y, &z);

	if (x - 1.0 < 1e-6 && y - 1.0 < 1e-6 && z - 1.0 < 1e-6) {

		max = 1000000;

		if (z * log(y) + log(log(1 / x)) - max < -1e-6) {
			max = z * log(y) + log(log(1 / x));
			ind = 1;
		}
// printf("%.15lf\n", z * log(y) + log(log(1 / x)));
		if (y * log(z) + log(log(1 / x)) - max < -1e-6) {
			max = y * log(z) + log(log(1 / x));
			ind = 2;
		}
// printf("%.15lf\n", y * log(z) + log(log(1 / x)));
		if (log(y) + log(z) + log(log(1 / x)) - max < -1e-6) {
			max = log(y) + log(z) + log(log(1 / x));
			ind = 3;
		}
// printf("%.15lf\n", log(y) + log(z) + log(log(1 / x)));

	if (z * log(x) + log(log(1 / y)) - max < -1e-6) {
			max = z * log(x) + log(log(1 / y));
			ind = 5;
		}
// printf("%.15lf\n", z * log(x) + log(log(1 / y)));
		if (x * log(z) + log(log(1 / y)) - max < -1e-6) {
			max = x * log(z) + log(log(1 / y));
			ind = 6;
		}
// printf("%.15lf\n", x * log(z) + log(log(1 / y)));
		if (log(x) + log(z) + log(log(1 / y)) - max < -1e-6) {
			max = log(x) + log(z) + log(log(1 / y));
			ind = 7;
		}
// printf("%.15lf\n", log(x) + log(z) + log(log(1 / y)));

	if (y * log(x) + log(log(1 / z)) - max < -1e-6) {
			max = y * log(x) + log(log(1 / z));
			ind = 9;
		}
// printf("%.15lf\n", y * log(x) + log(log(1 / z)));
		if (x * log(y) + log(log(1 / z)) - max < -1e-6) {
			max = x * log(y) + log(log(1 / z));
			ind = 10;
		}
// printf("%.15lf\n", x * log(y) + log(log(1 / z)));
		if (log(x) + log(y) + log(log(1 / z)) - max < -1e-6) {
			max = log(x) + log(y) + log(log(1 / z));
			ind = 11;
		}
// printf("%.15lf\n", log(x) + log(y) + log(log(1 / z)));

	} else {

		max = -1000;

		if (x - 1.0 > 0.01) {
			if (z * log(y) + log(log(x)) - max > 1e-6) {
				max = z * log(y) + log(log(x));
				ind = 1;
			}
// printf("%.15lf\n", z * log(y) + log(log(x)));
			if (y * log(z) + log(log(x)) - max > 1e-6) {
				max = y * log(z) + log(log(x));
				ind = 2;
			}
// printf("%.15lf\n", y * log(z) + log(log(x)));
			if (log(y) + log(z) + log(log(x)) - max > 1e-6) {
				max = log(y) + log(z) + log(log(x));
				ind = 3;
			}
// printf("%.15lf\n", log(y) + log(z) + log(log(x)));
		}

		if (y - 1.0 > 0.01) {
			if (z * log(x) + log(log(y)) - max > 1e-6) {
				max = z * log(x) + log(log(y));
				ind = 5;
			}
// printf("%.15lf\n", z * log(x) + log(log(y)));
			if (x * log(z) + log(log(y)) - max > 1e-6) {
				max = x * log(z) + log(log(y));
				ind = 6;
			}
// printf("%.15lf\n", x * log(z) + log(log(y)));
			if (log(x) + log(z) + log(log(y)) - max > 1e-6) {
				max = log(x) + log(z) + log(log(y));
				ind = 7;
			}
// printf("%.15lf\n", log(x) + log(z) + log(log(y)));
		}

		if (z - 1.0 > 0.01) {
			if (y * log(x) + log(log(z)) - max > 1e-6) {
				max = y * log(x) + log(log(z));
				ind = 9;
			}
// printf("%.15lf\n", y * log(x) + log(log(z)));
			if (x * log(y) + log(log(z)) - max > 1e-6) {
				max = x * log(y) + log(log(z));
				ind = 10;
			}
// printf("%.15lf\n", x * log(y) + log(log(z)));
			if (log(x) + log(y) + log(log(z)) - max > 1e-6) {
				max = log(x) + log(y) + log(log(z));
				ind = 11;
			}
// printf("%.15lf\n", log(x) + log(y) + log(log(z)));
		}
	}

	switch (ind) {
		case 1:
			printf("x^y^z\n");
			break;
		case 2:
			printf("x^z^y\n");
			break;
		case 3:
			printf("(x^y)^z\n");
			break;
		case 4:
			printf("(x^z)^y\n");
			break;
		case 5:
			printf("y^x^z\n");
			break;
		case 6:
			printf("y^z^x\n");
			break;
		case 7:
			printf("(y^x)^z\n");
			break;
		case 8:
			printf("(y^z)^x\n");
			break;
		case 9:
			printf("z^x^y\n");
			break;
		case 10:
			printf("z^y^x\n");
			break;
		case 11:
			printf("(z^x)^y\n");
			break;
		case 12:
			printf("(z^y)^x\n");
			break;
		default:
			printf("ERROR\n");
	}

	return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{
    long double r, g, b;
    double n, k;
    unsigned long int x;

    scanf("%lf %lf", &n, &k);

    r = ceil(2*n/k);
    g = ceil(5*n/k);
    b = ceil(8*n/k);

    x = r+g+b;

    printf("%lu", x);

    return 0;
}


#include<stdio.h>
#define TRI (c<a+b)
main()
{
    int a,b,c,t,s=0;
    scanf("%d%d%d",&a,&b,&c);
    if(a>c && a>b)
    t=c,c=a,a=t;
    else if(b>c && b>a)
    t=c,c=b,b=t;
    if(!TRI)
    printf("%d",c-a-b+1);
    else
    printf("0");

}


//Problem 331C1:  https://codeforces.com/problemset/problem/331/C1?locale=en

#include <stdio.h>

int max(int a, int b);

int main() {
    int cnt = 0;

    unsigned long long n;
    scanf("%llu", &n);
    int bigger = 0;

    while (n) {
        unsigned long long k = n;
        int aux = -1;
        while (k) {
            bigger = max(aux, k % 10);
            aux = bigger;
            k /= 10;
        }
        n -= bigger;
        cnt++;
    }

    printf("%d", cnt);
    return 0;
}

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


#include<stdio.h>
#define MAX 100000
int arr[MAX];
int main(int argc, char const *argv[])
{
    int n,maxh,nr,i,sh,eh,rh,j,sum=0;
    scanf("%d%d%d",&n,&maxh,&nr);
    for(i=1;i<=n;i++)
    {
        arr[i]=maxh;
    }
    for(i=1;i<=nr;i++)
    {
        scanf("%d%d%d",&sh,&eh,&rh);
        for(j=sh;j<=eh;j++)
        {
            if(arr[j]>rh)
            arr[j]=rh;
        }

    }
    for(i=1;i<=n;i++)
    {
        sum=sum+arr[i]*arr[i];
    }
    printf("%d",sum);

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

main( )
{  int x,y,d;
scanf("%d%d",&x,&y);
if(x<y-1||y==0)
    printf("NO");
else if(x>=y-1)
{
    y=y-1;
     d=x-y;
    if(y==0&&x>0)
        printf("NO");

   else if(d%2==0)
        printf("YES");
    else
        printf("NO");
}

   }


#include<stdio.h>
int main(void)
{
    int h,w,u1,d1,u2,d2,max,other,weight,other_w;
    scanf("%d %d %d %d %d %d",&w,&h,&u1,&d1,&u2,&d2);
    max=d1>d2?d1:d2;
    other=d1+d2-max;
    if(max==d1)
    {
        weight=u1;
        other_w=u2;
    }
    else
    {
        weight=u2;
        other_w=u1;
    }
    for(h;h>=max;h--)
        w+=h;
    if(w>=weight)
        w-=weight;
    else
        w=0;
    for(h;h>=other;h--)
        w+=h;
    if(w>=other_w)
        w-=other_w;
    else
        w=0;
    for(h;h>=0;h--)
        w+=h;
    printf("%d\n",w);
    return 0;
}


/* practice with Dukkha */
#include <stdio.h>

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

int count(int x1, int x2, int b) {
	if (x1 > x2)
		return count(x2, x1, b);
	if (x1 > 0)
		return x2 / b - x1 / b;
	if (x2 < 0)
		return -x1 / b - -x2 / b;
	return -x1 / b + x2 / b + 1;
}

int main() {
	int a, b, x1, y1, x2, y2, x, y;

	scanf("%d%d%d%d%d%d", &a, &b, &x1, &y1, &x2, &y2), a *= 2, b *= 2;
	x = x1 - y1, y = x1 + y1; x1 = x; y1 = y;
	x = x2 - y2, y = x2 + y2; x2 = x; y2 = y;
	printf("%d\n", max(count(x1, x2, b), count(y1, y2, a)));
	return 0;
}


#include<stdio.h>
int color[6];
int main(void)
{
  int i,one,two,three,four,five,six;
  char ch[10];
  while(scanf("%s",ch)!=EOF)
  {
    for(i=0;i<6;++i) color[i]=0;
    for(i=0;i<6;++i)
    {
      switch(ch[i])
      {
        case 'R': ++color[0];break;
        case 'O': ++color[1];break;
        case 'Y': ++color[2];break;
        case 'G': ++color[3];break;
        case 'B': ++color[4];break;
        case 'V': ++color[5];break;
      }
    }
    for(i=one=two=three=four=five=six=0;i<6;++i)
    {
      switch(color[i])
      {
        case 1: ++one;break;
        case 2: ++two;break;
        case 3: ++three;break;
        case 4: ++four;break;
        case 5: ++five;break;
        case 6: ++six;break;
      }
    }
    if(one==6) puts("30");
    else if(one==4) puts("15");
    else if(one==3) puts("5");
    else if(one==2)
    {
      if(four==1) puts("2");
      else puts("8");
    }
    else if(one==1)
    {
      if(five==1) puts("1");
      else puts("3");
    }
    else
    {
      if(six==1) puts("1");
      else
      {
        if(two==1&&four==1) puts("2");
        else if(three==2) puts("2");
        else if(two==3) puts("6");
      }
    }
  }
  return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
	long a,b,c,d;
	scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
	long ab,bc;
	//ab=abs(a-b);
	//bc=abs(b-c);
	//ca=abs(c-a);
	long time=0;

	long large,small,mid;

	if(a<b)
	{
		if(a<c)
		{
			small=a;
			if(b<c)
			{
				large=c;
				mid=b;
			}
			else
			{
				mid=c;
				large=b;
			}
		}
		else
		{
			mid=a;
			small=c;
			large=b;
		}
	}
	else
	{
		if(b<c)
		{
			small=b;
			if(a<c)
			{
				mid=a;
				large=c;
			}
			else
			{
				mid=c;
				large=a;
			}
		}
		else
		{
			mid=b;
			small=c;
			large=a;
		}
	}
	//printf("%ld %ld %ld ",small,mid,large);

	ab=mid-small;
	bc=large-mid;
	if(ab>=d && bc>=d)
	{
		time=0;
	}
	else
	{

			if(ab>=d)
			{
				time=d-bc;

			}
			else if(bc>=d)
			{
				time=d-ab;
			}
			else
			{
				time=d-ab+d-bc;
			}

	}
	printf("%ld",time);
	return 0;

}


//491bishwock
#include<stdio.h>
int main()
{
  char s[2][101];
  int bishwock=0,i,row=0,avail=0;
   for(i=0;i<2;i++)
    scanf("%s",s[i]);
  for(i=0;s[0][i];i++)
  {
    row=(s[0][i]=='0')+(s[1][i]=='0');
    avail+=row;
    if(avail>=3)
    {
      avail-=3;
      bishwock++;
    }
    else  avail=row;//not in bishwock shape
  }
  printf("%d\n",bishwock);
  return 0;
}


#include <stdio.h>
#include <stdlib.h>

int compare(const void *a, const void *b) {
	int ia = *(int *) a;
	int ib = *(int *) b;

	return ib - ia;
}

int main() {
	static int tt[128];
	int n, m, i;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++)
		scanf("%d", &tt[i]);
	for (i = 0; i < n; i++) {
		int t, cnt;

		t = tt[i];
		cnt = 0;
		m -= t;
		if (m < 0) {
			static int aa[128];
			int j, m_;

			for (j = 0; j < i; j++)
				aa[j] = tt[j];
			qsort(aa, i, sizeof *aa, compare);
			m_ = m;
			for (j = 0; j < i && m_ < 0; j++) {
				m_ += aa[j];
				cnt++;
			}
		}
		printf("%d ", cnt);
	}
	printf("\n");
	return 0;
}


/* Problem: 388A - Fox and Box Accumulation */
/* Solver: Gusztav Szmolik */

#include <stdio.h>
#include <stdlib.h>

unsigned short x[100];
unsigned short s[100];

int cmp (const void*, const void*);

int main ()
    {
    unsigned short n;
    unsigned short i;
    unsigned short pc;
    unsigned short bc;
    unsigned short sc;

    if (scanf("%hu",&n) != 1)
        return -1;
    if (n < 1 || n > 100)
        return -1;
    for (i = 0; i < n; i++)
        {
        if (scanf("%hu",&x[i]) != 1)
            return -1;
        if (x[i] > 100)
            return -1;
        s[i] = 0;
        }
    qsort (x,n,sizeof(unsigned short),cmp);
    pc = bc = 0;
    while (bc < n)
        {
        sc = 0;
        for (i = 0; i < n; i++)
            if (!s[i] && x[i] >= sc)
                {
                s[i] = 1;
                sc++;
                bc++;
                }
        pc++;
        }
    printf ("%hu\n",pc);
    return 0;
    }

int cmp (p1,p2)
    const void* p1;
    const void* p2;
    {
    unsigned short x1;
    unsigned short x2;

    x1 = *(unsigned short*)p1;
    x2 = *(unsigned short*)p2;
    if (x1 == x2)
        return 0;
    return (x1 > x2 ? 1 : -1);
    }


#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[])
{
	int n;
	scanf("%d",&n);
	int arr[n];
	for (int i = 0; i < n; ++i)
	{
		scanf("%d",&arr[i]);
	}
	int total_min_index = 0 , total_max_index = 0;
	int total_length = 0,curr_length;
	int curr_min_index = 0 , curr_max_index = 0;
	int flag = 1;

	for (int i = 0; i < n-1; ++i)
	{
		if (flag == 1)
		{
			curr_min_index = i;
		}

		if(arr[i+1] == arr[i]+1)
		{
			curr_max_index = i+1;
			flag = 0;
		}

		if(arr[i+1] != arr[i]+1 || (arr[i+1] == arr[i]+1 && i == n-2))
		{
			if (flag == 0)
			{
				if (curr_min_index == 0 && arr[curr_min_index] == 1)
				{
					curr_length = curr_max_index - curr_min_index;
				}
				else if (curr_max_index == n-1 && arr[curr_max_index] == 1000)
				{
					curr_length = curr_max_index - curr_min_index;
				}
				else
				{
					curr_length = curr_max_index - curr_min_index - 1;
				}
				if (curr_length > total_length)
				{
					total_length = curr_length;
					total_max_index = curr_max_index;
					total_min_index = curr_min_index;
				}
			}
			flag = 1;
		}
	}

	printf("%d\n",total_length);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
int main (void)
{
    int n;
    int i;
    int count;
    int sum;
    int j;
    int temp;
    double aver;
    int t[6];
    while(scanf("%d",&n)!=EOF){
            sum = 0;
            memset(t,0,sizeof(t));
            count = 0;
        for(i = 0; i < n; i++){
            scanf("%d", &temp);
            t[temp]++;
        }
    aver = 4.5*n;
    for(i = 2; i <= 5; i++)
        sum = sum + t[i]*i;
    for(i = 2; i <= 5; i++){
            if(sum>=aver)
                break;
        for(j = 0; j < t[i]; j++)
        if(sum < aver){
            sum = sum + (5-i);
            count++;
        }
        else
            break;
    }
    printf("%d",count);
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>

int func(int x);

int main(){
	int n,i;
	int ent;

	scanf("%d",&n);

	for(i=0;i<n;i++){
		scanf("%d",&ent);
		if(func(ent)==1)
			printf("YES\n");
		else
	  		printf("NO\n");
	}
	return 0;
}

int func(int x){
	if(x <=0){
		return 0;
	}else{
		if (x%3==0 || x%7==0 || x%10==0){
			return 1;
		}else{
			func(x-3);
	  		func(x-7);
	}
	}
}
/* 1519498211334 */


#include <stdio.h>

int main()
{
    int n,t,a,m,i,sum;
    while(~scanf("%d%d",&n,&m))
    {
        sum=1;
        for(i=0;i<n;i++)
        {
            if(i==0)
                t=m;
            scanf("%d",&a);
            if(a<=t)
               t-=a;
            else
                t=m-a,sum++;
        }
        printf("%d\n",sum);
    }
    return 0;
}


#include <stdio.h>

int main() {
	int i, x, y, a, b, c;

	scanf("%d%d", &x, &y);
	a = b = c = y;
	for (i = 0; a < x; i++) {
		int d = x < b + c - 1 ? x : b + c - 1;

		a = b, b = c, c = d;
	}
	printf("%d\n", i);
	return 0;
}


#include <stdio.h>

int count_zero(int n)
{
    int ans = 0;
    while(n){
        n /= 5;
        ans += n;
    }
    return ans;
}

int main()
{
	int n, zero;
	scanf("%d", &n);

	int high, low, mid;
	low = 0;
	high = 1000000;
	while (low <= high){
        mid = low + high;
        zero = count_zero(mid);
        if (zero == n){
            int res = (mid / 5) * 5;
            printf("5\n%d %d %d %d %d", res, res+1, res+2, res+3, res+4);
            return 0;
        }
        else if (zero > n)high = mid - 1;
        else if (zero < n)low = mid + 1;
	}
	printf("0");
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define uLL unsigned long long
#define LL long long
uLL exgcd64(uLL a,uLL b,uLL *x,uLL *y)
{
	static uLL gcd;
	if (a==0)
	{
		*x=0;*y=1;
		return b;
	}
	else
	{
		gcd=exgcd64(b%a,a,y,x);
		*x-=(b/a)*(*y)+b;
		*y+=a;
		return gcd;
	}
}
int main()
{
//	freopen("in.in","r",stdin);
	LL i,j,k,n,m,a,b,c,d,x,y,vx,vy,e;
	scanf("%lld%lld%lld%lld%lld%lld",&n,&m,&x,&y,&vx,&vy);
	if ((vx==0)||(vy==0))
	{
		if (vx==0)
		{
			if ((x==0)||(x==n))
			{
				if (vy<0) {printf("%lld 0\n",x);}
				else {printf("%lld %lld\n",x,m);}
			}
			else
			{
				printf("-1\n");
			}
		}
		if (vy==0)
		{
			if ((y==0)||(y==m))
			{
				if (vx<0) {printf("0 %lld\n",y);}
				else {printf("%lld %lld\n",n,y);}
			}
			else
			{
				printf("-1\n");
			}
		}
	}
	else
	{
		if (vx<0)
		{
			x=n-x;
		}
		if (vy<0)
		{
			y=m-y;
		}
		//printf("%lld %lld %lld %lld\n",n,m,x,y);
		c=exgcd64(m,n,&a,&b);
		e=c;
		d=x-y;
		if (d<0) {d=(d%m+m)%m;}
		if (d%c!=0) {printf("-1\n");}
		else
		{
			//printf("%lld %lld %lld\n",b%c,d,((d/c)*(b/1)%(m/c)*n)%m);
			d=(d/c)*(b)%(m/c);
			if (d==0) {d+=m/c;}
			c=d;
			d=(c*n-(x-y))/m;
			if (d<0)
			{
				a=(-d)/c+1;
				c+=a*(m/e);
				d+=a*(n/e);
			}
			//printf("%lld %lld %lld %lld\n",c,d*m,(c*n-(x-y))%m,x-y);
			c=c&1;d=d&1;
			if (vx<0) {c=c^1;}
			if (vy<0) {d=d^1;}
			c=c*n;d=d*m;
			printf("%lld %lld\n",c,d);
		}
	}
	return 0;
}


#include<stdio.h>
int main()
{
    int a;
    scanf("%d",&a);
    if(a>=10 && a<=999)
    {
        if(a%2==0)
        printf("0");
        else
        printf("1");
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    char str[1000];
    scanf("%s",str);
    // printf("%s",str);
    int i,cnt1=0,cnt2=0;
    int ln=(strlen(str));
    for(i=0; i<ln; i++)
    {
        if(str[i]=='a')
        {
            cnt1++;
        }
        else
        {
            cnt2++;
        }
    }
    //printf("%4d %4d\n",cnt1,cnt2);
    if(cnt1>cnt2)
        printf("%d\n",ln);
    else if(cnt1==cnt2)
        printf("%d\n",ln-1);
    else
        printf("%d\n",ln-((cnt2-cnt1)+1));

    }


#include<stdio.h>
#include<math.h>
// long long int poww(long long int a, long long int b)
// {
// 	long long int i,ret=1;
// 	for(i=0;i<b;i++)
// 		ret = ret * a;

// 	return ret;
// }
int main()
{
	int k;
	scanf("%d",&k);
	if(k>36)
	{
		printf("-1\n");
		return 0;
	}
	long long int ans = 0;
	long long int i = 0, mul = 1;
	for(i=0;i<(k/2);i++)
	{
		ans = ans + 8 * mul;
		mul = mul * 10;
	}
	if(k%2 == 1)
	{
		ans = ans*10 + 4;
	}

	printf("%lld\n", ans);
	return 0;
}


#include <stdio.h>

int main()
{
    int n,k,R;
    scanf("%d%d",&n,&k);
    if(k<2*n){
        R = 0;
    }else{
        R = n-k+(2*n);
        if(R<0){
            R = 0;
        }
    }
    printf("%d",R);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#define mod 1000000007

#ifdef __cplusplus
extern "C" {
#endif
__attribute__((always_inline, optimize(3)))
__inline__ void add(int *x, int y) {
	(*x += y) >= mod && (*x -= mod);
}
__attribute__((always_inline, optimize(3)))
__inline__ int mul(int x, int y) {
	return (long long)x * y - (long long)x * y / mod * mod;
}
__attribute__((always_inline, optimize(3)))
__inline__ int f(int n, int x, int y) {
	int tmp = 1 << x;
	y && (tmp *= 3);
	return n / tmp;
}
#ifdef __cplusplus
}
#endif
int main() {
	int n, p = 0; scanf("%d", &n);
	static int dp[1000005][21][2] = { };
	while ((1 << p) <= n) ++ p; dp[1][-- p][0] = 1;
	if ((3 << p - 1) <= n) dp[1][p - 1][1] = 1;
	for (int i = 1; i < n; ++ i)
		for (int x = 0; x <= p; ++ x)
			for (int y = 0; y < 2; ++ y) {
				add(dp[i + 1][x] + y, mul(dp[i][x][y], f(n, x, y) - i));
				x && (add(dp[i + 1][x - 1] + y, mul(dp[i][x][y], f(n, x - 1, y) - f(n, x, y))), 0);
				y && (add(dp[i + 1][x] + y - 1, mul(dp[i][x][y], f(n, x, y - 1) - f(n, x, y))), 0);
			}
	printf("%d\n", dp[n][0][0]);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
  int i,j,k,l,m,n;
  int x,y,num;
  int r,g;
  int ok_r, ok_g, ok_v;
  char mp[120][120];
  int grundy[10];

  while(scanf("%d%d%d",&x,&y,&k)==3){
    rep(i,x) scanf("%s",mp[i]);
    ok_g = ok_r = 0;
    rep(i,10) grundy[i] = 0;

    rep(i,x){
      r=g=-1; num = 0;
      rep(j,y){
        if(mp[i][j]=='G') g=j, num++;
        if(mp[i][j]=='R') r=j, num++;
      }
      if(r==-1 || g==-1){
        if(num < y){
          if(g>=0) ok_g = 1;
          if(r>=0) ok_r = 1;
        }
        continue;
      }

      if(r > g) m = r-g-1; else m = g-r-1;
      rep(j,10) if(m&1<<j) grundy[j]++;
    }

    if(ok_g && ok_r){
      puts("Draw"); continue;
    }
    if(ok_g){
      puts("First"); continue;
    }
    if(ok_r){
      puts("Second"); continue;
    }

    rep(i,10) if(grundy[i]%(k+1)) break;
    if(i==10) puts("Second"); else puts("First");
  }

  return 0;
}


#include <stdio.h>
#include <inttypes.h>

/* maximum factors count, 10 must be enough. I take few more ) */
const int64_t cnt = 1000;

int64_t
decompose(int64_t x, int64_t *p)
{
    /* factors counter */
    int64_t c = 0;
    /* separate process for 2 */
    if (x % 2 == 0)
        p[c++] = 2;
    while (x % 2 == 0)
        x /= 2;

    for (int64_t d = 3; d*d <= x; d += 2)
    {
        if (x % d == 0)
            p[c++] = d;
        while (x % d == 0)
            x /= d;
    }
    if (x != 1) {
        p[c++] = x;
    }
    return c;
}

int
main()
{
    int64_t x;
    int64_t p[cnt];
    scanf("%"SCNd64, &x);

    int64_t c = decompose(x, p);

    int64_t min_f = x - p[c-1] + 1;
    int64_t min = min_f;
    for (int64_t f = min_f; f < x; ++f) {
        c = decompose(f, p);
        if ((c != 1 || p[0] != f) && f - p[c-1] + 1 < min)
            min = f - p[c-1] + 1;
    }
    printf("%"PRId64"\n", min);
    return 0;
}


#include <stdio.h>

int pod(int n) {
    int p = 1;
    while(n > 0) {
        p *= n % 10;
        n /= 10;
    }
    return p;
}

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

int main() {
    int n;
    scanf("%d", &n);
    int maxpod = pod(n);
    int a = n / 10, b = 10;
    while(a > 0) {
        maxpod = max(maxpod, pod(a * b - 1));
        a /= 10; b *= 10;
    }
    printf("%d\n", maxpod);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
	char str[110];
	int A[4]={0};
	scanf("%s",str);
	int len=strlen(str);
	for(int i=0;i<len;i++)
	{
		if(str[i]=='n')
		A[0]++;
		else if(str[i]=='i')
		A[1]++;
		else if(str[i]=='e')
		A[2]++;
		else if(str[i]=='t')
		A[3]++;
	}
	A[0]=(A[0]-1)/2;
	A[2]=A[2]/3;
	int min=A[0];
	for(int j=1;j<=3;j++)
	{
		if(A[j]<min)
		min=A[j];
	}
	printf("%d",min);
	return 0;
}


#include<stdio.h>
int main(){
    int n,i,j,k;
    scanf("%d",&n);
    int num[n];
    for(i=0; i<n; i++){
        scanf("%d",&num[i]);
    }
    for(i=0; i<n; i++){
        int count=1;
        int j=2;
        while(j*j*j<=num[i]){
            count+=1;
            j++;
        }
        int k=2;
        while(k*k<=num[i]){
            count+=1;
            k++;
        }
        int c=2;
        while(c*c*c*c*c*c<=num[i]){
            count-=1;
            c++;

        }
        printf("%d\n",count);
    }

    return 0;
}


#include<stdio.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
  int N = 8, tm = 100;
  char mp[8][9], cp[8][8];

  int i, j, di, dj, ni, nj;

  rep(i,N) scanf("%s",mp[i]);

  while(tm--){
    rep(i,N) rep(j,N) cp[i][j] = mp[i][j];

    rep(i,N) rep(j,N) if(cp[i][j]=='M'){
      REP(di,-1,2) REP(dj,-1,2){
        ni = i + di; nj = j + dj;
        if(ni < 0 || nj < 0 || ni >= N || nj >= N || mp[ni][nj]=='S') continue;
        mp[ni][nj] = 'M';
      }
    }

    rep(i,N)   rep(j,N) if(cp[i][j]=='S') mp[i][j] = '.';
    rep(i,N-1) rep(j,N) if(cp[i][j]=='S') mp[i+1][j] = 'S';
  }

  if(mp[0][0]=='M') puts("WIN"); else puts("LOSE");

  return 0;
}


#include<stdio.h>
int main()
{
    int t,x,i;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        scanf("%d",&x);
        printf("%d\n",x/2);
    }
    return 0;
}


#include<stdio.h>
#include<math.h>
#define sqr(x) ((x)*(x))
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define M 1000000007
#define N 211111

#define maxN 555

int n, k;
int dp[maxN][maxN], dp2[maxN][maxN];
int w[maxN];

int add(int x, int y) {
	x += y;
	if (x >= M) x-= M;
	return (x);
}

int min(int a, int b)
	{
		if(a<b)return a;
		else return b;
	}

int main(){
	scanf("%d %d", &n, &k);
	w[0] = 1;
	int i,j,d;
	for ( i = 1; i <= n; i++) w[i] = w[i - 1] * 2 % M;
	dp[0][0] = 1;
	for ( i = 0; i < n; i++) {
		for ( j = 0; j <= n; j++) for ( d = 0; d <= k + 1; d++) dp2[j][d] = 0;
		for ( j = 0; j <= n; j++) for ( d = 0; d <= k + 1; d++) if (dp[j][d] > 0) {
			if (j > i) {
				int e = i + 1;
				int z = dp[j][d] * 1ll * w[e] % M;
				dp2[j][d]=(dp2[j][d], z);
				continue;
			}
			int z = (w[i - j + 1] - 1 + M);
			if (z >= M) z -= M;
			z = z * 1ll * w[j] % M;
			z = z * 1ll * dp[j][d] % M;
			dp2[i + 1][min(d + 1, k + 1)]=add(dp2[i + 1][min(d + 1, k + 1)], z);
			z = dp[j][d] * 1ll * w[j] % M;
			dp2[j][d]=add(dp2[j][d], z);
		}
		for ( j = 0; j <= n; j++) for (d = 0; d <= k + 1; d++) dp[j][d] = dp2[j][d];
	}
	int ans = 0;
	for ( i = 0; i <= n; i++) ans=add(ans, dp[i][k]);
	printf("%d\n",ans);
	return 0;

}


#include<stdio.h>

int main()
{
    unsigned long long n,m,k,left,right,mid,temp;

    scanf("%I64u",&m);
    left=0;
    right=(long long)0xffffffffffffffff;
    while(left<right)
    {
        mid=(right-left)/2+left;
        n=mid;
        k=2;
        temp=0;
        while(n/(k*k*k))
        {
            temp+=n/(k*k*k);
            k++;
        }
        if(temp<m)left=mid+1;
        else right=mid;
    }
    n=left;
    k=2;
    temp=0;
    while(n>=k*k*k)
    {
        temp+=n/(k*k*k);
        k++;
    }
    if(temp==m)printf("%I64u\n",n);
    else printf("-1\n");

    return 0;
}


#include <stdio.h>
#define MAX 5
void Read(int *a, int b[])
{
    int i;
    scanf("%d", a);
    for (i=0; i<*a; i++)
        scanf("%d", &b[i]);
    return;
}
void Write(int a)
{
    printf("%d\n", a);
    return;
}
void Swap(int *a, int *b)
{
    int t;
    t=*a;
    *a=*b;
    *b=t;
    return;
}
void QuickSort(int a[], int l, int r)
{
    int x = a[l + (r - l) / 2];
    int i = l;
    int j = r;
    while(i <= j)
    {
        while(a[i] < x) i++;
        while(a[j] > x) j--;
        if(i <= j)
        {
            Swap(&a[i], &a[j]);
            i++;
            j--;
        }
    }
    if (i<r)
        QuickSort(a, i, r);
    if (l<j)
        QuickSort(a, l, j);
    return;
}
int main()
{
    int n;
    int m[MAX];
    Read(&n, m);
    QuickSort(m, 0, n-1);
    Write(m[(n-1)/2]);
    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int p,i,t,n,k,u=0,f;
    scanf("%lld%lld",&n,&k);
    i=sqrt(k*2);
    p=i*(i+1)/2;
    t=i;
    for(;i<n;i++)
    {
        if(p<=k)
        {
            t++;
            p=t+p;

        }
        else
        {
            f=p-k;
            p=p-f;
            u=u+f;
            i=i+f-1;
        }

    }
    printf("%lld",u);
    return 0;

}


#include <stdio.h>

#define max(a, b) (((a) > (b)) ? (a) : (b))

struct dxy
{
	long long d;
	long long x;
	long long y;
};

long long gcd(long long a, long long b)
{
	 return (a*b == 0) ? (a + b) : gcd(b, a%b);
}

struct dxy ext_euc(long long a, long long b)
{
	long long x, y;
	struct dxy ans;
	if (b == 0)
	{
		ans.d = a;
		ans.x = 1;
		ans.y = 0;
		return ans;
	}

	ans = ext_euc(b, a%b);
	x = ans.y;
	y = ans.x - (a/b)*ans.y;

	ans.x = x;
	ans.y = y;
	return ans;
}

long long box(long long numer, long long denom)
{
	if (numer % denom == 0 || (numer >=0 && denom >= 0) || (numer < 0 && denom < 0))
	{
		return numer / denom;
	}

	return (numer / denom) - 1;
}

int main()
{
	long long a1, a2, b1, b2;
	long long L, R;
	long long alpha1, alpha2, r, start, end;
	long long p, p1, q, q1, i, j, ans, base;
	long long hcf;
	struct dxy temp;

	scanf("%lld %lld %lld %lld %lld %lld", &a1, &b1, &a2, &b2, &L, &R);

	hcf = gcd(a1, a2);
	if ((b2 - b1) % hcf != 0)
	{
		printf("%d\n", 0);
		return 0;
	}

	r = box((b2 - b1), hcf);
	alpha1 = box(a1, hcf);
	alpha2 = box(a2, hcf);

	temp = ext_euc(alpha1, -alpha2);
	p = temp.x * r;
	p1 = temp.y * r;
	if (temp.d < 0)
	{
		p = -p;
		p1 = -p1;
	}

	start = box((L-b1), a1) + 1;
	//printf("start = %lld\n", start);
	start -= ((L-b1) % a1) == 0 ? 1 : 0;
	end = box((R-b1), a1);

	q = box((start-p), alpha2) + 1;
	q -= ((start-p) % alpha2) == 0 ? 1 : 0;
	q1 = box((end-p), alpha2);
	//printf("q1 = %lld\n", q1);

	base = box(-p, alpha2) + 1;
	base -= (p % alpha2) == 0 ? 1 : 0;
	q = max(q, base);
	//printf("q = %lld\n", q);

	base = box(-p1, alpha1) + 1;
	base -= (p1 % alpha1) == 0 ? 1 : 0;
	q = max(q, base);
	//printf("q = %lld\n", q);

	ans = q1 - (q - 1);
	//printf("ans = %lld\n", ans);
	if (ans < 0 )
	{
		ans = 0;
	}

	/*
	j = 0;
	for (i = q; i <= box((end-p), alpha2); i++)
	{
		if (p + i*alpha2 >=0 && p1 + i*alpha1 >= 0)
		{
			j++;
		}
	}
	*/
	//printf("start = %lld, end = %lld\n", start, end);
	//printf("p = %lld, p1 = %lld, q = %lld, r = %lld\n", p, p1, q, r);
	//printf("%lld %lld\n", box((end-p), alpha2), box((start-p), alpha2));
	/*
	if (p + q*alpha2 < 0 || p1 + q*alpha1 < 0)
	{
		printf("%d\n", 0);
		return 0;
	}
	*/
	printf("%lld\n", ans);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int equations(int m, int n){
	int a, b, aux = sqrt(m), aux2 = sqrt(n), mayor, res = 0;
	if (aux >= aux2)
		mayor = aux;
	else
		mayor= aux2;
	for(a = 0; a<=aux; a++){
		b=0;
		while ((a*a + b) <= m){
			if(((a*a + b)==m)&&((b*b + a)==n)){
				res++;
				b++;}
			else
				b++;
		}
	}
	return res;
}

int main(void){
	int m, n;
	scanf("%d %d", &m, &n);
	printf("%d\n", equations(m, n));
	return 0;
}


#include<stdio.h>
int main()
{
	int n;
	int k;
	int i,sum=0;
	int ans=0;
	float floatk;
	scanf("%d %d",&n,&k);
	int a[n];

	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum=sum+a[i];
	}

	floatk=(float)(k-0.5);
	//printf("%f",floatk);

	while(floatk*(n+ans)>(sum+(k)*ans))
	{
		ans=ans+1;
	}

	printf("%d",ans);
	return 0;
}


#include <stdio.h>

/* http://codeforces.com/contest/411/submission/25959252 (Dukkha) */

int win(int a1, int b1, int a2, int b2) {
	return a1 > b2 && b1 > a2;
}

int main() {
	int a1, b1, a2, b2, a3, b3, a4, b4;

	scanf("%d%d%d%d%d%d%d%d", &a1, &b1, &a2, &b2, &a3, &b3, &a4, &b4);
	if ((win(a1, b2, a3, b4) && win(a1, b2, a4, b3))
			|| (win(a2, b1, a3, b4) && win(a2, b1, a4, b3))) {
		printf("Team 1\n");
		return 0;
	}
	if ((win(a3, b4, a1, b2) || win(a4, b3, a1, b2))
			&& (win(a3, b4, a2, b1) || win(a4, b3, a2, b1))) {
		printf("Team 2\n");
		return 0;
	}
	printf("Draw\n");
	return 0;
}


#include<stdio.h>
int main(){
int a,b,c,i,j;
scanf("%d %d %d",&a,&b,&c);
i=a*c-c*b;
j=i/b;
if(i%b!=0)
    j=j+1;
printf("%d",j);
}


#include<stdio.h>
long long int abs(long long int n)
{
	if (n < 0)
		n *= -1;
	return n;
}
int main()
{
	long long int x0, y0, ax, ay, bx, by;
	scanf("%lld %lld %lld %lld %lld %lld", &x0, &y0, &ax, &ay, &bx, &by);
	long long int xs, ys, t;
	scanf("%lld %lld %lld", &xs, &ys, &t);
	long long int x[102], y[102];
	x[0] = x0;
	y[0] = y0;
	long long int i, j;
	long long int max = 10000000000000016;
	for (i = 0; x[i] < max && y[i] < max; i++)
	{
		x[i + 1] = ax * x[i] + bx;
		y[i + 1] = ay * y[i] + by;
	}
	long long int c = i + 1;
	long long int ans = 0;
	for (i = 0; i < c; i++)
		for (j = 0; j < c; j++)
			if (abs(xs - x[i]) + abs(ys - y[i]) + abs(x[i] - x[j]) + abs(y[i] - y[j]) <= t)
				if (ans < abs(i - j) + 1)
					ans = abs(i - j) + 1;
	printf("%lld\n", ans);
	return 0;
}