#include<stdio.h>
#include<string.h>
int k,i;
char s[50],c[12][50]={"January","February","March","April","May","June","July","August","September","October","November","December"};
bool check(char *a,char *b)
{
    if(strlen(a)-strlen(b))return 0;
    for(int i=0;a[i];i++)if(a[i]-b[i])return 0;
    return 1;
}
int main()
{
    scanf("%s%d",s,&k);
    for(;i<12;i++)if(check(s,c[i]))break;
    printf("%s",c[(i+k)%12]);
}


#include<stdio.h>
#include<math.h>
int main(){
    int t;
    for(int i=0;i<t;i++){
        int n;
        scanf("%d",&n);
        int a=sqrt(n);
        int b=cbrt(n);
        int c=sqrt(cbrt(n));
        int ans=a+b-c;
    }
    printf("%d",&ans);
}


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

int main()
{
    int x,y,result;
    scanf("%d %d",&x,&y);
    if(x==0 && y==0)result=0;
    else if(x==1 && y==0)result=0;
    else if(x==0 && y==1)result=2;
    else if(x==0 && y==-1)result=4;
    else if(x==-1 && y==0)result=3;
    else if(x=>0 && y=>0)
    {
        if(x<y)
        result=(3*y)+(y-2);
        else
            result=(3*x)+(x-3);
    }
    else if(x<0 && y<0)
    {
        if(abs(x)<abs(y))
            result=4*abs(y);
        else
            result=(3*abs(x))+(abs(x)-1);
    }
    else if(x=>0 && y<0)
    {
        if(x>abs(y))
        {
            if(x-abs(y)==1)
            result=(4*abs(y));
            else
               result=(3*x)+(x-3);
        }
        else result=(4*abs(y));
    }
    else if(x<0 && y=>0)
    {
        if(abs(x)>y)
            result=(3*abs(x))+(abs(x)-1);
        else result=(3*y)+(y-2);
    }
    printf("%d",result);
    return 0;
}


#include<stdio.h>
int main()
{
int a,b,x,y;
scanf("%d%d",&a,&b);
if(a>b)
    {x=b;
    y=((a-x)/2);}
else if (b>a)
 {x=a;
y=((b-x)/2);}
printf("%d %d", x,y);


#include<stdio.h>
void main()
{
       int n,p,s,i;
       scanf("%d%d%d",&n,&p,&s);
        if((p-s)!=1)
           {   printf("<<");
           }
       for(i=p-s;i<=p+s;i++)
       {
          if(i==p)
            {  printf("(%d)",i);
          }else
       {printf("%d",i);
       }if(i==n)
       {
              break;
       }
       }
       if(i<n)
       printf(">>");
}


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

int main()
{
    int a;
	scanf("%d",&a);
	int x;
	for(int n=1;;n++){
		if(a%n==0){
			if(a/n<n){
			    printf("%d %d",x,a/x);
				break;
			}
			x=n;
		}
	}

	return 0;
}


#include<stdio.h>
main(){
	int y,z,i,j,si,n,m,x,bo,k,s=0;
	scanf("%d %d %d %d",&k,&n,&bo,&si);
	while(n>0){s++;y=(k<bo+1)?k:bo+1;bo-=y-1;n-=y*si;}printf("%d",s);}


#include<stdio.h>
int b[51];
void merge(int a[], int k,int l);
void merge_sort(int a[], int n);

int main()
{
    int n,m,k,i,s,flag,a[51];
    scanf("%d%d%d",&n,&m,&k);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    merge_sort(a,n);
    s=k;
    i=0;
    flag=0;
    while(s<m&&i<n)
    {
              s=s+a[n-1-i]-1;
              i++;
              if(s>=m) {flag=1;break;}
    }
    if(flag) printf("%d\n",i);
    else printf("-1\n");getch();
    return;
}
void merge_sort(int a[], int n)
{
if(n==1||n==0) return;
merge_sort(a, n/2);
merge_sort(a+n/2, n-n/2);
merge(a,n/2, n-n/2);
}

void merge(int a[], int k,int l)
{
 int i,j=k,c=0;
for(i=0;i<k&&j<k+l;)
{
while(a[i]<a[j]&&i<k){ b[c]=a[i]; c++; i++;} if(i==k) break;
while(a[i]>=a[j]&&j<k+l){ b[c]=a[j];c++; j++;} if(j==k+l) break;
}
if(i<k) {for(;i<k;i++){ b[c]=a[i];c++;}}
else if(j<k+l) { for(;j<k+l;j++){ b[c]=a[j];c++;}}

for(i=0;i<k+l;i++)
  a[i]=b[i];
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
    int s, x1, x2, p, d1, t1, t2, ans = 0;
    scanf("%d%d%d%d%d%d%d", &s, &x1, &x2, &t1, &t2, &p, &d1);
    int t_ig = abs(x1 - x2) * t2;
    int t_tr;
    if ((x2 - p) * d1 > 0) {
        t_tr = abs(x2 - p) * t1;
    }
    else{
        if (x2 < p){
            t_tr = (2 * s - p - x2) * t1;
        }
        else{
            t_tr = (p + x2) * t1;
        }
    }
    if (t_tr >= t_ig)
        ans = t_ig;
    else
        ans = t_tr;
    printf("%d", ans);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    int i,j,k,l,m,temp,res=0,max=0;
    char s[300],in[10];
    scanf("%s",s);
    scanf("%d",&k);
    l=strlen(s);
    if(k>=l)
        printf(“%d\n”,(((k+l)/2))*2);
    else
    {
        for(i=0;i<l-k;i++)
        {
            for(j=(l+k-i)/2;j>=1;j--)
            {
                temp=0;
                for(m=i;m<i+j;m++)
                {
                    if(m+j>=l)
                        break;
                    if(s[i]!=s[m+j])
                    {temp=-1;break;}
                }
                if(temp==0 && j>max)
                    max=j;
            }
        }
        if(max>k)
            printf("%d\n",2*max);
        else
            printf("%d\n",2*k);
    }
    return 0;
}


#include<stdio.h>
main()
{
    int small,c,w=1,j,k,n,m,i,bench[100];
    scanf("%d",&n);
     scanf("%d",&m);

    for(i=1;i<=n;i++) scanf("%d",&bench[i]);
    c=bench[1];
    for(i=2;i<=n;i++){if(c>bench[i]) c=c;else c=bench[i];}

   x : small=bench[1];
           j=1;

     for(i=2;i<=n;i++)
    {
      if(small<bench[i]) {small=small;j=j;}
      else {small=bench[i];j=i  ;}
    }

    if(w<=m){ bench[j]=bench[j]+1;
              w=w+1;
              goto x;}
     k=bench[1];
for(i=2;i<=n;i++) {if(k>bench[i] k=k;else k=bench[i];}

     printf("%d\n",k);
     printf("%d",m+c);
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll pw2[40],pw3[40];
int calc(ll k)
{

    int ret =  0 ;
    for (int i = 0  ; i <= 32 ; i ++)
        for (int j = 0 ; j <= 32 ; j ++)
            if  (k * 1.0 / pw3[j]  >= pw2[i]) ret ++ ;
    return ret;
}
int main()
{
    pw2[0] = pw3[0] = 1;
    for (int i = 1  ;  i <= 32  ; i++ ) pw2[i] = pw2[i-1] * 2;
    for (int i = 1  ;  i <= 32  ; i++ ) pw3[i] = pw3[i-1] * 3;

    int x , y;

    cin >> x >> y;
    cout<< calc(y) - calc(x-1) << endl;

    return 0;
}


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

int main(void)
{
    int len,i;
    long long num;
    char str[105];
    gets(str);
    len=strlen(str);
    if(len==19)
    {
            if(str[0]<='9'){if(str[1]<='2')if(str[2]<='2')if(str[3]<='3')if(str[4]<='3')if(str[5]<='7')if(str[6]<='2')if(str[7]<='0')if(str[8]<='3')if(str[9]<='6')if(str[10]<='8')if(str[11]<='5')if(str[12]<='4')if(str[13]<='7')if(str[14]<='7')if(str[15]<='5')if(str[16]<='8')if(str[17]<='0')if(str[18]<='7')}
            printf("long\n");
        else
            printf("BigInteger\n");
    }
    else if(len>19)
        printf("BigInteger\n");
    else
    {
        sprintf(num,"%s",str);
        if(num<=127)
            printf("byte\n");
        else if(num<=32767)
            printf("short\n");
        else if(num<=2147483647)
            printf("int\n");
    }
    return 0;
}


#include <stdio.h>
typedef long long unsigned int u64;
u64 dp[1<<24];
u64 solve(const u64 n, const u64 x, const u64 y) {
    dp[1] = x;
    for(int i = 1; i <= n; i++)
        if(i & 1) dp[i] = dp[i - 1] + x;
        else dp[i] = dp[i >> 1] + y < dp[i - 1] + x ? dp[i >> 1] + y : dp[i - 1] + x;
    return dp[n];
}

int main(void) {
    int n, x, y;
    scanf("%d%d%d", &n, &x, &y);
    printf("%llu", solve(n, x, y));
    return 0;


#include<stdio.h>
int main(){
int x,y,a,b,i,min,count = 0;
if (x>y) min = y else min = x;
scanf ("%d %d %d %d",&x,&y,&a,&b);
for (i=a;i<b+1;i+=min)
{
    if (i%x == 0 && i%y == 0)
        count++;
}

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

return 0;
}


#include <stdio.h>

int main(void) {
	// your code goes here
	char st1[1000000], st2[1000000];
	int count_a = 0, count_b = 0;
	char ch=getchar_unlocked();
	while(ch!='|')
		st1[count_a++] = ch, ch = getchar_unlocked();

	ch = getchar_unlocked();
	while(ch!='\n')
		st2[count_b++] = ch, ch = getchar_unlocked();
	ch = getchar_unlocked();
	while(ch>=65 && ch <= 90)
	{
		if(count_a <= count_b)
			st1[count_a++]=ch;
		else
			st2[count_b++]=ch;
		ch = getchar_unlocked();
	}

	if(count_a != count_b)
	{
		printf("Impossible\n");
	}
	else
	{
		st1[count_a] = '\0';
		st2[count_b] = '\0';
		printf("%s|%s\n", st1, st2);
	}
	return 0;
}


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

int main()
{

    long long int w,h,ans;

    scanf("%lld%lld",&w,&h);

    long long  int t=w+h;
    ans=pow(2,t);

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

    return 0;
}


#include<stdio.h>
int main()
{

    int a,i;
    int tc,t;
    scanf("%d",&tc);
    for(i=0; i<tc; i++)
            scanf("%d",&a) ;
          t=0;
        while(a>0)
        {

            if(a>=7)
                a=a-7;
            else if(a>=6)
                a=a-6;
            else if(a>=5)
                a=a-5;
            else if(a>=4)
                a=a-4;
            else if(a>=3)
                a=a-3;
            else if(a>=2)
                a=a-2;
            t++;

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

    }
    return 0;
}


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


#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdbool.h>
#define N 205
int main(void)
{
    int i,j,print,star=0,count1=0,count2=0,length;
    bool yn[N];
    char line[N];
    gets(line);
    scanf("%d",&length);
    for(i=0; i<N; i++)
        yn[i]=true;
    for(i=0; line[i]; i++)
    {
        if(isalpha(line[i]))
            count1++;
        else
            count2++;
        if(line[i]=='*')
            star++;
    }
    if(length<count1-count2)
        printf("Impossible\n");
    else if(length>count1&&!star)
        printf("Impossible\n");
    else
    {
        if(length>count1)
        {
            print=length-count1;
            for(i=0; i<line[i]; i++)
            {
                if(isalpha(line[i]))
                    printf("%c",line[i]);
                if(line[i]=='?')
                    i++;
                else
                    while(print--)
                        printf("%c",line[i-1]);
            }
            printf("\n");
        }
        if(count1==length)
        {
            for(i=0; i<line[i]; i++)
                if(isalpha(line[i]))
                    printf("%c",line[i]);
            printf("\n");
        }
        else
        {
            print=count1-length;
            for(i=0; line[i]; i++)
            {
                if(line[i]=='?'||line[i]=='*')
                    yn[i]=false;
                if((line[i]=='?'||line[i]=='*')&&print)
                {
                    yn[i-1]=false;
                    print--;
                }
            }
            for(i=0; line[i]; i++)
                if(yn[i])
                    printf("%c",line[i]);
            printf("\n");
        }
    }
    return 0;
}


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

int tab [110];

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

	int vsota = 0;
	int je = 1;

	int a;
	int b;

	for (int i = 1; i < n; i++){
		a = tab[i-1];
		b = tab[i];

		if ((a == 1 && b == 2)||
			(a == 2 && b ==1)){
			vsota += 3;
		}
		else if ((a == 1 && b == 3)||
				(a == 3 && b == 1)){
			vsota += 4;
		}
		else{
			je = 0;
			break;

		}

		/*
		if (tab [i] == 1 || tab[i-1] == 1){
			if (tab[i] == 2 || tab [i-1] == 2){
				vsota = vsota + 3;
			}
			else if ( tab[i] == 3 || tab [i-1] == 3){
				vsota = vsota + 4;
			}

		}

		if((tab[i] == 2 && tab [i-1] == 3 )||
			tab [i-1]== 2&& tab [i] == 3){
			je = 0;
			break;
		}
		*/

	}

	if (je == 1){
		printf("Finite\n");
		printf("%d\n",vsota );
	}
	else{
		printf("Infinite\n");

	}

	return 0;
}


#include <stdio.h>

int Win(int a, int b)
{
    return b == (a + 1) % 3;
}

int main()
{
    char ans[4] = "FMS";
    int choice[3];
    char str[15];
    for(int i = 0; i < 3; ++i) {
        scanf("%s", str);
        if(str[0] == 'r') {
            choice[i] = 0;
        } else if(str[i] == 's') {
            choice[i] = 1;
        } else if(str[i] == 'p') {
            choice[i] = 2;
        }
    }
    for(int i = 0; i < 3; ++i) {
        char allWin = 1;
        for(int j = 0; j < 3; ++j) {
            if(i != j && !Win(choice[i], choice[j])) {
                allWin = 0;
                break;
            }
        }
        if(allWin) {
            putchar(ans[i]);
            return 0;
        }
    }
    puts("?");
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
int a[1000];
int main()
{
//	freopen("datain.txt","r",stdin);
//	freopen("datain.txt","w",stdout);
	int n;
	scanf("%d",&n);
	int i=1;
	int len;
	int cnt=0;
	while(n>0)
    {
        a[i]=n%8;
        n /=8;
        i++;
        len = i;
    }
    for(i=1;i<=len;i++)
    {
        if(a[i]==1) cnt++;
    }
    printf("%d",cnt);
//	fclose(stdin);
//	fclose(stdout);
	return 0;
}


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

int main(){
    int n,pos,l,r,sec=0;
    scanf(" %d  %d  %d  %d",&n,&pos,&l,&r);
    if(pos>=l%%pos<=r){
    if(l==1&&r==n){
        sec=0;
    }else if(l==1&&r!=n){
        sec=r-pos+1;
    }else if(l!=1&&r==n){
        sec=pos-l+1;
    }else if(l!=1&&r!=n){
        if(pos-l<=r-pos){
            sec+=pos-l+1;
            sec+=r-l+1;
        }else if(pos-l>r-pos){
            sec+=r-pos+1;
            sec+=r-l+1;
        }
    }
    }else if(pos>r){
        if(l==1&&r!=n){
            sec=pos-r+1;
        }else if(l!=1&&r!=n){
            sec+=pos-r+1;
            sec+=r-l+1;
        }
    }else if(pos<l){
        if(r==n){
            sec=l-pos+1;
        }else if(l!=1&&r!=n){
            sec+=l-pos+1;
            sec+=r-l+1;
        }
    }
    printf("%d",sec);
    return 0;
}


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


#include<stdio.h>
int main()
{
	int len,array[105],last=4,count=0,i;
	scanf("%d",&len);
	for(i=1;i<=len;i++)
		scanf("%d",&array[i]);
	for(i=1;i<=len;i++)
	{
		if(array[i]==0)
		{
			count++;
		}
		else if(array[i]==1)
		{
			if(last==1)
			{
				count++;
				last=4;
			}
			else
				last=1;
		}
		else if(array[i]==2)
		{
			if(last==2)
			{
				count++;
				last=4;
			}
			else
				last=2;
		}
		else
		{
                     if(last==1)
			last=2;
                    else if(last==2)
                     last=1;
                    else
                      last=4;
		}
	}
         printf("%d\n",count);
	return 0;
}


#include<stdio.h>
int main()
{
  int x,y,a;
  scanf("%d %d %d",&x,&y,&z);
  float a2=float(a)/2;
  if(y%a==0)
  {
    printf("-1");
    retrun 0;
  }
  int ya=y/a+1;
  float xa=x/a2;
  int num=ya+(ya-1)/2;
  if(ya==1||ya%2==0)
  {
      if(xa!=0)
        printf("-1");
      else
        printf("%d",num);
       return 0;
  }
  else
 {
    if(xa>=2||xa<=-2||xa==0)
      {
         printf("-1");
         return 0;
      }
      else
      {
         if(xa>0)
            num++;
          printf("%d",num);
      }
      return 0;
 }


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

int comp(const void * elem1, const void * elem2)
{
	int f = *((int*) elem1);
	int g = *((int*) elem2);
	if(f > g) return 1;
	if(f < g) return -1;
	return 0;
}

int main()
{
	long long int n, w;
	scanf("%lld %lld", &n, &w);
	long long int total_volume, a[n], b[n];
	for(int i = 0; i < n; i++)
	{
		scanf("%lld", &a[i]);
		total_volume += a[i];
		b[i] = a[i]/2 + a[i]%2;
		w -= b[i];
	}
	if(w < 0 || total_volume  < w)
	{
		printf("-1\n");
		return 0;
	}
	else
	{
		int max_index = -1, max_volume = -1;
		while(w > 0)
		{
			for(int i = 0; i < n; i++)
			{
				if(a[i] > max_volume)
				{
					max_volume = a[i];
					max_index = i;
				}
			}
			if(b[max_index] == a[max_index])
			{
				a[max_index] = -1;
			}
			else
			{
				int volume = w - (a[max_index] - b[max_index]) < 0 ? w : a[max_index] - b[max_index];
				b[max_index] += volume;
				w -= volume;
			}
		}
	}
	for(int i = 0; i < n; i++)
	{
		printf("%lld ", b[i]);
	}
	printf("\n");
	return 0;
}


#include<stdio.h>
using namespace std;
int n,p,ans,tot;
char a[45][10];
int main() {
	scanf("%d%d",&n,&p);
	for(int i=1; i<=n; i++)scanf("%s",a[i]+1);
	for(int i=n; i>=1; i--) {
		if(a[i][5]=='p')tot=tot*2+1,ans+=tot*p/2;
		else tot*=2,ans+=tot*p/2;
	}
	printf("%d",ans);
	return 0;
}


// DHUOJ solution #297163 @ 2018-05-07 12:08:53.031

#include <iostream>
#include <cstdio>
#include<cstring>
#include <algorithm>
#include<set>
using namespace std;
int num[105];
set<int>cards;
set<int>::iterator it;
int main()
{
    int T,N,temp;
    while(~scanf("%d",&N))
    {
        memset(num,0,sizeof num);
        cards.clear();
        for(int i=0;i<N;i++)
        {
            scanf("%d",&temp);
            cards.insert(temp);
            num[temp]++;
        }
        if(cards.size()!=2)
            printf("NO\n");
        else
        {
            it=cards.begin();
            int n1=*it;
            int temp1=num[n1];
            it++;
            int n2=*it;
            int temp2=num[n2];
            if(temp1!=temp2)
                printf("NO\n");
            else
            {
                printf("YES\n");
                printf("%d %d\n",n1,n2);
            }
        }
    }
    return 0;
}


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

int main()
{
    int n,k,dem,max=0,z=0,i;
    scanf("%d%d",&n,&k);
    if (n==0)
        printf("%d",k);
    int a[n],b[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        b[z]=a[i];
        z++;
    }
    for(i=0;i<n;i++)
    {   dem=0;
        for(int j=i;j<n;j++)
        {
            if (a[j]==a[i])
                dem++;
        }
        if(dem>max)
            max=dem;
    }
    int kq,c,sodoi,sopt=1;
    for (i=0;i<n-1;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            if(a[i]<a[j])
            {
                sodoi=a[i];
                a[i]=a[j];
                a[j]=sodoi;
            }
        }
    }
    for (i=1;i<n;i++)
    {
        if (a[i] != a[i-1])
            sopt++;
    }
    kq=sopt*k-n;
    if (max>=k)
    {
        c=max/k;
        if ((float)max/k>0)
        {
            c++;
        kq=sopt*c*k-n;
        }
        kq=0;
    }
    printf("%d",kq);
return 0;
}


#include<stdio.h>
#include<string.h>
int is_big(char a)
{
	if(a>='A'&&a<='Z')
		return 1;
	else
		return 0;
}
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		getchar();
		char a[220];
		int max=0,sum=0,abc[27];
		for(int i=0;i<n;i++)
			scanf("%c",&a[i]);
		for(int i=0;i<n;i++)
		{
			memset(abc,0,sizeof(abc));
			if(!is_big(a[i]))
			{
				abc[a[i] - 'a' ] = 1;
				sum = 1;
				for(int j=i+1;j<n;j++)
				{
					if(!(is_big(a[j])) && abc[a[j] - 'a'] != 1)
					{
						sum++;
						abc[a[j] - 'a'] = 1;
					}
					else if(is_big(a[j]))
						break;
				}
				if(sum>max)
					max = sum;
			}
		}
		printf("%d\n",max);
	}
	return 0;
 }


#include <stdio.h>
int main(void){
	int s,v1,v2,t1,t2;
	scanf("%d%d%d%d%d",&s,&v1,&v2,&t1,&t2);
	int p1,p2;
	if(v1==v2&&t1==t2)
		printf("Friendship");
    else{
	p1=s/(s*v1-2t1);
	p2=s/(s*v2-2t2);
	if(p1==p2)
		printf("Friendship");
	if(p1>p2)
		printf("First");
	if(p2>p1)
		printf("Second");
}}


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

#define REP(i,n) for(int i=0;i<(int)n;++i)
typedef long long ll;

const int dy[] = {1,0,-1,0};
const int dx[] = {0,1,0,-1};

int d[100];
char s[105];
int vx[105], vy[105];
int ix, iy;
int main() {
  int a,b;
  while(scanf("%d%d", &a, &b) == 2) {
    scanf("%s",s);
    ll y=0,x=0;
    int n = strlen(s);
    REP(i,n) {
      d[i] = strchr("URDL", s[i]) - s;
    }
	ix = 0;
	iy = 0;
    vx[ix++] = 0;
	vy[iy++] = 0;
    REP(i,n) {
      y += dy[d[i]];
      x += dx[d[i]];
	  vy[iy++] = y;
      vx[ix++] = x;
    }
    ll Y = y;
    ll X = x;
    bool ok = 0;
    REP(i,n) {
      REP(j,n) {
        ll yy = vy[j];
        ll xx = vx[j];
        ll y = b-yy;
        ll x = a-xx;
        if (Y && y % Y == 0) {
          if (X*(y/Y) == x) {
            ok = 1;
          }
        }
        if (Y == 0 && y == 0) {
          if (x == 0 || (X && x % X == 0)) {
            ok = 1;
          }
        }
      }
    }
    printf("%s\n",ok?"Yes":"No");
  }
}


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

int n,k,b[233333],r[233333],o[233333],w[233333],rn,on,wn;
char s[233333];

int comp(const void* a,const void* b) {
	int arg1=*(int*)(a);
	int arg2=*(int*)(b);
	if(arg1 < arg2) return -1;
	if(arg1 > arg2) return 1;
    return 0;
}

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i) {
		scanf("%d",&b[i]);
	}
	scanf("%s",s+1);
	for(int i=1;i<=n;++i) {
		if(s[i]=='R') r[++rn]=b[i];
		else if(s[i]=='O') o[++on]=b[i];
		else if(s[i]=='W') w[++wn]=b[i];
	}
	if(on==0) {
		puts("-1");
		return 0;
	}
	if(rn==0&&wn==0) {
		puts("-1");
		return 0;
	}
	qsort(r,rn,sizeof(int),comp);
	qsort(o,on,sizeof(int),comp);
	qsort(w,wn,sizeof(int),comp);
	int ans=0,tmp=0,oo=on;
	if((rn+oo<k)&&(wn+oo<k)) {
		puts("-1");
		return 0;
	}
	if(rn+oo>=k) {
		for(int cnt=1;cnt<=k;++cnt) {
			if(r[rn]>o[on]&&rn) ans+=r[rn--];
			else ans+=o[on--];
		}
	}
	if(wn+oo>=k) {
		on=oo;
		for(int cnt=1;cnt<=k;++cnt) {
			if(w[wn]>o[on]&&wn) tmp+=w[wn--];
			else tmp+=o[on--];
		}
	}
	if(tmp>ans) ans=tmp;
	printf("%d\n",ans);

	return 0;
}


#include<iostream>

using namespace std;

int main()
{
    int n;
    cin>>n;
    cout << (n-2)*(n-2) <<endl;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
	char box[8][8],ch='B',temp;
	int i,j,k,FLAG=0;
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
		{
			scanf("%c",&box[i][j]);
			if(box[i][j-1]==box[i][j]&&J!=0)
			FLAG=1;
		}
	}

	if(FLAG==1)
	{
	  printf("NO");
	  exit(0);
	}
	else
	{

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

		if(box[i-1][j]==box[i][j])
			{
				temp=box[i][7];
				for(k=7;k>0;k--)
				{
					box[i][k]=box[i][k-1];
				}
				box[i][0]=temp;
     		}

	 }
	}
	printf("YES");
	return 0;
}


#include <stdio.h>

#define ll long long

int main(){
  long long int n, m, s, x ,y;

  scanf("%lld %lld %lld", &n, &m, &s);

  if (n <= s)
    x =  n;
  else
    x = (n-1)/s + 1;

  if (m <= s)
    y = m;
  else
    y = (m-1)/s + 1;

  if(s < n)
    x *= ((n - 1) %s) + 1;

  if(s < m)
    y *= ((m - 1) %s) + 1;

  printf("I64d\n", x*y);

  return 0;
}


#include<stdio.h>
long long int a[30000001];
int main()
{
    long long int n;
    int i,index;

        scanf("%lld",&n);
    for(i=1;i<=30000000;i++)
    {
    	a[i]=i*(i+1LL)/2;
    }
    //for(i=1;i<=10000000;i++)
      //  printf("%lld\n",a[i]);
    for(i=1;1<2;i++)
    {
    	if(a[i]>=n)
    	{
    		index=i;
    		break;
    	}
    }
    index--;
    //  printf("\nloda=%lld\n",a[index]);
    printf("%lld\n",n-a[index]);

    return 0;
}
close


#include<stdio.h>
long long int a[1000000];
main()
{
	long long int temp,j,n,m,b;
	int i=0;
	scanf("%lld%lld",&n,&m);
	temp=m;
	while(m>n)
	{
		if(m%2==0)
		{m/=2;
		a[i]=m;}
		else if((m-1)%10)==0)
		{m=(m-1)/10;
		a[i]=m;}
		i++;
	}
	if(m!=n)
	printf("NO");
	else
	{
		printf("YES\n");
		printf("%d\n",i+1);
		for(j=i-1;j>=0;j--)
		printf("%d ",a[j]);
		printf("%d",temp);
	}
}


#include<stdio.h>
int main(){
char c;int l;
 scanf("%c%d",&c,&l);
if(c=='a'||c=='h'){
    if(l==1||l==8)
    printf ('3');
else printf('5');

}
else printf('8');

return 0;


#include <stdio.h>
main() {printf("INTERCAL");}


#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 111111
#define M 1000000007
typedef long long ll;
int n, dp[N], ind, ans[N], first[N];
int strint(char *a){
    int len=strlen(a), tmp=0;
    for (int i=len-1, j=1; i>=0; i--, j*=10)
        tmp+=(a[i]-'0')*j;
    return tmp;
}
void solve(char *a){
    int len=strlen(a);
    if (len>6)
        return ;
    dp[ind]=strint(a);
    ind++;
    char *tmp=(char *) malloc((len*2)*sizeof(char));
    for (int i=0; i<len; i++)
        tmp[i]=a[i];
    tmp[len+1]='\0';
    tmp[len]='0';
    solve(tmp);
    tmp[len]='1';
    solve(tmp);
}
int find(int val){
    int l=0, r=ind-1, m, ret;
    while (l<=r){
        m=(l+r)/2;
        if (dp[m]<=val)
            ret=dp[m], l=m+1;
        else
            r=m-1;
    }
    return ret;
}
int max(int a, int b) {return a>b?a:b;}
int min(int a, int b) {return a<b?a:b;}
int comp(const void *a, const void *b){
    int aa=*(int *)a, bb=*(int *)b;
    return aa<bb?-1:aa>bb?1:0;
}
int main(){
    scanf("%d", &n);
    char *tmp=(char *) malloc(2*sizeof(char));
    tmp[0]='1', tmp[1]='\0';
    solve(tmp);
    qsort(dp, ind, sizeof(int), comp);
    ans[0]=0;
    for (int i=1; i<=n; i++){
        ans[i]=INT_MAX;
        for (int j=0; j<ind; j++)
            if (i-dp[j]>=0&&ans[i-dp[j]]+1<ans[i]){
                ans[i]=ans[i-dp[j]]+1;
                first[i]=dp[j];
            }
    }
    printf("%d\n", ans[n]);
    while (n>0){
        printf("%d ", first[n]);
        n-=first[n];
    }
}


#include <stdio.h>

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


#include <stdio.h>

#include <string.h>

int main()

{

    int n , k ;

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

    char lotus[100] , eater[100] ;

    scanf("%s",lotus) ;  //  char paie = getchar() ;

    char swap ;

    for( int a =  0 ; a < (n-1) ; a++ )  {

        for( int b = a+1 ; b < n ; b++ )  {

            if( lotus[a] > lotus[b] )  {

                swap = lotus[b] ;

                lotus[b] = lotus[a] ;

                lotus[a] = swap ;

            }

        }

    }
    /*
    //puts(lotus) ;

    strcpy(eater,lotus) ;

  //  puts(eater) ;

    int d ;

    n = strlen(eater) ;

    for( int c = 0 ; c < (n-1) ; c++ )  {

            int x = (eater[c+1] - eater[c] ) ;

            if( x == 1 )  {

                for( d = c+1 ; d < n ; d++ )  {

                    eater[d] = eater[d+1] ;

                }

            }

        n-- ;

    }
    puts(eater) ;  */
    /*int sum = lotus[0] - 96  ;
    for( int e = 0 ; e<k ; e++ )  {

        if( ( lotus[e+1] - lotus[e] ) > 1 )  {

            sum = sum + lotus[e+1] - 96 ;

        }

    }
    if(sum==1 && sum<k)  printf("-1\n") ;

    else
    printf("%d\n",sum) ;*/

    char x = ara[0] ;            // na parle za hoy arki

    int sum = x - 96 ;

    int count = 1 ;

    if(count==k) {

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

        return 0 ;

    }

    for( int i = 0 ; i < n ; i++ )  {

        if( lotus[i] - x >= 2 )  {

            sum = sum + lotus[i] - 96 ;

            count++ ;

            x = lotus[i] ;

            if(count==k)

                            {  break ;  }

        }

    }

    if( count > k )  {

        printf("-1\n") ;

    }

    else  {

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

    }

    return 0 ;

}


#include<stdio.h>
using namespace std;
long long a[1005];
int main()
{
	long long n,k,x;
	int i,j=0;
	scanf("%lld %lld",&n,&k);
	for(i=1;i<k;i++)
	{
		if(n%i!=0) continue;
		else a[j++]=k*(n/i)+i;
	}
	x=a[j-1];
	printf("%lld\n",x);
}


#include<stdio.h>
#include<string.h>
char min(char a,char b)
{
	return a>b?b:a;
}
int main()
{
	char str1[102];
	char str2[102];
	while(gets(str1))
	{
		char str[102];
	  gets(str2);
	  bool temp=false;
	  for(int i=0;i<strlen(str1);i++)
	  {
	  	if(str2[i]>str1[i])
	  	{
	  		temp=true;
		  }
		  if(temp)break;
		  str[i]=min(str2[i],str1[i]);
	  }
	  if(temp)printf("-1\n");
	  else puts(str);
	}
}


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


#include <stdio.h>
#include <iostream>
using namespace std;

/**
 * http://codeforces.com/contest/861/problem/A
 * */
long gcd(long a, long b) {
    long mod = a % b;
    while(mod > 0) {
        a = b;
        b = mod;
        mod = a % b;
    }
    return b;
}

long round(long n, long k) {
    long kk = 1;
    while(k > 0) {
        kk *= 10;
        k--;
    }
    long g = gcd(n, kk);
    return n * kk / g;
}

int main() {
    long n, k;
    scanf("%ld %ld", &n, &k);
//    printf("%ld\n", round(n, k));
    cout << round(n, k);
    return 0;
}


#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<deque>
#include<stack>
#include<string>

//long long int asd( long long int r);

int main()
{
    int n, b, p, m, r;
    scanf("%d %d %d", &n, &b, &p);
    r=n;
    int ans=0;
    while(r>1)
    {
        m=(r)/2; ans+=m; //r+=m-pow(2,m);
        r+=m-m*2;
    }
    b=ans*(b*2+1);
    p=p*n;
    printf("%d %d\n", b, p);
}

/*long long int asd( long long int r)
{
    long long int m=0; while(r>0)
    {
        r/=2;
        m++;
    }
    return m-1;
}*/


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

int main()
{
	long long int k,i,j,a,b,l,flag=0;
	scanf("%lld",&k);
	char arr[15] ="codeforces";
	// for(i=0;i<10;i++)
	// {
	// 	printf("%c-%lld\n",arr[i],i);
	// }
	a=1,b=2;
	while(1)
	{
		for(i=0;i<=10;i++)
		{
			if(int(pow(b,i)*pow(a,10-i))>=k)
			{
				flag=1;
				break;
			}
		}
		if(flag==1)
		{
			break;
		}
		a++;
		b++;
	}
	for(j=1;j<=i;j++)
	{
		for(l=1;l<=b;l++)
		{
			printf("%c",arr[j-1]);
		}
	}
	for(j=i+1;j<=10;j++)
	{
		for(l=1;l<=a;l++)
		{
			printf("%c",arr[j-1]);
		}
	}
	printf("\n");
}


#include <stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int count=0;
    int i,k,z,j=0;
    if(n>100)
    z=n-100;
    else
    z=1;
    int b[n/2];
    for(i=z;i<n;i++)
    {   j=0;
        k=i;
        while(k>0)
        {
            j=j+(k%10);
            k=k/10;
        }
        j=j+i;
        if(j==n)
        {
            b[count]=i;
             count++;
        }
    }
    printf("%d\n", count);
    for(i=0;i<count;i++)
    printf("%d\n", b[i]);
    return 0;
}


#include<stdio.h>
int comp(const void* a, const void* b)
{
    return *(int *)a - *(int *)b;
}
int main()
{
    int n,d;
    scanf("%d %d",&n,&d);
    int *arr=(int *)malloc(sizeof(int)*n);
    int i;
    int sum=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        sum+=arr[i];
    }
    qsort(sum,arr,sizeof(int),comp);
    int m,ans=0;
    scanf("%d",&m);
    if(m>n)
        ans=sum-((m-n)*d);
    else
    {
        for(i=0;i<m;i++)
        {
            ans+=arr[i];
        }
    }
    printf("%d\n",ans);

    return 0;
}


double people, to_make, can_make, paper_contain, paper_needed;
	int output;
	scanf("%d%d%d%d", &people, &to_make, &can_make, &paper_contain);
	paper_needed = ceil(to_make, can_make);
	output = people * paper_needed / paper_contain;
	printf("%d", output);
}


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

int a, b;
int abs(int p, int q){
    return (p-q)>0 ? (p-q) : (q-p);
}

int win(int num){
    if(abs(num,a) < abs(num,b)){
        return -1;
    }else if(abs(num,a) > abs(num,b)){
        return 1;
    }else{
        return 0;
    }
}

int main(){
    int aw = 0, d = 0, bw = 0;
    scanf("%d %d",&a,&b);
    for(int i=1; i<=6; i++){
        if(win(i) == -1){
            aw++;
        }else if(win(i) == 1){
            bw++;
        }else{
            d++;
        }
    }
    printf("%d %d %d\n",aw,d,bw);
    return 0;
}


#include<stdio.h>

void sort(int* seg,int x);
void judge(int* seg,int x);

int main() {
	int seg[100001] = { '\0' };
	int numOfLine,temp;
	scanf_s("%d", &numOfLine);
	for (int i = 0; i < numOfLine; i++) {
		scanf_s("%d", &temp);
		seg[i] = temp;
	}
	sort(seg, numOfLine);
	judge(seg,numOfLine);

}

void sort(int* seg,int x) {
	int isChanged = 0;
	for (int i = 0; i < x; i++) {
		isChanged = 0;
		for (int j = 0; j < x-1; j++) {
			if (seg[j] > seg[j + 1]) {
				int temp = seg[j];
				seg[j] = seg[j + 1];
				seg[j + 1] = temp;
				isChanged = 1;
			}
		}
		if (!isChanged)
			break;
	}

}

void judge(int* seg,int x) {
	int pd = 1;
	for (int i = 1; i < x - 1; i++) {
		if (seg[i - 1] + seg[i] > seg[i + 1]) {
			pd = 1;
			break;
		}
		else {
			pd = 0;
		}
	}
	if (pd)
		printf("yes");
	else
		printf("no");
}


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

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

int main() {
	char s[101];
	scanf("%s\n",s);
	int i,m,l=strlen(s);
	char *x[l],*p,*q;
	p=s;
	while (*p) {
		x[p-s]=p;
		p++;
	}
	qsort(x,l+1,sizeof *x,cmp);
	m=0;
	for (i=1;i<l;i++) {
		for (p=x[i],q=x[i-1];*p==*q;p++,q++) ;
		if (p-x[i]>m) m=p-x[i];
	}
	printf("%d\n",m);
	return 0;
}


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

int Destroy(int *Data, int Len)
{
    int i, j;
    int Pre = Data[0];
    int Con = 1;
    for(i=1; i<Len; ++i)
    {
        if(Data[i] == Pre)
        {
            ++Con;
        }
        else
        {
            if(Con > 2)
            {
                for(j=i-Con; j<i-Con+Len-Con; ++j)
                {
                    Data[j] = Data[j+Con];
                }
                return Con + Destroy(Data, Len-Con);
            }
            else
            {
                Pre = Data[i];
                Con = 1;
            }
        }
    }
    if(Con > 2)
    {
        return Con + Destroy(Data, Len-Con);
    }
    return 0;
}

int Fun(int *Data, int Len, int idx)
{
    int Array[101];
    memcpy(Array, Data, idx*sizeof(int));
    Array[idx] = Data[idx - 1];
    memcpy(Array+idx+1, Data+idx, (Len-idx)*sizeof(int));
    return Destroy(Array, Len+1);
}

int main()
{
    int N, K, X, i, Max, Sum;
    int Data[101];
    scanf("%d %d %d", &N, &K, &X);
    for(i=0; i<N; ++i)
    {
        scanf("%d", &Data[i]);
    }
    Max = 0;
    for(i=0; i<N; ++i)
    {
        if(Data[i]==X && i>0 && Data[i-1]==X)
        {
            Sum = Fun(Data, N, i+1)-1;
            if(Sum > Max)
            {
                Max = Sum;
            }
        }
    }
    printf("%d\n", Max);
    return 0;
}


#include<stdio.h>
int main()
{
    long long int d,k,a,b,t,s1,s2,s3,s4,s,x,y,z;
    scanf("%lld %lld %lld %lld %lld",&d,&k,&a,&b,&t);
    if(d<=k)
    {
        printf("%lld\n",a*d);
    }
    else if(d%k==0)
    {
        if(a*k+t>=b*k)
        {
            s=a*k+(d-k)*b;
        }
        else
        {
            s=((d/k)-1)*t+d*a;
        }
        printf("%lld\n",s);
    }
    else
    {
        x=d/k;
        z=d%k;
        y=x*k;
        if(a*k+t>=b*k)
        {
            s=a*k+(y-k)*b;
        }
        else
        {
            s=(x-1)*t+y*a;
        }
        if(t+z*a>=b*z)
        {
            s=s+b*z;
        }
        else
        {
            s=s+t+z*a;
        }
        printf("%lld\n",s);
    }
    return 0;
}


#include <stdio.h>
#define INF ~0ULL
#define ULL unsigned long long
ULL p[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
ULL n, ans;
void dfs(ULL depth, ULL temp, ULL num, ULL up)
{
    if (num == n && temp < ans) ans = temp;
    if (num >= n || depth == 16) return;
    for (int i = 1; i <= up; ++i)
    {
        if (temp * p[depth] >= ans) return;
        else dfs(depth + 1, temp = temp * p[depth], num * (i + 1), i);
    }
}
int main()
{
    while (scanf("%llu", &n) != EOF)
    {
        ans = INF;
        dfs(0, 1, 1, 64);
        printf("%llu\n", ans);
    }
}


/*
ID: mohamma73
LANG: C
TASK: crypt1
*/

#include"stdio.h"
#include"stdlib.h"
#include"ctype.h"
#include"math.h"
#include"string.h"
struct card{
	int val;
	char suit;
	int id;
};
struct point{
	int x;
	int y;
	int visit;
};
struct node{
	int id;
	int n;
	int nei[102];
};
struct person{
	int id;
	int nd;
	int nl;
	int like[2004];
	int dis[2004];
	int visit;
};
struct farmer{
	int p;
	int c;
};
void inc(int *a,int n){
	int i;
	if(a[0]!=2){
		a[0]++;
		return;
	}
	for(i=0;i<n && a[i]==2;i++)
		a[i]=0;
	if(i<n)
		a[i]++;
}
int cmp(char *s,char *t){
	int n=strlen(s);
	int m=strlen(t);
	int i,j;
	for(i=0,j=0;i<n && j<m && s[i]==t[j];i++,j++);
	if(s[i]>t[j])
		return 1;
	else if(s[i]<t[j])
		return -1;
	else
		return 0;

}
int getword(char *s,int n){
	int i;
	char c;
	while(isspace(c=getchar()));
	for(i=0;i<n && !isspace(c);i++,c=getchar())
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
int fgetword(char *s,int n,FILE *fp){
	int i;
	char c;
	while(isspace(c=getc(fp)));
	for(i=0;i<n && !isspace(c) && c!=EOF;i++,c=getc(fp))
		s[i]=c;
	s[i++]='\0';
	return i-1;
}
long long atll(char *s){
	long long n=0;
	int i;
	for(i=0;s[i]!='\0';i++){
		n*=10;
		n+=(s[i]-'0');
	}
	return n;
}
int Bsear(char *s,char words[][13],int n){
	int l=0;
	int h=n;
	int mid;
	while(l<h){
		mid=(l+h)/2;
		if(cmp(words[mid],s)==0)
			return 1;
		else if(cmp(words[mid],s)==1){
			h=mid;
		}else
			l=mid+1;
	}
	return -1;
}
void func(int *n,int base,int num){
	int i=0;
	while(num/base!=0){
		n[i++]=num%base;
		num/=base;
	}
	n[i++]=num;
	n[i++]=20;
}
int pal(int *n){
	int i,j;
	for(i=0;n[i]!=20;i++);
	for(j=0;j<i/2 && n[j]==n[i-j-1];j++);
	if(j==i/2)
		return 1;
	return 0;
}
int ispal(char *s, int i, int j){
	int k;
	for(k=0;k<((j-i+1)/2) && s[i+k]==s[j-k];k++);
	if(k==(j-i+1)/2)
		return 1;
	return 0;
}
void insort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++){
		j=i;
		while(j>0 && a[j]<a[j-1]){
			temp=a[j-1];
			a[j-1]=a[j];
			a[j]=temp;
			j--;
		}
	}
}
char lower(char c){
	return c<'a'?c+('a'-'A'):c;
}
void sort(int *a,int n){
	int i,j,temp;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
				temp=a[j];
				a[j]=a[j-1];
				a[j-1]=temp;

		}
}
void fun(int n,char *s){
	int i=0;
	for(i=0;n/10!=0;i++,n/=10)
		s[i]=n%10+'0';
	s[i++]=n+'0';
	s[i]='\0';
}
void sortIn(int *a,int *indx,int n){
	int t1;
	int i,j;
	for(i=1;i<n;i++)
		for(j=i;j>0 && a[j-1]>a[j];j--){
			t1=a[j-1];
			a[j-1]=a[j];
			a[j]=t1;
			t1=indx[j-1];
			indx[j-1]=indx[j];
			indx[j]=t1;
		}
}
int valid(int *a,int l,int r,int n){
	int f=0;
	if(l>0 && a[l-1]>a[r])
		f=1;
	if(a[l+1]<a[r])
		f=1;
	if(a[r-1]>a[l])
		f=1;
	if(r<n-1 && a[r+1]<a[l])
		f=1;
	if(f)
		return 0;
	return 1;
}
void change(char *stripe,int *colors,int idx,int k){
	int j=0;
	if(idx==1){
		if(stripe[0]-'A'>0)
			stripe[0]=colors[stripe[0]-'A'-1];
		else
			stripe[0]=colors[stripe[0]-'A'+1];
		return ;
	}
	for(j=0;j<idx;j+=2){
		if(stripe[j]-'A'>0){
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j+1]!=colors[stripe[j]-'A'-1])
				stripe[j]=colors[stripe[j]-'A'-1];
			else if(stripe[j]-'A'<k-1)
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'-2];
		}else{
			if(stripe[j]==stripe[j+1])
				stripe[j]=colors[stripe[j]-'A'+1];
			else
				stripe[j]=colors[stripe[j]-'A'+2];
		}
	}
}
int invite(struct point *nom[],int n,struct point *pts[],int m,struct point *invite[]){
	int i,j,idx=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			if(nom[i]->x==pts[j]->x || nom[i]->y==pts[j]->y){
				if(pts[j]->visit==0){
					invite[idx++]=pts[j];
					pts[j]->visit=1;
				}
			}
		}

	}
	return idx;
}
int feasible(struct person *a[],int n){
	int i,j,k;
	int flag=1;
	for(i=0;flag && i<n;i++)
		for(j=0;flag && j<a[i]->nd;j++)
			for(k=0;flag &&k<n;k++){
				if(a[k]->id==a[i]->dis[j]){
					flag=0;
					break;
				}
			}
	if(i==n)
		return 1;
	return 0;
}
int find(struct node *p,struct node *node[]){
	int i,j,k;
	int count=0;
	for(i=0;i<p->n;i++){
		if(p->nei[i]==-1)
			continue;
		for(j=0;j<node[p->nei[i]]->n;j++){
			if(node[p->nei[i]]->nei[j]==-1)
				continue;
			for(k=0;k<p->n;k++){
				if(p->nei[k]==-1)
					continue;
				if(node[p->nei[i]]->nei[j]==p->nei[k])
					count++;
			}
		}
	}

	return count;
}
void rem(struct node *p,struct node *nodes[],int n){
	int i,j;
	for(i=0;i<n;i++){
		if(nodes[i]==NULL)
			continue;
		for(j=0;j<nodes[i]->n;j++)
			if(nodes[i]->nei[j]==p->id)
				nodes[i]->nei[j]=-1;
	}
}
int dfs3(struct card piles[],int n,int a[55][55][55][55]){
	int dfs1(struct card[],int,int [][][][]);
	if(n<=3)
		return 0;
	if(a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]!=-1)
		return a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id];
	if(piles[n-1].suit==piles[n-4].suit || piles[n-1].val==piles[n-4].val){
		struct card p[n];
		int i;
		for(i=0;i<n;i++){
			p[i].suit=piles[i].suit;
			p[i].val=piles[i].val;
			p[i].id=piles[i].id;
		}
		p[n-4].suit=p[n-1].suit;
		p[n-4].val=p[n-1].val;
		p[n-4].id=p[n-1].id;
		if(dfs1(p,n-1,a) || dfs3(p,n-1,a))
			return a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]=1;
		else
			return a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]=0;
	}
	return a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]=0;
}
int dfs1(struct card piles[],int n,int a[55][55][55][55]){
	if(n==1)
		return a[n][piles[0].id][0][0]=1;
	if(n==2)
		if(a[n][piles[n-1].id][piles[n-2].id][0]!=-1)
			return a[n][piles[n-1].id][piles[n-2].id][0];
	if(n>2)
		if(a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]!=-1)
					return a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id];
	if(piles[n-1].val==piles[n-2].val || piles[n-1].suit==piles[n-2].suit){
		struct card p[n-1];
		int i;
		for(i=0;i<n-1;i++){
			p[i].suit=piles[i].suit;
			p[i].val=piles[i].val;
			p[i].id=piles[i].id;
		}
		p[n-2].val=piles[n-1].val;
		p[n-2].suit=piles[n-1].suit;
		p[n-2].id=piles[n-1].id;
		if(n==2)
			return a[n][piles[n-1].id][piles[n-2].id][0]=1;
		else {
			if(dfs1(p,n-1,a) || dfs3(p,n-1,a))
				return a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]=1;
			else
				return a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]=0;
		}
	}
	return a[n][piles[n-1].id][piles[n-2].id][piles[n-3].id]=0;
}
main(){
	char s[20];
	int i,j,k,l,idx=1;
	struct card piles[55];
	getword(s,20);
	int n=atoi(s);
	for(i=0;i<n;i++){
		piles[i].val=getchar();
		piles[i].suit=getchar();
		for(j=0;j<i;j++)
			if(piles[j].suit==piles[i].suit && piles[j].val==piles[i].val){
				piles[i].id=piles[j].id;
				break;
			}
		if(i==j)
			piles[i].id=idx++;
		getchar();
	}
	int a[n+1][idx+1][idx+1][idx+1];
	for(i=0;i<=n;i++)
		for(j=0;j<=idx;j++)
			for(k=0;k<=idx;k++)
				for(l=0;l<=idx;l++)
					a[i][j][k][l]=-1;
	if(dfs1(piles,n,a) || dfs3(piles,n,a))
		printf("YES");
	else
		printf("NO");
	return 0;
}


#include <iostream>
#include<string.h>
using namespace std;

int main ()
{

string arr;

cin >> arr;

int x, y, z, i = 0;

x = arr.find ('+'); //sticks before plus

y = arr.find ('=') - x - 1; //sticks btw plus and equal

z = arr.length () - y - x - 2; //sticks after equal

if ((x + y) == z)

    {

cout << arr << "\n";

}

  else if ((x + y + 1) == (z - 1))

    {

for (i = 0; i < x + 1; i++)

	{

cout << '|';

}

cout << '+';

for (i = 0; i < y; i++)

	{

cout << '|';

}

cout << '=';

for (i = 0; i < z - 1; i++)

	{

cout << '|';

}

}

  else if ((x > 1) && ((x + y - 1) == (z + 1)))

    {

for (i = 0; i < x - 1; i++)

	{

cout << '|';

}

cout << '+';

for (i = 0; i < y; i++)

	{

cout << '|';

}

cout << '=';

for (i = 0; i < z + 1; i++)

	{

cout << '|';

}

}

  else if ((y > 1) && ((x + y - 1) == (z + 1)))

    {

for (i = 0; i < x; i++)

	{

cout << '|';

}

cout << '+';

for (i = 0; i < y - 1; i++)

	{

cout << '|';

}

cout << '=';

for (i = 0; i < z + 1; i++)

	{

cout << '|';

}

}

  else

cout << "Impossible";

return 0;

}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
    long long int i,n,m,k,l,r,cnt,mid;
    scanf("%I64d%I64d%I64d",&n,&m,&k);
    left=1;
    right=n*m+1;
    while (l<r)
    {
        mid=(l+r)/2;
            cnt=0;
            for(i=1;i<=n;i++)
                cnt+=fmin(m,(mid-1)/i);
            if (cnt<k)
            l=mid+1;
            else
                r=mid;
    }
    printf("%I64d\n",l-1);
    return 0;
}


#include<stdio.h>
int main(){
 int t;
 scanf("%d",&t);

 while(t--){
  int n,k;
  int max=1e9+7;
  scanf("%d%d",&n,&k);
  long long int ans=1;
  for(int i=1;i<=n;i++){
   ans=(ans*i)%max;
  }
  printf("%lld",ans)
 }
 return 0;
}


#include<iostream>
#include<algorithm>
#include<cstring>
long long int mod = 1000000007;
long long int add(long long int a, long long int b)
{
	long long temp = a + b;
	return (temp%mod);
}
long long int mult(long long int a, long long int b)
{
	long long temp=a*b;
	return (temp%mod);
}
long long int f[500001];
int main()
{
	long long int l, r, t,i;
	scanf_s("%I64d %I64d %I64d", &t, &l, &r);
	for (i = 0; i <= r; i++)
		f[i] = 1e18;
	long long int ans=0,power=1,j,temp,g;
	f[1] = 0;
	for (i = 1; i <= r; i++)
	{
		for (j = 2 * i; j <= r; j += i)
		{
			g = j / i;
			temp = add(mult(((g*(g - 1)) / 2), i), f[i]);
			if (f[j] > temp)
				f[j] = temp;
		}
	}
	for (i = l; i <= r; i++)
	{
		ans = add(ans, mult(power, f[i]));
		power *= t;
	}
	printf("%I64d\n", ans);
	fflush(stdin);
	getchar();
	return 0;
}


#include<stdio.h>
char s[30];
int a[30];
int main()
{
    scanf("%s",s);
    int target=s[0]-'A'+1;
    int last=target;
    a[0]=target;
    for(int i=1;s[i]!='\0';i++)
    {
        int temp=s[i]-'A'+1;
        a[i]=temp;
        if(temp==last)
        {
            printf("Impossible\n");
            return 0;
        }
        last=temp;
    }
    for(int i=0;i<=26;i++)
    {
        for(int j=i+1;j<=26;j++)
            if(a[i]==a[j])
                target=a[i];
    }
    int flag=0;
    int start,end;
    start=end=0;
    for(int i=0;i<=27;i++)
    {
        if(a[i]==target&&flag==0)
            start=i,flag=1;
        else if(a[i]==target&&flag!=0)
            end=i;
    }
    int mid=(end-start-1)/2+start;
    //printf("%d\n",mid);
    if(mid>13){
        for(int i=mid-13;i<mid;i++)
            printf("%c",a[i]+'A'-1);
        printf("\n");
        for(int i=mid-14;i>=0;i--)
            printf("%c",a[i]+'A'-1);
        for(int i=26;i>=mid;i--)
        {
            if(i==end) continue;
            printf("%c",a[i]+'A'-1);
        }
        printf("\n");
    } else
    {
        for(int i=mid+1;i<=mid+13;i++)
            printf("%c",a[i]+'A'-1);
        printf("\n");
        for(int i=mid;i>=0;i--)
        {
            if(i==start) continue;
            printf("%c",a[i]+'A'-1);
        }
        for(int i=26;i>=mid+14;i--)
            printf("%c",a[i]+'A'-1);
        printf("\n");
    }

    return 0;
}


#include <stdio.h>
#include <math.h>
#define ll long long int
int main()
{
	ll a,b;
	scanf("%I64d%I64d",&a,&b);
	if(a==b)
	{
		printf("infinity\n");
	}
	else
	{
		ll i,num=a-b;
		ll ans=1;
		for(i=2;i<=sqrt(num);i++)
		{
			if(num%i==0)
			{
				if(a%i==b)
				{
					ans+=1;
				}
				if(i!=num/i)
				{
					if(a%(num/i)==b)
						ans+=1;
				}
			}
		}
		printf("%I64d\n"ans);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int jl[100];
int main()
{

    int n,k,c=0;
    cin>>n>>k;
    if(k==1)
    {
        cout<<n<<endl;
        return 0;
    }
    for(int i=2; n!=1; i++)
    {
        if(n%i==0)
        {
            n/=i;
            jl[c++]=i;
            if(c==k)
            {
                for(int j=0;j<k-1; j++)
                {
                    printf("%d ",jl[j]);
                }
                printf("%d\n",n*jl[c-1]);
                return 0;
            }
            i--;

        }
    }
    printf("-1\n");
}


#include <stdio.h>

int lTime(int h, int a, int d) {
    int i=-1;
    if(d>=a) return 999999999;
    while(h>0){
        h=h-(a-d);
        i++;
    }
    return i;
}
int main() {
    int yh,ya,yd;
    int mh,ma,md;
    int h,a,d;
    int lh,la,ld=1000;
    int i,j,k,cost,min=999999999,yaa=0;
    scanf("%d %d %d",&yh,&ya,&yd);
    scanf("%d %d %d",&mh,&ma,&md);
    scanf("%d %d %d",&h,&a,&d);
/*
    for(i=0;i<10000;i++)
        if(lTime(yh+i,ma,yd)>lTime(mh,ya,md))
            break;
    lh=i;
    for(i=0;i<10000;i++)
        if(lTime(yh,ma,yd)>lTime(mh,ya+i,md))
            break;
    la=i;
    for(i=0;i<10000;i++)
        if(lTime(yh,ma,yd+i)>lTime(mh,ya,md))
            break;
    ld=i;
*/
    lh=(h>10)?10000/h:1000;
    la=(a>10)?10000/a:1000;
    ld=(d>10)?10000/d:1000;
    if(ya<=md) yaa=md-ya+1;
//  printf("%d %d %d\n",lh,la,ld);
    for(i=0;i<lh;i++){
        for(j=yaa;j<la;j++) {
            for(k=0;k<ld;k++) {
                if(lTime(yh+i,ma,yd+k)>lTime(mh,ya+j,md)) {
                    cost=i*h+j*a+k*d;
                    if(cost<min) {
                        min=cost;
//                      printf("%d %d %d %d\n",i,j,k,cost);
                    }
                }
            }
        }
    }
    printf("%d\n",min);
    return 0;
}


#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
    char s[100], r[100], back[100];
    int ch[26] = {0};
    cin>>s;
    sort(s, s+strlen(s));
    //cout<<s<<endl;
    for(int i=0; i<strlen(s); i++){
        ch[s[i]-'a']++;
    }
    int i=0;
    for(i=25; i>=0 && ch[i]==0; i--){

    }
    int k=0;
    for(int j=0; j<ch[i]; j++){
        r[k++] = i+'a';
    }
    r[k] = '\0';
    cout<<r<<endl;
    return 0;
}


#include<stdio.h>
#include<math.h>
#define MAX 100
void nhapmang(int a[], int n)
{
	for (int i = 0; i<n;i++)
	{
		scanf("%d", &a[i]);
	}
}
void rutgon(int a[], int &n)
{
	for (int i = 0; i<n-1;i++)
	{
		for(int j = i+1;j<n;j++)
		{
			if(a[i]==a[j])
			{
				for(int k=j;k<n-1;k++)
				{
					a[k]=a[k+1];

				}
				n--;
				j--;
			}
		}
	}
}
int xetdk(int a[], int n)
{

	if(n==3)
	{
		if(a[0]+a[1]==a[2]*2) return abs(a[2]-a[0]);
		if(a[0]+a[2]==a[1]*2) return abs(a[1]-a[0]);
		if(a[2]+a[1]==a[0]*2) return abs(a[0]-a[1]);
	}
	if(n==2)
	{
		if((a[0]+a[1])%2==0)
		 	return abs((a[0]+a[1])/2-a[0]);
		else
			return abs(a[1]-a[0]);
	}
	return -1;
}
int main()
{
	int n, a[MAX];
	scanf("%d",&n);
	nhapmang(a,n);
	rutgon(a,n);
	printf("%d", xetdk(a,n));

}


#include <stdio.h>
int i, n, c;
int main() {
  scanf("%d", &n);
  while (n) {
    i++;
    if (i & 1) {
      if (n > 0) n--;
      else break;
      c++;
    } else {
      if (n > 1) n -= 2;
      else break;
      c++;
    }
  }
  print("%d", c);
}


#include<stdio.h>
#include<math.h>
main()
{
      long long int xa,xb,xc,ya,yb,yc ;
      scanf("%I64d%I64d",&xa,&ya);
      scanf("%I64d%I64d",&xb,&yb);
      scanf("%I64d%I64d",&xc,&yc);
      double m1 , m2 ;
      if(xb!=xa)
      m1=atanf((yb-ya)/(xb-xa));
      else
      m1=asinf(1);
      if(xc!=xb)
      m2=atanf((yc-yb)/(xc-xb));
      else
      m2=asinf(1);
      if(m1==m2)
      printf("TOWARDS");
      else if(m2>m1)
      printf("LEFT");
      else
      printf("RIGHT");
      getch();
      }


#include <stdio.h>

int main()
{
	int a,b,c;
	int two = 0,three = 0,four = 0;
	scanf("%d%d%d",&a,&b,&c);
	int miny = 2000;
	if (a < miny) miny = a;
	if (b < miny) miny = b;
	if (c < miny) miny = c;

	if (a == 2) two++;
	if (b == 2) two++;
	if (c == 2) two++;

	if (a == 3) three++;
	if (b == 3) three++;
	if (c == 3) three++;

	if (a == 4) four++;
	if (b == 4) four++;
	if (c == 4) four++;

	if (miny > 3) printf("NO\n");
	else
	{
		if (miny == 1) printf("YES\n");
		else if (three == 3) printf("YES\n");
		else
		{
			if (two == 2 || two == 3) printf("YES\n");
			else if (two == 1 && three == 2) printf("YES\n");
			else if (four == 2 && two == 1) printf("YES\n");
			else printf("NO\n");
		}
	}

	return 0;
}


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

typedef long long int lli;

lli FindFor(lli X)
{
	   lli ans=1;

	if(X%2==0)
	{
		  ans=2;
		  while(X%2==0)
			X>>=1;
	}

	for(lli i=3;i<=sqrt(X);i+=2)
	{
		if(X%i==0)
		{
			ans=ans*i;
			while(X%i==0)
				X=X/i;
		}
	}

	  if(X>2)
		ans=ans*X;

	return ans;
}

int main()
{
   lli N;

  scanf("%I64d",&N);
   printf("%I64d",FindFor(N));

	return 0;
}


//       In the name of         ****                      God                     ****

/*

Copyright (C)          oofMan

                                   Morocco

created : 30/3/2019

*/
#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

inline void oofMan() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}

char m[4][4];
int main(void) {
	//oofMan();
	bool flag=false;
	int xc[3]={1,0,1};
	int yc[3]={0,1,1};
	for(int i=0 ;i<4 ;i++)
		for(int j=0 ; j<4 ;j++)
			scanf("%c",&m[i][j]);

	for(int i=0 ;i<3 ;i++)
		for(int j=0 ; j<3 ;j++){
			int counter=0;
			for(int k=0;k<3;k++){
				if(i+xc[k]<4 && j+yc[k]<4)
					if(m[i][j]!=m[i+xc[k]][j+yc[k]])
						counter++;
			}
			if(counter==3 || counter<=1){
				flag=true;
				break;
			}

		}

	printf("%s",(flag?"YES":"NO"));

}


#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int f(int n,int v,int k)
{
    int s=0,m;
    for(m=1;(int)(v/m)>0;m=m*k)
    {
        s+=(int)(v/m);
    }
    if(s==n||s>n)
    {
        f(n,v-1,k);
    }
    else
        return v+1;
}

int main()
{
    int m,n,i,k,s;
    scanf("%d %d",&n,&k);
    m=n;
    i=f(n,m,k);
    printf("%d",i);
   // getch();
    return 0;
}


#include<stdio.h>

#define F(I) for(int i=0;i<n;i++)
#define F(J) for(int j=0;j<n;j++)

int main(){
    int T,S,q; int wehere=0,start=0;
    scanf("%d %d %d",&T,&S,&q);
    while(wehere<T){
    wehere=S+(q-1);
    start++;
    }
    printf("%d",start);
    return 0;
}


#include <stdio.h>
int main(void) {
    int l, r, s, p;
    bool res = false;
    for(int i = 0; i < 4; i++) {
        scanf("%d%d%d%d", &l, &r, &s, &p);
        if(p == 0) continue;
        else if(l | r | s == 1) res = true;
    }
    puts(res ? "YES" : "NO");
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int arr[101];
int n,dis;
int min(int x,int y)
{
	return x<y?x:y;
}
int comparator (const void * b, const void * a)
{
  return ( *(int*)b - *(int*)a );
}
int recur(int start,int end)
{
	if(start==end)
	 return 0;
	if(arr[end]-arr[start]<=dis)
	 return 0;
	int q1=recur(start+1,end);
	int q2=recur(start,end-1);
	return 1+min(q1,q2);
}
int main()
{
	scanf("%d %d",&n,&dis);
	//printf("%d\n",dis);
	int i,j,k;
	for(i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);
	}

	qsort(arr,n,sizeof(int),comparator);
	if(dis>arr[n-1])
	 printf("%d\n",n-1);
	else
	printf("%d\n",recur(0,n-1));
}


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

int main(){
int s,i,j,n,k,L[50];
printf("entrez n ;");
scanf('%d',&n);

while (s<=n){
s=s+i;
L[i-1]=i;
i=i+1;
}
if(s-i-1!=n){
   int j=n-s+i+1;
    for(i=0;i!=j;i++){
        L[i]+=1;
    }
}

}


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

int main(int argc, char *argv[])
{
	int i,cnt=0,a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a!=b)
		cnt++;
	if(c!=b&&c!=a)
		cnt++;
	if(d!=c&&d!=v&&d!=a)
		cnt++;
	printf("%d",cnt);
}


#include <bits/stdc++.h>
using namespace std;
int  s[2501][15]={0};
int s1[15]={0};
void  bit(int a)
{   int t=0;
    int b=a;
    while(a!=0)
    {
        s[b][t]=a%2;
        a=a/2;
        t++;
    }
  //  for(int i=0;i<13;i++)
   //  printf("%d ",s[b][i]);
  //  printf("\n");
}
long long int f(int i,int j)
{
    int sign=1;
    for(int a=13;a>=0;a--)
    {
        if(s[i][a]==s[j][a]&&sign==1&&s[i][a]==0)
            continue;
        else
            sign=0;
       if(s[i][a]==s[j][a])
            s1[a]=1;
        else
            s1[a]=0;}
    int c =0;
    for(int a=0;a<13;a++)
    {
        c=c+pow(2,a)*s1[a];
    }
    if(i==c||j==c)
        return 0;
    if(i+j<=c||j+c<=i||i+c<=j)
        return 0;
    else
    {
      //  printf("%d  %d  %d\n",i,j,c);
    return 1;
    }

}

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        bit(i);
    }
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i==j)
                continue;
            if(f(i,j))
                sum++;
        }
    }
    printf("%d",sum/6);
    return 0;
}


#include <cstdio>

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


#include <stdio.h>
#include <stdlib.h>
int compare(const void *data1,const void *data2){
	int *ptr1 = (int *)data1;
	int *ptr2 = (int *)data2;
	return (data1 > data2)? 1 : -1;
}
int main(){
	int n;
	int arr[100];
	scanf("%d",&n);
	for(int i = 0;i<n;i++){
		scanf("%d",&arr[i]);
	}
	int fuck1 = arr[2];
	qsort(arr,n,sizeof(int),compare);
	int fuck2 = arr[0];
	int fuck = fuck1+fuck2;
	printf("%d\n",fuck);
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define EPS 1e-11
#define SQ(x) ((x)*(x))
#define EQ(x,y) (fabs((x)-(y))<EPS)

int r,h;
double ax,ay,az,ad,bx,by,bz,bd,d,th,ha,hb,temp1,temp2;

void print(double a){exit(!printf("%.14f\n",a));}
void swap(double*a,double*b){double temp=*a;*a=*b;*b=temp;}
double hypot3(double x,double y,double z){return sqrt(x*x+y*y+z*z);}

double hh(double thp,double th){
    double lr,lb,bth;
    double tx=r*cos(th),ty=r*sin(th);
    lr=r*(1-cos(thp+th));
    bth=acos((tx*bx+ty*by)/(r*hb));
    lb=sqrt(SQ(d)+SQ(bd)-2*d*bd*cos(bth*r/d));
    return lr+lb;
}

double g(double th){
    double la,ath,sx,sy;
    double blg,brg,bllg,brrg,bld,brd;
    sx=r*cos(th); sy=r*sin(th);
    ath=acos((sx*ax+sy*ay)/(r*ha));
    la=sqrt(SQ(d)+SQ(ad)-2*d*ad*cos(ath*r/d));

    blg=0; brg=2*M_PI;
    while(brg-blg>EPS){
        bllg=(blg*19+brg)/20; brrg=(blg+brg*19)/20;
        bld=hh(th,bllg); brd=hh(th,brrg);
        bld>brd?blg=bllg:(brg=brrg);
    }
    return la+bld;
}

double f(double th){
    double tx=r*cos(th),ty=r*sin(th),lr,lb;
    lr=hypot(ax-tx,ay-ty);
    th=acos((tx*bx+ty*by)/(r*hb));
    lb=sqrt(SQ(d)+SQ(bd)-2*d*bd*cos(th*r/d));
    return lr+lb;
}

main(){
    int i,j;
    double ans=1e9,alg,arg,allg,arrg,ald,ard;

    scanf("%d%d%lf%lf%lf%lf%lf%lf",&r,&h,&ax,&ay,&az,&bx,&by,&bz);
    if(EQ(ax,bx)&&EQ(ay,by)&&EQ(az,bz)) print(.0);
    if(az<EPS&&bz<EPS) print(hypot(ax-bx,ay-by));
    if(bz<az)swap(&ax,&bx),swap(&ay,&by),swap(&az,&bz);
    ad=hypot3(ax,ay,az-h); bd=hypot3(bx,by,bz-h);
    d=hypot(h,r);
    ha=hypot(ax,ay); hb=hypot(bx,by);
    th=acos((ax*bx+ay*by)/(ha*hb));

    if(az<EPS&&!EQ(ha,r)){
        if(EQ(bz,h)) print(d+r-ha);
        alg=0; arg=2*M_PI;
        while(arg-alg>EPS){
            allg=(alg*19+arg)/20; arrg=(alg+arg*19)/20;
            ald=f(allg); ard=f(arrg);
            ald>ard?alg=allg:(arg=arrg);
        }
        print(ald);
    }
    if(EQ(bz,h)) print(ad);
    temp1=sqrt(SQ(ad)+SQ(bd)-2*ad*bd*cos(th*r/d));
    alg=0; arg=2*M_PI;
    while(arg-alg>EPS){
        allg=(alg*19+arg)/20; arrg=(alg+arg*19)/20;
        ald=g(allg); ard=g(arrg);
        ald>ard?alg=allg:(arg=arrg);
    }
    temp2=ald;
    print(temp1<temp2?temp1:temp2);
    return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    while(1)
    {
        long long int a,b,c,n,A1=0,A2=0;;
        scanf("%lld\n%lld\n%lld\n%lld",&n,&a,&b,&c);
        if(n>=b) A1=1+(n-b)/(b-c)+((n-b)%(b-c)+c)/a;
        if(n>=a) A2=1+n/a+max((n%a-b)/(b-c),(long long int)0);
        printf("%lld\n",max(A1,A2));
    }
    return 0;
}


#include <stdio.h>
unsigned int a,b;
char c;
int main()
{
	float f,l;
	int k,i=0;
	bool key=false;
	scanf("%d %d %d",&a,&b,&c);
	f=(float)a/b*10;
	k=(int)f;

	while (i<1000 && key==false)
	{
		k=k%10;
		if (k==c) key=true;
		l=(a-k*0.1*b)*10;
		a=(int)l;
		f=(float)a/b*10;
		k=(int)f;
		i++;
	}
	if (key==true) printf("%d",i);
	else printf("-1");
}


#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, temp;
	scanf("%d %d", &n, &k);
	long long dp[5], sum, tt;
	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, n - i) - 1;
			sum -= (tt - temp) * dp[j];
			temp += tt - temp;
		}
		dp[i] = sum;
	}

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


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

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

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

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

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

    if(cnt % (k+1) || ok_v){
      puts("First");
    } else {
      puts("Second");
    }
  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;
        if(n==1){
            cout<<1<<endl;
        }
        else{
            cout<<pow(2,n)<<endl;
        }
    }
    return 0;
}


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

int main()
{
    char str[102];
    while ((scanf("%s", str)))
    {
        int length = strlen(str);
        int count = 0;
        int i = 0;
        while (i < length)
        {
            int j = i + 1;
            while (j < length && str[j] == str[j - 1])
                j++;

            int diff = j - i;
            if (diff && diff % 2 == 0)
                count++;

            i = j;
        }
        print("%d\n", count);
    }

    return 0;
}


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

#define mset(a) memset(a,0,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
#define mcmp(a,b,n) memcmp(a,b,n)
#define maxint 2147483647
#define pi 3.14159265358979323846

long long n,t,ans=0,k;
long long a[111],cnk[111][111];

long long turn(long long t)
{
     long long i=0;

     if(t&(t-1))
       return -1;

     while(t>>=1)
       i++;
     return i;
}

int main()
{
    int i,j,l;

    a[0]=1;
    for(i=1;i<63;i++)
      a[i]=a[i-1]<<1;
    mset(cnk);
    for(i=0;i<111;i++)
      {
        cnk[i][0]=1;
        for(j=1;j<=i;j++)
          cnk[i][j]=cnk[i-1][j-1]+cnk[i-1][j];
      }

    scanf("%I64d%I64d",&n,&t);

    k=turn(t);
    if(k==-1)
      {
        printf("0\n");
        return 0;
      }

    for(i=1;n>a[i];i++)
      {
        ans+=cnk[i][k];
        n-=a[i];
      }
    for(i=62;i>=0;i--)
      if((~k)&&(n>>i&1))
        {
          ans+=cnk[i][k];
          k--;
        }

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

    //system("pause");
    return 0;
}


include<stdio.h>
int main()
{
    int a;
 scanf("%d",&a);

  if(a%2==0)
    printf("0");
else
     printf("1");
  return 0;
}


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

int64_t x, y;
int n_0, n_1, m;
int s_0[100], s_1[100], t[100];

void build(int64_t value, int* buffer, int* size, bool keep_trailing_zero) {
    *size = 0;
    if (!keep_trailing_zero)
        while (value % 2 == 0) value /= 2;
    while (value > 0) {
        buffer[(*size)++] = value % 2;
        value /= 2;
    }
}

void reverse(int* a, int size) {
    for (int i = 0, j = size - 1; i < j; i++, j--) {
        a[i] ^= a[j];
        a[j] ^= a[i];
        a[i] ^= a[j];
    }
}

bool try_match(int* s, int n, int* t, int m) {
    for (int i = 0; i + n <= m; i++) {
        if (t[i] == 0) break;
        bool good = true;
        for (int j = 0; j < n; j++) {
            if (t[i + j] != s[j]) {
                good = false;
                break;
            }
        }
        if (!good) continue;
        for (int j = i + n; j < m; j++) {
            if (t[j] == 0) {
                good = false;
                break;
            }
        }
        if (good) return true;
    }
    return false;
}

void solve() {
    scanf("%lld %lld", &x, &y);
    if (x == y) {
        printf("YES\n");
        return;
    }
    build(x, s_0, &n_0, false);
    build(x * 2 + 1, s_1, &n_1, true);
    build(y, t, &m, true);
    if (try_match(s_0, n_0, t, m)) {
        printf("YES\n");
        return;
    }
    reverse(s_0, n_0);
    if (try_match(s_0, n_0, t, m)) {
        printf("YES\n");
        return;
    }

    if (try_match(s_1, n_1, t, m)) {
        printf("YES\n");
        return;
    }
    reverse(s_1, n_1);
    if (try_match(s_1, n_1, t, m)) {
        printf("YES\n");
        return;
    }

    printf("NO\n");
}

int main() {
    int t = 1;
    // scanf("%d", &t);
    while (t--) solve();
}


#include<stdio.h>
#include<string.h>
int main() {
  char s[100+1];
  char t[100+1];
  scanf("%s",s);
  scanf("%s",t);
  int s_count[256];
  int t_count[256];
  int i;
  for(i=0;i<256;i++){
    s_count[i]=0;
    t_count[i]=0;
  }
  for(i=0;i<strlen(s);i++) {
    s_count[s[i]]++;
  }
  for(i=0;i<strlen(t);i++) {
    t_count[t[i]]++;
  }
  int more=0;
  int less=0;
  for(i='a';i<='z';i++) {
    if(s_count[i]<t_count[i]) less=1;
    else if(s_count[i]>t_count[i]) more=1;
  }
  int within=0;
  int j;
  while(i<strlen(s) && j<strlen(t)) {
    if(s[i]==t[j]) {
      i++;j++;
    } else {
      i++;
    }
  }
  if(j==strlen(t))within=1;
  if(!more && !less) {
    if(within==1)
      printf("need tree\n");
      //s,t is same and can't swap and delete.
    else
      printf("array\n");//s,t have same length, and s don't contain t,so we can only swap them to change s to t;
  }else if(less) {
    printf("need tree\n");//s don't have enough chars to delete to t or swap to t;
  }else if(more) {
    if(within==0)
      printf("both\n");//more and not within,so we should delete more words and swap wrong order chars;
    else
      //we can only use delete to get t,because s contains t;
      printf("automaton\n");
  }


#include <stdio.h>
#include <math.h>
int main(){
    long int n, i, a, b, c;
    scanf("%ld", &n);

    a = sqrt(n)/1;
    if(n > a*a && n <= a*(a+1)) printf("%ld", 2*a+1);
    if(n > a(a+1)) printf("%ld", 2*a+2);
    if(n == a*a)printf("%ld", 2*a);
    return 0;
}


#include<bits/stdc++.h>
cmpfun(const void*a,const void*b)
{
	return(*(int*)a-*(int*)b);
}
int main()
{
	int i,j,k,l,m,z=0,w=0,n;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	qsort(a,n,sizeof(int),cmpfun);
	k=a[0];
	a[0]=a[n-1];
	a[n-1]=k;
	for(i=0;i<n;i++)
	{
		printf("%d ",a[i]);
	}
	return 0;
}


#include <stdio.h>
int main()
{
int n;
scanf("%d",&n);
printf("%d", (n/2)+1);


#include <stdio.h>
int main(){
	long long a,b,x,y,count=0,m,n,l,k,gcd;
	scanf("%I64d %I64d %I64d %I64d",&a,&b,&x,&y);
	m=x;n=y;
	while(m!=n)
	{
		if(m>n)
		m=m-n;

		if(n>m)
		n=n-m;
	}
	gcd=m;
	y=y/m;
	x=x/m;
	a=a/x;
	b=b/y;
	if(a>b)
	printf("%I64d",b);
	else if
	printf("%I64d",a);

}


#include<stdio.h>
int main()
{
    int c,b;
    scanf("%c%d",&a,&c);

    b=c%2;
    if(b!=0){printf("1");

    }
    else
    printf("%d",b);
    return 0;
}


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

int main()
{
    int count[2000] ={0};
    int arr[1000] ={0};
    int n,m,i;
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++){
        scanf("%d",&arr[i]);
        count[arr[i]]++;
    }
    int max = m;
    if(max==0){
        printf("0");
        return 0;
    }
    int brr[1000];
    int b = 0;
    for(i=0;i<200;i++){
        if(count[i]>0){
            brr[b]=i;
            b++;
        }
    }

    while(max>=0){
        int f = 0;
        for(i=0;i<n;i++){
            f = f + count[brr[i]]/max;
        }
        if(f>=n){
            printf("%d\n",max);
            return 0;
            break;
        }
        max = max - 1;
    }

}


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

    return 0;
}


#include <stdio.h>

void   caballo (int m[][9], int f, int c)
{
/*8 mov tiene el caballo*/

    /*derecha 1 cuadro*/
  if(c+2<9 && f-1>0)/*9 final del tablero, arriba derecha columna+2*/
  {
    m[f-1][c+2]=1;

  }
    if(c+1<9 && f-2>0)/*9 final del tablero, arriba derecha columna+1*/
  {
    m[f-2][c+1]=1;
  }

  /*abajo derecha*/
    if(c+1<9 && f+2<9)/*9 final del tablero, arriba derecha colu+1*/
  {
    m[f+2][c+1]=1;
  }
    if(c+2<9 && f+1<9)/*9 final del tablero, arriba derecha colu+2*/
  {
    m[f+1][c+2]=1;
  }

  /*izquierda arriba*/
    if(c-1>0 && f-2>0)/* arriba del tablero, arriba izquierda fi-2*/
  {
    m[f-2][c-1]=1;
  }
    if(c-2>0 && f-1>0)/*arriba del tablero, arriba derecha fi-1*/
  {
    m[f-1][c-2]=1;
  }

  /*izquierda abajo*/
    if(c-1>0 && f+2<9)/*9 final del tablero, arriba derecha fi+2*/
  {
    m[f+2][c-1]=1;
  }
    if(c-2>0 && f+1<9)/*9 final del tablero, arriba derecha co+1*/
  {
    m[f+1][c-2]=1;
  }
  /*fin funcion*/

}

void torre (int m[][9], int f,int c)
{
    int aux;

    /*fila torre llenar de 1s*/
    for(aux=1; aux<=8; aux++)
    {
        m[f][aux]=1;
    }

        /*fila torre llenar de 1s*/
    for(aux=1; aux<=8; aux++)
    {
        m[aux][c]=1;
    }

}

void inici (int m[][9])
{
    int i,j;
    /*imprimir matriz*/
    for(i=1; i<9; i++){
        for(j=1; j<9; j++)
            m[i][j]=0;

    }
}

void resultado(int m[][9])
{
    int i,j,con=0;
    /*imprimir matriz*/
    for(i=1; i<9; i++){
        for(j=1; j<9; j++)
            if(m[i][j]==0)
                con++;
    }

    printf("%d",con);
}

main()
{

int ma[9][9]={0};
int i,j,i2;
char c;

/*primera linea entra torre*/
scanf("%c %d",&c,&i);
j=(int)c-'a';
j++; /*se pasa la letra a numero +1*/
i=9-i;/*posicion de fila invertida*/

inici(ma);
ma[i][j]=1;/*primera linea*/

/*se colocan 1s para la posicion del caballo y torre*/
caballo (ma,i,j);
torre (ma,i,j);

/*segunda linea*/
scanf("%1s %d",&c,&i2); /*guarda un solo caracter en la variable*/

j=(int)c-'a';
j++; /*se pasa la letra a numero +1*/
i2=9-i2;/*posicion de fila invertida*/
ma[i2][j]=1;/*primera linea*/

/*se colocan 1s para la posicion del caballo y torre*/
caballo (ma,i2,j);

resultado(ma);

}


#include<stdio.h>
int n, cube[3][6],v[3];

int dfs(int num){
	if (num == 0)return 1;
	for (int i = 0; i < n; i++){
		if (v[i])continue;
		int f = 0;
		for (int j = 0; j < 6; j++)
			if (num % 10 == cube[i][j])f = 1;
		if (!f)continue;
		v[i] = 1;
		if (dfs(num / 10))return 1;
		v[i] = 0;
	}
	return 0;
}
void main(){
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		for (int j = 0; j < 6; j++)scanf("%d", &cube[i][j]);

	for (int i = 0; i < 1000; i++){
		for (int j = 0; j < n; j++)v[j] = 0;
		if (!dfs(i)){
			printf("%d\n", i - 1);
			return;
		}
	}
}


#include<stdio.h>
long long product(char *ch){
     long long pr=1;
     if(ch[0]=='0')ch[0]='1';
     for(int i=0;ch[i]!='\0'; i++){
         pr=pr*(ch[i]-48);
     }
return pr;
}

int main(){

    char inp[12];
   long long in,pr,maxpr=0;
   gets(inp);
    pr=product(inp);
   if(pr>maxpr)maxpr=pr;
   int len=strlen(inp);
   for(int i=len-1;i>0; i--){
   if(inp[i]!='9'){
    inp[i]='9';
    if(inp[i-1]=='0'){
        inp[i-1]='9';
        if(inp[i-2]!='0')inp[i-2]--;
    }
    else inp[i-1]--;
   }
   pr=product(inp);
   if(pr>maxpr)maxpr=pr;
   }

printf("%ld",maxpr);

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int c,ha,hb,wa,wb;
int max1(int i)
{
	int k,j,count = 0;
	for(j = 0;j<=(c-i*wa)/wb;j++)
	{
		k = i*ha+j*hb;
		if(count < k)
			count = k;
	}
	return count;
}
int main()
{
	int ans = 0,i,j,k;
	float xa,xb,yw,yh,m = 3.3333*pow(10,4);
	scanf("%d%d%d%d%d",&c,&ha,&hb,&wa,&wb);
	if(wa<wb)
	{
		yw = wa;
		wa = wb;
		wb = yw;
		yh = ha;
		ha = hb;
		hb = yh;
	}
	if(wa>=m)
	{
		for(i = 0;i<m;i++)
		{
			k = max1(i);
			if(ans < k)
				ans = k;
		}
	}
	xa = (ha*10000)/wa;
	xb = (hb*10000)/wb;
	if(xa>xb)
	{
		yw = wa;
		wa = wb;
		wb = yw;
		yh = ha;
		ha = hb;
		hb = yh;
	}
	for(i = 0;i<=c/wb;i++)
	{
		k = max1(i);
		if(ans < k)
			ans = k;
	}
	printf("%d",ans);
	return 0;
}


#include <stdio.h>

int main(void)
{
    long long int n;
    long long int original_m;
    scanf("%ld", &n);
    scanf("%ld", &original_m);

	long long int m = original_m;

	long long int r = 1;
	long long int t = 1;

	while( m >= 1) {
		r = 1;
		while (r < t && t <= n) {
			m--;
			r++;
		}
		t++;
	}
	long long int count = n - r;

	long long int tempo = 1;
	long long int i = 2;
	m = original_m;
	long long int count_max = 1;

	while (m>= 1) {
		if (i>n) {
			count_max = 0;
			break;
		}
		m--;
		tempo+=2;
		i+=2;
	}
	if (count_max != 0) {
		count_max = n - tempo + 1;
	}

	printf("%ld ", count_max);
	printf("%ld\n", count);

    return 0;
}


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

int main()
{
    int n, m, x1, y1, x2, y2;

    scanf("%d %d %d %d %d %d", &n, &m, &x1, &y1, &x2, &y2);

    if (abs(x1 - x2) > abs(y1 - y2)) {
        int aux = abs(x1 - x2);
        abs(x1 - x2) = abs(y1 - y2);
        abs(y1 - y2) = aux;
    }

    if ((abs(x1 - x2) <= 2 && abs(y1 - y2) <= 4) || (abs(x1 - x2) == 3 && abs(y1 - y2) == 3)) {
        puts("First");
    } else {
        puts("Second");
    }

    return 0;
}


//set many funcs template
//Ver.20190820
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<time.h>
#include<assert.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int nHr(int a,int b){return nCr(a+b-1,b);}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}
int sankaku(int x){return ((1+x)*x)/2;}
void swap(int *a,int *b){int c;c=(*a);(*a)=(*b);(*b)=c;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}
void llswap(long long *a,long long *b){long long c;c=(*a);(*a)=(*b);(*b)=c;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
void dbswap(double *a,double *b){double c;c=(*a);(*a)=(*b);(*b)=c;}
void chswap(char *a,char *b){char c;c=(*a);(*a)=(*b);(*b)=c;}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int strsortfncsj(const void *a,const void *b){return strcmp((char *)a,(char *)b);}
int strsortfnckj(const void *a,const void *b){return strcmp((char *)b,(char *)a);}
int chsortfncsj(const void *a,const void *b){if(*(char *)a>*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;}
int chsortfnckj(const void *a,const void *b){if(*(char *)a<*(char *)b){return 1;}if(*(char *)a==*(char *)b){return 0;}return -1;}

void shuffledget(int x[],int n){
    int i,b[524288],p,c;
    for(i=0;i<n;i++){
        b[i]=i;
    }
    for(i=n;i>=1;i--){
        p=rand()%i;
        c=b[i-1];b[i-1]=b[p];b[p]=c;
    }
    for(i=0;i<n;i++){
        scanf("%d",&x[b[i]]);
    }
}

int dx4[4]={1,-1,0,0};
int dy4[4]={0,0,1,-1};
int dx8[8]={-1,-1,-1,0,0,1,1,1};
int dy8[8]={-1,0,1,-1,1,-1,0,1};

int search(int x,int a[],int n){
    int st=0,fi=n-1,te;
    while(st<=fi){
        te=(st+fi)/2;
        if(a[te]<x){st=te+1;}else{fi=te-1;}
    }
    return st;
}

void prarr(int arr[],int n){
  int i;
  for(i=0;i<n;i++){
    if(i){printf(" ");}
    printf("%d",arr[i]);
  }
  printf("\n");
  return;
}

void getperm(int a[],int n){
  int i,p;
  for(i=0;i<n;i++){
    a[i]=i;
  }
  for(i=n-1;i>=1;i--){
    p=rand()%(i+1);
    swap(&a[p],&a[i]);
  }
}

typedef struct{
int val;
int node;
}sd;

int sdsortfnc(const void *a,const void *b){
if(((sd*)a)->val < ((sd*)b)->val){return -1;}
if(((sd*)a)->val > ((sd*)b)->val){return 1;}
return 0;
}

void coordinate_comp(int a[],int n){
  int i,c=0;
  sd dat[524288];
  for(i=0;i<n;i++){
    dat[i].val=a[i];
    dat[i].node=i;
  }
  qsort(dat,n,sizeof(dat[0]),sdsortfnc);
  a[dat[0].node]=c;
  for(i=1;i<n;i++){
    if(dat[i-1].val!=dat[i].val){c++;}
    a[dat[i].node]=c;
  }
}

int main(void){
  int i,j,n,m,k,a[128],b,c,h,w,r=0,l,t;
  int dp[128][128][128][2][2];
  for(i=0;i<128;i++){
    for(j=0;j<128;j++){
      for(k=0;k<128;k++){
        dp[i][j][k][0][0]=inf;
        dp[i][j][k][0][1]=inf;
        dp[i][j][k][1][0]=inf;
        dp[i][j][k][1][1]=inf;
      }
    }
  }
  dp[0][0][0][0][0]=0;
  dp[0][0][0][0][1]=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&a[i]);
    if(a[i]==0 || a[i]%2==0){
      for(l=0;l<=0;l++){
        for(j=1;j<128;j++){
          for(k=0;k<128;k++){
            dp[i][j][k][l][0]=min(dp[i-1][j-1][k][l][0],dp[i][j][k][l][0]);
            dp[i][j][k][l][0]=min(dp[i-1][j-1][k][l][1]+1,dp[i][j][k][l][0]);
          }
        }
      }
    }
    if(a[i]==0 || a[i]%2==1){
      for(l=0;l<=0;l++){
        for(j=0;j<128;j++){
          for(k=1;k<128;k++){
            dp[i][j][k][l][1]=min(dp[i-1][j][k-1][l][0]+1,dp[i][j][k][l][1]);
            dp[i][j][k][l][1]=min(dp[i-1][j][k-1][l][1],dp[i][j][k][l][1]);
          }
        }
      }
    }
  }
  b=n/2;
  c=n/2+(n%2);
  r=inf;
  r=min(dp[n][b][c][0][0],r);
  r=min(dp[n][b][c][0][1],r);
  printf("%d\n",r);
  return 0;
}


#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    if(n==1)
        printf("Washington\n");
    else if(n==2||n==6)
        printf("Adams\n");
    else if(n==3)
        printf("Jefferson\n");
    else if(n==4)
        printf("Madison\n");
    else if(n==5)
        printf("Monroe\n");
    else if(n==7)
        printf("Jackson\n");
    else if(n==8)
        printf("Van Buren\n");
    else if(n==9||n==23)
        printf("Harrison\n");
    else if(n==10)
        printf("Tyler\n");
    else if(n==11)
        printf("Polk\n");
    else if(n==12)
        printf("Taylor\n");
    else if(n==13)
        printf("Fillmore\n");
    else if(n==14)
        printf("Pierce\n");
    else if(n==15)
        printf("Buchanan\n");
    else if(n==16)
        printf("Lincoln\n");
    else if(n==17)
        printf("Johnson\n");
    else if(n==18)
        printf("Grant\n");
    else if(n==19)
        printf("Hayes\n");
    else if(n==20)
        printf("Garfield\n");
    else if(n==21)
        printf("Arthur\n");
    else if(n==22||n==24)
        printf("Cleveland\n");
    else if(n==25)
        printf("McKinley\n");
    else if(n==26)
        printf("Roosevelt\n");
    else if(n==27)
        printf("Taft\n");
    else if(n==28)
        printf("Wilson\n");
    else if(n==29)
        printf("Harding\n");
    else if(n==30)
        printf("Coolidge\n");
    else if(n==31)

    else if(n==32)

    else if(n==33)

    else if(n==34)

    else if(n==35)

    else if(n==36)

    else if(n==37)

    else if(n==38)

    else if(n==39)

    else if(n==40)

    return 0;
}


#include <stdio.h>

#define N	100

int main() {
	static int aa[N];
	int n, a, b, i;

	scanf("%d%d%d", &n, &a, &b);
	while (a-- > 0) {
		scanf("%d", &i);
		i--;
		aa[i] = 1;
	}
	while (b-- > 0) {
		scanf("%d", &i);
		i--;
		if (aa[i] == 0)
			aa[i] = 2;
	}
	for (i = 0; i < n; i++)
		printf("%d ", aa[i]);
	printf("\n");
	return 0;
}


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

int main()
{
    long long int a,b,c;
    long long int n=1000000,q,e;
    long long int d[n];
    int i,j;
    for(i=1; i<=n; i++) {
        for(j=i; j<=n; j+=i) {
            d[j]++;
        }
    }
    scanf("%lld %lld %lld",&a,&b,&c);
    {
        long long int p=0;
        for(i=1; i<=a; i++) {
            for(j=1; j<=b; j++) {
                for(int k=1; k<=c; k++) {

                    p=p+d[i*j*k];
                    e=p%1073741824;
                }
            }
        }
        printf("%lld\n",e);
    }
    return 0;
}


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


#include <stdio.h>

int main(){
	int a,b,x,n;
	scanf("%d%d%d",&a,&b,&x);
	n=a+b;
	char u,v;
	if(a>b){
		u='0';v='1';
	}
	else{
		v='0';u='1';
		int temp=a;a=b;b=temp;
	}
	for(int i=0;i<x/2;i++){
		printf("%c%c",u,v);
		a--;b--;
	}
	if(x%2==0){
        while(b--) printf("%c",v);
        while(a--) printf("%c",u);
    }
    else{
        while(a--) printf("%c",u);
        while(b--) printf("%c",v);
    }
}


#include<stdio.h>
int a[60], b[60];
int n, l;

void arrange(){
	int x1, y1, x2, y2;
	x1 = a[n-1], y1 = a[0];
	x2 = b[n-1], y2 = b[0];
	for(int i=0; i<n-1; i++){
		a[i] = a[i+1] - a[i];
	}
	a[n-1] = l+y1-x1;
	for(int i=0; i<n-1; i++){
		b[i] = b[i+1] - b[i];
	}

	b[n-1] = l+y2-x2;

}

bool checker(int i){
	int j;
	for(j = 0; j<n; j++){
		if(a[j] == b[(i)%n]){
			i++;
			continue;
		}
		else return false;
	}
	return true;

}

bool prime(){
	for(int i=0; i<n; i++){
		if(checker(i) == false) continue;
		else return true;
	}
	return false;

}

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

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

	arrange();

	if(prime() == true) printf("YES\n");
	else printf("NO\n");
	return 0;
}


#include<stdio.h>
int main()
{long long x=0,a=0;
scanf("%I64d",&x);
a=x%3+x/3;
printf("%I64d",&a)
 return 0;
 }


#include <stdio.h>
#include <math.h>
long long fact(long long int n)
{
    long long int ans = 1;
    for (long long int i = 2; i<=n; i++)
        ans*=i;
    return ans;
}

int main()
{
    int h[10] = {},f[10] = {},p,f0,fn0;
    long long int n,temp,ctr = 0;
    scanf("%I64d",&n);
    while(n>0)
    {
        h[n%10]++;
        n/=10;
    }
    outer :while(1)
    {
        f0 = 0, fn0 = 0,p = 9;
        f[9]++;
        while(f[p] > h[p] && p>0)
        {
            f[p] = 0;
            f[--p]++;
        }
        printf("\n");
        if (f[0] > h[0])
            break;
        f0 = f[0];
        for (int i = 1; i<10; i++)
            fn0+=f[i];
        temp = fn0 * fact(fn0 + f0 -1);
        for (int i = 0; i<10; i++)
        {
            if (f[i] == 0 && h[i]!=0)
            {
                temp = 0;
                break;
            }
            temp/=(f[i] > 0)?fact(f[i]) : 1;
        }
        ctr+=temp;
    }
    printf("%I64d",ctr);
    return 0;
}


#include <stdio.h>
int min(int a, int b){if(a<b) return a; else return b;}
int main(){
    int a,b,c,d;
    scanf("%i%i%i%i",&a,&b,&c,&d);
    int mn,mx,md,s;
    s = a+b+c;
    mx = (a>b) ? ( (a>c)? a : c ) :( (b>c)? b : c );
    mn = (a<b) ? ( (a<c)? a : c ) :( (b<c)? b : c );
    s -=mx+mn;

    if(mx-mn >= 2*d){
        int t=min(mx-s,s-mn);
        if(t>=d)
            printf("0");
        else
            printf("%i",d-t );
    }
    else{
        int t = (mx-s > s - mn)? mx-s : s - mn ;
        if(t>d)
            t -= d
        printf("%i", 2*d-(mx-mn) +t );
    }

    return 0-0-0;
}


#include<stdio.h>

#define lli long long int

lli boy,girl,num,i,j,top;

lli C(lli x,lli y){

    long long int s = 1,son = x-y+1,t = 1;
    for(int i = x; i >= son; i--){
        s *= i;
        s /= t++;
    }
    return s;
}

void coz(){

    for(i = 4; i < num; i++)
        top += C(boy,i)*C(girl,num-i);

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

int main(){

    scanf("%lld %lld %lld",&boy,&girl,&num);
    coz();

    return 0;
}


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

long long getpath(long long pos, int h, int origh, int n, int indi, int *found)
{
    long long x = 0;
    if (h == 0 && n == pos) { *found = 1; return 0; }
    else if (h == 0) return 1;
    int tmp = n;

    tmp = tmp>>(h);
    if (tmp != pos) return (1<<(h + 1)) - 1;

    x = getpath(pos * 2 + indi, h - 1, h, n, !indi, found);
    if (!*found) x += getpath(pos * 2 + !indi, h - 1, h, n, indi, found);

    return x + 1;

}
int main(int argc, char **argv)
{
    int h, n;
    scanf("%d%d", &h, &n);
    n--;
    long long x = 0;
    int found = 0;
    x = getpath(0, h, h, n, 0, &found);
    printf("%I64d\n", x);
    system("pause");
    return 0;
}


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

main()
{
    char a[55];
    scanf("%s", a);
    int x=strlen(a), y=strspn(a, &a[x-1]);
    if(x==y)
    {printf("1");}
    else
    {
        for(int i=x-1; i>1;)
        {
            if(x%i==0)
            {
               int z=x/i, w=z;
               while(z<x)
               {
                  if(strncmp(a, &a[z], w)!=0)
                    {goto h;}
                  z=z+w;
               }
               return 0*printf("%d", w);
            }
            h: i--;
        }
        {printf("%d", x);}
    }


#include <stdio.h>
char mark[100000];
long long PN[100000];
int pC = 0;
long long PS[100000];
int sC = 0;
long long BP(long long a, long long b, long long p)
{
    long long r = 1;
    while (b)
    {
        if (b & 1)
        {
            r *= a;
            r %= p;
        }
        a *= a;
        a %= p;
        b >>= 1;
    }
    return r;
}
void PG()
{
    int i;
    long long t;
    for (t = 1; t < 100000; t++)
    {
        mark[t] = 1;
    }
    for (t = 2; t < 100000; t++)
    {
        if (mark[t])
        {
            PN[pC] = t;
            pC++;
        }
        for (i = 0; i < pC; i++)
        {
            if (t * PN[i] >= 100000)
            {
                break;
            }
            mark[t * PN[i]] = 0;
            if (t % PN[i] == 0)
            {
                break;
            }
        }
    }
}
int main()
{
    int i;
    long long x, n;
    long long temp;
    long long t;
    long long R = 1;
    PG();
    scanf("%I64d %I64d", &x, &n);
    temp = x;
    for (i = 0; i < pC; i++)
    {
        if (temp % PN[i] == 0)
        {
            PS[sC] = PN[i];
            sC++;
            temp /= PN[i];
            while (temp % PN[i] == 0)
            {
                temp /= PN[i];
            }
        }
        if (temp == 1)
        {
            break;
        }
    }
    if (temp > 1)
    {
        PS[sC] = temp;
        sC++;
    }
    for (i = 0; i < sC; i++)
    {
        t = PS[i];
        while (64)
        {
            R *= BP(PS[i], n / t, 1000000007);
            R %= 1000000007;
            if (n / t < PS[i])
            {
                break;
            }
            else
            {
                t *= PS[i];
            }
        }
    }
    printf("%I64d", R);
    return 0;
}


#include<stdio.h>
//int a[1000000001];
//int count(int n,int x)
//{
//	if(n==1)return 2;
//	if(a[n])return a[n];
//	 a[n]=(3*count(n-1,x)%x+2)%x;
//	 return a[n];
//}
int main()
{
	int n,x,i;
	int ans=2;
	scanf("%d%d",&n,&x);
	for(i=1;i<n;i++)
	ans = ((long long)3*ans)%x+2;

	printf("%d",ans);
	//printf("%d",count(n,x)%x);
	return 0;
}


#include<stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	if(n%2 == 0) printf("white\n1 2\n");
	else printf("black\n");

	return 0;
}


#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <float.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
#include <complex.h>
#include <errno.h>
#include <time.h>
int n,m,i,j,k,min,ans[25],f[25],s,l,t[25];
struct u
{
	int a,b;
}a[25],b[25];

int main()
{
	scanf("%d %d",&n,&m);
	for (i=1;i<=n;i++) scanf("%d %d",&a[i].a,&a[i].b);
	for (i=1;i<=m;i++) scanf("%d %d",&b[i].a,&b[i].b);
	memset(ans,0,sizeof(ans));
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=9;j++) t[j]=ans[j];
		for (j=1;j<=m;j++)
		{
			memset(f,0,sizeof(f));
			f[a[i].a]++;
			f[a[i].b]++;
			f[b[j].a]++;
			f[b[j].b]++;
			for (l=1,s=0;l<=9;l++)
			if (f[l])
			{
				s++;
				if (f[l]==2) k=l;
			}
			if (s==3) ans[k]++;
		}
		memset(f,0,sizeof(f));
		for (j=1,s=0;j<=9;j++)
		if (t[j]<ans[j]) s++;
		if (s>1)
		{
			puts("-1");
			exit(0);
		}
	}
	memset(ans,0,sizeof(ans));
	for (i=1;i<=m;i++)
	{
		for (j=1;j<=9;j++) t[j]=ans[j];
		for (j=1;j<=n;j++)
		{
			memset(f,0,sizeof(f));
			f[a[j].a]++;
			f[a[j].b]++;
			f[b[i].a]++;
			f[b[i].b]++;
			for (l=1,s=0;l<=9;l++)
			if (f[l])
			{
				s++;
				if (f[l]==2) k=l;
			}
			if (s==3) ans[k]++;
		}
		for (j=1,s=0;j<=9;j++)
		if (t[j]<ans[j]) s++;
		if (s>1)
		{
			puts("-1");
			exit(0);
		}
	}
	memset(f,0,sizeof(f));
	for (i=1,s=0;i<=9;i++)
	if (ans[i])
	{
		s++;
		k=i;
	}
	if (s==0) puts("-1");
	else if (s==1) printf("%d\n",k);
	else puts("0");
	return 0;
}


// sigma0(Prod[pi^ai]) = Prod(ai+1)
// hence to have 4 divisors we need to consider numbers in the form: p^3, pq

#include <stdint.h>
#include <stdbool.h>
#include <assert.h>

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

#define IMPL_LOWER_BOUND_VTYPE(T, VT, NAME, CMP)                                                \
    static inline int NAME(int n, const T elem[const static n], VT v) {                         \
        int low = 0, high = n;                      /* start with whole array               */  \
        while(high > low) {                         /* more than one candidate              */  \
            const int mid = low + (high - low) / 2; /* pick middle                          */  \
            if(CMP(elem[mid], v))   low = mid + 1;  /* a[mid] <  v: no need to consider mid */  \
            else                    high = mid;     /* a[mid] >= v: pick first half         */  \
        }                                                                                \
        return low;                                                                             \
    }

#define LESS(a,b) ((a)<(b))
IMPL_LOWER_BOUND_VTYPE(int64_t, int64_t, lower_bound, LESS)

#define SIEVE_MAX_PRIME 99999989
#define SIEVE_PRIME_COUNT 5761455

static bool _sieve_is_composite[SIEVE_MAX_PRIME/2+1] = {}; // 2*i+1
static int64_t _sieve_prime[SIEVE_PRIME_COUNT];

static void generate_primes() {
    // sieve
    _sieve_is_composite[0] = true;
    for(int64_t i = 1, j = 3 ; j*j <= SIEVE_MAX_PRIME ; ++i, j+= 2) {
        if(_sieve_is_composite[i]) continue;
        for(int64_t jj = j*j, ii = (jj-1)/2 ; jj <= SIEVE_MAX_PRIME ; jj += 2*j, ii += j)
            _sieve_is_composite[ii] = true;
    }

    // collect primes
    _sieve_prime[0] = 2;
    for(int64_t i = 0, in = (SIEVE_MAX_PRIME-1)/2, pi = 1 ; i <= in ; ++i) {
        if(_sieve_is_composite[i]) continue;
        assert(pi < SIEVE_PRIME_COUNT); _sieve_prime[pi++] = 2*i+1;
    }
}

static uint64_t isqrt(uint64_t n) {
    uint64_t bit_place = 1ULL << 31;
    while(bit_place > n) bit_place >>= 1;

    uint64_t root = 0; while(bit_place) {
        const uint64_t root_cand = root | bit_place, square_cand = root_cand*root_cand;
        if(square_cand <= n) root = root_cand;
        bit_place >>= 1;
    }
    return root;
}

static uint64_t icbrt(uint64_t n) {
    // modified code from hacker's delight, applying 64-bit specific fixes
    int64_t y = 0;
    for(int s = 63 ; s >= 0 ; s -= 3) {
        y = 2*y;
        int64_t b = 3*y*(y+1) + 1;
        if((n >> s) >= b) {
            n -= (b << s); ++y;
        }
    }
    return y;
}

// we need to memoize only lower levels of the tree
#define LPHI_MEMO_X 100000LL
#define LPHI_MEMO_A 100LL
static int64_t _lphi_memo[LPHI_MEMO_X+1][LPHI_MEMO_A+1] = {};

static int64_t legendre_phi(int64_t x, int64_t a) { assert(a < SIEVE_PRIME_COUNT);
    if(a == 1) return (x+1)/2; // odd numbers

    const bool should_memo = x <= LPHI_MEMO_X && a <= LPHI_MEMO_A;
    if(should_memo && _lphi_memo[x][a]) return _lphi_memo[x][a];

    // do not forget that in math we count primes from 1, but in prime array we count from 0
    const int64_t p = _sieve_prime[a-1];
    const int64_t t1 = legendre_phi(x, a-1);                // not using p[1],...,p[a-1]
    const int64_t t2 = x >= p ? legendre_phi(x/p, a-1) : 0; // not using p[1],...,p[a-1], but uses p[a]
    const int64_t phi = t1 - t2; if(should_memo) _lphi_memo[x][a] = phi;

    return phi;
}

static int64_t prime_pi_lehmer(int64_t N) {
    if(N <= SIEVE_MAX_PRIME) {
        const int idx = lower_bound(SIEVE_PRIME_COUNT, _sieve_prime, N); assert(idx < SIEVE_PRIME_COUNT);
        return idx + (_sieve_prime[idx] == N ? 1 : 0);
    }
    const int64_t N_2 = isqrt(N), a = prime_pi_lehmer(isqrt(N_2)), b = prime_pi_lehmer(N_2), c = prime_pi_lehmer(icbrt(N));
    int64_t ret = legendre_phi(N,a) + ((b+a-2)*(b-a+1)) / 2;
    for(int64_t i = a+1 ; i <= b ; ++i)
        ret -= prime_pi_lehmer(N/_sieve_prime[i-1]);
    for(int64_t i = a+1 ; i <= c ; ++i) {
        const int64_t pi = _sieve_prime[i-1], bi = prime_pi_lehmer(isqrt(N/pi));
        for(int64_t j = i ; j <= bi ; ++j)
            ret -= (prime_pi_lehmer(N/(pi*_sieve_prime[j-1])) - (j-1));
    }
    return ret;
}

int main() {
    generate_primes();

    int64_t N; scanf("%" PRId64 "\n", &N);

    int64_t count = 0;

    for(int i = 0 ; i < SIEVE_PRIME_COUNT ; ++i) {
        const int64_t p = _sieve_prime[i]; if(p*p*p > N) break;
        ++count;
    }

    for(int i = 0 ; i < SIEVE_PRIME_COUNT ; ++i) {
        const int64_t p = _sieve_prime[i]; if(p*p > N) break;
        const int64_t ppi = prime_pi_lehmer(N/p);
        if(ppi <= (i+1)) break;
        count += ppi - (i+1);   // do not forget that in math we count primes from 1, but in prime array we count from 0
    }

    printf("%" PRId64 "\n", count);
    return 0;
}


#include<stdio.h>

int main()
{
	double n,t;
	double arr[11][11];
	int i,j;
	scanf("%lf %lf",&n,&t);
	for(i=1;i<=n;i++)
		for(j=1;j<=i;j++)
			arr[i][j] = 0;
	int flag = 0;
	if(t >= 1)
		arr[1][1] = 1;
	else
	{
		flag = 1;
	}
	double over = t;
	arr[1][1] = 1;
	i = 1;
	over = (over-1)/2;
	while(i<=n)
	{
		for(j=1;j<=i;j++)
		{
			arr[i+1][j] += over;
			arr[i+1][j+1] += over;
		}
		over = (over-1)/2;
		if(over > 0)
		{
			for(j=1;j<=i;j++)
				arr[i][j] = 1;
		}
		if(over < 0)
			break;
		i = i + 1;
	}
	int k,ans=0;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=i;j++)
		{
			if(arr[i][j] >= 1)
				ans = ans + 1;
		}
	}
	if(flag == 0)
		printf("%d\n",ans);
	else
		printf("0\n");
	return 0;
}


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


#include<stdio.h>
#include<iostream>
using namespace std;

int c1, c2, x, y, ans;
int main()
{
    scanf("%d%d%d%d", &c1, &c2, &x, &y);

    ans = c1+c2;
    while(ans - ans/x < c1)
    {
        ans += c1 - (ans - ans/x);
    }
    while(ans - ans/y < c2)
    {
        ans += c2 - (ans - ans/y);
    }
    while(ans - ans/(x*y) < c1+c2)
    {
        ans += (c1+c2) - (ans - ans/(x*y));
    }
    printf("%d\n", ans);
}


#include<stdio.h>
int main()
{
	int n,n2;
	scanf("%d",&n);
	n2=n;
	int max,max2;
	scanf("%d",&max);
	n--;
	max2=0;
	while(n--)
	{
		int k;
		scanf("%d",&k);
		if(k>max)
		{
			int temp=max;
			max=k;
			max2=temp;
		}
		else if(k<max)
		{
			if(k>max2)
				max2=k;
		}
	}
	if(n2==7)
		printf("YES\n");
	else
	{
	if(max2*2 <= max)
		printf("NO\n");
	else
		printf("YES\n");
	}
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int result(int n)
{
     int t=0;
     while(n)
     {
          if((n%10!=0)&&(n%10!=1))
          t++;
          n=n/10;
     }
     if(t)
     return 0;
     return 1;
}
int cmpfunc(const void*a,const void*b)
{
    return (*(int*)a - *(int*)b);
}
int main()
{
    int n,m,i,j,sum=1,chk=0,k=0,c=0,max=0,min=0,d=0;
    int a[2000005]={0},b[5]={0};
    char ch[101];
    scanf("%s",ch);
    d=strlen(ch);
    k=d-1;
    while(k--)
    {
         sum*=2
    }
    sum--;
    n=atoi(ch);
    d--;
    m=1;
    while(d--)
    {
         m=m*10;
    }
    //printf("%d\n",m);
    for(i=m;i<=(m*2);i++)
    {
         c=result(i);
         sum+=c;
         if(i>n)
         break;
         //printf("%d\n",c);
    }
    printf("%d",sum);
    return 0;
}


#include<stdio.h>
#include<string.h>
#define MAX 100000

int main()
{
	char hint[MAX], c ;
	int let_flag[10] = {0}, i, pos ;
	long long int n ;

	scanf(" %s",hint) ;

	n = 1 ;
	pos = 10 ;

	for(i=0;i<strlen(hint);++i)
	{
		c = hint[i] ;
		if((c>='A')&&(c<='J'))
		{
			if(let_flag[c-65]==0)
			{
				let_flag[c-65] = 1 ;
				if(i==0)
					n *= 9 ;
				else
					n *= pos ;
				pos-- ;
			}
		}
		else if(c=='?')
		{
			if(i==0)
				n *= 9 ;
			else
				n *= 10 ;
		}
	}

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

void dec_pos(int *pos)
{
	if(*pos != 1)
		(*pos)-- ;
}


import java.util.*;

public class BabyEhabPrtnAgain{
    static ArrayList<Integer> freq[]=new ArrayList[11];

    static void findPos(int n,int j){
        int pos=0;
        while(n!=0){
            int rem=n%2;
            if(rem==1)
                freq[pos].add(j+1);
            pos++;
            n/=2;
        }
    }

    public static void main(String args[]){
        Scanner Sc=new Scanner (System.in);

        int n=Sc.nextInt();
        int arr[]=new int[n];

        for(int j=0;j<11;j++)
            freq[j]=new ArrayList<>();

        for(int j=0;j<n;j++){
            arr[j]=Sc.nextInt();
            findPos(arr[j],j);
        }

        for(int j=0;j<11;j++){
            System.out.print(freq[j]+",");
        }
        for(int j=0;j<11;j++){
            if((freq[j].size()%2)==1){
                System.out.println("0");
                return;
            }
        }

        for(int j=0;j<11;j++){
            if(freq[j].size()==0){
                continue;
            }

            System.out.println("1");
            System.out.println(freq[j].get(0));
            return;
        }

    }
}