#include<stdio.h>
#include<string.h>
int main() {
    char str[101];
    scanf("%s",&str);
    char *sa=strstr(str,"ABC"),*sb=strstr(str,"ACB"),*sc=strstr(str,"BCA"),*sd=strstr(str,"BAC"),*se=strstr(str,"CAB"),*sf=strstr(str,"CBA");
    if(sa!=NULL||sb!=NULL||sc!=NULL||sd!=NULL||se!=NULL||sf!=NULL)
        printf("Yes");
    else
        printf("No");
}


/* https://codeforces.com/contest/653/submission/19859515 (rainboy) */
#include <stdio.h>

#define Q	36

int main() {
	static char ab[Q][4], cc[Q];
	static int dp[6][6];
	int n, q, i, j, k;

	scanf("%d%d\n", &n, &q);
	for (i = 0; i < q; i++)
		scanf("%s %c", ab[i], &cc[i]);
	for (i = 0; i < 6; i++)
		dp[0][i] = 1;
	for (i = 1; i < n; i++)
		for (j = 0; j < 6; j++)
			for (k = 0; k < q; k++)
				if (j + 'a' == cc[k])
					dp[i][j] += dp[i - 1][ab[k][0] - 'a'];
	printf("%d\n", dp[n - 1][0]);
	return 0;
}


#include "stdio.h"
int main()
{
	int i,n,d=1;
	char str[101],temp;
	scanf("%d",&n);
	scanf("%s",str);
	while(d<=n)
	{
		if(n%d==0)
		{
			for(i=0;i<=(d-1)/2;i++)
			{
				temp = str[i];
				str[i] = str[d-1-i];
				str[d-1-i] = temp;
			}
		}
		d++;
	}
	printf("%s",str);
}


#include <stdio.h>

int main(void)
{
    short counter=0, i=0,size=0;

    char string[100];

    scanf("%s",string);

    size=strlen(string);
    while(i<size){
    if(string[i]=='H'||string[i]=='Q'||string[i]=='9'){
         counter++;
    }

   i++;

}
if(counter>=1){
    printf("YES\n");

}
else
    printf("NO\n");

    return 0;
}


#include <stdio.h>

int min(int a, int b){ return a < b ? a : b; }
int abs(int x){ return x < 0 ? -x : x; }

int main(){
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    int res = 1e9;
    for(int i=1; i<=n; i++){
        int a;
        scanf("%d", &a);
        if(a != 0 && a <= k) res = min(res, abs(i-m));
    }
    printf("%d", 10*res);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int i,len;
    char ch,str[110];
    gets(str);
    len=strlen(str);
    for(i=0;i<len;i++)
    {
        if((str[i]>='a' && str[i]<='z') || (str[i]>='A' && str[i]<='Z'))
        {
            ch=str[i];
        }
    }
    if(ch=='A' || ch=='a' || ch=='E' || ch=='e' || ch=='I' || ch=='i' || ch=='O' || ch=='o' || ch=='U' || ch=='u' || ch=='Y' || ch=='y')
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}


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

int main(void)
{
    int n, a, b, m, r, *app;

    scanf("%d %d %d %d", &a, &b, &m, &r);
    app = (int *)calloc(m, sizeof(int));
    for (n = 1; 1; n++)
    {
        r = (a * r + b) % m;
        if (app[r])
        {
            printf("%d\n", n - app[r]);
            break;
        }
        else
            app[r] = n;
    }

    return 0;
}


#include<stdio.h>

int isLeap(year)
{
	if(year%4==0 && year%100!=0 || year%400==0)
		return 29;
	else
		return 28;
}

int no_of_days_remaining(int mon,int year)
{
	int days=0;
	switch(mon)
		{
			case 1:days+=31;
			case 2:days+=isLeap(year);
			case 3:days+=31;
			case 4:days+=30;
			case 5:days+=31;
			case 6:days+=30;
			case 7:days+=31;
			case 8:days+=31;
			case 9:days+=30;
			case 10:days+=31;
			case 11:days+=30;
			case 12:days+=31;
		}
	return days;
}

int no_of_days_passed(int mon, int year)
	{
		int days=0;
		switch(mon)
			{
			case 12:days+=31;
			case 11:days+=30;
			case 10:days+=31;
			case 9:days+=30;
			case 8:days+=31;
			case 7:days+=31;
			case 6:days+=30;
			case 5:days+=31;
			case 4:days+=30;
			case 3:days+=31;
			case 2:days+=isLeap(year);
			case 1:days+=31;
			}
		return days;
	}

int no_of_days(int year)
{
	int k=31*7+30*4+isLeap(year);
	return k;
}

int main()
{
	int mm1,dd1,yy1,mm2,dd2,yy2,i,j,k,nodA,nodC,nodB=0,nod,start,end,m1,d1,y1,m2,d2,y2;
	scanf("%d:%d:%d",&yy1,&mm1,&dd1);
	scanf("%d:%d:%d",&yy2,&mm2,&dd2);
	if(yy2>yy1)
		{
			m1=mm1;
			y1=yy1;
			d1=dd1;
			m2=mm2;
			y2=yy2;
			d2=dd2;
		}
	else
		{
			m1=mm2;
			y1=yy2;
			d1=dd2;
			m2=mm1;
			y2=yy1;
			d2=dd1;
		}
		nodA=no_of_days_remaining(m1,y1);
		nodC=no_of_days_passed(m2-1,y2);
		if(yy2>yy1)
		{
			start=yy1;
			end=yy2;
		}
	else
		{
			start=yy2;
			end=yy1;
		}
	for(i=y1+1;i<=y2-1;i++)
	{
		nodB+=no_of_days(i);
	}
	nod=(nodA-d1+1) + (nodC+d2) + nodB-1;
	if(yy1==yy2)
		{
			if(mm2>mm1)
			   //nod=-1*(365-nod+1)+1;
			   nod=(no_of_days_remaining(mm1,yy1)-dd1+1)-(no_of_days_remaining(mm2,yy2)-dd2+1);
			else if(mm2<mm1)
				//nod=365-nod+1;
				nod=(no_of_days_remaining(mm2,yy2)-dd2+1)-(no_of_days_remaining(mm1,yy1)-dd1+1);
			else
				{
					if(dd1>dd2)
						nod=dd1-dd2;
					else
						nod=dd2-dd1;
				}
		}
	printf("%d",nod);
}


#include <stdio.h>

int main(){
	int n,i;
	scanf("%d",&n);
	for(i=0;(i*(2*i*i+6*i+4))/12<=n;i++);
	printf("%d",i-1);
	return 0;
}


#include<stdio.h>
int main()
{
	long long int i,j,n,l,a,k;
	scanf("%lld",&n);
	k=2520;
	a=n/k;
	printf("%lld\n",a);
	return 0;
}


#include<stdio.h>

int main(){
    char comp[3][4];

    for(int i = 0; i < 3; i++){
        scanf("%s", comp[i]);
    }

    char first[3], sec[3], op[4];

    for(int i = 0; i < 3; i ++){
        if(comp[i][1] == '>'){
            first[i] = comp[i][0];
            sec[i] = comp[i][2];
        }

        else{
            first[i] = comp[i][2];
            sec[i] = comp[i][0];
        }
    }

    if(sec[0] == sec[1])
        printf("%c", sec[0]);
    else if(sec[0] == sec[2])
        printf("%c", sec[0]);
    else if(sec[1] == sec[2])
        printf("%c", sec[2]);
    else;

    if(first[0] == first[1]){
        printf("%c%c", first[2], first[0]);
    }
    else if(first[0] == first[2])
        printf("%c%c", first[1], first[0]);
    else if(first[2] == first[1])
        printf("%c%c", first[0], first[1]);
    else
        printf("Impossible");
}


#include<stdio.h>

main(){
    double d,l,v1,v2;
    scanf("%lf %lf %lf %lf",&d,&l,&v1,&v2);
    printf("%0.10lf",(l-d)/(v1+v2));
}


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

int main()
{
    char str[11];
    scanf("%s", str);
    int len = strlen(str);
    unsigned ans = 1;
    for(int i = 0; i < len; ++i) {
        ans *= str[i] - '0';
    }
    for(int i = 0; i < len; ++i) {
        if(str[i] != '0') {
            unsigned cur = 1;
            for(int j = 0; j < i; ++j) {
                cur *= str[j] - '0';
            }
            cur *= str[i] - '0' - 1;
            if(str[i] == '1' && i == 0) {
                cur = 1;
            }
            for(int j = i + 1; j < len; ++j) {
                cur *= 9;
            }
            if(ans < cur) {
                ans = cur;
            }
        }
    }
    printf("%u\n", ans);
    return 0;
}


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

int main() {
	int i, l;
	static char n[11];
	static char *s[] = {
		"O-|-OOOO",
		"O-|O-OOO",
		"O-|OO-OO",
		"O-|OOO-O",
		"O-|OOOO-",
		"-O|-OOOO",
		"-O|O-OOO",
		"-O|OO-OO",
		"-O|OOO-O",
		"-O|OOOO-"
	};
	scanf("%s", n);
	l = strlen(n);
	for (i = l - 1; i >= 0; i--)
		printf("%s\n", s[n[i] - '0']);
	return 0;
}


#include<stdio.h>
int main()
{
 int n;
 scanf("%d",&n);
 printf((n%4 && n%7 && n%47 && n%74 && n%477)?"NO":"YES");
 return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int a,b,i,n;
    char s[1000];
    scanf("%s",s);
    n=strlen(s);
    a=b=0;
    for(i=0;i<n;i++)
    {
        if(s[i]=='o')
            b++;
        else
            a++;
    }
    if(b!=0 && a%b!=0)
        printf("NO\n");
    else
        printf("YES\n");
    return 0;
}


#include<stdio.h>

int main()
{
  long long int i,j,k=0,n,x;
  scanf("%lld%lld",&n,&x);
  for(i=1;i<=n;i++)
  {
   if(x%i==0 && x/i<=n)
   {
    k++;
   }
  }
 printf("%lld",k);
}


#include "stdio.h"
#include "math.h"
void desort(int a[50],int size)
{
	int i=0;
	int j=0;
	int temp=0;
	    for (i = 0; i < size; ++i)
    	{
        	for (j = i + 1; j < size; ++j)
        	{
            	if (a[i] < a[j])
            	{
                	temp =  a[i];
                	a[i] = a[j];
                	a[j] = temp;
            	}
        	}
    	}
}
int main()
{
	int n,m,k;
	scanf("%d %d %d",&n,&m,&k);
	int i=0,a[50],b[50];
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	desort(a,n);
	desort(b,n);
	int sum=0;
	for(i=0;i<n-1;i++)
		{
			b[i]=b[i]-1;
			sum=sum+b[i];
		}
sum=sum+b[n-1]+(k-1);
//printf("The sum is %d\n",sum );
if(sum <m)
	printf("-1\n");
else if (m<=k)
	printf("0\n");
else
	{
		int sock=k-1;
		int device=m-sock;
		int count=1;
		for(i=0;i<n;i++)
			{
				/*if((b[i]+a[i+1])>=device)
				{
					count++;
					break;
				}
				else
				{
					count++;
					device=device-b[i];

				}*/
				if(device>a[i])
				{
					device=device-b[i];
					count++;
				}
				else break;
			}
		printf("%d\n",count);
	}
return 0;
}


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

int main()
{
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);

    int K = (a+b-c)/2;
    int K2 = (b+c-a)/2;
    if(K >= 0 && K2>= 0 && a- K >=0 && 2*(K + K2 + (a - K)) == (a + b + c))
    {
        printf("%d %d %d\n",K,K2,a-K);
    }
    else
    {
        printf("Impossible\n");
    }
    return 0;
}


#include <stdio.h>

int main()
{
   long long int n;
   long long ans = 0, a = 2, b = 1, c = 0;
   scanf("%lld", &n);
   if(n == 2) {printf("1\n");return 0;}
   else if(n == 3) {printf("2\n");return 0;}
   else
    while(1)
   {
      if(a > n) break;
      ans++;
      c = b;
      b = a;
      a += c;
   }
   printf("%lld", ans);
   return 0;

}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
main()
{
	int sum,g,temp,no[300]={0};
	int i,j,k,l,m,n,mid,mid2;
	int res,or;
	char s[1000];
	scanf("%s",s);
	i=0;l=strlen(s);
	while (1) if (s[i++]==':') break;
    mid=i-1;
	for (j=0;j<mid-1;j++)
		if (s[j]!='0') break;
	k=0;
	for (i=j;i<=mid;i++)
		s[k++]=s[i];
	mid2=k-1;
	for (j=mid+1;j<l-1;j++)
		if (s[j]!='0') break;
	for (i=j;i<=l;i++)
		s[k++]=s[i];
	l=strlen(s);
	res=1;
	for (i=0;i<l;i++)
	{
		if (s[i]==':') continue;
		if (isdigit(s[i]))
		temp=s[i]-'0';
		if (s[i]>='A' && s[i]<='Z')
		temp=s[i]-'A'+10;
		if (res<temp) res=temp;
	}
	or = res;
	if (l==3)
	{
		if (isdigit(s[0]) || 'A'<=s[0] && s[0]<'O')
		{
			printf("-1");
				return 0;
		}
	}
	while (no[res]==0)
	{
		res++;
		sum=0;
		for (i=0;i<mid2;i++)
		{
			if (isdigit(s[i]))
			{
				temp=s[i]-'0';
				sum=sum*res+temp;
			}
			else if(s[i]>='A' && s[i]<='Z')
			{
				temp=s[i]-'A'+10;
				sum=sum*res+temp;
			}
		}
		if (sum>=24) no[res]=1;
		sum=0;
		for (i=mid2+1;i<l;i++)
		{
			if (isdigit(s[i]))
			{
				temp=s[i]-'0';
				sum=sum*res+temp;
			}
			else if(s[i]>='A' && s[i]<='Z')
			{
				temp=s[i]-'A'+10;
				sum=sum*res+temp;
			}
		}
		if (sum>=60) no[res]=1;
	}

	if (or+1>=res) putchar('0');
	else
	for (i=or+1;i<res;i++)
	{
		printf("%d",i);
		if (i!=res-1) putchar(' ');
	}
return 0;
}


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

typedef long long ll;
typedef unsigned int uint;

#define si(x) scanf("%d", &x)
#define sl(x) scanf("%ld", &x)
#define sll(x) scanf("%lld", &x)
#define sc(x) scanf("%c", &x)
#define ss(x) scanf("%s", x)
#define f(i, a, b) for(i = a; i < b; i++)

int main() {
  char a[101], b[101];

  ss(a);
  ss(b);

  int l1 = 0, l2 = 0;
  int countA[26] = {0}, countB[26] = {0}, i;
  for(i = 0; a[i]; i++) {
    countA[a[i] - 'a']++;
    l1++;
  }

  for(i = 0; b[i]; i++) {
    countB[b[i] - 'a']++;
    l2++;
  }

  if(l2 > l1) {
    printf("need tree\n");
    return 0;
  }

  int flagA = 0, flagB = 0;
  f(i, 0, 26) {
    if(countA[i] > countB[i]) {
      countA[i] = countA[i] - countB[i];
      countB[i] = 0;
    } else {
      countB[i] = countB[i] - countA[i];
      countA[i] = 0;
    }

    if(countA[i] > 0)
      flagA = 1;

    if(countB[i] > 0)
      flagB = 1;
  }

  if(!flagA && !flagB)
    printf("array\n");
  else if(flagB)
    printf("need tree\n");
  else {
    int j = 0;

      f(i, 0, l2) {
        while(j < l1 && b[i] != a[j])
          j++;

        if(j == l1)
          break;
        else
          j++;
      }

      if(i == l2)
        printf("automaton\n");
      else
        printf("both\n");
  }
  return 0;
}


#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
int main()
{
    int n,i,j,f=0;

   scanf("%d",&n);
   int *a=(int *)calloc(n+1,sizeof(int));
   a[1]=1;
   j=1;
   for(i=1;i<n;i++)
   {
       if((i+j)<=n)
       {
           a[i+j]=1;
            j=j+i;
       }
       else
       {
           a[i+j-n]=1;
           j=j+i-n;
       }
     //  printf("j=%d\n",j);

   }
   for(i=1;i<=n;i++)
   {
       if(a[i]!=1)
       {
           f=1;
           break;
       }
   }
   if(f==1)
   {
       printf("NO");
   }
   else printf("YES");
}


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

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

int main(void) {
	char a[5];
	char b[5];

	scanf("%s%s", &a, &b);

	int a_length = strlen(a);
	int b_length = strlen(b);

	int max_digit = 0;
	int i;
	for (i = 0; i < a_length; i++) {
		a[i] -= '0';
		max_digit = max(max_digit, a[i]);
	}

	for (i = 0; i < b_length; i++) {
		b[i] -= '0';
		max_digit = max(max_digit, b[i]);
	}

	int base = max_digit + 1;

	i = a_length - 1;
	int j = b_length - 1;
	int carry = 0;
	int sum;
	while (i >= 0 || j >= 0) {
		sum = 0;
		if (i >= 0) { sum += a[i]; i--; }
		if (j >= 0) { sum += b[j]; j--; }
		sum += carry;
		carry = sum / base;
	}

	int result = max(a_length, b_length);
	if (carry) result++;

	printf("%d\n", result);

	return 0;
}


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

        }
    else
        printf("0\n");
    return 0;
}


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

unsigned long long int pgcd(unsigned long long int x,unsigned long long int y)
    {
        if (x==0) return y;
        if (y==0) return x;
        if ((x==1) || (y==1)) return 1;
        if (x==y) return x;
        if (x<y) return pgcd(x,y%x);
        return pgcd(x%y,y);
    }

main()
    {
        unsigned long long int t,w,b,ww,bb,m,a,r,p,q,d,s;
        scanf("%llu%llu%llu",&t,&w,&b);
        if (w<b) m = w;
        else m = b;
        d = pgcd(w,b);
        ww = w / d;
        bb = b / d;
        if (t<ww)
            {
                a = 0;
                r = t;
            }
        else
            {
                s = ww;
                if ((t/s)<bb)
                    {
                        a = 0;
                        r = t;
                    }
                else
                    {
                        s = ww * bb;
                        if ((t/s)<d)
                            {
                                a = 0;
                                r = t;
                            }
                        else
                            {
                                s = ww * bb * d;
                                a = t / s;
                                r = t % s;
                            }
                    }
            }
        if (m<=r) p = ((a + 1) * m) - 1;
        else p = (a * m) + r;
        q = t;

        d = pgcd(p,q);
        p = p / d;
        q = q / d;
        printf("%llu/%llu",p,q);
    }


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

int main()
{
    int n,m;
    scanf("%d %d", &n, &m);
    int count = 0;
    int a, b = 0;
    for (a = 0; b >= 0; a++)
    {
        b = n - a * a;
        if (a + b * b == m && b >= 0)
            count++;
    }
    printf("%d\n", count);
    return 0;
}


#include <stdio.h>

int main() {

        int w,h,w1,h1,w2,h2;
        scanf("%d %d %d %d %d %d",&w,&h,&w1,&h1,&w2,&h2);

        int ans=w;
        for(int i=h ; i>=0 ; i--)
        {
            ans+=i;
            if(h1==i)
                ans -= w1;
            else if(h2==i)
                ans -= w2;

            if(ans<0)
            ans=0;

        }
        printf("%d",ans);

}


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

int main()
{
    char arr[10];
    int n,m;
    float hr,min;
    scanf("%s",arr);
        n=(arr[0]-48)*10+(arr[1]-48);
        if(n>=12)
        n-=12;
        hr=n*30;
        m=(arr[3]-48)*10+(arr[4]-48);
        hr+=(float)m/2;
        min=6*m;
        printf("%f %f\n",hr,min);
    return 0;
}


#include<stdio.h>
int main()
{
    unsigned long long l1,r1,l2,r2,k,start,end,sum=0;
    scanf("%llu%llu%llu%llu%llu",&l1,&r1,&l2,&r2,&k);
    if(l2>r1 || r2<l1)
        printf("0");
    else
    {
       if(l1>l2)
            start=l1;
       else
            start=l2;
       if(r2==r1)
            end =r2;
       else if(r2>r1)
            end=r1;
       else
            end=r2;
       sum=sum+end-start+1;
       if(k>=start && k<=end)
            sum=sum-1;
       printf("%llu",sum);
    }
}


#include<stdio.h>
#include<math.h>
long long n,m,a,pows,i,c;
int main() {

scanf("%I64d%I64d",&n,&m);
if(n>=34)
printf("%I64d",m);
else
{
    pows=2;
    for(i=1;i<n;i++)
    pows *= 2;
    c = m%pows;
    printf("%I64d",c);
}
}


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

int n,k;
int dem[101];
int main()
{
	int web,i;
	scanf("%d%d",&n,&k);
	for(i=1 ; i<=n ; i++)
	{
		scanf("%d",&web);
		dem[i%k]+=web;
		dem[k]+=web;
	}

	int kq=0;
	for(i=0 ; i<k ; i++)
	{
		dem[i]=abs(dem[k]-dem[i]);
		kq=kq>dem[i]?kq:dem[i];
	}

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


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

int main()
{
    char s[100];
    scanf("%s",s);

    int l = strlen(s);
    int len = 0;

    for(int i = 0; i<l; i++)
    {
        for(int j = i+1; j<l; j++)
        {
            int n = 0;
            while(s[i+n] == s[j+n])
                n++;
            if(n>len)
                len = n;
        }
    }

    printf("%d\n",len);

    return 0;
}


#include <stdio.h>

int main()
{
    int n, amount=0;
    scanf("%d", &n);
    int b[3001] = {0};
    int factores[3001] = {0};
    for (int i = 2; i <= n; ++i)
    {
        if (!b[i]){
            for (int j = i + i; j <= n; j += i){
                b[j] = 1;
                factores[j] += 1;
            }
        }

        if (factores[i] == 2)amount++;
    }
    printf("%d\n", amount);
    return 0;
}


#include <stdio.h>
int main()
{
    long long int i, b;
    long long int count=0;
    long long int flag=0;
    scanf("%lld", &b);
    for(i=1; i*i<=b; i++)
    {
        if(b%i==0)
            count++;
        if(i*i==b)
            flag=1;
    }
    if(flag==0)
        count=(2*count);
    else
        count=((2*count)-1);
    printf("%lld\n", count);
    return 0;
}


#include <stdio.h>

int main() {
	int n;
	scanf("%d",&n);
	if(n%2==0)
	{
	    printf("%d\n",n/2-1);
	}
	else
	{
	    printf("%d\n",n/2);
	}
	return 0;
}


#include <stdio.h>

int main(void) {
    int left = 0, right = 0;
    int n = 0, m = 0, k = 0;
    int i = 1, val = 1;

    scanf("%d %d %d", &n, &m, &k);
    left = right = k;
    m -= n;

    while (m >= i) {
        val++;
        m -= i;
        if (left > 1) {
            left--;
            i++;
        }

        if (right < n) {
            right++;
            i++;
        }

        if (left == 1 && right == n) {
            val = val + m / n;
            break;
        }
    }

    printf("%d\n", val);

    return 0;
}


#include<stdio.h>

int selectSort(int *mas, int n){
	int tmp,i,j;
	int cur=0;
	for (i=0;i<n;i++){
		for (j=i;j<n;j++){
			if (mas[i]>mas[j]){
				tmp=mas[i];
				mas[i]=mas[j];
				mas[j]=tmp;
			}
		}
	}
	return 0;
}
int main(){
	int st[100];
	int n,i,j,max,count,t;
	scanf("%d",&n);
	for (i=0;i<n;i++){
		scanf("%d",&st[i]);
	}
	scanf("%d",&t);
	selectSort(st,n);
	printf("\n");
	max=1;
	for (i=0;i<n-1;i++){
		count=1;
		for (j=i+1;j<n;j++){
			if (st[j]-st[i]<=t) count++;
		}
		if (max<count) max=count;
	}
	printf("%d\n",max);
	return 0;
}


#include<stdio.h>
#include<string.h>
const int N=1000000007;
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		long long a,b;
		scanf("%lld%lld",&a,&b);
		long long t=1;
		while(b--){
			t=t*a;
			t=t%N;
		}
		printf("%lld\n",t);
	}
	return 0;
}


#include<stdio.h>
int main()
{
   long long int n,k;
   scanf("%lld %lld", &n,&k);
   if(k==1)
    printf("%lld",n);
   else
    {   long long i = 1;
        while(i<n)
            i=i*2+1;
        printf("%lld",i);
    }
    return 0;
}


#include<stdio.h>
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int count=0;
    for(int i=1;i<=n;i++){
        if(i%m==0){
            if(i>=(float)n/2 && i<=n){
            printf("%d",i);
            count++;
            break;
            }
        }
    }
    if(count==0)
        printf("-1");
}


#include <stdio.h>
#include <string.h>
#include <math.h>
int main(){
	int n,i, count1, count2, Scount, Ncount;
	char c[10] = {118,60,94,62};
	char ch1, ch2;
	scanf("%c %c", &ch1, &ch2);
	scanf("%d", &n);
	for(i = 0;i < 4; i++)
	{
		if(ch1 == c[i])
			count1 = i;
		if(ch2 == c[i])
			count2 = i;
	}

	if(ch1 == ch2||count1-count2 == 2 ||count2 - count1 ==2)
	{
		printf("undefined\n");
		return 0;
	}
	else if(count1 > count2)
	{
		Scount = count2- count1 + 4;
		Ncount = count1 - count2;
	}
	else
	{
		Scount = count2 - count1;
		Ncount = count1 - count2 + 4;
	}
	int num = n % 4;
	if((Scount != num)&&(Ncount != num)||(Scount == num)&&(Ncount == num))
		printf("undefined\n");
	else if(Scount == num&&Ncount != num)
		printf("cw\n");
	else
		printf("ccw\n");
	return 0;
}


#include<stdio.h>
int main()
{
    int i,a,b,c,k,l;
    scanf("%d%d%d",&a,&b,&c);
    if((a+b)==c){
        printf("1\n");
        return 0;
    }
    k=a;
    k=k<b?k:b;
    k=k<c?k:c;
    if(a==k && b<c){
     printf("%d\n",a-c+b+1);
    return 0;
    }
    else if(b==k && a<c){
      printf("%d\n",b-c+a+1);
    return 0;
    }
    printf("%d\n",k+1);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,b,p,nb,np,temp,count=0,r;
    scanf("%d %d %d",&n,&b,&p);
    printf("%d %d",(n-1)*(2*b+1),n*p);

    return 0;
}


#include<stdio.h>
int main()
{
	int a,b,c,n;
	scanf("%d %d %d %d",&a,&b,&c,&n);
	int ans;
	ans=n-(a+b-c);
	if(ans<=0||c>a||c>b)
	printf("-1");
	else printf("%d",ans);

}


#include<stdio.h>
int main()
{
    int n,a,b,p,q,a1,b1,ab,c=0,temp;
    long long ans,lcm,m;
    scanf("%d%d%d%d%d",&n,&a,&b,&p,&q);
    a1=n/a;
    b1=n/b;
    m=1ll*a*b;
    while(a&&b)
    {
        temp=b%a;
        b=a;
        a=temp;
    }
    lcm=m/b;
    ab=n/lcm;
    //printf("%d\n",lcm);
    if(p>q)
    {
        b1=b1-ab;
    }
    else
    {
        a1=a1-ab;
    }
    ans=1LL*p*a1+1LL*q*b1;
    printf("%lld",ans);
    return 0;
}


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

int answer(double a,double b,double c)
{
    int res=0;
	if(c>=a&&c<=b)
        res++;

    return res;
}

int main()
{
	int h,t1,t2,temp,k=0;
	int m,s;
	double a,b,c,d,e;
	scanf("%d %d %d %d %d",&h,&m,&s,&t1,&t2);

		if(t1>t2){
		temp=t1;
		t1=t2;
		t2=temp;
		}

		a=t1*30.0;
		b=t2*30.0;
		c=(h*30)+m*0.5+s/120.0;
		d=m*6.0+s*1.0/60.0;
		e=s*6.0;

		k=k+answer(a,b,c);
		k=k+answer(a,b,e);
		k=k+answer(a,b,d);
		if(k==0||k==3)
            printf("YES");
		else
            printf("NO");

	return 0;
}


#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
/*int cmp(const void *a, const void *b)
{
     return(*(int *)a-*(int *)b);
}*/
//  qsort(a,n,sizeof(a[0]),cmp);

int main()
{
    int a,b,c,x,y,z;
    scanf("%d %d %d",&a,&b,&c);
    scanf("%d %d %d",&x,&y,&z);
    if((a>x) && (b>y) && (c>z))
    {
        printf("Yes");
    }
    else if((a<x) && (b<y) && (c<z))
    {
        printf("No");
    }
    else if((a>=x) && (b<=y) && (c<=z))
    {
        if((a-x)/2 >= (y-b+z-c))
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    else if((a>=x) && (b>=y) && (c<=z))
    {
        if((a-x)/2 + (b-y)/2 >= (z-c))
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    else if((a>=x) && (b<=y) && (c>=z))
    {
        if((a-x)/2 + (c-z)/2 >= (y-b))
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    else if((a<=x) && (b>=y) && (c>=z))
    {
        if((b-y)/2 + (c-z)/2 >= (x-a))
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    else if((a<=x) && (b<=y) && (c>=z))
    {
        if((c-z)/2 >= (x-a+y-b))
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    else if((a<=x) && (b>=y) && (c<=z))
    {
        if((b-y)/2 >= (x-a+z-c))
        {
            printf("Yes");
        }
        else
        {
            printf("No");
        }
    }
    else
    {
        printf("Yes");
    }
    return 0;
}


#include<stdio.h>
#include<math.h>
int sai(const void* a,const void* b)
{
	return *(int*)a-*(int*)b;
}
int main( )
{
	int n,d,a[101]={0},m,i,j,k,c=0;
	scanf("%d %d",&n,&d);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	scanf("%d",&m);
	qsort(a,n,sizeof(int),sai);
	if(n<=m)
	{
		for(i=0;i<=n;i++)
		{
			c+=a[i];
		}
		c-=((m-n)*d);
	}
	else
	{
		for(i=0;i<m;i++)
		{
			c+=a[i];
		}
	}
	printf("%d\n",c);
	return 0;
}


#include<stdio.h>
int main()
{
    int x, y, z;
    scanf("%d%d%d",&x,&y,&z);
    if(x==0||y==0||z==0){
    if(x==0 && y>z){
    printf("-");
    }

    else if(y==0 && x>z){
    printf("+");

    }
    else  if(z==0){
    if(y==x && x>0 && y>0){
    printf("0");
    }
    else if(x>y){
    printf("+");
    }
    else if(x<y){
    printf("-");
    }
    else if(x==y){
    printf("0");
    }
    }

  else{
  printf("?");
  }

 }
   else if(x>y||y>x){
   if(y+z<x){
   printf("+");
   }
   else if(x+z<y){
   printf("-");
   }
   else{
  printf("?");
  }

   }
  else{
  printf("?");
  }

    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>
#define m 1000000007

long int power(long int a,long int b)
{
    long int ans=1;
    if(b==0)
        return 1;
    while(b>0) {
        if (b % 2 != 0)
            ans= ans * a;
        a = a * a;
        b = b / 2;
    }
    return ans;
}

int main()
{
    long int n,i=0,index=0;
    scanf("%ld",&n);
    while(n>0)
    {
        int rem=n%10;
        if(rem==4)
            index+=power(2,i);
        else
            index+=power(2,i+1);
        n=n/10;
        i++;
    }
    printf("%ld\n",index);
}


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

int main()
{
    char s[101];
    int n, i, j, l, k;
    scanf("%s", s);
    l = strlen(s);

    for(i=1,k=1, j=1; i<l; i++)
    {
        if(s[i]!=s[i-1])
        {
            k++;
            j=1;
        }
        else
            j++;
        if(j>5)
        {
            k++;
            j=1;
        }
    }
    printf("%d\n", k);
    return 0;
}


#include <stdio.h>
int main()
{
	int x;
	scanf("%d", &x);
	if (x % 4 == 1)
		printf("0 A");
	else if (x % 4 == 0)
		printf("1 A");
	else if (x % 4 == 2)
		printf("1 B");
	else
		printf("2 A");
}


#include<stdio.h>
int main() {
	int n,a = 0,i,j,h,sayac=0;
	scanf("%d",&n);
	char d[n],k;
	for(i = 1 ; i <= n ; i++)
	{
		scanf(" %c",&k);
		if(k == '0')
		{
			a = i;
			break;
		}
	}
	printf("%d",a + n * (a == 0));
	return 0;
}


#include<stdio.h>
int main()
{
    int a, b, c, x, y, z;
    scanf("%d%d%d%d%d%d",&x,&y,&z,&a,&b,&c);
    a -= x;
    if(a<0){
       printf("NO\n");
        return 0;
    }
    if(a+b < y){
        printf("NO\n");
        return 0;
    }
    if(a+b+c-y < z){
        printf("NO\n");
        return 0;
    }
    else
    printf("YES");

    return 0;
}


#include <stdio.h>

long long summer(long long a)
{
    long long sum =0;
    while(a>0)
    {
        sum+=a%10;
        a/=10;
    }
    return sum;
}

int main()
{
    long long n;
    scanf("%lld",&n);
    long long b=0;
    while(b<n)
    {
        b = b*10 + 9;
    }
    b/=10;
    printf("%lld",summer(b)+summer(n-b));
}


#include <stdio.h>
int min(int a,int b){
    return a>b?b:a;
}
int max(int a,int b){
    return a<b?b:a;
}

int main()
{
    int b,r,mi,ma;

    scanf("%d",&b);
    scanf("%d",&r);
        mi=min(b,r);
        ma=max(b,r);
    printf("%d %d",mi,(ma-mi)/2);

    return 0;
}


#include <stdio.h>
#include <assert.h>

int
main()
{
    int n, x=0, y=0;
    scanf("%d%*c", &n);
    for (int i = 0; i < n; ++i) {
        char c;
        scanf("%c", &c);
        if (c == 'U') {
            y += 1;
        }
        else if (c == 'D') {
            y -= 1;
        }
        else if (c == 'R') {
            x += 1;
        }
        else if (c == 'L') {
            x -= 1;
        }
        else {
            assert(0);
        }
    }
    if (x < 0) x = -x;
    if (y < 0) y = -y;
    printf("%d\n", n - x - y);
    return 0;
}


/*
 * mishka.c
 *
 * Copyright 2019 Lenovo <Lenovo@LAPTOP-PV3PDF40>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 * MA 02110-1301, USA.
 *
 *
 */

#include <stdio.h>
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		}
	int cnt=0,i=0,j=n-1;
	int f1=-0,f2=0;
	if(n>1){
		while((f1==0||f2==0)&&(i<=j)){
			if(a[i]<=k){cnt++;i++;}
			else{f1=1;}
			if(a[j]<=k){cnt++;j--;}
			else{f2=1;}
			if(i==j&&a[i]<=k&&a[j]<=k){cnt--;}
			}
		}
		if(n==1&&a[0]<=k){cnt=1;}
		printf("%d\n",cnt);
		return 0;
	}


#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(){
    char s[101];
    scanf("%s",s);
    int cnt1=0,cnt2=0;
    for(int i=0;i<strlen(s);i++){
        if(islower(s[i])){
            cnt1++;
        }else{
            cnt2++;
        }
    }for(int i=0;i<strlen(s);i++){
        if(cnt1>=cnt2){
            s[i]=tolower(s[i]);
        }else if(cnt1<cnt2){
            s[i]=toupper(s[i]);
        }
    }
    printf("%s",s);
    return 0;

}


#include<stdio.h>

long long  mini(long long a, long long b, long long c)
{

 return a<=b?a<=c?a:c : b<=c?b:c;

}

int main(void)
{

long long min,n,a,b,c;

scanf("%lld%lld%lld%lld",&n,&a,&b,&c);

if(n%4==0)
{
printf("0");
return 0;
}

else if(n%4==3)
{

min = mini(a,b+c,3*c);

}

else if(n%4==2)
{

  min = mini(2*a, b, 2*c);

}

else if(n%4==1)
{

min = mini(3*a, c, a+b);

}

printf("%lld",min);

return 0;
}


#include<stdio.h>
int main()
{
  int n,a,x,b,y;
  scanf("%d %d %d %d %d",&n,&a,&x,&b,&y);
  while(1)
  {
    if(a==b)
    {
      printf("YES\n");
      return 0;
    }
    if(a==x || b==y)
      break;
    if(a==n-1)
      a=n;
    else
      a=(a+1)%n;
    if(b==1)
      b=n;
    else
      b=(b-1+n)%n;
  }
  printf("NO");
}


#include<stdio.h>
#include<stdlib.h>
int cmpfun(const void * a, const void * b)
{
   return ( *(int*)a - *(int*)b );
}
int main()
{
    int a,ac,b,bc,cc,c,n,i,days=0,day,j,d[3];
    scanf("%d %d %d",&a,&b,&c);
    d[0]=a/3;
    d[1]=b/2;
    d[2]=c/2;
    qsort(d,3,sizeof(int),cmpfun);

    day=d[0]*7;
    a-=(d[0]*3);
    b-=(d[0]*2);
    c-=(d[0]*2);

    for(j=1;j<8;j++)
    {
        n=0;
        ac=a;
        bc=b;
        cc=c;
        i=j;
        while(1)
        {

            if(i==1||i==4||i==7)
            {
                if(ac==0)break;
                ac--;
            }
            else if(i==2||i==6)
            {
                if(bc==0)break;
                bc--;
            }
            else
            {
                if(cc==0)break;
                cc--;
            }
            if(i==7)i=1;
            else i++;
            n++;
            //printf("%d %d %d\n",ac,bc,cc);
        }
        if(days<n)days=n;
    }
    printf("%d",days+day);
}


#include<stdio.h>
int minimo(int a, int b);
int main(){
    int v[5], i, j, k, total = 0, min;
    for(i = 0; i < 5; i++){
        scanf("%d", &v[i]);
        total = total + v[i];
    }
    min = total;
    for(i = 0; i < 5; i++){
        for(j = i + 1; j < 5; j++){
            if(v[i] == v[j]){
                if(total - 2*v[i] < min)
                    min = total - 2*v[i];
            }
        }
    }
    for(i = 0; i < 5; i++){
        for(j = i + 1; j < 5; j++){
            for(k = j + 1; k < 5; k++){
                if(v[i] == v[j] && v[i] == v[k]){
                    if(total - 3*v[i] < min)
                    min = total - 3*v[i];
                }
            }
        }
    }
    printf("%d", min);
}


 #include<stdio.h>

int main()
{
    int a,b,c,d,h=0;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a==b || a==c || a==d)
        h=h+1;
    if(b==c || b==d)
        h=h+1;
    if(c==d)
        h=h+1;
    printf("%d",h);
    return 0;
}


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


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

typedef unsigned int uint;

int cmpfuncAZ(const void *a, const void *b) {
  return *(uint*)a - *(uint*)b;
}
int cmpfuncZA(const void *a, const void *b) {
  return *(uint*)b - *(uint*)a;
}

void sort(uint b[], bool order) {
  if (order) {
    qsort(b, 3, sizeof(uint), cmpfuncZA);
  } else {
    qsort(b, 3, sizeof(uint), cmpfuncAZ);
  }
}

uint sum(uint b[]) {
  uint res = 0;
  for (uint i = 0; i < 3; i++) res += b[i];
  return res;
}

int main() {
  uint left[3], right[3], n[6];

  for (uint i = 0; i < 6; i++) {
    char c;
    scanf("%c", &c);
    n[i] = atoi(&c);
  }

  for (uint i = 0; i < 3; i++) {
    left[i] = n[i];
    right[i] = n[i+3];
  }

  int diff = sum(left) - sum(right);

  if (diff < 0) {
    sort(left, false);
    sort(right, true);
    for (uint i = 0; i < 3; i++)
      left[i] = 9 - left[i];
    diff = -1 * diff;
  } else
  if (diff > 0) {
    sort(left, true);
    sort(right, false);
    for (uint i = 0; i < 3; i++)
      right[i] = 9 - right[i];
  } else {
    puts("0\n");
    return 0;
  }

  // for (uint i = 0; i < 3; i++)
  //   printf("%d ", left[i]);
  // puts("\n");
  // for (uint i = 0; i < 3; i++)
  //   printf("%d ", right[i]);
  // puts("\n");

  uint costL = 0, costR = 0, costLR = 0, tmp;

  // Change left side
  tmp = 0;
  while (tmp < diff) {
    tmp += left[costL];
    costL++;
  }

  // Change right side
  tmp = 0;
  while (tmp < diff) {
    tmp += right[costR];
    costR++;
  }

  // Change both sides
  tmp = 0;
  uint i = 0, j = 0;

  while (tmp < diff) {
    if (costLR % 2 == 0) {
      tmp += left[i];
      i++;
    } else {
      tmp += right[j];
      j++;
    }
    costLR++;
  }

  uint costs[3] = {costL, costR, costLR};
  sort(costs, false);

  // for(uint i = 0 ; i < 3; i++) printf("%d ", costs[i]);
  // puts("\n");

  printf("%d\n", costs[0]);

  return 0;
}


#include<stdio.h>

int main()
{
	int a, b,diff=0,i,count=0;
	scanf("%d %d", &a, &b);
	if (a < b)
		diff = b - a;
	else
		diff = a - b;
	for (i = 1; i <= diff/2; i++)
		count += i;
	if (diff % 2 != 0)
		count = (count * 2) + ((diff / 2) + 1);
	else
		count = count * 2;

	printf("%d", count);
	//_getch();
	return 0;
}


#include<stdio.h>
int main()
{
    int n,s,i,j,flag=0,sum=0;
    scanf("%d%d",&n,&s);
    int ara[n],max=0;
    for(i=0;i<n;i++){
        scanf("%d",&ara[i]);
        sum+=ara[i];
    }
    for(i=0;i<n;i++){
        if(ara[i]>max)
            max=ara[i];
    }
    sum-=max;
    if(s>=sum)
        printf("YES\n");
    else
        printf("NO\n");

}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int X, f;
    scanf("%lld",&X);
    if(X%2 == 0)
    {
        f = X/2;
        printf("%lld\n",f);
    }
    else
    { f = (- X - 1)/2 ;
        printf("%lld\n",f);}
    return 0;
}
// 1461347183703


#include<stdio.h>

int main()
{
    long int a,b,i,j,vla,val;
    scanf("%ld%ld",&a,&b);
    vla=a;
    val=b;

    if( b==1)
    {
        printf("Valera\n");
    }
    else
    {
        for(i=1,j=2;i>0,j>0;i=i+2,j=j+2)
        {
            vla=vla-i;

             if(vla<0)
            {
                printf("Vladik\n");
                goto end;
            }
            val=val-j;

            if(val<0)
            {
                printf("Valera\n");
                goto end;
            }
        }

    }
    end:
        return 0;

}


#include<stdio.h>
typedef long long int L;
int k;
L i,s,n;
int check(L m)
{
    s=0;
    for(i=m;i>0;i=i/k)
    {
        s=s+i;
        if(s>=n) return 1;
    }
    return 0;
}
int main()
{
    L low=1,high,mid;
    scanf("%I64d%d",&n,&k);
    high=n;
    while(low<high)
    {
        mid=(low+high)/2;
        if(check(mid))
        high=mid;
        else
        low=mid+1;
    }
    printf("%I64d\n",high);
    return 0;
}


#include <stdio.h>
#include <math.h>
int main()
{
	int n,i,j,s,t,f,w,mini,min,maxi,max;
	scanf("%d",&n);
	int ara[10][4];
	for (i=0;i<n;i++){
		for (j=0;j<4;j++){
			scanf("%d",&ara[i][j]);
		}
	}
	f=0;
	for (i=0;i<n;i++){
		s=abs(ara[i][0]-ara[i][2]);
		t=abs(ara[i][1]-ara[i][3]);
		f=f+(s*t);
		//printf("%d\n",f);
	}
	mini=100000;
	min=100000;
	maxi=0;
	max=0;
	for(i=0;i<n;i++){
		if (ara[i][0]<mini){
			mini=ara[i][0];
		}
		if (ara[i][1]<min){
			min=ara[i][1];
		}
		if (ara[i][2]>maxi){
			maxi=ara[i][2];
		}
		if (ara[i][3]>max){
			max=ara[i][3];
		}
	}
	//printf("%d",maxi);
	w=(maxi-mini)*(max-min);
	//printf("%d",f);
	if (f==w && (maxi-mini)==(max-min)){
		printf("YES");
	}
	else{
		printf("NO");
	}
	return 0;
}


#include<stdio.h>
int main()
{
    int i,j,k,l,a,b,c,sum=0,m;
    scanf("%d %d %d",&i,&j,&k);
    int ara[i];
    for(l=0;l<i;l++)
    {
        ara[l]=j*j;
    }
    for(l=1;l<=k;l++)
    {
        scanf("%d %d %d",&a,&b,&c);
        for(m=a;m<=b;m++)
        {
            if(c*c<ara[m-1])
            {
                ara[m-1]=c*c;
            }
        }
    }
    for(l=0;l<i;l++)
    {
        sum=sum+ara[l];
    }
    printf("%d",sum);
}


#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main(){
int count=0,couta=0;
char s[52];
int x,i,n;
int y;
scanf("%s",&s);
x=strlen(s);
for(i=0;i<x;i++){
if(s[i]=='a'){
couta++;
}
if(s[i]>='b'&& s[i]<='z'){
count++;
}
}

if(couta>count){
    printf("%d",x);

}
else if(count>couta){
    y=count-couta;
    printf("%d",x-y-1);
}
else if(couta==count){
    printf("%d",x-1);
}

return 0;
}


#include <stdio.h>

int main()
{
    long long n, k, d, a, b, c;
    scanf("%lld %lld", &n, &k);
    d = n/2;
    a = d/(k+1);
    b = a*k;
    c = n-a-b;

    printf("%lld %lld %lld\n",a, b, c);
    return 0;
}


#include<stdio.h>
int main()
{
    char myarray[1000];
    scanf("%s",&myarray);
    int i,cnt=0,j,k,l,len=0;
    len=strlen(myarray);
    for(i=0; i<len; i++)
    {
        if(myarray[i]=='Q')
        {
            for(j=i+1; j<len; j++)
            {
                if(myarray[j]=='A')
                {
                    for(l=j+1; l<len; l++)
                    {
                        if(myarray[l]=='Q')
                        {
                            cnt++;
                        }
                    }
                }
            }
        }
    }
    printf("%d",cnt);
    return 0;
}


/* Sachin Chandani */

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

#define INF INT_MAX
#define rep(i,a,b) for(i=a;i<=b;i++)
#define inp(x) scanf("%d",&x)
int min(int a,int b);
int max(int a,int b);
int cmp(const void * a,const void *b);

int main()
{
	float n,k;
	float a[1000];
	float total=0.0;
	int cnt=0;
	scanf("%f%f",&n,&k);
	for(int i=1;i<=n;i++) {scanf("%f",&a[i]);total+=a[i];}
	while(1)
	{
		if(k-(total/n)>0.5000000) {total+=k;n++;cnt++;}
		else {
			printf("%d\n",cnt);
			return 0;
		}
	}

//	qsort( , ,sizeof(int),cmp);
	return 0;
}
int min(int a,int b)
{
	return (a>b?b:a);
}

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

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


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(void)
{
	long int n;
	scanf("%ld",&n);
	if(n<=3)
	printf("0");
	else
	{
		if(n%2==0)
		{
	n=n/2;
	if(n%2==0)
	printf("%d",(n-2)/2);
	else
	printf("%d",(n-1)/2);
}
else
printf("0");
}

}


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

int good(int p, int s) {
	int i, j;

	i = (s / 50) % 475;
	for (j = 0; j < 25; j++) {
		i = (i * 96 + 42) % 475;
		if (26 + i == p)
			return 1;
	}
	return 0;
}

int main() {
	int p, x, y, z;

	scanf("%d%d%d", &p, &x, &y);
	for (z = x; z >= y; z -= 50)
		if (good(p, z)) {
			printf("0\n");
			return 0;
		}
	for (z = x; ; z += 50)
		if (good(p, z)) {
			printf("%d\n", (z - x + 50) / 100);
			return 0;
		}
	return 0;
}


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

int main()
{
    int n;
    scanf("%d",&n);
    int a[110]={0};
    int i;
    for(i=1;;i++)
    {
        if(n==1) {break;}
        int yushu,deshu;
        yushu=n%2;
        n=n/2;
        a[i]=yushu;
        if(n==1) {i++;break;}
    }
    printf("%d",i);
    i--;
    for(;i>=0;i--)
        if(a[i]) printf(" %d",i);
    printf("\n");
}


#include<stdio.h>
int main() {
      long long int n,k;

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

      if (k <= (n + 1) / 2)
    {
        printf("%lld",k * 2 - 1 );
    }
    else
    {
       printf("%lld",(k - (n + 1) / 2) * 2 );
    }

}


#include<stdio.h>

int main(void){
  int x,y,z,x0,y0,z0;
  int a[6],*p=a-1;
  int i,j,k,num=0;

  scanf("%d%d%d",&x,&y,&z);
  scanf("%d%d%d",&x0,&y0,&z0);
  for(i=1;i<=6;i++) scanf("%d",p+i);

  if(y<0) num+=p[1];
  else if(y>y0) num+=p[2];

  if(z<0) num+=p[3];
  else if(z>z0) num+=p[4];

  if(x<0) num+=p[5];
  else if(x>x0) num+=p[6];

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


#include <stdio.h>
int main()
{
    long long int n;
    scanf("%lld", &n);
    n = n+1;
    if(n%2==0||n-1==0)
    printf("%lld",n/2);
    else
    printf("%lld",n);
}


#include<stdio.h>

long remove_zeros(long num) {
    return num % 10 == 0 ? remove_zeros(num / 10) : num;
}

int solve(long num) {
    if(num < 10)
        return 9;

    return 10 - (num % 10) + solve(remove_zeros(num / 10 + 1));
}

int main() {
    long num;

    scanf("%ld", &num);
    printf("%d\n", solve(num));

    return 0;
}


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

char str[256], used[256];
int l, k;

int main()
{
    int i;
	scanf("%d %s", &k, str);
	l = strlen(str);
	for(i=0; i<l; ++i) {
		if (str[i]!='?') {
			int a = l-1-i;
			if (str[a]=='?') str[a]=str[i];
			if (str[a]!=str[i]) {
				printf("IMPOSSIBLE");
				return 0;
			}
		}
	}
	for(i=0; i<l; ++i) used[(int)str[i]] = 1;
	int c = 'a' + (k-1);
	for(i=(l+0)/2; i>=0; --i) {
		while(c>='a' && used[c]) --c;
		if (str[i]!='?') continue;
		int a = l-1-i;
		if (c>='a') {
			str[a] = str[i] = c--;
		} else {
			str[a] = str[i] = 'a';
		}
	}
	while(c>='a' && used[c]) --c;
	if (c>='a') {
		printf("IMPOSSIBLE");
		return 0;
	}
	printf("%s", str);
}


#include <stdio.h>
#include <stdlib.h>
int buy[30],sell[30];
int main()
{
    int n,m,r,i,min=1001,max=0;
    scanf("%d %d %d",&n,&m,&r);
    for(i=0;i< n;i++)//n´ÎÂò
    {
        scanf("%d",&buy[i]);
        if(buy[i]<min)
        {
            min=buy[i];
        }
    }
    for(i=0;i<m;i++)//m´ÎÂò
    {
        scanf("%d",&sell[i]);
        if(sell[i]>max)
        {
            max=sell[i];
        }
    }
    if(min>=max)
    {
        printf("%d",r);
    }
    else
    {
        printf("%d",r/min*max+r%min);
    }
    return 0;
}


#include<stdio.h>
typedef struct abc
{
	int a;
	int b;
}abc;

abc ar[8];

static int compare(const void *i1,const void *i2)
{
	        const abc *p1=(const abc *)i1;
		const abc *p2=(const abc *)i2;
		return (p1->a-p2->a);
}

int main()
{
	int x,y,z,min,max;

	for(x=0;x<8;x++)
	{
		scanf("%d %d",&ar[x].a,&ar[x].b);
	}
        qsort(&ar[0],8,sizeof(abc),compare);

	if(ar[0].a != ar[1].a || ar[0].a != ar[2].a)
		printf("ugly\n");
	else if(ar[5].a != ar[6].a || ar[5].a != ar[7].a)
		printf("ugly\n");
	else if(ar[3].a != ar[4].a)
		printf("ugly\n");
	else if(ar[0].a == ar[7].a)
		printf("ugly\n");
	else if(ar[0].a == ar[3].a)
		printf("ugly\n");
	else
	{
		x=ar[0].b;y=ar[1].b;z=ar[2].b;
		if(x==y || x==z)
			printf("ugly\n");
		else
		{
			min=10000000;max=-1;
			for(x=5;x<8;x++)
			{
				if(ar[x].b<min)
					min=ar[x].b;
				if(ar[x].b>max)
					max=ar[x].b;
				for(y=0;y<=2;y++)
				{
					if(ar[x].b==ar[y].b)
						break;
				}
				if(y==3)
					break;
			}
			if(y==3)
				printf("ugly\n");
			else
			{
				x=ar[5].b;y=ar[6].b;z=ar[7].b;
				if(x==y || x==z)
					printf("ugly\n");
				else if(!(ar[3].b == min || ar[3].b ==max))
					printf("ugly\n");
				else if(!(ar[4].b == min || ar[4].b ==max))
					printf("ugly\n");
				else if(ar[3].b == ar[4].b)
					printf("ugly\n");
				else
					printf("respectable\n");
			}
		}
	}
	return 0;
}


#include<stdio.h>
int main()
{
	long long int a,b;
	scanf("%lld %lld",&a,&b);
	while((a!=0)&&(b!=0))
	{
		if(a>=2*b)
		{
			a=a%(2*b);
		}
		else if(b>=2*a)
		{
			b=b%(2*a);
		}
		else
		{
			break;
		}
	}
	printf("%lld %lld",a,b);
	return 0;
}


#include <stdio.h>

int main()
{
    long long int Ax,Ay,Bx,By,Cx,Cy,ABx,ABy,BCx,BCy,temp;
    scanf("%lld %lld %lld %lld %lld %lld",&Ax,&Ay,&Bx,&By,&Cx,&Cy);

    ABx=Bx-Ax;
    ABy=By-Ay;
    BCx=Cx-Bx;
    BCy=Cy-By;

    temp=ABx*BCy-ABy*BCx;

    if(temp==0)
        printf("TOWARDS\n");
    else if(temp<0)
        printf("RIGHT\n");
    else
        printf("LEFT\n");

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAXN 210

int main ()
{
    static char data[MAXN];
    static int a[MAXN][MAXN];
    memset(a,0,sizeof(a));
    scanf("%s",data);
    int N = strlen(data);
    int x = 105;
    int y = 105;
    a[x][y] = 1;
    int i;
    for (i = 2; i <= (N+1); i++)
    {
        int nx = x;
        int ny = y;
        if (data[i-2] == 'L') nx--;
        else if (data[i-2] == 'R') nx++;
        else if (data[i-2] == 'U') ny++;
        else ny--;

        if ((a[nx-1][ny] > 0) && (a[nx-1][ny] < (i-1)))
        {
            printf("BUG\n");
            return 0;
        }
        if ((a[nx+1][ny] > 0) && (a[nx+1][ny] < (i-1)))
        {
            printf("BUG\n");
            return 0;
        }
        if ((a[nx][ny-1] > 0) && (a[nx][ny-1] < (i-1)))
        {
            printf("BUG\n");
            return 0;
        }
        if ((a[nx][ny+1] > 0) && (a[nx][ny+1] < (i-1)))
        {
            printf("BUG\n");
            return 0;
        }
        if (a[nx][ny] > 0)
        {
            printf("BUG\n");
            return 0;
        }

        a[nx][ny] = i;
        x = nx;
        y = ny;
    }
    printf("OK\n");
    return 0;
}


#include<stdio.h>
int main()
{
	int n,i=0,c=0;
	char s[60];
	long long int j=0;
	scanf("%d",&n);
	scanf("%s",s);
	while(s[i]!='\0')
		j=j*10+(int)(s[i++])-48;
	while(j>0)
	{
		if(j%2==0)
		c++;
		else
			break;
		j>>=1;
	}
	printf("%d\n",c+1);
	return 0;
}


#include<stdio.h>
int min2(int a,int b)
{
    if(a<b)
        return a;
    else
        return b;
}
int min(int x,int y,int z)
{
    int c = 0;
    while (x && y && z) {
        x--;
        y--;
        z--;
        c++;
    }
    return c;
}
int main()
{
    int a,b,c,d,e,f,m;
    long long int price=0;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    if(e>f)
    {
        if(a<d)
        {
            price=a*e;
            d-=a;
            m=min(b,c,d);
            price+=m*f;

        }
        else
        {
            price=e*d;
            d=0;
        }
    }
    else
    {
        m=min(b,c,d);
        price=m*f;
        d-=m;
        if(a>d)
            price+=d*e;
        else
            price+=a*e;
    }

    printf("%lld\n",price);
}


#include <stdio.h>

int gcd(int a, int b)
{
	if(b == 0)
	{
		return a;
	}

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

int main()
{
	int a,b,c,q = 0;

	scanf("%d %d %d",&a,&b,&c);

	int lcm = a * b;

	int x = gcd(a,b);

	lcm /= x;

	c /= lcm;

	printf("%d\n",c);

	return 0;
}


#include<stdio.h>
#include<string.h>
int main() {
	char str[100];
	scanf("%s", str);
	int n, b = 0, c = 0, i, j;
	n = strlen(str);
	for(i = 0; i < n; ) {
		b = 1;
		for( j = i + 1; j < n; j++)
			if(str[i] == str[j])
				b++;
			else
				break;
		if(b % 2 != 0) {
			i = i + b;
			continue;
		}
		else {
			c++;
			i = i + b;
		}
	}
	printf("%d", c);
	return 0;
}


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

int main() {
	long long xa, ya, xb, yb, xc, yc;

	scanf("%lld%lld%lld%lld%lld%lld", &xa, &ya, &xb, &yb, &xc, &yc);
	printf((xa - xb) * (xa - xb) + (ya - yb) * (ya - yb) == (xc - xb) * (xc - xb) + (yc - yb) * (yc - yb) && (xb - xa) * (yc - yb) != (yb - ya) * (xc - xb) ? "Yes\n" : "No\n");
	return 0;
}


#include <stdio.h>
int c[26],i;
void reset()
{
	for(i=0;i<26;i++)
		c[i]=0;
}
int main()
{
	int num,i,count=0,max=0;
	scanf("%d",&num);
	char a[num+1];
	scanf("%s",a);

	reset();
	for(i=0;i<num;i++){
		if(a[i]>='A' && a[i]<='Z'){
			count=0;
			reset();
		}
		else if(c[a[i]-'a']==0){
			c[a[i]-'a']++;
			count++;
		}
		if(count>max){
			max=count;
		}
	}
	printf("%d\n",max);
	return 0;
}


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

int main(int argc, char **argv)
{
	int x1,y1,x2,y2,x,y;
	scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x,&y);
	int rep1=abs(x2-x1)/x, rep2=abs(y2-y1)/y;
	if(abs(x2-x1)%x==0&&abs(y2-y1)%y==0&&rep1%2==rep2%2)
        printf("YES\n");
    else
        printf("NO\n");
	return 0;
}


#include<stdio.h>
long long int mod=1000000007;
long long int modpowfast(long long int b,long long int e)
{
	long long int ans=1;
	while(e>0)
	{
		if(e&1)
			ans=(ans*b)%mod;
		b=(b*b)%mod;
		e=e>>1;
	}
	return ans;
}
int main()
{
	long long int p,k,m,x;
	scanf("%lld %lld",&p,&k);
	if(k==0)
	{
		printf("%lld\n",modpowfast(p,p-1));
	}
	else if(k==1)
	{
		printf("%lld\n",modpowfast(p,p));
	}
	else
	{
		x=k;
		for(m=1;x!=1;m++)
		{
			x=(x*k)%p;
		}
		printf("%lld\n",modpowfast(p,(p-1)/m));
	}
	return 0;
}


/*
   Harrit Lamster (s1552295)
   harrit.lamster@gmail.com
   AADS '17-'18, 2018-02-18
   Assignment 2, TABLE
*/

#include <stdio.h>
#define DEBUG 0
#if DEBUG
  #include <assert.h>
#endif

//0.130s

typedef long long ll;

ll min(ll x, ll y) {
  return x < y ? x : y;
}

void swap(ll *xp, ll *yp) {
  ll h = *xp;
  *xp = *yp;
  *yp = h;
}

ll lessEqualInTable(int n, int m, ll x) {
  ll result = 0;
  ll rightmostFullColumn = min(x, x/m);
  result += rightmostFullColumn * min(x, m);
  ll rightmostColumn = min(x, n);
  ll rightmostMoreThanOneColumn = min(x / 2, n);
  result += (rightmostColumn - rightmostMoreThanOneColumn);
  for (ll column = rightmostFullColumn + 1; column <= rightmostMoreThanOneColumn; column++)
    result += x / column;
  return result;
}

ll findKthInList(ll n, ll m, ll k) {
  if (n > m)
    swap(&n, &m);
  if (k == 1)
    return 1;
  ll l = 1, r = n*m, mid;
  while (r - l > 1) {
    mid = (l + r) / 2;
    if (lessEqualInTable(n, m, mid) >= k)
      r = mid;
    else
      l = mid;
  }
  return l + 1;
}

#if DEBUG
void assertions() {
  assert(findKthInList(10, 10, 98) == 90);
  assert(findKthInList(10, 10, 97) == 81);
  assert(findKthInList(4, 7, 4) == 3);
  assert(findKthInList(1, 1, 1) == 1);
  assert(findKthInList(100000, 100000, 10000000000) == 10000000000);
  assert(findKthInList(100000, 100000, 1) == 1);
  assert(findKthInList(100000, 100000, 2) == 2);
  assert(findKthInList(100000, 100000, 3) == 2);
  assert(findKthInList(100000, 100000, 4) == 3);
  assert(findKthInList(100000, 100000, 5) == 3);
  assert(findKthInList(1, 5, 2) == 2);
  assert(findKthInList(5, 1, 2) == 2);
  printf("assertions OK\n");
}
#endif

int main() {
  ll n, m, k;
  #if DEBUG
    assertions();
  #endif
  scanf("%lld %lld %lld", &n, &m, &k);
  printf("%lld\n", findKthInList(n, m, k));
  return 0;
}


#include<stdio.h>
#include<stdbool.h>
bool is_leap_year(int year);
int count_year(int year);
int main() {
	int t;
	int year, same_year;

	scanf("%d", &year);
		printf("%d\n", count_year(year));
}

bool is_leap_year(int year) {
	if (year % 400 == 0)
		return true;

	else if ((year % 4 == 0) && (year % 100 != 0))
		return true;

	else
		return false;
}

int count_year(int year) {
	int count = 0;

	if (is_leap_year(year)) {
		do {
			if (is_leap_year(year))
				count += 2;
			else
				count += 1;
			year++;
		} while (((count % 7 != 0) || (!is_leap_year(year)))) ;

	}

	else {
		do {
			if (is_leap_year(year))
				count += 2;
			else
				count += 1;
			year++;

		} while ((count % 7 != 0)|| (is_leap_year(year)));
	}

	return year;

}


#include<stdio.h>
int main()
{
    int n,k,x,y,s;
    scanf("%d %d",&n,&k);
    x=n/k;
    y=x+1;
    s=y*k;
    printf("%d",s);
    return 0;

}


#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    char s[101];
    int ar[n],fsum=0,g=0;
    scanf("%s",s);
    for(int i=0;i<n;i++)
    ar[i]=s[i]-'0';
    for(int i=0;i<n-1;i++)
    {
    fsum+=ar[i];
    int j=i+1,tsum=0,f=0;
    while(j<n)
    {
    tsum+=ar[j++];
    if(tsum==fsum)
    {
    tsum=0;
    f=2;
    }
    else if(tsum>fsum)
    {
    f=1;
    break;
    }
    }
    if(f==2&&j==n&&tsum==0)
    {
    g=1;
    break;
    }
    }
    if(g==1)
    printf("YES");
    else
    printf("NO");
    return 0;
}


#include <stdio.h>

int main(void) {
	// your code goes here
	int i,j;
	scanf("%d%d",&i,&j);

	if(i==0&&j==0)
	{
		printf("NO");

}
else
{
	if((i-j)==1||(j-i)==1||i==j)
	{

		printf("YES");
	}
else
{
	printf("NO");
	}
}
	return 0;

}


#include<stdio.h>
int main(void)
{
	unsigned long n,m,i,c;
	scanf("%lu",&n);
	for(i=1;i*i<n;i++){

	}
	if(i*(i-1)>=n)
	  {
		m=2*i-1;
      }
	else m=2*i;
	printf("%lu\n",m);
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()
{
    int n,i,j=0;
    scanf("%d", &n);
    int k[n];
    for(i=0;i<n;i++)
    {
        scanf("%d", &k[i]);

    }
    for(i=0;i<n;i++)
    {
        j+=i*k[i];
    }
    printf("%d", j*4);
    return 0;

}


#include <stdio.h>
#include <stdlib.h>
int main(){
        long int a,b,c;

        scanf("%ld",&a);
        scanf("%ld",&b);
        scanf("%ld",&c);
        a = abs(a);
        b = abs (b);
        if(c==(a+b)){
           printf("YES");
        }
        else if(c>(a+b)&&((a+b)-c)%2==0){
           printf("YES");
        }
        else {
           printf("NO");
        }

    return 0;
}


#include<stdio.h>
int main(){
	long long int a,b,c,y,q,p=1000000007,res=1;

	scanf("%lld%lld",&a,&b);

	y=b;
	c=2;
         while(y>0)
	 {
		 if(y%2!=0)
			 res=(res*c)%p;
		 y=y>>1;
		 c=(c*c)%p;
	 }
	 q=(res%p+(p-1))%p;

	 y=a;
	 c=q;
	 res=1;
	  while(y>0)
         {
                 if(y%2!=0)
                         res=(res*c)%p;
                 y=y>>1;
                 c=(c*c)%p;
         }
         printf("%lld\n",res);
	 return 0;
}


#include <stdio.h>
#include <string.h>
enum { BIG = 1000000007 };

int n;
char s[240];
int slen;
int dp[201][101];
int next[201][2];
int fail[201];

void nextstep(int eo) {
    int i, j;
    for (i = 0; i <= slen; i++) {
        int lp = next[i][0];
        int rp = next[i][1];
        for (j = eo; j <= n; j+=2) {
            int now = dp[i][j];
            if (j < n) {
                int add = dp[lp][j+1] + now;
                dp[lp][j+1] = add < BIG ? add : add - BIG;
            }
            if (j > 0) {
                int add = dp[rp][j-1] + now;
                dp[rp][j-1] = add < BIG ? add : add - BIG;
            }
        }
    }
    for (i = 0; i <= slen; i++) {
        for (j = eo; j <= n; j+=2) {
            dp[i][j] = 0;
        }
    }
    /*for (i=0;i<=slen;i++){
        for (j=0;j<=n;j++){
            printf("%3d,",dp[i][j]);
        }
        puts("");
    }
    puts("");*/
}

int main() {
    scanf("%d", &n);
    scanf(" %202s", s);
    slen = strlen(s);
    int i;
    // build state machine
    fail[0] = fail[1] = 0;
    if (s[0] == '(') {
        next[0][0] = 1;
        next[0][1] = 0;
    }
    else {
        next[0][0] = 0;
        next[0][1] = 1;
    }
    for (i = 1; i < slen; i++) {
        int r = s[i] == ')';
        int f = fail[i];
        next[i][r] = i+1;
        next[i][1-r] = next[f][1-r];
        fail[i+1] = next[f][r];
    }
    next[slen][0] = next[slen][1] = slen;
    dp[0][0] = 1;
    for (i = 0; i < n; i++) {
        nextstep(0);
        nextstep(1);
    }
    printf("%d\n", dp[slen][0]);
    return 0;
}


//324B.c
#include<stdio.h>
#include<math.h>

long long int c=1000000007;

long long int power(long long int a,long long int b)
{
    if(b==0)
        return 1;
    else if(b==1)
        return a%c;
    else
        return ((power(a,b/2)%c)* (power(a,b-b/2)%c))%c;

}
int main()
{
   // int ans = power(2,3);
   // printf("%d",ans);

    long long int  n,number,total,extra,ans;
    scanf("%lld",&n);

    number=3*n;

    total=power(3,number);
    //printf("%lld\n",total);
    //calcualting when = 6

    extra=power(7,n);
        //printf("%lld\n",extra);
    ans=total-extra;
   // ans=abs(ans);
   if(ans>0)
    ans=(ans)%c;
    else
     ans=c+(ans%c);

    printf("%lld",ans);

    return 0;
}


	#include<stdio.h>

	int main(){
		int n;
		scanf("%d",&n);
		int r[n],b[n];
		int topr=0,topb=0,sayac=0;
		for(int i=0;i<n;i++){
			scanf("%d",&r[i]);
			topr+=r[i];
		}
		for(int i=0;i<n;i++){
			scanf("%d",&b[i]);
			topb+=b[i];
		}
		for(int i=0;i<n;i++){
			if(r[i]>b[i]){
				sayac++;
			}
		}
		if(sayac==0 ){
			puts("-1");
		}
		else if(topb==n)
			puts("-1");
		else{
			for(int i=1;i<=n;i++){
					if(((sayac*i)+(topr-sayac))>topb){
						printf("%d",i);
						break;
					}
			}
		}
		return 0;
	}


#include <stdio.h>
int main()
{
    long int k,n;
    scanf("%ld",&k);
    n=abs(k);
    long int sum=0, ans=0, p=1,diff;
    for(p = 1; sum < n; sum=sum+p, p++, ans++);

         diff = sum - n;
        if(n == 0)
        {
            printf("0");
        }
        else if(diff % 2 == 0)
        {
            printf("%ld\n", ans);
        }
        else if((diff + p) % 2 == 0)
        {
            printf("%ld\n", ans + 1);
        }
        else
        {
            printf("%ld\n", ans + 2);
        }

    return 0;
}


#include<stdio.h>
#include<string.h>
char s[220];
long n,len;
long check(long a)
{
    long i;
    for(i=1;i<=a-n;i++)
        if(s[len-i]!=s[len-i-a])
            return 0;
    return 1;
}
int main()
{
    long i,k,j,ans=0,key,max,min,temp=0;
    scanf("%s",s);
    len=strlen(s);
    scanf("%ld",&n);

    if(n>len)
        min=(len+n)/2;
    else min=n;

    max=(len+n)/2;
    for(i=0;i<len;i++)
        for(j=1;j*2+i<=len;j++)
            {   key=1;
                for(k=1;k<=j;k++)
                    if(s[i+k-1]!=s[i+k+j-1])
                    key=0;
                if(key==1)
                    if(j>temp)
                        temp=j;
            }

    for(i=max;(i>=min)&&(ans==0);i--)
        if(check(i)==1)
            ans=i;
    if(min>ans)
        ans=min;
    if(temp>ans)
        ans=temp;
    printf("%ld",2*ans);

return 0;
}


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

int len;

void cyclicShift(char str[])
{
	char temp = str[0];

	for(int i = 0; i < len; i++)
	{
		str[i] = str[i + 1];
	}

	str[len - 1] = temp;
}

int tot = 0;
char stack[51][51];

void isdistinct(char str[])
{
	for(int i = 0; i < tot; i++)
	{
		if(strcmp(str, stack[i]) == 0)
		{
			return;
		}
	}

	strcpy(stack[tot++], str);
}

int main(void)
{
	char str[51];
	scanf("%s", &str);

	len = strlen(str);

	for(int i = 0; i < len; i++)
	{
		isdistinct(str);
		cyclicShift(str);
	}

	printf("%d\n", tot);

	return 0;
}


#include<stdio.h>
int main()
{
    int n,x,y,r,m;
    scanf("%d %d %d",&n,&x,&y);
    if((y*n)%100==0)
    {
        r=((y*n)/100);
        if(r>x)
        printf("%d",r-x);
        else
        printf("%d",0);
    }
    else
    {
        r=(y*n)/100;
        m=r+1;
        if(m>x)
        printf("%d",m-x);
        else
            printf("%d",0);

    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int compare(const void *a,const void *b)
{
    return ( *(int*)a - *(int *)b );
}
int main()
{
    int n,i,s=0,p=0,j=0;
    scanf("%d",&n);
    int a[12];

    for(i=0;i<12;i++)
    scanf("%d",&a[i]);

    qsort(a,12,sizeof(int),compare);

   if(n!=0)
{    for(i=11;i>=0;i--)
    {

         s=s+a[i];
         if(s<n)
           p++;
         else
         { p++;
          j++;
           break;

         }
    }
    if(j==0)
    printf("-1");
    else
    printf("%d",p);
}
else
printf("0");

}


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

main(){

    int n,i,j,k,pom;

    scanf("%d",&n);

    int br = 0;

    for(i = 1; i <= n; i++){
        for(j = 1; j <= n; j++){
            k = i ^ j;
            if(i + j > k && i + k > j && k + j > i && i <= j && j <= k && k <= n){
                br++;
            }
        }
    }

    printf("%d",br);

}


#include <stdio.h>

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

	int i, temp, last = 0, last_loc, current_cycle = 0, max_cycle = 0;
	for(i = 0; i < n; i++) {
		scanf("%d", &temp);
		current_cycle = (temp + m - 1) / m;
		if(current_cycle >= max_cycle) {
			last_loc = i + 1;
			max_cycle = current_cycle;
		}
	}

	printf("%d\n", last_loc);

	return 0;
}


#include <stdio.h>
int main()
{
	int h,w,k;

	scanf("%d %d %d",&w,&h,&k) ;

	int sum = 0 ;

	while(k)
	{

		if (h == 1 && w == 1)
		    sum = sum + 1;
		if (h == 1 && w != 1)
		    sum = sum + w;
		if (h != 1 && w == 1)
		    sum = sum + h;
		if (h != 1 && w != 1)
		    sum = sum + (w*2 + h*2 - 4) ;

		h = h - 4 ;
		w = w - 4 ;

		k--;

	}
	printf("%d",sum);

	return 0;
}


#include<stdio.h>
int main()
{
    long long int c,a,n,m,b,d,e,f;
    scanf("%lld%lld%lld%lld",&n,&m,&a,&b);
    c=n%m;
    d=m-n%m;
    b=b*c;
    a=a*d;
    if(a>b)
        printf("%lld\n",b);
    else
        printf("%lld\n",a);
    return 0;
}


#include<stdio.h>
int main()
{
	int i,j,k,n,a,b,v;
	int temp,temp1,flag,count,cap,flag3=0;
	scanf("%d%d%d%d",&k,&a,&b,&v);
//	while(1)
//	{
		temp=b/(k-1);
		temp1=b%(k-1);
		cap=temp*v*k;
		count=0;
		if(cap>a)
		{
			flag3=1;
		//	cap=1;
			while(cap>=a)
			{
				cap=cap-(v*k);
				temp--;
			}
		}

		if(cap<a&&flag3==0)
		{
                        //count=0;
		      flag=1;
			cap=cap+v*(temp1+1);
			if(cap<a)
			{
			//	count=0;
				while(cap<a)
				{
					cap=cap+v;
					count++;
				}
			}
		}
		if(flag==1&&flag3==0)
		{
			printf("%d\n",temp+1+count);
		}
		else if(flag3==1)
			printf("%d\n",temp+1);
		else
			printf("%d\n",temp);
//	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
	int x,y,z,t1,t2,t3;
	scanf("%d%d%d%d%d%d",&x,&y,&z,&t1,&t2,&t3);
	if(3*t3+(abs(x-z)+abs(x-y))*t2>(abs(x-y))*t1)
	    printf("NO");
	else
	    printf("YES");
}


#include<stdio.h>
#include<string.h>
int main()
{
	long long i, j, k;
	long long n;
	long long arr[10000];
	char str[1000];
	scanf("%lld", &n);
	scanf("%s", str);
	long long len=strlen(str);
	long long maj_count=0,count=0,flag=0;
	k=0;
	for(i=0;str[i]!='\0';i++)
	{
		if(str[i]=='B')
			count++;
		if((str[i]=='W' &&  str[i-1]=='B') || (str[i]=='B' && i==len-1))
		{
			flag=1;
		//	printf("%c",str[i]);
			arr[k]=count;
			k++;
			count=0;
			maj_count++;
		}
	}

	printf("%lld\n",maj_count);
	for(i=0;i<k-1 && arr[i]!=0;i++)
		printf("%lld ",arr[i]);
	if(flag==1)
		printf("%lld\n",arr[k-1]);
//	printf("%lld\n",k);
	return 0;
}


#include <stdio.h>
int main ()
{
    long long n;
    scanf("%lld",&n);
    if(n%2==0)
    {
        printf("%lld\n",n/2);
        return 0;
    }
    for(long long i=2;(i*i)<=n;i++)
    {
        if(n%i==0)
        {
            int flag=0;
            for(long long j=2;j<i;j++)
            {
                if(i%j==0)
                {
                    flag=1;
                }
            }
            if(flag==0)
            {
                printf("%lld\n",((n-i)/2)+1);
                return 0;
            }
        }
    }
    printf("1\n");
    return 0;
}


#include <stdio.h>

int main() {
	int a, b, f, k, i, x, ans;

	scanf("%d%d%d%d", &a, &b, &f, &k);
	x = b;
	ans = 0;
	for (i = 0; i < k; i++)
		if (i % 2 == 0)
			if (x >= f && (i == k - 1 && x >= a) || x >= a + a - f)
				x -= a;
			else if (x >= f && b >= a - f)
				x = b - (a - f), ans++;
			else {
				printf("-1\n");
				return 0;
			}
		else
			if (x >= a - f && (i == k - 1 && x >= a) || x >= a + f)
				x -= a;
			else if (x >= a - f && b >= f)
				x = b - f, ans++;
			else {
				printf("-1\n");
				return 0;
			}
	printf("%d\n", ans);
	return 0;
}


#include<stdio.h>
typedef long long int ll;
int main()
{
  ll n;
  scanf("%lld",&n);
  if(n%2==0)
  {
  	/*ll mid = n/2,mid1= mid+1;
  	ll sum1=0,sum2=0,dif=0;
  	for(ll i=1;i<mid;i++)
  	{
  		if(i%2!=0)
  			sum1 = sum1+n;
  		else
  			sum2=sum2+n;
  	}
  	if(sum2-sum1==0)
  		dif = 1;
  	else
  		dif =0;
  	printf("%lld",dif);*/
    if(n%4==0)
      printf("0");
    else
      printf("1");
  }
  else
  {
  	if(n%4==3)
  		printf("0");
  	else
  		printf("1");
  }

  return 0;
}


#include <stdio.h>

int main() {
	long int x,y;
	scanf("%ld %ld",&x,&y);
	if(x==y)
	    printf("=");
	else if((x==2)&&(y==3))
	    printf("<");
	else if((x==3)&&(y==2))
	    printf(">");
	else if((x==2)&&(y==4))
	    printf("=");
	else if((x==4)&&(y==2))
	    printf("=");
	else if(x==1)
	    printf("<");
	else if(y==1)
	    printf(">");
	else if(x<y)
	    printf(">");
	else
	    printf("<");
	return 0;
}


#include <stdio.h>

int main(){
    int repaso,limite,paginas,inicio,aceleracion;
    int cant=0;
    scanf("%d %d %d %d %d",&paginas,&inicio,&limite,&aceleracion,&repaso);
    while(paginas>0){

        if(cant==0){
            paginas=paginas-inicio;

        }
        else{
            paginas=paginas-inicio+repaso;

        }
        if(limite > inicio+aceleracion)
            inicio=inicio+aceleracion;
        else
            inicio=limite;
        cant++;

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


#include<stdio.h>
int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
if(n<=a&&n<=b)
    printf("YES\n");
else
    printf("NO\n");
}


#include<stdio.h>

int small(int,int);
int big(int,int);

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	int maxn=n*2;
	int maxm=m*3;
	int count=0;

	while(small(maxn,maxm)/6-count)
	{
		if(maxn+2 < maxm+3)
			maxn+=2;
		else
			maxm+=3;
		count++;
	}

	printf("%d\n",big(maxn,maxm));
	return 0;
}

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

int big(int a,int b)
{
	if(a>b)
		return a;
	else
		return b;
}


#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#define N 50
int main(){
    char opcion1[]= {"http://"};
    char opcion2[]={"ftp://"};
    char opcion3[]={".ru"};
    char opcion4= '/';

    int i=0;
    int subindice=0;
    int j=0;
    int bandera=0;
    char direccion[N];

    scanf("%s",direccion);
    if(direccion[0]== 'h'){
        printf("%s",opcion1);
        i+=4;
    }
    else {
        i+=3;
        printf("%s",opcion2);
    }
    while(direccion[i]!='\0'){
        if(direccion[i]=='r' && direccion[i+1]=='u' && bandera==1){
            printf("%s",opcion3);
            i+=2;
            if(direccion[i]!='\0'){
                printf("%c",opcion4);
                for(subindice=i; subindice<(strlen(direccion)); subindice++){
                    printf("%c",direccion[subindice]);
                }
                i=strlen(direccion);
            }
        }
        else if (bandera==0){
            if(direccion[i]=='r' && direccion[i+1]=='u'){
                printf("%c",direccion[i]);
                i++;
                printf("%c",direccion[i]);
                i++;
                bandera=1;
            }
            for(subindice=i; subindice<strlen(direccion); subindice++){
                if(direccion[i]== 'r' && direccion[i+1]=='u'){
                    i=subindice;
                    bandera=1;
                    break;
                }
                else {
                    printf("%c",direccion[subindice]);
                    i++;
                }
            }
        }
    }
    return 0;
}


//Date : 27 - 12 - 17

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<float.h>
#include<math.h>
#include<inttypes.h>
#include<assert.h>
#include<ctype.h>
#include<limits.h>
#include<time.h>
#define ll long long
#define For(i,n)	for(i=0;i<n;i++)
#define rep(i ,a ,b)	for(i=(a);i<=(b);i++)
#define mset(a ,value)	memset(a ,value ,sizeof(a))
#define s(a)	scanf("%d" ,&a);
#define ls(a)	scanf("%ld" ,&a)
#define reg(i)	register int i
#define infinite INT_MAX
#define MAX 100005
#define NIL -1
int min(int a,int b){	return (a < b ? a : b)	;}
int max(int a,int b){	return (a > b ? a : b)	;}
ll gcd(ll a,ll b){
	if(a==0)	return b;
	return gcd(b%a ,a);
}
/*
char a[11] ,b[11] ,ans[23];
int main(){
	scanf("%s %s" ,a ,b);
	int n = strlen(a) ,m = strlen(b) ,i;
//puts(a);	puts(b);
	ans[0] = a[0];
	i = 1;
	while(i < n){
		if(a[i] >= b[0])	break;
		ans[i] = a[i];
		i++;
	}
	ans[i++] = b[0];
	ans[i++] = '\0';
	printf("%s" ,ans);
	return 0;
}
*/

int main(){
	int n ,i ,l;
	s(n);
	ll ans = 0;
	for(l = 1 ; l <= n ; l++)
		ans += 1 + min(l - 1 ,n - l);
	printf("%I64d" ,ans);
	return 0;
}
/*
const int MOD = 1e9+7;
int n;
ll dt[5010][5010];
ll ans;
int main(){
    char c, prev = 0;
    scanf("%d", &n);
    dt[0][0] = 1;
    for (int i = 1; i <= n; i++){
        scanf(" %c", &c);
        if (prev == 'f')
            for (int j = 0; j < n; j++)	dt[i][j] = dt[i-1][j-1];
        else
            for (int j = n-1; j >= 0; j--)	dt[i][j] = (dt[i][j+1]+dt[i-1][j])%MOD;
        prev = c;
    }
    for (int i = 0; i < n; i++)
        ans = (ans+dt[n][i])%MOD;
    printf("%I64d\n", ans);
}*/


#include<stdio.h>
int m(int a,int b)
{
	int ma=(a>b?a:b);
    return ma;
}
int main()
{
	int n;
	scanf("%d",&n);
	int i,a[n],max,min,ans=0;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		if(a[i]==n)
			max=i;
		else if(a[i]==1)
			min=i;
	}
	ans=m(ans,n-min);
	ans=m(ans,n-max);
	ans=m(ans,max-1);
	ans=m(ans,min-1);
	printf("%d",ans);
	return 0;
}


#include <stdio.h>
long long x,bx,y,by,a[100],b[100],m,n,t,k,i;

int main() {
    t=1;k=1;
    scanf("%lld %lld",&x,&bx);
    for (i=1;i<=x;i++)
    scanf("%lld",&a[i]);
    scanf("%lld %lld",&y,&by);
    for (i=1;i<=y;i++)
    scanf("%lld",&b[i]);
    for (i=x;i>=1;i--)
    {

    m=m+a[i]*t;
    t=t*bx;
    }
    for (i=y;i>=1;i--)
    {

    n=n+b[i]*k;
    k=k*by;
    }

    if (m==n) { printf("=");}
    else if (m>n) printf(">");
    else if(m<n) printf("<");

}


#include<stdio.h>
int main(){
int n,m,a,b,i,count,count1=0,count2,count3;
scanf("%d %d %d %d",&n,&m,&a,&b);
count=n*a;
if(n%m==0){count3=(n/m)*b;}
else{count3=((n/m)+1)*b;}
while(n>=0){
    if(n>m){
        n=n-m;
        count1=count1+b;
    }
    else{
        count2=count1+n*a;
        count1=count1+b;
        n=n-n;
    }
    if(n==0){break;}
}

if(count<=count1&&count<=count2&&count<=count3){
    printf("%d",count);
}
else if(count1<count&&count1<=count2&&count1<=count3){
    printf("%d",count1);
}
else if(count2<count&&count2<count1&&count2<=count3){
    printf("%d",count2);
}
else if(count3<count&&count3<count1&&count3<count2){
    printf("%d",count3);
}
}


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

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

    char s[n + 1];
    scanf("%s", s);

    int cnt = 0;
    bool maxN = true, res = false;
    for(int i = 0; i < n; ++i) {
        cnt = (s[i] == 'N' ? cnt + 1 : 0);
        maxN &= cnt <= k;
    }

    if (maxN) {
        for (int i = 0; i + k <= n; ++i) {
            bool f = true;
            for (int j = i; j < i + k; ++j)
                f &= s[j] != 'Y';

            if (i != 0)
                f &= s[i - 1] != 'N';
            if (i + k != n)
                f &= s[i + k] != 'N';

            res |= f;
        }
    }

    puts(res ? "YES" : "NO");
}


#include<stdio.h>
int main()
{
    int i,j,t,a,b,page, sum =0;
    int day[8];

    scanf ("%d",&page);

    for(i=1; i<8; i++){
        scanf("%d", &day[i]);
    }

    j = 0;
    while(1){
        j++;
        sum = sum + day[j];
        if(sum >= page){
            printf("%d\n", j);
            break;
        }
        else if(j==7){
            j = 0;
        }

    }
}


#include <stdio.h>
#include <limits.h>

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for((i) = 0; (i) < (n); (i)++)
#define REP1(i, n) for((i) = 1; (i) <= (n); (i)++)

#define SIZE 1000002

static int s[SIZE], p[SIZE], np, min;

static void sieve(void)
{
  int i, j;

  for (i = 2; i < SIZE; i++) {
    if (s[i] == 0) {
      p[np++] = i;

      for (j = 2; i * j < SIZE; j++) {
        s[i * j] = 1;
      }
    }
  }
}

#define MAX(x, y) ((x) > (y) ? (x) : (y))

static void solve(int x, int l)
{
  int i, d, lf = -1, ox = x;

  if (x < min) {
    min = x;
  }

  if (l == 0) {
    return;
  }

  for (i = 0; p[i] * p[i] <= x; i++) {
    if (ox % p[i] == 0) {
      lf = MAX(lf, p[i]);
      while (ox % p[i] == 0)
        ox /= p[i];
    }
  }
  if (ox > 1 && ox != x)
    lf = MAX(lf, ox);

  if (lf == -1) {
    return;
  }

  if (l == 1) {
    x = x - lf + 1;
    if(x < min)
      min = x;
    return;
  }

  for (d = x - lf + 1; d < lf * (x / lf); d++) {
    solve(d, l - 1);
  }
}

int main(void)
{
  int x2;

  s[0] = s[1] = 1;
  sieve();
  min = INT_MAX;

  scanf("%d", &x2);
  solve(x2, 2);
  printf("%d", min);

  return 0;
}


#include<stdio.h>
int main()
{
int n,i,j,p,flag=0,cnt=0;
char A[105];
scanf("%d",&n);
scanf("%s",A);
for(i=1;i<n;i++)
{
flag=0;
if(A[i]==A[0])
{
p=1;
for(j=i+1;p<i;j++)
{
if(j==n)
{
flag=1;
break;
}
else if(A[j]!=A[p])
{
flag=1;
break;
}
else
{
p++;
}
}
if(flag==0 && p>cnt)
{
cnt=p;
}
}
}
if(cnt!=0)
{
 printf("%d\n",(n-cnt)+1);
}
else
{
printf("%d\n",n);
}
}


#include <stdio.h>

int main(){
	int n;
	scanf("%d", &n);
	long long int ans=2;
	for(long long int i=0; i<n-1; ++i){
		ans*=(i+1);
	}
	ans/=n;
	printf("%lld\n", ans);
	return 0;
}


#include<stdio.h>

int main(){
	int dim;
	scanf("%d",&dim);
	int v[dim];

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

	if(dim%2==0){
		puts("No");
	}else{
		if(v[0]%2==0 || v[dim-1]%2==0){
			puts("No");
		}else{
			puts("Yes");

		}
	}

	return 0;
}


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


#include<stdio.h>
int main()
{
    long long int n,m,r;
    long long int max,min,d;
    scanf("%lld%lld",&n,&m);
    max=((n-m)*(n-m+1))/2;
    d=n/m;
    r=n%m;
    min=(m-r)*(((d)*(d-1))/2LL)+r*(((d+1)*(d))/2);
    printf("%lld %lld",min,max);
    return 0;
}


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

int arr[105];
int chk[105];
int main(void)

{
	int i, j, k;
	int tmp;
	int N;

	scanf("%d", &N);

	for (i = 1; i <= N; ++i){
		scanf("%d", &arr[i]);
		tmp = arr[i];
		++chk[arr[i]];
	}
	if (chk[tmp] == N){
		printf("0");
		return 0;
	}
	else{
		for (i = 1; i <= 100; ++i){
			memset(chk, 0, sizeof(chk));
			for (j = 1; j <= N; ++j){
				if (arr[j] - i >= 0){
					++chk[arr[j] - i];
				}
				if (arr[j] + i <= 100){
					++chk[arr[j] + i];
				}
				++chk[arr[j]];
			}

			for (j = 0; j <= 100; ++j){
				if (chk[j] == N){
					printf("%d", i);
					return 0;
				}
			}

		}
		printf("-1");
		return 0;
	}
}


#include<stdio.h>

int main()
{
    int x, y;
    scanf ("%d %d", &x, &y);
    if (x == y) {
        printf ("No\n");
        return 0;
    }
    else if (x < y) {
        if (y - x == 1) {
            printf ("Yes\n");
            return 0;
        }
        else {
            printf ("No\n");
            return 0;
        }
    }
    else {
        if (y == 0 || y == 1) {
            printf ("No\n");
            return 0;
        }
        y = y - 1;
        x = x - y;
        if (x & 1) {
            printf ("No\n");
            return 0;
        }
        else {
            printf ("Yes\n");
            return 0;
        }
    }
    return 0;
}


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

int main(int argc, char **argv)
{
	char codigo[81];

	scanf("%s",codigo);
	int i;
	char matriz[10][11];
	for(i = 0 ; i < 10 ; i++){
		scanf("%s",&matriz[i][0]);

	}

	int j ;
	char *p = codigo;

	for( i = 0 ; i < 9; i++){

			for( j = 0 ;  j < 10 ; j++){
					if(strncmp(p,matriz[j],10) == 0){
							printf("%d",j);
							break;

					}

			}
			p= p + 10;

	}
	return 0;
}


#include<stdio.h>
int main ()
{
    int x,y,z,i,j,a;
    int sum=0,ck=0;
    int arr[1001];
    scanf("%d",&i);
    for(j=0;j<i;j++){
        scanf("%d",&arr[j]);
    }
    arr[j]=90;
    for(j=0;j<=i;j++){
        a=arr[j]-sum;
        if(a>15){
            printf("%d\n",sum+15);
            ck=1;
            break;
        }
        sum=arr[j];
    }
    if(ck==0){
        printf("%d\n",90);
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
int main()
{
    int T;
    scanf("%d",&T);
    for(int i=0;i<T;i++)
    {
        int n;
        scanf("%d",&n);
        long long sum=1;
        for(int j=0;j<n;j++)
        {
            sum*=2;
        }
        sum-=1;
        printf("%lld\n",sum);
    }
    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    long long int n,k;
    int s;
    scanf("%lld %lld",&n,&k);
    s=(n*2-1)/k+(n*5-1)/k+(n*8-1)/k+3;

    printf("%d",s);

}


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


#include<stdio.h>
#include<string.h>
int main()
{
	int n;
	char a[10];
	char b[10];
	scanf("%d",&n);
	scanf("%s",a);
	scanf("%s",b);
	int flag=0,i;

	if(b[0]=='m')
	{
		flag=1;
	}

	if(flag==1)
	{
		if(n<=29)
		{
			printf("%d",12);
		}
		else if(n==30)
		{
			printf("%d",11);
		}
		else
		{
			printf("%d",7);
		}
	}
	else
	{
		if(n==5||n==6)
		{
			printf("%d",53);
		}
		else
		{
			printf("%d",52);
		}
	}

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define LAST 1000000000000000001L
main()
{
	long long int year, yarr[4000];
	long long twop[66];
	long long p,pmax,a,b;
	int i,j,ind,count;
	p = 1;
	twop[0]=1;
	for (i=1; p<LAST; i++)
	{
		p = p*2;
		twop[i] = p;
	}
	pmax=i;
	ind=0;
	for (i=2; i< pmax; i++)
		for (j=i-1; j>0; j--)
			yarr[ind++] = twop[i]-1-twop[j-1];
	scanf("%lld %lld", &a, &b);
	count=0;
	for (i=0; i<ind; i++)
		if (a<= yarr[i] && b >= yarr[i]) count++;
	printf("%d\n",count);
	return 0;
}


#include<stdio.h>
int main()
{
    long long int N, M;
    scanf("%lld%lld", &N, &M);
    printf("%lld\n", (M!=1)?(M-1)*N:(N-1)*M);
    return 0;
}


#include<stdio.h>
int main()
{
    long long int n;
    scanf("%lld",&n);
    if(n>=0)
        printf("%lld\n",n);

    else
    {
        long long int a = n/10;
        long long int b = a/10 *10 + n%10;
        if(a>b)
            printf("%lld\n",a);
        else
            printf("%lld\n",b);
    }
    return 0;
}


#include <stdio.h>

int main()
{
	double l,r,x,y,k,i;
	scanf("%lf%lf%lf%lf%lf",&l,&r,&x,&y,&k);

	for(i= x; i<=y ; i++)
	{
		double val = 0;
		val = i*k;
		if(val>=l && val<=r)
		{
			printf("YES\n");
			return 0;
		}
	}
		printf("NO\n");
		return 0;
}


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

typedef struct {
    int len;
    char letter;
}nodes;

int main()
{
    int i=0,j=0,k=0,flag=0,flag2=2,q=0;
    nodes node[5];
    char stra[105],strb[105],strc[105],strd[105];
    scanf("%s",&stra);
    scanf("%s",&strb);
    scanf("%s",&strc);
    scanf("%s",&strd);
    node[0].len=strlen(stra)-2;
    node[0].letter='A';
    node[1].len=strlen(strb)-2;
    node[1].letter='B';
    node[2].len=strlen(strc)-2;
    node[2].letter='C';
    node[3].len=strlen(strd)-2;
    node[3].letter='D';
    //at least half shorter
    for(i=0;i<4;i++) {
        for(j=0;j<4;j++) {
            if(i==j) {k++;continue;}
            if(2*node[i].len<=node[j].len) k++;
        }
        if(k==4) {flag++;flag2=0;break;}
        else k=0;
    }
    k = 0 ;
    //at least twice longer
    for(q=0;q<4;q++) {
        for(j=0;j<4;j++) {
            if(q==j) {k++;continue;}
            if(node[q].len>=2*node[j].len) k++;
        }
        if(k==4) {flag++;flag2=1;break;}
        else k=0;
    }
    if(flag>1) printf("C");
    else if(flag2==0) printf("%c",node[i].letter);
    else if(flag2==1) printf("%c",node[q].letter);
    else {
        printf("C");
    }
}


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

int main()
{
    int k,a,b,x,y,m;
    scanf(" %d %d %d",&k,&a,&b);

    if((a<k && b<k) || (a<k && b%k!=0) || (b<k && a%k!=0)){
        printf("-1\n");
    }
    else{
        printf("%d\n",(a/k)+(b/k));
    }

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define N 9
//8!=P
#define P 50000
int record[P][N];
int nr=0;
int max=0;

/* function to swap array elements */

void swap (int p[], int i, int j) {
    int     t;
    t = p[i];
    p[i] = p[j];
    p[j] = t;
}
long long f(int p[],int n){
    int mins[N][N];
    int i,j;
    for(i=0;i<n;i++){
        mins[i][i]=p[i];
        for(j=i+1;j<n;j++){
            if(p[j]<mins[i][j-1]){
                mins[i][j]=p[j];
            }else{
                mins[i][j]=mins[i][j-1];
            }
        }
    }
    long long fp=0;
    for(i=0;i<n;i++){
        for(j=i;j<n;j++){
            fp+=(long long)mins[i][j];
        }
    }
    return fp;
}

/* recursive function to generate permutations */
void perm (int p[], int n, int i) {
    /* this function generates the permutations of the array
     * from element i to element n-1
     */
    int     j;
    /* if we are at the end of the array, we have one permutation
     * we can use (here we print it; you could as easily hand the
     * array off to some other function that uses it for something
     */
    if (i == n) {
        for (j=0; j<n; j++){
            record[nr][j]=p[j];
        }
        record[nr][n]=f(p,n);
        if(record[nr][n]>max)max=record[nr][n];
        nr++;
    } else
        /* recursively explore the permutations starting
         * at index i going through index n-1
         */
        for (j=i; j<n; j++) {

            /* try the array with i and j switched */

            swap (p, i, j);
            perm (p, n, i+1);

            /* swap them back the way they were */

            swap (p, i, j);
        }
}

/* little driver function to print perms of first 5 integers */

//如果是50，我们生成所有排列的时间就已经超时了！
int main() {
    //f(p)=sum i from 1 to n ( sum j from i to n (min(pi,pi+1,...,pj)))
    //i=1 sum j from 1 to n (min(p1,p2,...,pj)))
    //i=2 sum j from 2 to n (min(p2,p3,...,pj)))
    //i=3 sum j from 3 to n (min(p3,p4,...,pj)))
    //
    //i=n sum j from n to n (min(pn,...,pj)))
    //
    //i=1 (j=1 min(p1)
    //     j=2 min(p1,p2)
    //     j=n min(p1,p2,...,pn)
    //i=2 (j=2 min(p2)
    //     j=3 min(p2,p3)
    //     j=n min(p2,p3,...,pn)
    //i=3 (j=3 min(p3)
    //     j=4 min(p3,p4)
    //     j=n min(p3,p4,...,pn)
    //i=n (j=n min(pn))
    //有思路了！
    //min(p1) + min(p1,p2) + min(p1,p2,...,pn)
    //min(p2) + min(p2,p3) + min(p2,p3,...,pn)
    //min(p3) + min(p3,p4) + min(p3,p4,...,pn)
    //min(pn))

    int n,m;
    scanf("%d%d",&n,&m);
    int p[N];
    int i,j,k;
    for (i=0; i<n; i++)
        p[i] = i+1;
    perm (p, n, 0);
    for (i=0; i<nr-1; i++){
        int min=i;
        for (j=i+1; j<nr; j++){
            if(record[j][n]<record[min][n]){
                min=j;
            }else if(record[j][n]==record[min][n]){
                for(k=0;k<n;k++){
                    if(record[j][k]>record[min][k]){
                        break;
                    }else if(record[j][k]<record[min][k]){
                        min=j;
                        break;
                    }
                }
            }
        }
        int tmp[N];
        for (j=0; j<=n; j++){
            tmp[j]=record[min][j];
        }
        for (j=0; j<=n; j++){
            record[min][j]=record[i][j];
        }
        for (j=0; j<=n; j++){
            record[i][j]=tmp[j];
        }
    }
    //printf("max record\n");
    int mp[N];
    int count=0;
    for (i=0; i<nr; i++){
        if(record[i][n]==max){
            count++;
            if(count==m){
                for(j=0;j<=n;j++){
                    mp[j]=record[i][j];
                }
                break;
            }
        }
    }
    for (i=0; i<n; i++){
        printf(" %d",mp[i]);
    }
    printf("\n");

    /*8!=2*3*4*5*6*7*8
      int pro=1;
      for(i=2;i<=8;i++){
      pro*=i;
      printf("\n%d\n",pro);
      }
      */
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
main()
{
      int n;
      scanf("%d",&n);
      switch(n){
                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;
                case 20: printf("twenty"); break;
                case 21: printf("twenty-one"); break;
                case 22: printf("twenty-two"); break;
                case 23: printf("twenty-three"); break;
                case 24: printf("twenty-four"); break;
                case 25: printf("twenty-five"); break;
                case 26: printf("twenty-six"); break;
                case 27: printf("twenty-seven"); break;
                case 28: printf("twenty-eight"); break;
                case 29: printf("twenty-nine"); break;
                case 30: printf("thirty"); break;
                case 31: printf("thirty-one"); break;
                case 32: printf("thirty-two"); break;
                case 33: printf("thirty-three"); break;
                case 34: printf("thirty-four"); break;
                case 35: printf("thirty-five"); break;
                case 36: printf("thirty-six"); break;
                case 37: printf("thirty-seven"); break;
                case 38: printf("thirty-eight"); break;
                case 39: printf("thirty-nine"); break;
                case 40: printf("forty"); break;
                case 41: printf("forty-one"); break;
                case 42: printf("forty-two"); break;
                case 43: printf("forty-three"); break;
                case 44: printf("forty-four"); break;
                case 45: printf("forty-five"); break;
                case 46: printf("forty-six"); break;
                case 47: printf("forty-seven"); break;
                case 48: printf("forty-eight"); break;
                case 49: printf("forty-nine"); break;
                case 50: printf("fifty"); break;
                case 51: printf("fifty-one"); break;
                case 52: printf("fifty-two"); break;
                case 53: printf("fifty-three"); break;
                case 54: printf("fifty-four"); break;
                case 55: printf("fifty-five"); break;
                case 56: printf("fifty-six"); break;
                case 57: printf("fifty-seven"); break;
                case 58: printf("fifty-eight"); break;
                case 59: printf("fifty-nine"); break;
                case 60: printf("sixty"); break;
                case 61: printf("sixty-one"); break;
                case 62: printf("sixty-two"); break;
                case 63: printf("sixty-three"); break;
                case 64: printf("sixty-four"); break;
                case 65: printf("sixty-five"); break;
                case 66: printf("sixty-six"); break;
                case 67: printf("sixty-seven"); break;
                case 68: printf("sixty-eight"); break;
                case 69: printf("sixty-nine"); break;
                case 70: printf("seventy"); break;
                case 71: printf("seventy-one"); break;
                case 72: printf("seventy-two"); break;
                case 73: printf("seventy-three"); break;
                case 74: printf("seventy-four"); break;
                case 75: printf("seventy-five"); break;
                case 76: printf("seventy-six"); break;
                case 77: printf("seventy-seven"); break;
                case 78: printf("seventy-eight"); break;
                case 79: printf("seventy-nine"); break;
                case 80: printf("eighty"); break;
                case 81: printf("eighty-one"); break;
                case 82: printf("eighty-two"); break;
                case 83: printf("eighty-three"); break;
                case 84: printf("eighty-four"); break;
                case 85: printf("eighty-five"); break;
                case 86: printf("eighty-six"); break;
                case 87: printf("eighty-seven"); break;
                case 88: printf("eighty-eight"); break;
                case 89: printf("eighty-nine"); break;
                case 90: printf("ninety"); break;
                case 91: printf("ninety-one"); break;
                case 92: printf("ninety-two"); break;
                case 93: printf("ninety-three"); break;
                case 94: printf("ninety-four"); break;
                case 95: printf("ninety-five"); break;
                case 96: printf("ninety-six"); break;
                case 97: printf("ninety-seven"); break;
                case 98: printf("ninety-eight"); break;
                case 99: printf("ninety-nine"); break;
                default: printf("NO"); break; }
                return 0;
}


#include <stdio.h>

int main()
{
	int i = 2, num;

	scanf("%d", &num);
	printf("%d ", num);

	while(num > 1){
		for(i = 2; i < num && num % i != 0; i++){}
		num /= i;
		printf("%d ", num);
	}

	return 0;
}


#include<stdio.h>
int main(void)
{
    long int a,b,c,d,max,min,mid,total=0;
    scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
    max=a>b?a>c?a:c:b>c?b:c;
    min=a<b?a<c?a:c:b<c?b:c;
    mid=a+b+c-max-min;
    if(max-mid<d)
    {
        total=d-max+mid;
    }
    if(mid-min<d)
    {
        total+=d-mid+min;
    }
    printf("%ld\n",total);
    return 0;
}


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

int main()
{
    int board[4][4] = {0};
    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 4; j++) {
            char c;
            scanf("%c ", &c);
            if (c == 'x') board[i][j] = 1;
            else if (c == 'o') board[i][j] = -3;
            else board[i][j] = 0;
        }
    bool can_win = false;
    for (int i = 0; !can_win && i < 4; i++) {
        for (int j = 0; j < 4; j++) {
            if (board[i][j] >= 0) { /* 'x' or '.' */
                int sum_hor = 0, sum_dia_up = 0, sum_dia_down = 0, sum_ver = 0;
                if (j < 2)
                    sum_hor = board[i][j] + board[i][j+1] + board[i][j+2];
                if (i < 2)
                    sum_ver = board[i][j] + board[i+1][j] + board[i+2][j];
                if (i < 2 && j < 2)
                    sum_dia_up = board[i][j] + board[i+1][j+1] + board[i+2][j+2];
                if (i >= 2 && j < 2)
                    sum_dia_down = board[i][j] + board[i-1][j+1] + board[i-2][j+2];

                if (sum_hor == 2 || sum_dia_up == 2 || sum_dia_down == 2 || sum_ver == 2) {
                    can_win = true;
                    break;
                }
            }
        }
    }
    if (can_win)
        puts("YES");
    else
        puts("NO");
    return 0;
}


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

int main(void)
{
    int a, b, c, i, ans = 0;
    scanf("%d%d", &a, &b);
    c = a - b;
    if (c == 0)
    {
        printf("infinity");
        return 0;
    }

    for (i = 1; i * i <= c; i++)
    {
        if (c % i == 0)
        {
            if (i > b)
                ans++;
            if ((c / i != i) && (c / i > b))
                ans++;
        }
    }

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


#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 <string.h>

#define N	100

int main() {
	static char cc[N + 1];
	int n, i, ans, zero;

	scanf("%s", cc), n = strlen(cc);
	ans = (n - 1) / 2 + 1;
	zero = 1;
	for (i = 1; i < n; i++)
		if (cc[i] != '0') {
			zero = 0;
			break;
		}
	if (n % 2 == 1 && zero)
		ans--;
	printf("%d\n", ans);
	return 0;
}


#include<stdio.h>
int main(){
int i,j,m,max=0,min,A[100],n,a;
scanf("%d",&n);
scanf("%d",&m);
for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    if(A[i]>max){
        max=A[i];
    }
}
a=m;
i=0;
while(m>0&&i<n){
    if(A[i]!=max){
        if(m>=(max-A[i])){
            m=m-(max-A[i]);
            //printf("%d %d\n",A[i],m);
        }
        else if(m<(max-A[i])){
            A[i]=A[i]+m;
            m=0;
        }

    }
     min=max;
    i=i+1;
}

//printf("%d %d",min,m);
if(m!=0)
    min=min+m/n;
if(m%n!=0)
    min=min+1;
printf("%d %d",min,max+a);
}


#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>
#include <string.h>
#include <stdbool.h>
#include <assert.h>

#define MAX 1000010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

void fft(long long n, long long* ar){
    long long i, j, x, g = n, flag = 0;
    while (((g != 1) || flag) && n > 1){
        flag = 0;
        if (g != 1) g *= 0.77425;

        for (i = 0; (i + g) < n; i++){
            if (ar[i] > ar[i + g]){
                flag = 1;
                x = ar[i], ar[i] = ar[i + g], ar[i + g] = x;
            }
        }
    }
}

long long n, x, y, l, r, a, b, A[MAX], B[MAX], ar[MAX];

long long generate(long long b, long long* ar){
    long double p = 1.0;
    long long i, j, x = 1, len = 0;

    while (p < 2e18 && x <= (1LL << 60)){
        ar[len++] = x;
        p *= b, x *= b;
    }
    return len;
}

int main(){
    long long i, j, k, u, v, w, res, prev;

    while (scanf("%lld %lld %lld %lld", &x, &y, &l, &r) != EOF){
        a = generate(x, A);
        b = generate(y, B);

        clr(ar);
        n = 0, res = 0, prev = 1;
        for (i = 0; i < a; i++){
            for (j = 0; j < b; j++){
                ar[n++] = A[i] + B[j];
            }
        }
        ar[n++] = 0, ar[n++] = 1LL << 61;
        fft(n, ar);

        for (i = 1; i < n; i++){
            u = ar[i - 1] + 1, v = ar[i] - 1;
            if (u <= v){
                if (u < l) u = l;
                if (v > r) v = r;
                if ((v - u + 1) > res) res = v - u + 1;
            }
        }

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


#include<stdio.h>
typedef unsigned u;
u w,m;
int main()
{
	scanf("%u%u",&w,&m);
	while(m)
	{
		if(m%w==1)--m;
		if(m%w==w-1)++m;
		if(m%w==0)m/=w;
		else{printf("NO\n");return 0;}
	}
	printf("YES\n");
	return 0;
}


#include <stdio.h>

void TryAppend(int (*Queue)[2], int head, int *tail, int val)
{
    int i;
    for(i = head + 1; i < *tail; ++i) {
        if(Queue[i][0] == val) {
            break;
        }
    }
    if(i == *tail) {
        Queue[*tail][0] = val;
        Queue[*tail][1] = head;
        ++(*tail);
    }
}

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    int Queue[10000][2];
    int Ans[10000];
    int size = 0;
    int head = 0, tail = 1;
    Queue[head][0] = b;
    Queue[head][1] = -1;
    while(head < tail) {
        if(Queue[head][0] == a) {
            puts("YES");
            Ans[size++] = Queue[head][0];
            int pre = Queue[head][1];
            while(~pre) {
                Ans[size++] = Queue[pre][0];
                pre = Queue[pre][1];
            }
            printf("%d\n", size);
            for(int i = 0; i < size; ++i) {
                printf("%d ", Ans[i]);
            }
            return 0;
        }
        int new;
        if(!(Queue[head][0] & 1)) {
            new = Queue[head][0] / 2;
            if(new >= a) {
                TryAppend(Queue, head, &tail, new);
            }
        }
        if(Queue[head][0] % 10 == 1) {
            new = (Queue[head][0] - 1) / 10;
            if(new >= a) {
                TryAppend(Queue, head, &tail, new);
            }
        }
        ++head;
    }
    puts("NO");
    return 0;
}