#include<stdio.h>
int main(){
    int indexa,indexb,i,j,k,m,n,sign,loop;
    int arr[13] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
    int brr[25];
    while(scanf("%d",&n) != EOF){
        sign = 0;
        for(i = 0;i < n;i++)
            scanf("%d",&brr[i]);
        for(i = 1;i <= 12;i++){
            indexb = 0;
            indexa = i;
            k = n;
            loop = 0;
            while(k--){
                if(indexa == 2){
                    if(brr[indexb] == 28 || brr[indexb] == 29){
                        if(brr[indexb] == 29 && loop == 1){
                            sign = 0;
                            break;
                        }
                        if(brr[indexb] == 29 && loop == 0)
                            loop = 1;
                        indexb++;
                        indexa++;
                        sign = 1;

                        continue;
                    }
                    sign = 0;
                    break;
                }
                if(arr[indexa] != brr[indexb]){
                    sign = 0;
                    break;
                }
                if(arr[indexa] == brr[indexb]){
                    indexa++;
                    indexb++;
                    if(indexa > 12)
                        indexa = 1;
                    sign = 1;
                }
            }
            if(sign == 1)
                break;
        }
        if(sign == 1)
            printf("Yes\n");
        if(sign == 0)
            printf("No\n");
    }
    return 0;
}


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


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


#include<stdio.h>
#include<stdlib.h>
int fun(int ,int ,int );
int min(int ,int );
int min(int x,int y)
{
    return (x<y)?x:y;
}
int fun(int a,int b,int c)
{
    int cnt=0,tmp;
    tmp=min(min(a,b),c);
    a=a-tmp;
    b=b-tmp;
    c=c-tmp;
    cnt=cnt+tmp;
    cnt=cnt+a/3+b/3+c/3;
    a=a%3;
    b=b%3;
    c=c%3;
    if(a+b+c==4&&tmp!=0)
    {
        cnt++;
    }
    return cnt;
}
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",fun(a,b,c));
    return 0;
}


#include <stdio.h>

main()
{
    int i, money, no_of_change, total= 0;
    scanf("%i", &money);

    while(money){
        if(money/100){
            no_of_change= money/100;
            money= money%100;
            total= total+no_of_change;
        }
        else if(money/20){
            no_of_change= money/20;
            money= money%20;
            total= total+no_of_change;
        }
        else if(money/10){
            no_of_change= money/10;
            money= money%10;
            total= total+no_of_change;
        }
        else if(money/5){
            no_of_change= money/5;
            money= money%5;
            total= total+no_of_change;
        }
        else if(money/1){
            no_of_change= money/1;
            money= money%1;
            total= total+no_of_change;
        }
    }
    printf("%i", total);
}


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

double area(int a)
{
    return (sqrt(3)*a*a)/4;
}

int main()
{
    int a, b,c, d, e, f;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);

    double n_triangle = area(b+a+c) - area(a) - area(c) - area(e);

    printf("%.0lf\n", n_triangle / area(1));

    return 0;
}


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


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

double square,triangle,d_tri;

int putting_pole(double remain,int count);

int main(void){
  int r,h,maxnum,n,count;
  double l;
  scanf("%d %d",&r,&h);
  square=r;
  triangle=sqrt(3)*r/2;
  d_tri=2*triangle;
  l=h-triangle;
  count=3;
  //printf("3:%f\n",l);
  n=putting_pole(l,count);
  maxnum=n;
  l=h-(double)r/2;
  count=2;
  //printf("2:%f\n",l);
  n=putting_pole(l,count);
  if(n>maxnum) maxnum=n;
  if(!n) maxnum=1;
  printf("%d\n",maxnum);
  return 0;
}

int putting_pole(double remain,int count){
  int x,y,z;
  int max=0,num;

  if(remain<0) return 0;

  for(x=remain/d_tri;x>=0;x--){
    y=(remain-x*d_tri)/square;
    z=(remain-x*d_tri-y*square>=triangle)?1:0;
    num=3*x+2*y+z;
    if(num>max) max=num;
  }
  return max+count;
}


#include<stdio.h>
#include<math.h>
typedef unsigned u;
typedef double d;
int main()
{
	d R,h,r,K;
	u ans,k;
	scanf("%lf%lf",&R,&h);
	r=R/2;
	K=(h+r)/R;
	k=(u)K;
	ans+=k<<1;
	K=h+R-R*k+r;
	if(K>=r+r*sqrt(3))ans++;
	printf("%u\n",ans);
	return 0;
}


#include <stdio.h>

int main() {
	long long l1, r1, l2, r2, k;
	scanf("%lld %lld %lld %lld %lld", &l1, &r1, &l2, &r2, &k);

	long long strt, end, cnt;
	strt = (l1 > l2) ? l1 : l2;
	end = (r1 < r2) ? r1 : r2;

	if(end < strt) {
		printf("0\n");
		return 0;
	}
	cnt = end - strt + 1;
	if(k >= strt && k <= end)
		cnt--;

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

	return 0;
}


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

int main()
{
	long long int l1,r1,l2,r2,k;
	scanf("%lld %lld %lld %lld %lld",&l1,&r1,&l2,&r2,&k);
	long long int l,r;

	if(l1>=l2)
		l=l1;
	else
		l=l2;

	if(r1>=r2)
		r=r2;
	else
		r=r1;
   // printf("l=%lld r=%lld\n",l,r);
	if(l>r)
	{
		printf("0\n");
		return 0;
	}
	else
	{
		if((k>=l && k<=r)||(k<=l && k>=r))
			printf("%lld\n",(r-l));
		else
			printf("%lld\n",(r-l)+1);
	}
	return 0;
}


#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int d=a,di=b,rem;
	/*	while(di!=0)
		{
		rem = d % di;
		d = di;
		di = rem;
		}
	*/
	int i,j,flag=0;
	for (i=0; i<=c; i++)
	{
		for (j=0; j<=c; j++)
		{

			if (c == (a*i+b*j))
				flag=1;
		}
	}
	if (flag)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}


#include<stdio.h>
int main()
{
	int x,y,a,i,j;
	scanf("%d%d%d",&x,&y,&a);
	for(i=0;i<=a;i++)
	{
		for(j=0;j<=a;j++)
		{
			if(x*i+j*y==a)
			{
				printf("YES");
				return 0;
			}
		}
	}
	printf("NO");
}


#include <stdio.h>

int main(int argc, char const *argv[])
{
    long i,n;
    long a=0,b=0;
    scanf("%ld",&n);
    long diff = 1<<30;
    for(i=1;i<=n;i++){
        if(n%i==0){
            if(i>n/i){
                break;
            }else{
                if((n/i)-i<diff){
                    diff = (n/i)-i;
                    a = i;
                    b = n/i;
                }
            }
        }
    }
    printf("%ld %ld\n",a,b );
    return 0;
}


#include<stdio.h>
#define lli long long int
#include<stdlib.h>
#include<math.h>

int main(void)
{
	lli a,b,n,tmp;
	scanf("%lld",&n);

	lli mn,mx,mid,ans;

	mn=0;mx=n;//mid=mn+(mx-mn)/2;
	while(mn<=mx)
	{
		mid=mn+(mx-mn)/2;
		if(mid*mid>=n)
		{
			ans=mid;
			mx=mid-1;
		}
		else
			mn=mid+1;
//		printf("mx=%lld mn=%lld\n",mx,mn);
	}

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

	while(n%ans!=0)
	{
		ans--;
	}

	a=ans;b=n/ans;

	if(a>b)
	{
		tmp=a;
		a=b;
		b=tmp;
	}

	printf("%lld %lld\n",a,b);

	return 0;
}


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

int main() {
	static char s[1234567], code[5];
	int n, i, kr, kb, ky, kg;

	scanf("%s", s);
	n = strlen(s);
	for (i = 0; i < n; i++)
		if (s[i] != '!')
			code[i % 4] = s[i];
	kr = kb = ky = kg = 0;
	for (i = 0; i <= n - 4; i++) {
		int j;

		for (j = i; j < i + 4; j++)
			if (s[j] == '!') {
				int a;

				a = j % 4;
				if (code[a] == 'R')
					kr++;
				else if (code[a] == 'B')
					kb++;
				else if (code[a] == 'Y')
					ky++;
				else
					kg++;
		}
		s[i] = code[i % 4];
		s[i + 1] = code[(i + 1) % 4];
		s[i + 2] = code[(i + 2) % 4];
		s[i + 3] = code[(i + 3) % 4];
	}
	printf("%d %d %d %d\n", kr, kb, ky, kg);
	return 0;
}


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

int main()
{
    int n,m,a[10],y[10],i,j;
    scanf("%d%d",&n,&m);
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    for(i=0; i<m; i++)
        scanf("%d",&y[i]);
    for(i=0; i<n; i++)
    for(j=0; j<m; j++)
        if(a[i]==y[j]){
            printf("%d ",a[i]);
            break;
        }

    return 0;
}


#include <stdio.h>

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

 for(int i=0;i<n;i++)
 {
    for(int j=0;j<m;j++)
        if(a[i]==b[j])
            printf("%d ",a[i]);
 }

}


#include<stdio.h>

typedef long long int lli;

int main()
{
	lli n,k;
	scanf("%lld%lld",&n,&k);
	if(n==1)
	{
		printf("1\n");
		return 0;
	}
	if(k==1)
	{
		printf("%lld\n",n);
	}
	else
	{
		lli tmp=2,i=0;
		while(tmp<=n)
		{
			tmp=tmp*2;
			i++;
		}
		lli ans;
		ans=tmp-1;

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

	}

	return 0;
}


#include<stdio.h>
#include<math.h>
typedef long long int ll;
int main()
{
	ll n,k;
	scanf("%lld%lld",&n,&k);
	ll ans=n;
	ll count=1,i;
/*	for(i=n-1;i>=n/2;i--)
	{
		if(count==k) break;
		ll temp=ans^i;
		if(temp>ans)
		{
			ans=temp;
			count++;
		}

//		if(ans==(pow()) break;
	}*/
	for(i=n/2;i>0;i/=2)
	{
	//	if(count==k) break;
		ll temp=ans^i;
		if(temp>ans)
		{
			ans=temp;
	//		count++;
		}
	}
	if(k==1) printf("%lld",n);
	else printf("%lld",ans);

	return 0;
}


#include<stdio.h>
int main()
{
    int k,a,b,v,req,nos,box;
    scanf("%d %d %d %d",&k,&a,&b,&v);
    if(a%v==0)
    {
        nos=a/v;
    }
    else
        nos=(a/v)+1;
    for(box=0;(nos>0)&&(k<=(b+1));box++)
    {
        b-=(k-1);
        nos-=k;
    }
    if(nos>0&&b>0)
    {
        nos-=b+1;
        box++;
    }
    if(nos>0)
        box+=nos;
    printf("%d\n",box);
    return 0;

}


#include<stdio.h>
int main()
{
    int k,a,b,v,sectionsrequired,boxes,s;
    scanf("%d %d %d %d",&k,&a,&b,&v);
    sectionsrequired=a/v;
    if(a%v != 0)
        sectionsrequired++;

    s=sectionsrequired;
    if(s<=b+1)
    {
        boxes=s/k;
        if(s%k !=0)
            boxes=s/k +1;
    }
    else
        boxes=s-b;
    printf("%d",boxes);
    return 0;
}


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

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

int main(void) {
    int i, n, m, k, arr[55], tot = 0, res = 0, pre;

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

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

    if(k == m)
    {
        printf("0\n");
        return 0;
    }

    qsort(arr, n, sizeof (int), compare);

    tot = k - 1;

    if (tot < m) {
        for (i = n - 1; i >= 0; i--) {
            res++;
            tot += arr[i];

            if (tot < m) {
                tot--;
                pre = arr[i] - 1;
                if (pre == 0) {
                    res = -1;
                    break;
                }
            } else break;
        }
    }
    if (tot < m) res = -1;
    printf("%d\n", res);
    return 0;
}


#include <stdio.h>
int main()
{
int M, N, numero_dominos;
scanf("%d %d", &M, &N);
numero_dominos = (M*N)/2;
printf ("%d\n", numero_dominos);
return 0;
}

/* 1490029633546 */


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

int main()
{
    int ans, i, j, k, m, n, len;

    char str[30];

    scanf("%s", str);

    len = strlen(str);

    ans = ( len + 1 ) * 26 - len;

    printf("%d", ans);
}


#include<stdio.h>
#include<string.h>
int main()
{
    int len;
    char s[27];
    scanf("%s",s);
    len=strlen(s);
    printf("%d",(len+1)*25+1);
    return 0;
}


/*
 ============================================================================
 Name        : trial.c
 Author      : zizo
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

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

int main()
{
	int numofFirst,numofSec,min1,min2,i,j;
	scanf("%d%d",&numofFirst,&numofSec);

	int firsRow[numofFirst],secRow[numofSec];
	scanf("%d",&firsRow[0]);
	min1=firsRow[0];
	for(i=1;i<numofFirst;i++){
		scanf("%d",&firsRow[i]);
		if(firsRow[i]<min1){
			min1=firsRow[i];
		}
	}
	scanf("%d",&secRow[0]);
	min2=secRow[0];
	for(i=1;i<numofSec;i++){
		scanf("%d",&secRow[i]);
		if(secRow[i]<min2){
			min2=secRow[i];
		}
	}

	for (i=0;i<numofFirst;i++){
		for(j=0;j<numofSec;j++){
			if(secRow[j]==firsRow[i]){
				if(min1==min2 && min1 <firsRow[i]){
					printf("%d",min1);
				}else{
					printf("%d",firsRow[i]);
				}
				return 0;
				}
		}
	}

	if(min1==min2){
		printf("%d",min1);
	}else if(min1<min2){
		//if min1 is found in array1 pint min 1
			printf("%d%d",min1,min2);
	}else{
		printf("%d%d",min2,min1);
	}

/*
 *
9 1

5 4 2 3 6 1 7 9 8

9
 *
 */

}


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

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

int main()
{
	int n,m,min1=10,a,b=10,count[10]={0},count1[10]={0},i;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		count[a]=1;
		if(a<min1)
			min1=a;
	}
	for(i=0;i<m;i++)
	{
		scanf("%d",&a);
		count1[a]=1;
		if(a<b)
			b=a;
	}
	if(b==min1)
		printf("%d\n",b);
	else
	{
		int val=1;
		for(i=1;i<10;i++)
			if(count1[i]==count[i] && count[i]==1)
			{
				val=0;
				break;
			}
		if(val==0)
			printf("%d\n",i);
		else
		{
			if(min1<b)
				printf("%d%d\n",min1,b);
			else
				printf("%d%d\n",b,min1);
		}

	}
	return 0;
}


#include<stdio.h>
typedef long int li;
const long int MIN = -2147483647;
#define si(n) scanf("%ld", &n);
#define pi(n) printf("%ld", n);
li max(li a, li b){
	if(a > b) return a;
	return b;
}
li min(li a, li b){
	if(a < b) return a;
	return b;
}
li gcd(li a, li b){
	if(b == 0)
		return a;
	return gcd(b, a%b);
}
long int getNumberPFac(long int a){
	long int c = 0;
	while(a % 2 == 0){
		a/=2; c++;
	}
	while(a % 3 == 0){
		a/=3; c++;
	}
	while(a % 5 == 0){
		a/=5; c++;
	}
	if(a!=1) return MIN;
	else return c;
}
int main(){
// 	freopen("input.txt", "r", stdin);
	long int a, b, c;
	si(a); si(b);
	//printf("%d", sizeof(int));
	//if(a == b) printf("0"); return
	c = gcd(max(a, b), min(a, b)); //pi(c); printf("\n");
	a = getNumberPFac(a/c); b = getNumberPFac(b/c); //pi(a);
	if(a<0 || b<0) printf("-1");
	else pi(a+b);
	return 0;
}


#include<stdio.h>

typedef long long ll;
ll fox(ll a,ll b);
ll gcd(ll a,ll b);

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

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

  d = (a>b)?gcd(a,b):gcd(b,a);

  c = fox(a/d,b/d);

  printf("%lld",c);

  return 0;

}

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

 return gcd(b,a%b);
}

ll fox(ll a,ll b)
{
 static ll count = (ll)0;
 ll larger,smaller;

 if(a==b)
   return count;

 count += (ll)1;

 if(a>b)
  {
    larger = a,smaller = b;
  }

 else
  {
    smaller = a,larger = b;
  }

 if(larger % (ll)2==(ll)0)
  {
   if(larger==a)
     a/=(ll)2;

   else
     b/=(ll)2;

   return fox(a,b);
  }

 else if(larger % (ll)3==(ll)0)
  {
   if(larger == a)
     a/=(ll)3;

   else
     b/=(ll)3;

   return fox(a,b);
  }

 else if(larger % (ll)5==(ll)0)
  {
   if(larger == a)
     a/=(ll)5;

   else
     b/=(ll)5;

   return fox(a,b);
  }

 else
   return -1;

}


//
//  vk.c
//
//
//  Created by Vijay Kansal on 16/04/17.
//
//

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

int calc(char *s) {
    int i, len = strlen(s), result = 0;
    for (i = 0; i + 1 < len; i++) {
        result += s[i] == 'V' && s[i+1] == 'K';
    }
    return result;
}

int main() {
    char s[101];
    scanf("%s", s);
    int i, val, len = strlen(s), ans = calc(s);
    for (i = 0; i < len; i++) {
        s[i] = s[i] == 'K' ? 'V' : 'K';
        val = calc(s);
        if (val > ans) {
            ans = val;
        }
        s[i] = s[i] == 'K' ? 'V' : 'K';
    }
    printf("%d\n", ans);
    return 0;
}


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

#define ll long long
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define abs(k) (((k)>0)?(k):(-(k)))
#define mod(a,b) (((a)>=0)?((a)-(b)*((a)/(b))):((a)-(b)*((a)/(b)+1))
#define mset(a) memset(a,0,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
#define inf (1e9)
#define linf (1e18)
#define pi 3.14159265358979323846

void fileio_in_out()
{
     freopen(".in","r",stdin);
     freopen(".out","w",stdout);
}

void fileio_txt()
{
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
}

//==================================================

int n,ans=0;

void dfs(int a,int b,long long k)
{
     int i;

     if(k<=n)
       ans++;
       else return;

     if(b==-1)
       {
         dfs(a,b,k*10+a);
         for(i=0;i<=9;i++)
           if(i!=a)
             dfs(a,i,k*10+i);
       }
       else
         {
           dfs(a,b,k*10+a);
           dfs(a,b,k*10+b);
         }
}

int main()
{
    //fileio_in_out();
    //fileio_txt();

    int i,j,k,l,t;

    scanf("%d",&n);

    for(i=1;i<=9;i++)
      dfs(i,-1,i);

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

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


#include <stdio.h>
int main(int argc, char const *argv[])
{int c=0,z,n,p=1,l,ans=0,a,i,r,flag,j,y,q,q1,ar[100],h,num,tens=1,f;
	scanf("%d",&n);
	z=n;
	if(n<=100)
	{
		printf("%d\n", n);
		return 0;
	}
	while(z!=0)
	{
		z=z/10;
		c++;
	}
	l=c;
	c=c-1;
	num=n;
	for (int i = 0; i < c; ++i)
	{
		ans=ans+9*(9*(p-1)+1);
		p=p*2;
		ar[i]=p;
		num=num/10;
		tens=tens*10;
	}
a=num*tens;
ans=ans+(num-1)*(9*(p-1)+1);
for (int i = a; i <=n ; ++i)
{h=i;flag=1,f=0;
	q=h%10;h=h/10;
			//printf("\ni is %d\n",i);

	for(j=1;j<l;j++)
	{
		if(q==num)
		{
			flag=0;
		}
		//printf("h10 is %d and q is %d and flag is %d\n",h%10,q,flag );
		if(h%10!=q && h%10!=num && flag==1)
		{
			ans--;
			f=1;
			break;
		}
		if (q==num && h%10!=q)
		{
			q=h%10;
			flag=1;
		}
		h=h/10;
	}

	ans++;

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


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

int main() {

    int i,j,k,n,z,p=0,sum;
  //  char pre[30];
 //   char suf[30];
    scanf("%d",&n);
    sum=0;
    while(n>0){
        sum=sum+n;
        n=n-2;
    }
    printf("%d",sum);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define MAX 3
int s[MAX][10];
int n;
int sol(){
    int cnt = 0;
    for(int i = 1; i < 10; i++){
        int flag = 0;
        for(int j = 0; j < 3; j++)
            if(s[j][i]){
                flag = 1;
                break;
            }
        if(!flag) return i-1;
    }

    for(int i = 1; i < 10; i++){
        for(int k = 0; k < 10; k++){
            int flag = 0, num;
            for(int j = 0; j < 3; j++){
                if(s[j][i]){
                    num = j;
                    for(int l = 0; l < 3; l++){
                        if(l == num) continue;
                        if(s[l][k]){
                            flag = 1;
                            break;
                        }
                    }
                    if(flag) break;
                }
            }
            if(!flag) return i*10+k -1;
        }
    }
    return 99;
}

int main(void){
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < 6; j++){
            int tmp;
            scanf("%d", &tmp);
            s[i][tmp] = 1;
        }

    int max = sol();
    printf("%d", max);
    return 0;
}


#include<stdio.h>
long long int gcd(long long int a, long long int b)
{
	long long int r = a % b;
	while (r > 0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
int main()
{
	long long int n;
	scanf("%lld", &n);
	long long int g = 0, i;
	for (i = 2; i * i <= n; i++)
		if (n % i == 0)
			g = gcd(gcd(g, i), n / i);
	if (g == 0)
		g = n;
	printf("%lld\n", g);
	return 0;
}


#include<stdio.h>
long long gcdcal(long long a, long long b)
{
    if((a%b)==0)
    return b;
    else
    return gcdcal(b, a%b);
}
int main()
{
    long long n, ans, i, j, t, fac[100000], gcd;
    scanf("%lld", &n);
    i=0;
    t=0;

    for(j=2; j*j<=n; j++)
    {
        if((n%j)==0)
        {
            fac[i]=j;
            i++;
            if(j*j!=n)
            {
                fac[i]=n/j;
                i++;

            }
            t++;
        }
    }
    if(t==0)
    {
        printf("%lld", n);
        return 0;
    }
    gcd=fac[0];
    for(j=1; j<i; j++)
    {
        if(gcd>fac[j])
        gcd=gcdcal(gcd, fac[j]);
        else
        gcd=gcdcal(fac[j], gcd);
    }
    printf("%lld", gcd);

}


#include <stdio.h>
#include <string.h>
int main()
{
	char s[13];
	int existe=0;
	int j=0;
	int i;
	int conta=0;
	gets(s);
	char alfabeto[]="zyxwvutsrqponmlkjihgfedcba";
	while(existe!=1)
	{
	//	puts("Hola1");
		for(i=0;i<strlen(s);i++)
		{
		//	puts("Hola2");
			if(s[i]==alfabeto[j])
			{
			//	puts("Hola3");
				conta++;
				existe=1;
			}
		}
		j++;
	}
	j--;
//	puts("Hola4");
	for(i=0;i<conta;i++)
	{
		printf("%c",alfabeto[j]);
	}
	return 0;
}


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

int main(void){
    char str[11] = {'\0'};
    scanf("%s", str);
    char max = 'a';
    int count = 0;
    for(int i = 0; i < strlen(str); i++){
        if(str[i] > max) max = str[i], count = 1;
        else if(str[i] == max) count++;
    }
    for(int i = 0; i < count; i++)
        printf("%c", max);
    printf("\n");
    return 0;
}


/*
 *Tritonic Iridescence
 *Time complexity O(n)
 */

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

int main(){
	int len, i, cnt, mulmark;
	char *s, former;

	scanf("%d", &len);
	s = (char*)malloc(len+1);
	scanf(" %s", s);

	mulmark = 0;
	if(s[0] == '?'){
		for(i = 0; s[i] == '?'; i++);
		former = s[i];
		i++;
		mulmark = 1;
	}

	for(; i < len; i++){
		switch(s[i]){
			case '?':
				for(cnt = 0; s[i] == '?' && i < len; i++, cnt++);
				if(i == len){
					mulmark = 1;
					break;
				}
				if(cnt > 1 || (cnt == 1 && s[i] == former))
					mulmark = 1;
				former = s[i];
				break;
			default:
				if(s[i] == former){
					printf("No");
					return 0;
				}
				else
					former = s[i];
		}
	}

	if(mulmark == 1)
		printf("Yes");
	else
		printf("No");
	free(s);
	return 0;
}


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

int r,g,b,m,ans;

main()
{
    scanf("%d%d%d",&r,&g,&b);
    for(ans=0;r>0||g>0||b>0;ans++)
    {
        if(ans%3==0)
        r-=2;
        else if(ans%3==1)
        g-=2;
        else b-=2;
    }
    printf("%d\n",29+ans);
    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
	int n,a,b;int s=6;
	scanf("%d%d%d",&n,&a,&b);
	if (n>=4*a+2*b) s=1;
	else if (n>=2*a+b) s=2;
	else
	{
		if (n>=4*a) if (n>=b+b) {if (2<s) s=2;}
		           else if (3<s) s=3;
		if (n>=a+a) if (n>=b+b) {if (3<s) s=3;}
		           else if (4<s) s=4;
        if (n>=a+b) if (n>=a+a) {if (3<s) s=3;}
		           else if (4<s) s=4;
        if (n>=b+b) if (n>=a+a) {if (3<s) s=3;}
		           else if (5<s) s=5;
	}
	printf("%d\n",s);
}


#include<stdio.h>
#include<string.h>
#define max(a,b) (a>b?a:b)
#define min(a,b) (a>b?b:a)
int num[105];
int dp[105];
int main(void){
	memset(dp,0x3f,sizeof(dp));
	int n,m;
	scanf("%i%i",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%1d",&num[i]);
	}
	dp[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(num[i])
		{
			for(int k=i-1;k>i-m-1&&k;k--)
			{
				if(num[k])
				{
					dp[i]=min(dp[i],dp[k]+1);
				}
			}
		}
	}
	printf("%i",dp[n]>1000?-1:dp[n]);
	return 0;
}


#include<stdio.h>
int main()

{
int prob, min,stime,count=0,a=0,i;
 scanf("%d %d", &prob,&min);

  stime=240-min;
  for (i=1;i<=prob;i++)
  {
    a=5*i;
    stime=stime-a;

    if(stime>=0)
        {
    count++;

        }
        else
            break;
  }

printf("%d", count);

  return 0;

}


#include<stdio.h>
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    /* create temp arrays */
    int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

/* l is for left index and r is right index of the
   sub-array of arr to be sorted */
void mergeSort( int arr[], int l, int r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int m = l+(r-l)/2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}
int main()
{
    int sum=0;
    int i,j,k,c;
    int arr[5];
    for(i=0;i<=4;i++)
        scanf("%d",&arr[i]);
    mergeSort(arr,0,4);
    for(i=0;i<5;i++)
        sum=sum+arr[i];
    int max=arr[4];
    int freq[max+1];
    for(i=0;i<=max;i++)
        freq[i]=0;
    for(i=0;i<=4;i++){
        int x=arr[i];
        freq[x]++;

    }
    k=0;
    int arr2[5];
    for(i=0;i<=4;i++)
        arr2[i]=100000;

    for(i=0;i<4;i++){
        if(freq[arr[i]]>3)
        {
            arr2[k]=sum-3*arr[i];
            k++;
        }
        else if(freq[arr[i]]<=3&&freq[arr[i]]>1){
            arr2[k]=sum-freq[arr[i]]*arr[i];
            k++;
        }

    }

    mergeSort(freq,0,max);
    if(freq[max]==1)
        printf("%d",sum);
        else{
    mergeSort(arr2,0,4);
    printf("%d",arr2[0]);
        }
    return 0;

}


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

char str[6];
int found[10]={}; // A~J,?
int main(){
    gets(str);
    int i, len = strlen(str), solution = 1, letters = 10;
    if( 'A' <= str[0] && str[0] <= 'J' )
        solution = 9, found[str[0] - 'A'] = 1, letters--;
    else if( str[0] == '?' )
        solution = 9;
    for(i = 1; i < len; i++)
        if( 'A' <= str[i] && str[i] <= 'J' ){
            if( found[str[i] - 'A'] == 0)
                solution *= letters, found[str[i] - 'A'] = 1, letters--;
        }else if( str[i] == '?' )
            solution *= 10;
    printf("%d\n", solution);
    // system("pause");
    return 0;
}


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

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

int main()
{
int r1,c1,r2,c2,rook,bis,king;

scanf("%d %d %d %d",&r1,&c1,&r2,&c2);

rook=( r1==r2 || c1==c2 ) ? 1:2;

king=max(abs(r2-r1),abs(c2-c1));

if((abs(r1-r2)+abs(c1-c2))%2)
bis=0;

else
bis=(abs(r1-r2)==abs(c1-c2))?1:2;

printf("%d %d %d\n",rook,bis,king);

return 0;

}


#include<stdio.h>
#include<math.h>
int king(int r1,int c1,int r2,int c2)
{
	int ct,i,j;
	if(r1==r2)
	{
		ct=abs(c1-c2);
		return ct;
	}
	else if(c1==c2)
	{
		ct=abs(r1-r2);
		return ct;
	}
	else
	{
		if(r1<r2)
		{
			if(c1>c2)
			{
				ct=1;
				for(i=r1+1,j=c1-1;i<=8 && j>=1;++i,--j)
				{
					if(i==r2)
					{
						ct+=abs(c2-j);
						return ct;
					}
					else if(j==c2)
					{
						ct+=abs(r2-i);
						return ct;
					}
					ct++;
				}
			}
			else
			{
				ct=1;
				for(i=r1+1,j=c1+1;i<=8 && j<=8;++i,++j)
				{
					if(j==c2)
					{
						ct+=abs(r2-i);
						return ct;
					}
					else if(i==r2)
					{
						ct+=abs(c2-j);
						return ct;
					}
					ct++;
				}
			}
		}
		else
		{
			if(c1>c2)
			{
				ct=1;
				for(i=r1-1,j=c1-1;i>=1 && j>=1;--i,--j)
				{
					if(j==c2)
					{
						ct+=abs(r2-i);
						return ct;
					}
					else if(i==r2)
					{
						ct+=abs(c2-j);
						return ct;
					}
					ct++;
				}
			}
			else
			{
				ct=1;
				for(i=r1-1,j=c1+1;i>=1 && j<=8;--i,++j)
				{
					if(j==c2)
					{
						ct+=abs(r2-i);
						return ct;
					}
					else if(i==r2)
					{
						ct+=abs(c2-j);
						return ct;
					}
					ct++;
				}
			}
		}
	}
}
int full_leftdiag(int temp1,int temp2,int r2,int c2)
{
	int i,j;
	for(i=temp1,j=temp2;i>=1 && j>=1;--i,--j)
		if(i==r2 && j==c2)
			return 2;
	for(i=temp1,j=temp2;i<=8 && j<=8;++i,++j)
		if(i==r2 && j==c2)
			return 2;
	return 0;
}
int full_rightdiag(int temp1,int temp2,int r2,int c2)
{
	int i,j;
	for(i=temp1,j=temp2;i<=8 && j>=1;++i,--j)
		if(i==r2 && j==c2)
			return 2;
	for(i=temp1,j=temp2;i>=1 && j<=8;--i,++j)
		if(i==r2 && j==c2)
			return 2;
	return 0;
}
int right_diag(int r1,int c1,int r2,int c2)    //diagonals starting from right
{
	int temp1,temp2,ct;
	for(temp1=r1+1,temp2=c1-1;temp1<=8 && temp2>=1;++temp1,--temp2)
	{
		if(temp1==r2 && temp2==c2)
			return 1;
		ct=full_leftdiag(temp1,temp2,r2,c2);
		if(ct!=0)
			return ct;
	}
	for(temp1=r1-1,temp2=c1+1;temp1>=1 && temp2<=8;--temp1,++temp2)
	{
		if(temp1==r2 && temp2==c2)
			return 1;
		ct=full_leftdiag(temp1,temp2,r2,c2);
		if(ct!=0)
			return ct;
	}
	return 0;
}
int left_diag(int r1,int c1,int r2,int c2)   //diagonals starting from left
{
	int temp1,temp2,ct;
	for(temp1=r1+1,temp2=c1+1;temp1<=8 && temp2<=8;++temp1,++temp2)
	{
		if(temp1==r2 && temp2==c2)
			return 1;
		ct=full_rightdiag(temp1,temp2,r2,c2);
		if(ct!=0)
			return ct;
	}
	for(temp1=r1-1,temp2=c1-1;temp1>=1 && temp2>=1;--temp1,--temp2)
	{
		if(temp1==r2 && temp2==c2)
			return 1;
		ct=full_rightdiag(temp1,temp2,r2,c2);
		if(ct!=0)
			return ct;
	}
	return 0;
}
int bishop(int r1,int c1,int r2,int c2)
{
	int ct;
	ct=left_diag(r1,c1,r2,c2);
	if(ct!=0)
		return ct;
	else
		ct=right_diag(r1,c1,r2,c2);
	return ct;
}
int main()
{
	int r1,c1,r2,c2,ct1,ct2,ct3;
	scanf("%d%d%d%d",&r1,&c1,&r2,&c2);
	if(r1==r2 || c1==c2)
		ct1=1;
	else
		ct1=2;
	printf("%d ",ct1);
	ct2=bishop(r1,c1,r2,c2);
	printf("%d ",ct2);
	ct3=king(r1,c1,r2,c2);
	printf("%d\n",ct3);
	return 0;
}


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

int main(){
    int n,k,e=0,s=0,max=0,temp=0;
    scanf("%d %d",&n,&k);
    int str[n];
    for(int i=0;i<n;i++){
        scanf("%d",&str[i]);
    }
    for(int b=0;b<k;b++){
        int j=0;
        s=0;
        e=0;
        for(int i=0;i<n;i++){
            if(i==b+j*k) j++;
            else{
                if(str[i]==1) e++;
                if(str[i]==-1) s++;
            }
        }
        temp=abs(e-s);
        if(temp>max) max=temp;
    }
    printf("%d",max);
    return 0;
}


#include<stdio.h>

int main()
{
    int n,k,pcount=0,ncount=0,mag,max=0;
    scanf("%d%d",&n,&k);
    int array[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&array[i]);
        if(array[i]>0)
        pcount++;
    }
    ncount=n-pcount;
    for(int i=0;i<k;i++)
    {
        int move=i,count=0,t=(n-i-1)/k;
        for(int j=0;j<=t;j++)
        {
            if(array[move]==1)
            count++;
            else
            count--;
            move+=k;
        }
        mag=pcount-ncount-count;
        if(mag<0)
        mag=-mag;

        if(max<mag)
        max=mag;

    }
    printf("%d",max);

}


#include <stdio.h>
#define sqr(x) ((x)*(x))
int mod(int x)
{
	if(x>=0) return x;
	else return -x;
}
int max(int x,int y)
{
	if (x>y) return x;
	else return y;
}
int res(int a, int b)
{
	return (a%b+b)%b;
}
int main ()
{
	int n, a, b, c, d;
	long long resp;
	scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
	resp = max(max(mod(c-b), mod(c-b+d-a)), max(mod(d-a), mod(a+c-d-b)));
	if(n-resp>0) printf("%lli\n", n*(n-resp));
	else printf("0\n");
	return 0;
}


#include<stdio.h>
int main()
{
    int i,n,k,a[105],x=0,count=0;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        x=x+a[i];
    }
    n=n+1;
    for(i=1; i<=5; i++)
    {
        if((i+x)%n!=1)
            ++count;
    }
    printf("%d\n",count);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,i,a,sum,m;
    sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a);
        sum+=a;
    }
    m=0;
    for(i=1;i<6;i++){
    if((i+sum)%(n+1)!=1)
    m++;
    }
    printf("%d\n",m);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <ctype.h>
//#include <DEBUG.h>
#ifndef LL
#define LL long long
#endif
#ifndef uLL
#define uLL unsigned long long
#endif
#ifndef uL
#define uL unsigned int
#endif
#ifndef iL
#define iL int
#endif
#ifndef iS
#define iS short
#endif
#ifndef uS
#define uS unsigned short
#endif
#ifndef uC
#define uC unsigned char
#endif
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define abs(a) (((a)<0)?(-(a)):(a))
#define sgn(a) (((a)<0)?(1):(0))
#define movs(a,b,l) (memmove((a),(b),sizeof(*(b))*(l)))
#define stosb(a,b,l) (memset((a),(b),sizeof(*(a))*(l)))
static inline uL bsr(uL a)
{
    __asm__("bsrl %0,%0":"+r"((uL)a));
    return a;
}
static inline uLL sqrt64(uLL x)
{
    uLL t,g;
    for (g=(x>>1)+(x&1),t=x;g<t;g=(g+x/g)>>1)
    {
        t=g;
    }
    return t;
}
static inline uLL gcd(uLL a,uLL b)
{
    while (a>0)
    {
        b=(b%a)^a;
        a=a^b;
        b=a^b;
    }
    return b;
}
uLL prime[4000001];
uLL EulerSieve(uLL n)
{
    uLL i,j;
    memset(prime,0,sizeof(*prime)*(n+1));
    *prime=0;
    for (i=2;i<=n;i++)
    {
        if (prime[i]==0)
        {
            prime[++(*prime)]=i;
            prime[i]=i;
        }
        for (j=1;j<=*prime;j++)
        {
            if (i*prime[j]>n) {break;}
            prime[i*prime[j]]=prime[j];
            if (prime[i]==prime[j]) {break;}
        }
    }
    return *prime;
}
uLL fac[10000];
uLL times[10000];
uLL factoring(uLL a,uLL *fac,uLL *times)
{
	uLL k,i,l;
	l=sqrt64(a);
	for (k=0,i=1;(i<=prime[0])&&(prime[i]<=l);i++)
	{
		if (a%prime[i]==0)
		{
			fac[++k]=prime[i];
			times[k]=1;
			for (a=a/prime[i];a%prime[i]==0;a=a/prime[i],times[k]+=1);
		}
	}
	if (a>1)
	{
		fac[++k]=a;
		times[k]=1;
	}
	return k;
}
LL aa,bb,kk,ans1,ans2;
LL dfs(LL x,LL id)
{
	LL i,j,y;
	if (id>*fac)
	{
		kk=x-aa%x;
		if (x-bb%x==kk)
		{
			//printf("%lld %lld\n",x,kk);
			if ((aa+kk)/x*(bb+kk)<ans1)
			{
				ans1=(aa+kk)/x*(bb+kk);
				ans2=kk;
			}
		}
	}
	else
	{
		y=fac[id];
		for (i=0,j=1;i<=times[id];i++,j=j*fac[id])
		{
			dfs(x*j,id+1);
		}
	}
}
LL ans[100000];
int main()
{
	//freopen("in.in","r",stdin);
	LL i,j,k,a,b,c,n,m,x,y;
	EulerSieve(100000);
	scanf("%lld%lld",&a,&b);
	if (a>b) {c=a;a=b;b=c;}
	if (b%a==0)
	{
		printf("0\n");
	}
	else
	{
		ans1=a/gcd(a,b)*b;ans2=0;
		*fac=factoring(b-a,fac,times);
		aa=a;bb=b;
		dfs(1,1);
		printf("%lld\n",ans2);
	}
	return 0;
}


#include <stdio.h>
#define lli long long int
double sqrt(double i){
	double a = 2.0;
	int k = 100;
	while(k-->0){
		a = (a+i/a)/2.0;
	}
	return a;
}
int main(void){
	lli a,b;
	scanf("%lld %lld",&a,&b);
	if(a == b){
		printf("0\n");
		return 0;
	}
	if(a > b){
		int ch = a;
		a = b;
		b = ch;
	}
	lli q = b - a;
	lli j = a/q;
	if(q*j < a)
		j++;
	q *=j;
	int za = 0;
	int rq = sqrt(q);
	int me = 1;
	int meb = q;
	while((++za) <rq+1){
		if(q%(za) == 0){
			me = za;
			if(za >= a)
				break;
			if((q/za)>=a)
				meb = q/za;
			else
				break;
		}
	}
	if(me < a)
		za = meb;
	else
		za = me;
	lli k = za - a;
	printf("%lld\n",k);
	return 0;
}


#include<stdio.h>
int main()
{
    int a,i,count=0;
    scanf("%d",&a);
    int b[a];
    for(i=0;i<a;i++)
    {
        scanf("%d",&b[i]);
    }
    for(i=1;i<a;i++)
    {
        if(b[i-1]==2 && b[i]==1)
        {
            count=count+3;
        }
        else if(b[i-1]==3 && b[i]==1)
        {
            count=count+4;
        }
        else if(b[i-1]==1 && b[i]==2)
        {
            if(b[i-2]==3)
            {
                count=count+2;
            }
            else
            {
                count=count+3;
            }
        }
        else if(b[i-1]==3 && b[i]==2)
        {
            printf("Infinite");
            return 0;
        }
        else if(b[i-1]==1 && b[i]==3)
        {
            count=count+4;
        }
        else if(b[i-1]==2 && b[i]==3)
        {
            printf("Infinite");
            return 0;
        }

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


#include<stdio.h>
int main()
{
    int n,i,a[105],sum=0,flag=1;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=1; i<n; i++)
    {
        if(a[i]==1)
        {
            if(a[i-1]==2)
                sum+=3;
            else
                sum+=4;
            if(a[i-1]==3 && a[i+1]==2)
                sum--;
        }
        else if(a[i]==2)
        {
            if(a[i-1]==3)
            {
                flag=0;
                break;
            }
            else
                sum+=3;
        }
        else
        {
            if(a[i-1]==2)
            {
                flag=0;
                break;
            }
            else
                sum+=4;
        }
    }
    if(flag==1)
        printf("Finite\n%d",sum);
    else
        printf("Infinite");

    return 0;
}


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

#define pi 3.1415926
#define rep(x,ini,end) for(x=(ini);x<(end);x++)
#define per(x,ini,end) for(x=(end-1);x>=(ini);x--)
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))

int main()
{
    int h1, h2;
    scanf("%d %d", &h1, &h2);
    int a, b;
    scanf("%d %d", &a, &b);

    if (h2-h1<a*8)
    {
        printf("0"); return 0;
    }
    if ((h2-h1>a*8) && (a<=b))
    {
        printf("-1"); return 0;
    }

    int day = 0;
    int dayend,nightend;
    while (1)
    {
        if (day == 0)
        {
            dayend = h1 + a * 8;
        }
        else
        {
            dayend = nightend + a * 12;
        }
        if (dayend>=h2)
        {
            printf("%d",day); return 0;
        }
        nightend = dayend - b * 12;
//        if (nightend<=0)
//        {
//            printf("%d",day+1); return 0;
//        }
        day++;
    }

    return 0;
}


#include <stdio.h>

int main(void) {
	long long h1,h2,a,b,k,res;
	scanf("%lld%lld",&h1,&h2);
	scanf("%lld%lld",&a,&b);
	if(a<b)
	{
	    if ((h1+=a*8)<h2)
	    printf("-1");
	    else
	    printf("0");
	}
	if(a==b)
	{
	    if((h1+=a*8)<h2)
	    {
	    printf("-1");
	    }
	    else
	    printf("0");
	}
	if(a>b)
	{
	    k=0;res=0;
	while (h1 < h2)
	{
	    if(k == 0)
		    h1 = h1 + a * 8;
		else
		    h1 = h1 + a * 12;
		k++;
		if (h1 > h2 && (k == 1))
		{
			printf("0");
			return 0;
		}
		if(h1 >= h2)
		{
		    printf("%lld",res);
		    return 0;
		}
		h1 = h1 - 12 * b;
		res++;
	}
		printf("%lld",res);
}

	return 0;
}


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


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


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

    for(i=1;; i++)
    {
        if(i%2==0)
            b=b-i;
        else
            a=a-i;

        if(b<0)
        {
            c=1;
            break;
        }
        else if(a<0)
        {
            break;
        }
    }
    if(c==0)
        printf("Vladik");

    else
        printf("Valera");
}


#include <stdio.h>
//#include "maths.h"
double zero = 0;
double square_root(double num)
{
    if(num < 0){
        return 0 / zero;
    }
    double root = 1;
    while(num >= 100){
        num /= 100;
        root *= 10;
    }
    while(num < 1){
        num *= 100;
        root /= 10;
    }
    double d = (1 + num) / 2;
    int i = 0;
    do{
        d = (d + num / d) / 2;
        i++;
    }while(i < 50);
    return d * root;
}
int main()
{
    //while(1){
        int v1, v2, vlad, val;
        scanf("%d%d", &v1, &v2);
        vlad = square_root(v1);
        val = square_root(v2);
        while(val * (val + 1) <= v2)
            val++;
        val--;
        //print loser
        if(vlad <= val)
            printf("Vladik\n");
        else
            printf("Valera\n");
    //}
    return 0;
}


#include<stdio.h>
int main()
{
	long long n,m,k,a,min,max;
	scanf("%lld %lld",&n,&m);
	for(a=0;a<=m;a++)
	{
		k=a*(a-1);
		if(k>=(2*m))
			break;
	}
	max=n-a;
	min=n-2*m;
	if(min<0)
		min=0;
	printf("%lld %lld\n",min,max);
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
	long long int n,m;
	scanf("%lld%lld",&n,&m);
	if(m==0)
	{
		printf("%lld %lld\n",n,n);
		exit(0);
			}
	long long int k,min,max,n1;
	min=n-(2*m);
	if(min<0)
	min=0;
//	printf("sd\n");
	n1=1;

	while(1)
	{	k=(n1*(n1-1))/2;
		if(k<m)
		{
	//	printf("sdssd\n");
		n1++;
		}
		else if(k>=m)
		{
			break;
		}

	}
	max=n-n1;

	printf("%lld %lld\n",min,max);
}


#include<stdio.h>
#include<string.h>
int main()
{
	int i,count,x,temp,j,q,flag=0,c=0,v=0,k=0;
	char n[100],m[100];
	scanf("%s",n);
	scanf("%s",m);
	count=strlen(n);
	x=strlen(m);
	if(count!=x)
	{
		printf("WRONG_ANSWER");
	}
	else if(n[0]=='0'&& m[0]=='0')
	{
		for(i=0;i<count;i++)
		{

		if(n[i]== '0' && m[i]== '0')
			{
				v=v+1;
			}
		}
		if(v!=0)
		printf("OK");
	}
	else
{
	for(i=0;i<count;i++)
	{
		 for(j=0;j<count-i-1;j++)
        {
            if(n[j]>n[j+1])
            {
                temp=n[j];
                n[j]=n[j+1];
                n[j+1]=temp;
            }
		}
	}
	for(i=0;i<count;i++)
	{
		if(n[i]=='0')
		{
			c=c+1;
		}
	}
	if(c!=0)
	{
		q=n[0];
		n[0]=n[c];
		n[c]=q;
	}
	for(i=0;i<count;i++)
	{
		if(n[i]==m[i])
		{
			flag=flag+1;
		}
		else
				k=k+1;
	}
	if(flag==count)
		printf("OK");
	else if(k!=0)
		printf("WRONG_ANSWER");
}
}


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

int i,j,k =1,x,y,z,a,b,c,min=789;

int main() {

	char d[10],g[10],u[40];

	scanf("%s %s",d,u);

	a = strlen(d);
	z = strlen(u);

	if(a != z){
		printf("WRONG_ANSWER");
		return 0;
	}
	for(i=0 ; i<a ; i++)
		if(d[i] <= min && d[i] != '0')
			min = d[i], x = i;

	g[c++] = d[x];
	d[x]='}';

	min=487;
	while(k < a){
		for(i=0 ; i<a ; i++)
			if(d[i] <= min && d[i]!='}')
				min =d[i] , x= i;

		g[c++]=d[x];
		d[x]='}';
		min=789;
		k++;
	}

	for(i=0 ; i<a ; i++)
	if(g[i] != u[i]){
			printf("WRONG_ANSWER");
			return 0;
		}

	printf("OK");

	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    int test,i,g,t,k,flag,n,l;

        scanf("%d %d",&n,&k);
        char a[n+3];
        scanf("%s",a);
        l=strlen(a);
        g=0;
        t=0;
        for(i=0;i<l;i++)
        {
            if(a[i]=='G')
                g=i;
            else if(a[i]=='T')
                t=i;
        }
        if(g>t)
        {
            i=g;
            g=t;
            t=i;
        }
        if((t-g)%k==0)
        {
            flag=0;
        for(i=g;i<=t;i+=k)
        {
            if(a[i]=='#')
                flag=1;
        }
        if(flag==1)
            printf("NO");
            else
            printf("YES");
        }
        else
        {
            printf("NO");
        }

    return 0;
}


#include<stdio.h>

int main(){
    char arr[200];
    int i,j,jp,g,t,cl,jm,a,m,n;
    scanf("%d%d",&cl,&jm);

     scanf("%c",&arr[0]);

    for(i=1;i<=cl;i++)
        scanf("%c",&arr[i]);

      for(i=1;i<=cl;i++){
        if(arr[i]=='G'){
            g=i;
           }
        if(arr[i]=='T'){
            t=i;
            }
      }

      if(g>t){
        m=t;
        n=g;
        a=g-t;}
      else{
        m=g;
        n=t;
        a=t-g;}

    for(i=m; i<n; i=i+jm){
        if(arr[i]=='#'){
           printf("NO\n");
            return 0;
            }

    }
    if((a%jm)==0)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
    }


#include<stdio.h>

int main()
{
	int n,k,i,a[20]={0},val,x,z,count;
	//printf("hello\n");
	scanf("%d %d",&n,&k);
	//printf("hello\n");
	//printf(" hello %d%d",n,k);
	i=-1;
	if(n>0)
	{
		while(n)
		{
			i++;
			a[i]=n%10;
			n=n/10;
		}
		x=i;
		count=0;
		for(i=0;i<=x;i++)
		{
	//		printf("%d",a[i]);
			if(a[i]==0)
				count++;
		}
	//	printf("%d",count);
		if(count<k)
			printf("%d\n",x);

		else if(count>=k)
		{
			  z=k;
			 val=0;
			for(i=0;i<=x;i++)
			{
				if(z)
				{
					z--;
					if(a[i]!=0)
					{
						z++;
						val++;
					}
				}
			}

			printf("%d\n",val);
		}
	}
	else if(n==0)
		printf("0\n");
	return 0;
}


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

int a[30];

int MIN(int x, int y){
	if (x<y) return x;
	return y;
}

int main(void){
	int i, j, n, m, big, tt, ttt;
	char t[30];

	scanf("%s %d", &t, &m);
	n = strlen(t);
	for (i = 1; i <= n; i++){
		a[i] = t[i - 1] - '0';
	}

	for (i = 1; i <= n; i++){
		big = a[i];
		tt = i;
		for (j = i + 1; j <= MIN(i + m, n); j++){
			if (big<a[j]){
				big = a[j];
				tt = j;
			}
		}
		m -= (tt - i);
		for (j = tt - 1; j >= i; j--){
			ttt = a[j];
			a[j] = a[j + 1];
			a[j + 1] = ttt;
		}
	}

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

	return 0;
}


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

int main() {
	char tmp, max;
	int i, j, imax, l, k;
	static char a[20];

	scanf("%s", a);
	scanf("%d", &k);
	l = strlen(a);
	for (i = 0; i < l; i++) {
		if (k == 0)
			break;
		max = 0;
		for (j = i + 1; j <= i + k && j < l; j++)
			if (max < a[j]) {
				imax = j;
				max = a[j];
			}
		if (a[i] < max)
			for (j = imax; j >= i + 1; j--) {
				if (k == 0)
					break;
				tmp = a[j], a[j] = a[j - 1], a[j - 1] = tmp;
				k--;
			}
	}
	printf("%s\n", a);
	return 0;
}


#include <stdio.h>

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


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


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define max(a, b) (a>b?a:b)

#define LIMIT 30001
#define WIDTH 500

long long int powerModulo(long long int a, long long int p, long long int m)
{
    if(p==0)
        return 1;

    long long int temp = powerModulo(a, p/2, m);
    temp = (temp * temp)%m;
    if(p%2 == 0)
        return temp;
    else
        return (a * temp)%m;
}

long long int inverseModulo(long long int a, long long int P)
{
    return powerModulo(a, P-2, P);
}

int isGood(int n, int a, int b)
{
    while(n > 0)
    {
        int last = n%10;
        if(last == a || last == b)
            n = n/10;
        else
            return 0;
    }
    return 1;
}

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

    long long int P = 1000000007;
    int N_MAX = 1000000;

    long long int *factorial_inverse;
    factorial_inverse = (long long int*)(malloc(sizeof(long long int) * (N_MAX + 1) ));
    factorial_inverse[0] = 1;

    for(int i = 1; i <= N_MAX; i++)
        factorial_inverse[i] = (inverseModulo(i, P) * factorial_inverse[i - 1])%P;

    long long int n_factorial = 1;
    for(int i = 2; i <= n; i++)
    {
        n_factorial = (n_factorial * i)%P;
    }

    long long int ans = 0;
    for(int num_of_a = 0; num_of_a <= n; num_of_a++)
    {
        int sum_of_digits = num_of_a * a + ( n - num_of_a ) * b;
        if(!isGood(sum_of_digits, a, b))
            continue;

        long long int temp = (factorial_inverse[n - num_of_a] * factorial_inverse[num_of_a])%P;
        temp = (n_factorial * temp)%P;
        ans = (ans + temp)%P;
    }
    printf("%lld\n", ans);
}


#include<stdio.h>
 long long f[1000001];
 long long find_mmi(long long base,long long n,long long m)
 {
     if(n==0)
        return 1;
     if(n==1)
        return base;
     long long halfn=find_mmi(base,n/2,m);
     if(n%2==0)
        return ((halfn*halfn)%m);
     else
        return ((halfn*halfn)%m*base)%m;
 }
main()
{
    int a,b,n,eat=0,iter;long long div=1000000007;
    scanf("%d%d%d",&a,&b,&n);
    f[0]=1;
    for(iter=1;iter<=n;iter++)
           f[iter]=((f[iter-1]*(n-iter+1))%div*find_mmi(iter,div-2,div))%div;
    long long no=a*n,new_no,k,tot_no=0;
   while(no<=b*n)
   {
    new_no=no;
    while(new_no>0)
    {
        k=new_no%10;
     if(k!=a&&k!=b)
     {
         eat=1;
         break;
     }
     new_no/=10;
    }
    if(eat==0)
        tot_no=(tot_no+f[(no-a*n)/(b-a)])%div;
   no+=b-a;
   eat=0;
   }
   printf("%I64d",tot_no%div);
   return 0;
}


#include <stdio.h>
#define ll long long
int main(){
    ll p,d;
	scanf("%lld %lld",&p,&d);
    ll n=++p;
    for(ll k=10;;k*=10){
        if(p%k>d)
			break;
        n=p-(p%k);
    }
	printf("%lld",n-1);
}


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

int main() {
	long long p, d, x, q_;
	int i;

	scanf("%lld%lld", &p, &d);
	q_ = p;
	x = 1;
	for (i = 0; i < 18; i++) {
		long long q;

		x *= 10;
		q = p % x == x - 1 ? p : (p / x - 1) * x + x - 1;
		if (p - q <= d)
			q_ = q;
	}
	printf("%lld\n", q_);
	return 0;
}


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

char greeting[5] = {'A', 'C', 'T', 'G','\0'};

int substring(char arr[]){
    int i,temp,sum=0,temp1;
    for(i=0;i<4;i++){
        if(greeting[i] != arr[i]){
            if(greeting[i] < arr[i]){
                temp = abs(greeting[i]-arr[i]);
                temp1 = 1 + abs('Z' - arr[i]) + abs('A' - greeting[i]);
                if(temp<temp1)
                    sum += temp;
                else
                    sum += temp1;
            }
            else{
                temp = abs(greeting[i]-arr[i]);
                temp1 = 1 + abs('A' - arr[i]) + abs('Z' - greeting[i]);
                if(temp<temp1)
                    sum += temp;
                else
                    sum += temp1;
            }
        }
    }
    return sum;
}

int main(){
    int n;
    char s[50];
    int i,count = 1000;
    scanf("%d",&n);
    scanf("%s",s);
    for(i=0;i<=n-4;i++){
        int temp = substring(s+i);
        if(temp<count){
            count = temp;
        }
    }
    printf("%d\n",count);
    return 0;
}


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

int main()
{
	int x,y,z,t1,t2,t3,time1,time2;
	scanf("%d%d%d%d%d%d",&x,&y,&z,&t1,&t2,&t3);
	time1=abs(y-x)*t1;
	time2=abs(x-z)*t2+3*t3+abs(x-y)*t2;
	if(time2<=time1)printf("YES\n");
	else printf("NO\n");
	return 0;
}


#include <stdio.h>

int main()
{
   int m,k,q,n=0,t,i;
   scanf("%d %d",&m,&k);
   i=2;
   while (i<9)
   {
	   t=m*i;
	   q=t/k;
	   if ((t%k)!=0)
	   n=n+q+1;
	   else
	   n=n+q;
	   i=i+3;
   }
   printf ("%d",n);
   return 0;
}


#include<stdio.h>
int main()
{
    int a[101][101];
    int n,i,j,t;
    long long int sum=0;
    scanf("%d",&n);
    t=n/2;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    for(i=0;i<n;i++)
    {
        sum+=a[i][i];
    }
    for(i=0,j=n-1;i<n;i++,j--)
    {
        if(i==j)continue;
        else
            sum=sum+a[i][j];
    }
    for(i=0;i<n;i++)
    {
        if(i==t)continue;
        else
            sum+=a[i][t]+a[t][i];
    }
    printf("%lld\n",sum);
    return 0;
}


#include<stdio.h>

int main()
{
    long long int l,r;
    scanf("%lld %lld",&l,&r);

    int len2 = 0, len3 =0;

    long long int pow2[100],pow3[100];
    long long ans =0;

    long long int x = 1;
    while(x<=r)
    {
        pow2[len2++]=x;
        if(x>=l)
        {
            //printf("%lld\n",x);
            ans++;
        }
        x*=2;
    }

    x = 1;
    while(x<=r)
    {
        pow3[len3++]=x;
        if(x>=l)
        {
            //printf("%lld\n",x);
            ans++;
        }
        x*=3;
    }

    int i,j;
    for(i = 1;i<len2;i++)
    {
        for(int j=1;j<len3;j++)
        {
            x = pow2[i]*pow3[j];
            if(x>= l && x<=r)
            {
                //printf("%lld\n",x);
                ans++;
            }
        }
    }

    if(l==1)
        ans--;

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


#include <stdio.h>

int main(){
  int n, k;
  scanf("%d%d", &n, &k);
  if(!k || k == n){
    printf("0 0\n");
  }
  else{
    printf("1 %d\n", (k <= n/3) ? 2*k : n-k);
  }
}


#include <stdio.h>

int main(){

	long long int n,k, max=0LL;
	int min = 1;

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

	if ( k >= ((n % 3 == 0)? n/3 : n/3+1) )
		max = n-k;
	else
		max = 2*k;

	if ( k == 0 || k == n){
		max = 0LL;
		min = 0;
		}

	printf("%i %lld\n", min, max);

	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    char a[101];
    int i,j,k,sum=0;
    scanf("%s",a);
    k=strlen(a);
    for(i=0;i<k;i++)
    {
        if(a[i]=='>')
            sum=sum*16+8;
        else if(a[i]=='<')
            sum=sum*16+9;
        else if(a[i]=='+')
            sum=sum*16+10;
        else if(a[i]=='-')
            sum=sum*16+11;
        else if(a[i]=='.')
            sum=sum*16+12;
        else if(a[i]==',')
            sum=sum*16+13;
        else if(a[i]=='[')
            sum=sum*16+14;
        else if(a[i]==']')
            sum=sum*16+15;

        sum=sum%1000003;
    }
    printf("%d",sum);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>
const int p = 1000003;
int convtoint(char s)
{
    switch(s)
    {
        case '1': return 1;
        /*case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;*/
        case '0': return 0;
    }
}

int power(int a, int b)
{
    int s = 1;
    for(int i = 0; i < b; i++)
    {
        s *= a;
        s %= p;
    }
    return s;
}

int main(void)
{
    char ss[101];
    char bin[401];
    unsigned long long int sum = 0;
    int f = 0;
    strcpy(bin, "");
    scanf("%s", ss);
    int len = strlen(ss);
    for(int i = 0; i < len; i++)
    {
        switch(ss[i])
        {
            case '>': strcat(bin, "1000"); break;
            case '<': strcat(bin, "1001"); break;
            case '+': strcat(bin, "1010"); break;
            case '-': strcat(bin, "1011"); break;
            case '.': strcat(bin, "1100"); break;
            case ',': strcat(bin, "1101"); break;
            case '[': strcat(bin, "1110"); break;
            case ']': strcat(bin, "1111");
        }
    }
    for(int i = strlen(bin)-1; i >= 0; i--)
    {
        sum += power(2, f) * convtoint(bin[i]);
        sum %= p;
        f++;
    }
    printf("%I64u", sum);
    return 0;
}


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

int main()
{
	int x, i, h, f=0, y=0;
	char s[501];

	scanf("%s", s);
	x=strlen(s);
	int a[x+1];

	for(h=0; h<x; h++)
	{
		a[h]=s[h]-97;
	}
	for(i=0; i<x; i++)
	{
		if(i==0 && a[i]!=0)
		{
			y=1;
			break;
		}
		else if(a[i]>f)
		{
			if(a[i]-f==1)
			{
				f++;
			}
			else
			{
				y=1;
				break;
			}
		}
	}
	if(y==1)
	{
		printf("NO");
	}
	else
	{
		printf("YES");
	}
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
   char s[502];
   scanf("%s",s);
   int ans[502];
   int m=strlen(s);
   for(int i=0;i<m;i++)
       ans[i]=s[i]-'a';
    int max=0;
    if(ans[0]!=0)
    {
        printf("NO");
        return 0;
    }
    else
    {
        for(int i=1;i<m;i++)
        {
            if(ans[i]>max+1)
            {
                printf("NO");
                return 0;
            }
            else if(ans[i]==max+1)
                max++;
        }
        printf("YES");
    }
    return 0;
}


#include <stdio.h>
int main(int argc, char const *argv[])
{ int n,m,v;
  scanf("%d %d %d",&n,&m,&v);
  if (n==1 || m==1 || v==1) {
    printf("YES\n");
    return 0;
    /* code */
  }
  if (n==2 && m==2) {
    printf("YES\n");
    return 0;
    /* code */
  }
  if (m==2 && v==2) {
    printf("YES\n");
    return 0;
    /* code */
  }
  if (v==2 && n==2) {
    printf("YES\n");
    return 0;
    /* code */
  }
  if (m==3 && n==3 && v==3) {
    printf("YES\n");
    return 0;
    /* code */
  }
  if (m==4 && n==4 && v==2) {
    printf("YES\n");
    return 0;
    /* code */
  }
  if (v==4 && n==4 && m==2) {
    printf("YES\n");
    return 0;
    /* code */
  }
  if (m==4 && v==4 && n==2) {
    printf("YES\n");
    return 0;
    /* code */
  }
  printf("NO\n" );
  return 0;
}


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

int compare_char(char *a,char *b){
	return strcmp(a,b);
}

int intsort(const void *a, const void *b){
	return *(int*)b - *(int*)a;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}

int main(){
	int i,N,j,p,a[4]={0},b[i],cnt=0,min,ans=0,x,y,z,day=0;
	for(i=0;i<3;i++){
	scanf("%d",&a[i]);
	}
/*	if(a[0]%3==0){
*/

b[0]=a[0]/3;
min=b[0];
/*	}else{
		b[0]=a[0]/3+1;
	}
	if(a[1]%2==0){
*/
b[1]=a[1]/2;
if(min>b[1])min=b[1];
/*	}else{
		b[1]=a[1]/2+1;
	}
	if(a[2]%2==0){
*/
b[2]=a[2]/2;
if(min>b[2])min=b[2];
/*	}else{
		b[2]=a[2]/2+1;
	}
*/

ans=min*7;
a[0]-=3*min;
a[1]-=2*min;
a[2]-=2*min;
min=0;
x=a[0];
y=a[1];
z=a[2];
	//sun
	while(1){
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	}
	min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
				//月
	while(1){
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
			//火曜
	while(1){
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
			//水曜
	while(1){
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
			//木曜
	while(1){
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

	day=0;
	x=a[0];
	y=a[1];
	z=a[2];
			//金曜
	while(1){
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

day=0;
x=a[0];
y=a[1];
z=a[2];

			//土曜
	while(1){
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(y>0){
	y--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	if(x>0){
	x--;
	day++;
	}else{
	break;
	}
	if(z>0){
	z--;
	day++;
	}else{
	break;
	}
	}
	if(min<day)min=day;

printf("%d\n",ans+min);
	return 0;
}


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

int main(){

    long long  totald,min,a,b,c,ca,cb,cc;
    scanf("%lld%lld%lld",&a,&b,&c);
    ca=a/3;a=a%3;
    cb=b/2;b=b%2;
    cc=c/2;c=c%2;
    min=ca<cb?(ca<cc?ca:cc):(cb<cc?cb:cc);
    ca-=min;
    cb-=min;
    cc-=min;
    totald=min*7;
    a+=ca*3;
    b+=cb*2;
    c+=cc*2;

     //printf("%lld %lld %lld %lld\n",a,b,c,totald);

    long long count,max=-1,tmpa,tmpb,tmpc,arr[14];
    for(int i=0;i<14; i++){
        tmpa=a;
        tmpb=b;
        tmpc=c;
        memset(arr,0,sizeof(arr));
        for(int j=i;j<14; j++){
            if((j%7==0 || j%7==3) && tmpb){
                arr[j]=1;
                tmpb--;
            }
            else if((j%7==1 || j%7==2 || j%7== 5 )&& tmpa){
                arr[j]=2;
                tmpa--;
            }
            else if((j%7==4 || j%7==6 )&& tmpc){
                arr[j]=3;
                tmpc--;
            }
        }
        count=0;
        for(int k=i;k<14; k++){
            if(arr[k]==0)break;
          //printf("%d ",arr[k] );
            count++;
        }
      //puts("");
        if(count>max){
            max=count;
        }
    }
    printf("%lld\n",totald+max);
    return 0;
}


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


#include<stdio.h>

int main()
{
	int a,b;
	scanf("%d %d",&a,&b);

	int i,j,calc=0;

	for(i=1;;i++) {
		calc=b*i;
		if(calc>a) {
			printf("%d",calc);
			break;
		}
	}
	return 0;
}


#include<stdio.h>
int main()
{
    int i,n,a=0;
    scanf("%d",&n);
    int t[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&t[i]);
    }
    for(i=0;i<n;i++)
    {
        if(t[i]-a<=15) a=t[i];
        else break;
    }
    if(90-a<=15) a=90;
    else a=a+15;
    printf("%d",a);
    return 0;
}


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

int main()
{
    int n,i,sum=0,v;
    scanf("%d",&n);
        int a[n];

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

        }
            else
            {

            break;}

        }
        sum=sum+15;
        if(sum>=90)
            sum=90;
    printf("%d",sum);
    return 0;
}


#include<stdio.h>
int main()
{
    int a,i,j,temp,sum=0,count=0;
    int ara[12];

    scanf("%d",&a);

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

    for(i=0;i<11;i++)
    {
        for(j=0;j<11;j++)
        {
            if(ara[j]<ara[j+1])
            {
                temp=ara[j];
                ara[j]=ara[j+1];
                ara[j+1]=temp;
            }
        }

    }

    for(i=0;i<12;i++)
    {
        sum=sum+ara[i];
        count++;
        if(sum>=a)break;

   } if(a==0)printf("0");
   else if(sum<a)printf("-1");
   else if(sum>=a) printf("%d",count);

}


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


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


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

int main(void)
{
    int n;
    int d1, d2;
    scanf("%d", &n);
    if(n==1||n==2)
        printf("%d", n+1);
    else
    {
        for(int m=1; m<=n+1; m++)
        {
            if(m%2==0)
            {
                d1 = m/2;
                d2 = m/2;
                int max = d1*d2;
                if(n<=max)
                {
                    printf("%d", m);
                    break;
                }
            }
            else
            {
                d1=m/2;
                d2=m/2 + 1;
                int max = d1*d2;
                if(n<=max)
                {
                    printf("%d", m);
                    break;
                }
            }
        }
    }
}


#include<stdio.h>
int main(void)
{
    int s,v1,v2,t1,t2,x,y;
    scanf("%d %d %d %d %d",&s,&v1,&v2,&t1,&t2);
    x=(s*v1)+(t1*2);
    y=(s*v2)+(t2*2);
    if(x<y) printf("First");
    else if(x>y) printf("Second");
    else printf("Friendship");
    return 0;
}


#include<stdio.h>
int main()
{
    int s,v1,v2,t1,t2;
    int p,q;
    scanf("%d %d %d %d %d",&s,&v1,&v2,&t1,&t2);
    p=s*v1+2*t1;
    q=s*v2+2*t2;
    if(p>q)
    printf("Second");
    else if(q>p)
    printf("First");
    else
    printf("Friendship");

    return 0;
}


//BR34k
#include <stdio.h>
int min(int a, int b)
{
     if (a < b) {
      return a;
     } else {
      return b;
     }
}
int gcd(int a, int b)
{
     if (a < b)
        return gcd(b, a);
     if (a % b == 0)
        return b;
    return gcd(b, a % b);
}

int main()
{
     int a, b, x, y, g;
     scanf("%d %d %d %d", &a, &b, &x, &y);
     g = gcd(x, y);
     x /= g; y /= g;
     a /= x; b /= y;
     printf("%d %d\n", min(a, b) * x, min(a, b) * y);

     return 0;
}


#include <stdio.h>
#define max(a,b) (a>=b?a:b)
#define min(a,b) (a<=b?a:b)
int gcd (int a , int b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}/*
int max(int x,int y)
{
    return x>=y?x:y;
}
int min(int x,int y)
{
    return x<=y?x:y;
}*/
int main()
{
    int a,b,x,y;
    int deltab=0;
    int comm_ratio,m;
    scanf("%d %d %d %d",&a,&b,&x,&y);

    comm_ratio=gcd(max(x,y),min(x,y));
    x/=comm_ratio;
    y/=comm_ratio;

    m=min(a/x,b/y);

    if ( m==0)
    {
        printf("0 0\n");
    }
    else
    {
        printf("%d %d\n",x*m,y*m);
    }

    return 0;
}


#include<stdio.h>

int main()
{
    int a,b,c=0;
    scanf("%d %d",&a,&b);
    while(a<=b)
    {
        a=a*3;
        b=b*2;
        if(b<a)
        {
            c++;
            break;
        }
        else
        {
            c++;
        }
    }
    printf("%d",c);
    return 0;
}


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

int main()
{
    int a,b;
    int years = 1;
    scanf("%d %d",&a,&b);
    while(a <= b)
    {
        a = a*3*years;
        b = b*2*years;
        years++;
    }
    years--;
    printf("%d",years);
    return 0;
}


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

int main()
{
    int n,m,p,d,r;  //the number of lane r, the number of desk d
    char side;      //side of the desk

    scanf("%d", &n);
    scanf("%d", &m);
    scanf("%d", &p);

    if(p % 2 != 0)
    {
        side = 'L';
        p++;
    }
    else side = 'R';

    d = (p/2) % m;
    if (d == 0) d = m;

    r = (p-2*d)/(2*m) + 1;

    printf("%d %d %c", r,d,side);
}


#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    if(n==20)printf("15");
    else if(n>=11 && n<=21)printf("4");
    else printf("0");
}


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

    x=n-10;
    if(x<=0 || x>11)
    printf("0\n");
    else if(x<10 || x==11)
        printf("4\n");
    else if(x==10)
        printf("15\n");
    return 0;
}


#include<stdio.h>

int main()
{
    int n,m,a,b,c,count=0,x;
    scanf("%d%d",&n,&m);

    for(a=0;a<=1000;a++)
    {
        b = n - a*a;
        if(b>=0)
        {
            x = a +b*b;
            if(x == m)
                count++;
        }
    }
    printf("%d",count);
    return 0;
}


#include <stdio.h>
int main() {
  int n,m,cnt=0;
  scanf("%d%d",&n,&m);
  for (int i=0;i<=31;i++)
    for (int j=0;j<=31;j++)
      if (i*i+j==n&&j*j+i==m) cnt++;
  printf("%d\n",cnt);
  return 0;
}


#include<stdio.h>

int main(){
	int i,a;
	int n,bx,m,by;
	long long int num1=0,num2=0;
	scanf("%d %d",&n,&bx);
	for(i=0;i<n;i++){
		scanf("%d",&a);
		num1=num1*bx+a;
	}
	scanf("%d %d",&m,&by);
	for(i=0;i<m;i++){
		scanf("%d",&a);
		num2=num2*by+a;
	}
	long long int check=num2-num1;
	if(check==0){
		printf("=\n");
	}
	else if(check<0){
		printf(">\n");
	}
	else if(check>0){
		printf("<\n");
	}
	return 0;
}


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

int main(){
	int n, m;
	int bx, by;
	long long a =0, b = 0;
	int i;
	int digit;
	long long mul = 1;

	scanf("%d %d", &n, &bx);
	for(i=0; i<n-1; i++){
		mul *= bx;
	}
	for(i=0; i<n; i++){
		scanf("%d", &digit);
		a = a + (digit * mul);
		mul /= bx;
	}

	scanf("%d %d", &m, &by);
	mul = 1;
	for(i=0; i<m-1; i++){
		mul *= by;
	}
	for(i=0; i<m; i++){
		scanf("%d", &digit);
		b = b + (digit * mul);
		mul /= by;
	}

	if(a > b) printf(">");
	if(a < b) printf("<");
	if(a == b) printf("=");

	return 0;
}


#include<stdio.h>
int main(){
    int l,d,g,r,v,sum,ok=0,a;
    double t,t1,t2,t3;
    scanf("%d%d%d%d%d",&l,&d,&v,&g,&r);
    t=((double)d)/((double)v);
    t1=((double)l)/((double)v);
    sum=g+r;
    t2=t/(double)sum;
    a=(int)t2;
    if(a*sum+g>t){
                  printf("%lf\n",t1);
                  }
    else{
         t3=(a+1)*sum+(double)(l-d)/(double)v;
         printf("%lf\n",t3);
         }
    return 0;
}


#include <stdio.h>

int main() {
	int l,d,v,g,r,dr;
	scanf("%d %d %d %d %d\n",&l,&d,&v,&g,&r);
	dr=d%((g+r)*v);
	if (dr<g*v) printf("%lf\n",l*1./v);
	else printf("%lf\n",(d+r*v)/(v*(g+r))*(g+r)+(l-d)*1./v);
	return 0;
}


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

#define N 1000001

int main() {
    int b[N];
    for (int i = 0; i < N; i++) {
        b[i] = 1;
    }

    for (int i = 2; i < (int)sqrt(N)+1; i++) {
        if (b[i-2]) {
            for (int j = 2*i; j < N; j += i) {
                b[j-2] = 0;
            }
        }
    }

    int x2;
    scanf("%d", &x2);
    /*if (x2 == 1000000) {
        printf("3");
        return 0;
    }*/

    int p = 1;
    int inter1 = 1;
    while (p*p <= x2) {
        if (x2%p == 0) {
            if (b[x2/p-2]) {
                if (x2/p > inter1) {
                    inter1 = x2/p;
                }
            }
            else if (b[p-2]) {
                if (p > inter1) {
                    inter1 = p;
                }
            }
        }
        p++;
    }

    int ans = x2;
    for (int x1 = x2; x1 > x2-inter1; x1--) {
        int p = 2;
        int inter2 = 1;
        while (p*p <= x1) {
            if (x1%p == 0) {
                if (b[x1/p-2]) {
                    if (x1/p > inter2) {
                        inter2 = x1/p;
                    }
                }
                else if (b[p-2]) {
                    if (p > inter2) {
                        inter2 = p;
                    }
                }
            }
            p++;
        }
        //printf("%d\n", inter2);
        if (x1-inter2+1 < ans) ans = x1-inter2+1;
    }
    if (ans < 3) {
        printf("3");
    }
    else{
        printf("%d", ans);
    }
}


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

long v[1000001];

long min(long a,long b)
{
    if (a>b)
        return b;
    else
        return a;
}

int main()
{
    long n,i,j,result;
    scanf("%ld",&n);
    for (i=1;i<=1000000;i++)
        v[i]=1;
    for (i=2;i<=1000000;i++)
        if (v[i]==1)
        {
            j=i;
            while (j<=1000000)
            {
                v[j]=i;
                j+=i;
            }
        }
    result=1000000000;
    //printf("%ld\n",n-v[n]+1);
    for (i=n-v[n]+1;i<=n;i++)
        if (i!=v[i])
            result=min(result,i-v[i]+1);
    printf("%ld\n",result);
    return 0;
}
// x0>=3


#include<stdio.h>
int main(){
    long long n;
    scanf("%lld",&n);
    printf("%lld",n/2520);

}


#include<stdio.h>
#include<math.h>
int main()
{
   long long int n,m;
    scanf("%lld",&n);
    printf("%lld\n",(n/2520));
}


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

int main(int argc, char const *argv[])
{
	long long int i,j,k,l,n,q,x,y,p,m,a,b,c,d;
	// a = c
	// b = x0;
	// c = x1;
	// d = a;
	// l = l;
	scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&l);
	x = 0;
	i = 0;
	j = 0;
	long long int count = 0;
	while(x<a){
		if(count >= 1)
			x = x-l;
		if(x < 0)
			x = 0;
		p = b + count*d;
		if(p>c)
			p = c;
		x = x + p;
		//printf("x : %d\n",x );
		count++;
	}

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

	return 0;
}


 #include<stdio.h>
 int main()
   {
       int c,v,p,a,l,i=0,r=0,b,d;
       scanf("%d %d %d %d %d",&c,&v,&p,&a,&l);
       if(c==v)
        printf("1");
    else{
      for(i=0;i!=-1;i++)
      {
          if(i>0)
          r=r-l;
         d=v+i*a;
          if(d<=p)
           r=r+d;
         else if(d>p)
            r=r+p;
        if(r>=c)
       {
          b=i+1;
          i=-1;
          break;
        }
    }
      printf("%d",b);
    }
      return(0);
   }


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

int main()
{
    int i,j,res=0;
    char day1[15];
    char day2[15];

    char test[26][15]={"tu","tu","th","th","su","su","we","we","sa","sa","mo","mo","th","sa","tu","fr","fr", "su","we","fr","su","tu","fr","mo","we"};
    gets(day1);
    gets(day2);
    day1[2]='\0';
    day2[2]='\0';
    for(i=0,j=1;j<27;i++,j++)
    {
        if(!strcmp(day1,test[i]) && !strcmp(day2,test[j]))
            res=1;
    }

    if(res)
        printf("YES");
    else
        printf("NO");

    return 0;
}


/*#include<stdio.h>
#include<string.h>
//char days[][16] ={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
char *s[7] ={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
int jiancha(char*x)
{
	int i;
	for(i=0;i<7;i++)
	if(strcmp(x,s[i])==0)
	      break;
		return i;
}
int main()
{
	//static char s1[10],s2[10];
	char s1[10],s2[10];
	int a,b,c;
	scanf("%s%s",s1,s2);
	a=jiancha(s1);
	printf("%d\n",a);
	b=jiancha(s2);
	printf("%d\n",b);
    c=a>b?7+b-a:b-a;
	if(c==0||c==2||c==3)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}*/
#include<stdio.h>
#include<string.h>
char *s[7]={"monday","tuesday","wednesday","thursday","friday","saturday","sunday"};
int jiancha(char*x)
{
	int i;
	for(i=0;i<7;i++)
		if(strcmp(x,s[i])==0)
		break;
		return i;
}
int main()
{
	char s1[10],s2[10];
	int a,b,c;
	scanf("%s%s",s1,s2);
	a=jiancha(s1);

	b=jiancha(s2);
    c=a>b?7+b-a:b-a;

	if(c==0||c==2||c==3)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main()
{
    long long n,m,k,t,d=1;
    scanf("%lld%lld%lld",&n,&m,&k);
    t=abs(m)+abs(n);
    if(t<k)
        d=k-t;
    if(t==k||d%2==0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


#include <stdio.h>

int main() {
	static int aa[10];
	int n, i, j, amax, imax;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	for (i = 0; i < n; i++) {
		for (j = 1; j < n - i; j++)
			if (aa[j] - aa[j - 1] >= 2 || aa[j] - aa[j - 1] <= -2) {
				printf("NO\n");
				return 0;
			}
		amax = 0;
		for (j = 0; j < n - i; j++)
			if (amax < aa[j])
				amax = aa[j], imax = j;
		for (j = imax; j < n - i - 1; j++)
			aa[j] = aa[j + 1];
		aa[n - i - 1] = amax;
	}
	printf("YES\n");
	return 0;
}


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


#include<stdio.h>
int n,l,r,x,a[20],ans=0,state=0;
void func(int k,int d,int e,int h,int t)
{
	if(k==n)
	{
		if(h-e>=x && d>=l && d<=r && t>1)
		{
			ans++;
			//	printf("%d %d %d %d\n",t,d,e,h);
		}
		return;
	}
	if(state==0)
	{
		state=1;
		func(k+1,d+a[k],a[k],a[k],t+1);
		state=0;
		func(k+1,d,e,h,t);
	}
	else
	{
		if(a[k]<e)
		{
			func(k+1,d+a[k],a[k],h,t+1);
			func(k+1,d,e,h,t);
		}
		else if(a[k]>h)
		{
			func(k+1,d+a[k],e,a[k],t+1);
			func(k+1,d,e,h,t);
		}
		else
		{
			func(k+1,d+a[k],e,h,t+1);
			func(k+1,d,e,h,t);
		}
	}
	return;
}
int main()
{
	int i;
	scanf("%d %d %d %d",&n,&l,&r,&x);
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	func(0,0,0,0,0);
	printf("%d\n",ans);
	return 0;
}


/*
Spirits coming from the mind,
waking up my deepest horrors,
capture my thoughts, make me blind.

Weird, ‘cause I don't want to see
the abyss of my possibilities.

Scared I can't look away.

It has come to my side.
Sister demon - my bride.

I want you, I need you
and I have set you free.
You're always right behind me,
I know the devil's sent you to me.
You want me, you need me,
now that I've set you free.
Look always right behind you,
You know the devil's sent me to you.

What has started as a longing
almost is possession now,
it drives me again and again.
Put a light into your window,
maybe I can find a hold.
I run against myself ‘till I find the end.

Sent by the devil
*/

/* .................... compiled by alankar....................
*/

//......................SHORTCUTS..............................

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

#define pi 3.14159265358979323846  //float type
#define MAX 100000  //for rmq
#define SQRTMAX 317   //for rmq
//#define gc getchar_unlocked

#define FOR(i,a,b) for(i=(a);i<(b);i++)

//only for +ve and single terms
#define s(x) scanf("%d",&x);
#define sl(x) scanf("%lld",&x);
#define p(x) printf("%d\n",x);
#define pl(x) printf("%lld\n",x);
//..........................................................

typedef long long int ll;
const ll MOD=1000000007;

//returns int and +ve numbers

/*inline int inp(){
    int n=0;
    char c;
    c=gc();
    while(c<'0' || c>'9'){
        c=gc();
    }
    while(c>='0' && c<='9'){
        n=(n<<3)+(n<<1)+c-'0';
        c=gc();
    }
    return n;
}
*/
//...................................

//power with mod........long long int
 ll power(ll a,ll b,ll mod){
      if(b==0)
            return 1;
      ll temp=power(a,b/2,mod);
      temp=(temp*temp)%mod;
      if(b&1)
            temp=(temp*a)%mod;
      return temp;
}

 //power without mod........ int
ll pwr(ll a,ll b){
      if(b==0)
            return 1;
      ll temp=pwr(a,b/2);
      temp=(temp*temp);
      if(b&1)
            temp=(temp*a);
      return temp;
}
 // .....long long int
ll gcd(ll a,ll b){
      return b==0?a:gcd(b,a%b);
}
 //......long long int
ll lcm(ll a,ll b){
      return (a/gcd(a,b))*b;
}
 //......long long int with mod
ll modularInverse(ll a,ll m){
      return power(a,m-2,m);
}

 //only for int
 int min(int a,int b) { return a<b? a : b; }
 int max(int a,int b) { return a>b? a : b; }

//normal compare func on integers //for qsort(name,size,sizeof(type),compare)
int compare (const void * a, const void * b)
{
  return ( *(int*)a - *(int*)b );
}

int BinarySearch(int *array, int number_of_elements, int key)
{
        int low = 0, high = number_of_elements-1, mid;
        while(low <= high)
        {
                mid = (low + high)/2;
                if(array[mid] < key)
                {
                        low = mid + 1;
                }
                else if(array[mid] == key)
                {
                        return mid;
                }
                else if(array[mid] > key)
                {
                        high = mid-1;
                }

        }
        return -1;
}
//.......................................................

//segment tree
//not template but how to use ST
//for minimum element
/*
long long s[400000];
long long a[1000000];
int create(long long b,long long e,long long n)
{
    if(b==e)
    {
        s[n]=a[b];
    }
    else
        {
            create(b,(b+e)/2,2*n+1);
            create((b+e)/2+1,e,2*n+2);
            s[n]=s[2*n+1]<s[2*n+2]?s[2*n+1]:s[2*n+2];
        }
    return 0;
}

//for finding minimum element b/w l and r
long long messi(long long b,long long e,long long l,long long r,long long n)
{
    long long i,j;
    if(e<l||b>r)
    {
        return 100000001;
    }
    if(b>=l&&e<=r)
    {
        return s[n];
    }
    i=messi(b,(b+e)/2,l,r,2*n+1);
    j=messi((b+e)/2+1,e,l,r,2*n+2);
    return i<j?i:j;
}
*/
//............................................................................
//range minimam query
//for mim and max number
/*

//preprocess create the min array

long min[SQRTMAX], max[SQRTMAX], b[MAX];
int size, n;

void preProcess(int n){
    int i=0, j=0, k=0;
    long minimum, maximum;

    size = sqrt(n);
    //printf("size = %d\n",size);
    while(j<size){
        minimum = maximum = b[i];
        for(k=0 ; k<size ; k++){
            if(minimum>b[i])
                minimum = b[i];
            if(maximum<b[i])
                maximum = b[i];
            i++;
        }
        min[j] = minimum;
        max[j] = maximum;
        j++;
    }
}

long findMin(int l, int r){
    int j, j2;
    long minimum = b[l];

    j = l/size + 1;
    j2 = r/size - 1;

    //printf("j= %d and j2 = %d\n", j,j2);
    while(l<j*size && l<=r){
        if(minimum > b[l]){
            minimum = b[l];

        }
        //printf("Checked for %d\n", l);
        l++;
    }
    while(j<=j2 && l<=r && j<size){
        if(minimum > min[j])
            minimum = min[j];
        l = (j+1)*size;
        //printf("Checked for %d  <-->  %d\n", j*size, l-1);
        j++;
    }
    while(l<=r){
        if(minimum > b[l]){
            minimum = b[l];
        }
        //printf("Checked for %d\n", l);
        l++;
    }
    return minimum;
}

//finding max value
long findMax(int l, int r){
    int j, j2;
    long maximum = b[l];

    j = l/size + 1;
    j2 = r/size - 1;

    //printf("j= %d and j2 = %d\n", j,j2);
    while(l<j*size && l<=r){
        if(maximum < b[l]){
            maximum = b[l];

        }
        //printf("Checked for %d\n", l);
        l++;
    }
    while(j<=j2 && l<=r && j<size){
        if(maximum < max[j])
            maximum = max[j];
        l = (j+1)*size;
        //printf("Checked for %d  <-->  %d\n", j*size, l-1);
        j++;
    }
    while(l<=r){
        if(maximum < b[l]){
            maximum = b[l];
        }
        //printf("Checked for %d\n", l);
        l++;
    }
    return maximum;
}
*/

//...........................................END OF TEMPLATE.................................................................

ll a[20];
int main()
{ ll i,j=20,k=20,t,n,l,r,x,ans=0,xe,tot,sum=0,ju=0,ma,mi;
    sl(n)
    sl(l)
    sl(r)
    sl(x)

    FOR(i,0,n)
    sl(a[i])

    qsort(a,n,sizeof(ll),compare);

    FOR(i,0,n)
    {
        if(a[i]>=l)
        {
            j=i;
            break;
        }
    }

    for(i=n-1;i>=0;i--)
    {
        if(a[i]<=l)
        {
            k=i;
            break;
        }
    }

    if(n<2)
        printf("0\n");

      else
      {

          FOR(i,3,1<<n)
          {
              xe=i;
              tot=0;
              while(xe)
              {
                  xe=(xe&(xe-1));
                  tot++;
              }
             // pl(tot)
              if(tot<2)
                continue;

               sum=0;
                ju=0;
                ma=0,mi=1000000000000;
               FOR(j,0,n)
               {
                   if((i>>j)&1)
                   {

                       {
                           if(a[j]>=ma)
                            ma=a[j];
                           if(a[j]<=mi)
                            mi=a[j];
                           sum=sum+a[j];
                       }

                   }
               }
               if(sum>=l&&sum<=r&&ju==0&&(ma-mi>=x))
                ans++;

          }

          pl(ans)
      }

    return 0;
}


#include <stdio.h>

int main(int argc, char **argv)
{
  unsigned long tie, scarf, vest, jacket;
  int suit_cost_jt, suit_cost_jsv, no_suit_jt = 0, no_suit_jsv = 0;
  // zero input protection or validation
  scanf("%lu\n%lu\n%lu\n%lu\n%d\n%d", &tie, &scarf, &vest, &jacket, &suit_cost_jt, &suit_cost_jsv);

  if ( jacket <= scarf && jacket <= vest ) {
        no_suit_jsv = jacket;
        jacket = 0;
  } else if ( scarf <= jacket && scarf <= vest) {
        no_suit_jsv = scarf;
        jacket -= scarf;
  } else {
        no_suit_jsv = vest;
        jacket -= vest;
  }

  if (tie > jacket) {
        no_suit_jt = jacket;
        tie -= jacket;
  } else {
        no_suit_jt = tie;
        tie = 0;
  }

  if (suit_cost_jt > suit_cost_jsv) {
        if (tie > no_suit_jsv)
          tie = no_suit_jsv % tie;
        no_suit_jsv -= tie;
        no_suit_jt  += tie;
  }

  printf("%d\n", no_suit_jt * suit_cost_jt + no_suit_jsv * suit_cost_jsv);
  return 0;
}


#include <stdio.h>

int main() {

	int i, index, index2, suit1Cost, suit2Cost, remainder, total=0;
	unsigned int clothes[4];
	unsigned int smallest = 100001;

	scanf("%d", &clothes[0]);
	scanf("%d", &clothes[1]);
	scanf("%d", &clothes[2]);
	scanf("%d", &clothes[3]);
	scanf("%d", &suit1Cost);
	scanf("%d", &suit2Cost);

	for (i = 0; i < 4; i++) {
		if (clothes[i] < smallest) {
			smallest = clothes[i];
			index = i;
		}
	}

	if (suit1Cost <= suit2Cost) {
		if (index == 0) {
			smallest = 100001;
			for (i = 1; i < 4; i++) {
				if (clothes[i] < smallest) {
					smallest = clothes[i];
					index = i;
				}
			}
			if (index == 3) {
				total = clothes[index] * suit2Cost;
			}
			else {
				remainder = clothes[3] - smallest;
				if (remainder <= clothes[0]) {
					total = ((smallest)*suit2Cost) + (remainder * suit1Cost);
				}
				else {
					total = ((smallest)*suit2Cost) + (clothes[0] * suit1Cost);
				}
			}
		}
		else if (index == 3) {
			total = clothes[index] * suit2Cost;
		}
		else {
			remainder = clothes[3] - smallest;
			if (remainder > 0) {
				total = smallest * suit2Cost;
				if (remainder <= clothes[0]) {
					total += remainder * suit1Cost;
				}
				else {
					total += clothes[0] * suit1Cost;
				}
			}
			else {
				total = clothes[3] * suit2Cost;
			}
		}
	}
	else if (suit1Cost > suit2Cost) {
		remainder = clothes[3] - clothes[0];
		if (index == 0) {
			total = clothes[0] * suit1Cost;
			smallest = 100001;
			for (i = 1; i < 4; i++) {
				if (clothes[i] < smallest) {
					smallest = clothes[i];
					index = i;
				}
			}

			if (remainder <= smallest) {
				total += remainder * suit2Cost;
			}
			else {
				total += smallest * suit2Cost;
			}
		}
		else if (index == 3) {
			total = clothes[3] * suit1Cost;
		}
		else {
			if (remainder > 0) {
				total = clothes[0] * suit1Cost;
				if (remainder <= smallest) {
					total += remainder * suit2Cost;
				}
				else {
					total += smallest * suit2Cost;
				}
			}
			else {
				total = clothes[3] * suit1Cost;
			}
		}
	}

	printf("%d", total);

	return 0;
}


#include<stdio.h>

int main(){
	int n,m;
	int i;
	scanf("%d%d",&n,&m);
	if(m/n!=2){
		printf("%d",0);
	}else{
		printf("%d",2*n-(m-n));
	}
	return 0;
}


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


#include<stdio.h>

int re(int n) {
	int f=1,r=0;
	for(;n;n/=10) if (n%10!=0) {
		r+=n%10*f;
		f*=10;
	}
	return r;
}

int main() {
	int a,b;
	scanf("%d %d",&a,&b);
	if (re(a)+re(b)==re(a+b)) puts("YES"); else puts("NO");
	return 0;
}


#include<stdio.h>

int digits(int num)
{
    int res=0, sum=1;
    while(num!=0)
    {
        res=res+(num%10)*sum;
        if(num%10!=0)
            sum=sum*10;
        num/=10;
    }
    return res;
}
int main()
{
    int a, b,c;
    scanf("%d %d", &a, &b);
    if(digits(a+b)==digits(a)+digits(b))
        printf("YES");
    else
        printf("NO");
    return 0;
}


#include <stdio.h>

#define N	1000000
#define MD	998244353

int kk[N + 1];

void init() {
	int i, j;

	for (i = 1; i <= N; i++)
		for (j = i; j <= N; j += i)
			kk[j]++;
}

int main() {
	int n, i, x, y;

	init();
	scanf("%d", &n);
	x = y = 1;
	for (i = 2; i <= n; i++)
		y = (y + (x = (y + kk[i]) % MD)) % MD;
	printf("%d\n", x);
	return 0;
}


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

int main(int argc, char *argv[]) {
	int h, m;
	scanf("%d:%d", &h, &m);
	h = h < 12 ? h : h - 12;
	if (m % 2 == 0) {
		printf("%.0f %d\n", h * 30.0 + m * 0.5, m * 6);
	} else {
		printf("%.1f %d\n", h * 30 + (float)m * 0.5, m * 6);
	}
	return 0;
}


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

#define Min(a, b) ((a) < (b) ? (a) : (b))

int ans[205], k = 0;

int sum(int x){
	int res = 0;
	while(x){
		res += x % 10;
		x /= 10;
	}
	return res;
}

int main(){
	int n, i;
	scanf("%d", &n);
	for(i = n-Min(n, 100); i < n+100; i++){
		if(i+sum(i) == n){
			ans[k++] = i;
		}
	}
	printf("%d\n", k);
	for(i = 0; i < k; i++){
		printf("%d ", ans[i]);
	}
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,a[10010],cnt,temp,sum,j;
    int ans=0;
    scanf("%d",&n);
    cnt=0;
    temp=n;
    memset(a,0,sizeof(a));
    while(temp)
    {
        temp=temp/10;
        cnt++;
    }
    for(i=n-9*cnt;i<=n;i++)
        {
            j=i;
            sum=i;
            while(j)
            {
                 sum+=(j%10);
                j/=10;
            }
            if(sum==n) a[ans++]=i;
        }

    if(ans==0) printf("0");
    else
    {
        printf("%d\n",ans);
        for(i=0;i<ans;i++)
            printf("%d ",a[i]);
    }
    return 0;
}


#include<stdio.h>
int max(int a,int b)
{
return (a>b?a:b);
}
int main()
{
int tux,pur,buz,bar,foo,quiz;
scanf("%d",&tux);
foo=bar=buz=0;
quiz=1;
while(tux--)
{
scanf("%d",&pur);
foo+=pur;
bar+=1;
if(max(foo*quiz,bar*buz)==foo*quiz)
{
buz=foo;
quiz=bar;
}
else
break;

}
printf("%.6f\n",(float)(buz)/(float)quiz);

return 0;

}


#include <stdio.h>

int a[50];

int main()
{
    int n;
    scanf("%d", &n);
    int i;
    double ans = -1;
    double sum = 0;
    for (i = 1; i <= n; i++)
    {
        int now;
        scanf("%d", &now);
        sum += now;
        if (sum / i > ans)
            ans = sum / i;
    }
    printf("%.10f\n", ans);
    return 0;
}


#include <stdio.h>

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

int main(void){ // HAI
    int tux; // I HAS A TUX
    scanf("%d", &tux); // GIMMEH TUX
    int foo = 0; // I HAS A FOO ITS 0
    int bar = 0; // I HAS A BAR ITS 0
    int baz = 0; // I HAS A BAZ ITS 0
    int quz = 1; // I HAS A QUZ ITS 1
    while (tux--){ // IM IN YR LOOP NERFIN YR TUX TIL BOTH SAEM TUX AN 0
        int pur; // I HAS A PUR
        scanf("%d", &pur); // GIMMEH PUR
        foo += pur; // FOO R SUM OF FOO AN PUR
        bar += 1; // BAR R SUM OF BAR AN 1
        if (max(foo * quz, bar * baz) == foo * quz){ // BOTH SAEM BIGGR OF PRODUKT OF FOO AN QUZ AN PRODUKT OF BAR BAZ AN PRODUKT OF FOO AN QUZ
            baz = foo; // BAZ R FOO
            quz = bar; // QUZ R BAR
        }
    }
    printf("%lf\n", (double)baz / quz); // VISIBLE SMOOSH QUOSHUNT OF BAZ QUZ
    return 0;
}


main()
{
    float ans;
    int n,a,b,c,d,num;
    scanf("%d",&n);
    a = 0;
    b = 0;
    c = 0;
    d = 1;
    while (n--) {
        scanf("%d",&num);
        a = a + num;
        b = b + 1;
        if (a * d >= b * c) {
            c = a;
            d = b;
        }
    }
    ans=(float)c;
    ans=ans/d;
    printf("%f",ans);
    return 0;
}


#include<stdio.h>

int main(){
	int tux=0,pur=0;
	scanf("%d",&tux);
	double foo=0,bar=0,baz=0,quz=1;
	for(int i=1;i<=tux;i++){
		scanf("%d",&pur);
		foo=foo+pur;
		bar++;
		if(foo*quz>baz*bar){
			baz=foo;
			quz=bar;
		}
	}
	printf("%.6f",baz/quz);
	return 0;
}


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

	int TUX;
	scanf("%d",&TUX);
	int FOO = 0, BAR = 0, BAZ = 0, QUZ = 1;
	while(TUX!=0)
	{
		int PUR;
		scanf("%d", &PUR);
		FOO = FOO + PUR;
		BAR = BAR + 1;
		if(FOO*QUZ >= BAR*BAZ)
		{
			BAZ = FOO;
			QUZ = BAR;
			//break;
		}
		else
			break;
		TUX--;
	}
	printf("%f\n", (BAZ*1.0)/QUZ);
	return 0;

}


#include<stdio.h>

int main(){
    int n;
    scanf("%d", &n);
    printf("%d", n ? 1 + (n - 1) % 9 : 0);
    return 0;
}


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

int main()
{
     int x,y,z,i,j,k,a,b,c = 0,n,m,t;
     scanf("%d",&a);

     loop:
     while(a > 0)
     {
          c += a%10;
          a /= 10;
     }

     if(c >= 10)
     {
          a = c;
          c = 0;
          goto loop;
     }
     printf("%d\n",c);
     return 0;
}


#include<stdio.h>
int lucky(long x,int l)
{
    if(x<0)
        x=-x;
    while(x>0)
    {
        if(x%10 == l)
            return 1;
        else
            x/=10;
    }
    return 0;
}
int main()
{
    long n;
    int l=8;
    scanf("%ld",&n);
    for(int p = 1;p <= 1000; p++)
    {
        if(lucky(n+p,l))
        {
            printf("%d\n",p);
            return 0;
        }
    }
}


#include <stdio.h>

int islucky(int n){

  if(n<0){
    n=-n;
  }

  int modfac=10;
  int divfac=1;

  while(n/divfac>0){
    int digit=(n%modfac)/divfac;
    if(digit==8){
      return 1;
    }
    modfac*=10;
    divfac*=10;
  }

  return 0; //n is not lucky
}

int main(void){

  int a;
  int b=1;
  scanf("%d", &a);

  while(islucky(a+b)==0){
    b+=1;
  }
  printf("%d\n", b);
}


#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
#define rep(start, n, c) for(((i)=(start));((i)<(n));((i)+=(c)))
#define MAX 100000
#define MAX_INT INT_MAX
int main() {
  int p, x, y;
  scanf("%d %d %d", &p, &x, &y);
  int *arr = (int*)malloc(25 * sizeof(int));
  int i;
  int k = 0, x_temp = x;
  // while(x_temp >= y) {
  //   int j = (x_temp / 50) % 475;
  //   for(i = 0;i < 25;i++) {
  //     //printf("%d ", (((j * 96 + 42) % 475) + 26));
  //     j = (((j * 96 + 42) % 475) + 26);
  //     if(j == p) {
  //       printf("%d", k);
  //       return 0;
  //     }
  //   }
  //   x_temp -= 100;
  // }
  while(1) {
    x_temp = x + 100 * k;
    while(x_temp >= y) {
      int j = (x_temp / 50) % 475;
      for(i = 0;i < 25;i++) {
        j = ((j * 96 + 42) % 475);
        // printf("%d ", j);
        if((j + 26) == p) {
          printf("%d", k);
          return 0;
        }
      }
      x_temp -= 50;
    }
    k++;
  }
  return 0;
}


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

int search(int arr[], int n, int x);
void mergeSort(int arr[], int l, int r);
void merge(int arr[], int l, int m, int r);

int main(void){
	int a, b, c, x, y, z;
	scanf("%i %i %i %i %i %i", &a, &b, &c, &x, &y, &z);
	int n1 = x-a, n2 = y-b, n3 = z-c;
	int n = ((n1>0)?n1:0) + ((n2>0)?n2:0) + ((n3>0)?n3:0);
    int m = 0;

    if(n1<0){
        m += abs(n1)/2;
    }
    if(n2<0){
        m += abs(n2)/2;
    }
    if(n3<0){
        m += abs(n3)/2;
    }

    if(m>=n){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
}

int search(int arr[], int n, int x)
{
    int i;
    for (i = 0; i < n; i++)
        if (arr[i] == x)
            return i;
    return -1;
}

void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 = r - m;

    /* create temp arrays */
    int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1 + j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2) {
        if (L[i] <= R[j]) {
            arr[k] = L[i];
            i++;
        }
        else {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1) {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2) {
        arr[k] = R[j];
        j++;
        k++;
    }
}

void mergeSort(int arr[], int l, int r)
{
    if (l < r) {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int m = l + (r - l) / 2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m + 1, r);

        merge(arr, l, m, r);
    }
}


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


#include<stdio.h>
#include<stdlib.h>
#define mod 1000000009u
typedef long long unsigned llu;
typedef unsigned u;
u F(u x)
{
	u r=1,e=2;
	for(++x;x;x>>=1)
	{
		if(x&1)r=r*(llu)e%mod;
		e=e*(llu)e%mod;
	}
	return r;
}
int main()
{
	u n,m,k,x,y,r;
	scanf("%u%u%u",&n,&m,&k);
	y=n-n/k;x=m-y;
	if(m<=y){printf("%u\n",m);return 0;}
	if((r=F(x)+mod-x-2)>=mod)r-=mod;
	r=(x+y+r*(llu)k)%mod;
	printf("%u\n",r);
	return 0;
}


#include <stdio.h>
#include <math.h>
#define modu 1000000009
__int64 answ;
int main()
{
	int n, m, k;
	__int64 pa, pb, pg;
	__int64 tt, ta;

	scanf("%d%d%d", &n, &m, &k);
	pa = n - m;
	pg = (pa + 1)*(k - 1);
	if (pg >= m)
	{
		answ = m;
		answ = (answ) % modu;
		printf("%I64d\n", answ);
		return 0;
	}
	else
	{
		pb = m - pg;
		tt = pb / k;
		if (pb%k != 0)
			tt = tt + 1;
		answ = 1;
		ta = 2;
		m = m - tt*k;
		tt = tt + 1;
		while (tt > 0)
		{
			if (tt & 1)
			{
				answ = answ * ta;
			}
			answ = answ%modu;
			ta = ta * ta;
			ta = ta%modu;
			tt = tt >> 1;
		}
		answ = answ*k - 2 * k;
		if (answ < 0) answ = answ + modu;
		answ = answ%modu;
	}
	answ = (answ + m) % modu;
	printf("%I64d\n", answ);
	return 0;
}


#include <stdio.h>
char s[101];
int min(int a,int b){return (a<b)?a:b;}
int main()
{
    int len,i;
    scanf("%d",&len);
    scanf("%s",s);
    int l,r,u,d;
    l=u=r=d=0;
    for(i=0;i<len;i++)
    {
        if(s[i]=='L') l++;
        else if(s[i]=='U') u++;
        else if(s[i]=='R') r++;
        else d++;
    }
    printf("%d\n",2*min(l,r)+2*min(u,d));
    return 0;
}


#include<stdio.h>
int min(int y,int x)
{
	if (y<x) return y;

	return x;
}
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int result = n-m;

	if (m==0)
	{
		printf("1\n");
	}
	else
	{
		printf("%d\n",min(result,m));
	}
	return 0;
}


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


#include<stdio.h>
int main(){
	long int a,b;
	scanf("%ld%ld",&a,&b);
	/*if(a%2!=0 && b%2!=0){
		if(a>b)
			printf("Masha\n");
		else if(a<b)
			printf("Dasha\n");
		else
			printf("Equal\n");
	}*/
	//if(a%2==0 || b%2==0){
	long int r,x,y;
	x=a;
	y=b;
	while(y!=0){
		r=x%y;
		x=y;
		y=r;
	}
//	printf("%ld\n",x);
	a=a/x;
	b=b/x;
		if(b-a==1 || a-b==1)
			printf("Equal\n");
		else if(a>b)
			printf("Masha\n");
		else if(a<b)
			printf("Dasha\n");
		else
			printf("Equal\n");
//	}
	return 0;
}


#include<stdio.h>
long long int GCD(long long int a,long long int b)    //recursive

{

   if (b==0) return a;

   return GCD(b,a%b);

}
int main()
{
    long long int a,b,lcm;
    scanf("%lld%lld",&a,&b );
    lcm=(a*b)/GCD(a,b);
    if(a<b)
    {
        if((lcm/a-1)<lcm/b)
        printf("Masha\n");
        else if((lcm/a-1)>lcm/b)
        printf("Dasha\n");
        else printf("Equal\n");
    }
    else
    {
        if((lcm/b-1)<lcm/a)
        printf("Dasha\n");
        else if((lcm/b-1)>lcm/a)
        printf("Masha\n");
        else printf("Equal\n");
    }
}


#include <stdio.h>

char passwd[4], str[4];
int main(){
  scanf("%s", passwd);

  int T, num=0, chk=0;
  scanf("%d", &T);
  while (T--) {
    scanf("%s", str);
    if (str[0]==passwd[0] && str[1] == passwd[1])
      chk=4;
    else if (str[1]==passwd[0] && str[0]==passwd[1])
      chk=4;
    else if (str[0]==passwd[1]){
      if (chk<4){
        if (chk==1) chk=4;
        else chk=2;
      }
    }
    else if (str[1]==passwd[0]){
      if( chk<4) {
        if (chk==2) chk=4;
        else chk=1;
      }
    }
  }

  if (chk==4) printf("YES\n");
  else printf("NO\n");

}


#include<stdio.h>
#include<string.h>
main()
{
    char c[90];
    int d=1,i,j,l;
    scanf("%d ",&l);
    gets(c);
    for(i=1;i<l;i++)
    {
        d=d+c[i]-48;
        if(c[i]=='0')
        {
            printf("%d",d);
            d=0;
        }
    }
    printf("%d",d);
}