#include <stdio.h>

int main(){
    int l,t;
    scanf("%d%d",&l,&t);
    char que[l];
    scanf("%s",que);
    while(t--){
       for(int i=0; i<l-1;){
            if(que[i]=='B'&& que[i+1]=='G'){
                que[i]=='G';
                que[i+1]=='B';
                i++;
            }
        }
    }

    printf("%s\n",que);

}


#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<cstring>
using namespace std;
#define Max 100010
queue<int>q;
int fa[Max],t,num[Max],du[Max];
bool vis[Max],inStack[Max];
stack<int>s,temp;
vector<int>g[Max],dg[Max];
bool haveCrcle(int n)
{
	bool ans=false;
	int u;
	while(!s.empty())
	{
		u=s.top();
		if(!du[u])
		q.push(u);
		temp.push(u);
		s.pop();
	}
	int cunt=0;
	while(!q.empty())
	{
		u=q.front();
		cunt++;
		q.pop();
		for(int i=0;i<g[u].size();i++)
		{
			int v=g[u][i];
			du[v]--;
			if(!du[v])
			{
				q.push(v);
			}
		}
	}

	if(cunt!=temp.size()) ans=true;
	return ans;
}
void tarjan(int rt)
{
	vis[rt]=true;
	s.push(rt);
	int i,a;
	inStack[rt]=true;
	for(i=0;i<dg[rt].size();i++)
	{
		int v=dg[rt][i];
		if(!vis[v])
		{
			tarjan(v);
		}
	}
}
int main()
{
	int n,m,i,j,a,b,fx,fy,ffx,ffy,ans=0;
		scanf("%d%d",&n,&m);
		for(i=0;i<m;i++)
		{
			scanf("%d%d",&a,&b);
			g[a].push_back(b);
			du[b]++;
			dg[a].push_back(b);
			dg[b].push_back(a);
		}
		for(i=1;i<=n;i++)
		{
			//printf("=%d\n",i);
			if(!vis[i])
			{
				memset(inStack,false,sizeof(inStack));
				 tarjan(i);
				 t++;//printf("\nt=%d\n"
				 if(haveCrcle(i)) ans+=temp.size();
				 else ans+=temp.size()-1;
				 while(!temp.empty())
				{
					temp.pop();
				 }
			 }
		}
		printf("%d",ans);
	return 0;
}


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

int max(int a[], int n) {
	int max, maxKey, i;

	max = 0;

	for(i = 0; i < n; i++) {
		if(max < a[i]) {
			max = a[i];
			maxKey = i;
		}
	}

	return maxKey;
}

int getOverlapCount(char s1[], char s2[]) {
	int i, c, overlapCount;

	overlapCount = 0;

	for(i = 0; s1[i] != '\0' && s2[i] != '\0'; i++) {
		if(s1[i] == s2[i]) overlapCount++;
	}

	return overlapCount;
}

int main(void) {
	char input[10];
	int letterCount;
	char* possibleSolutions[8] = {"vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"};
	int overlaps[8] = { 0 };
	int i;

	scanf("%d", &letterCount);
	scanf("%s", input);

	for(i = 0; i < 8; i++) {
		if(strlen(possibleSolutions[i]) == letterCount) {
			overlaps[i] = getOverlapCount(input, possibleSolutions[i]);
		}
	}

	printf("%s", possibleSolutions[max(overlaps, 8)]);

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
int main(void) {
  int n, d, fp, cp=1,jumps=0,j;
	char *path;
	scanf("%d %d",&n,&d);
	getchar();
	path = (char*)calloc(n,sizeof(n));
	scanf("%s",path);
	for(fp=n;fp>1 && cp!=n;fp--){
		if(path[fp-1]=='1'){
			for(j=d;cp+j>fp;j--);
			if(cp+j==fp){
				cp=fp;
				jumps++;
				fp=n+1;
			}
		}
	}
	if(cp==n)
		printf("%d",jumps);
	else
		printf("-1");
  return 0;
}


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

int main(void)
{
    int i, n, s, pos_c, pos_s, vel_c, win;
    char states[200], direction[10];

    scanf("%d%d%d%*s%s%s", &n, &pos_s, &pos_c, direction, states);

    if (!strcmp(direction, "head")) vel_c = -1;
    else vel_c = 1;

    s = strlen(states);

    if (pos_s < pos_c) pos_s = 1;
    else pos_s = n;

    win = 0;

    for (i = 0; i < s; i++)
    {
        if (pos_c == pos_s) { win = 1; break; }
        if (pos_c == 1 && vel_c == -1) vel_c = 1;
        if (pos_c == n && vel_c == 1) vel_c = -1;

        if (states[i] == 0)
        {
            pos_c += vel_c;
        }
        else
        {
            if (pos_c < pos_s && vel_c == 1)
                pos_s = 1;
            if (pos_c > pos_s && vel_c == -1)
                pos_s = n;
        }
    }

    if (win)
        printf("Controller %d\n", i+1);
    else
        printf("Stowaway\n");

    return 0;
}


#include <stdio.h>
int main() {
	int n,m,k;
	int i;
	char a[3],b[5];
	char c[201];
	char *p;
	// 1->     -1<-
	int d;
	scanf("%d %d %d", &n, &m, &k);
	scanf("%s %s",a,b);
	scanf("%s", c);

	if(n==2){
		printf("Controller 1\n");
		return 0;
	}

	if(b[0] == 'h')
		d = -1;
	else
		d = 1;

	for(p=c,i=1; *p!='\0'; p++,i++) {
		// move stowaway
		int f = 0
		if(d == 1) {
			if(*p=='1'){
				if(k!=1)
					m = k-1;
				else
					m = k+2;
			} else if(m-k==1 && m!=n){
				m += 1;
			}
			f = 1;
		}else{
			if(*p=='1'){
				if(k!=n)
					m = k+1;
				else
					m = k-2;
			} else if(k-m==1 && m!=1){
				m -= 1;
			}
		}

		// move controller
		k += d;
		if(k == 1)
			d = 1;
		if(k == n)
			d = -1;

		if(k == m && f == 0){
			printf("Controller %d\n",i);
			return 0;
		}
	}

	printf("Stowaway\n");

	return 0;
}


//http://codeforces.com/contest/569/problem/A

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

int main(void){
    int i,j;
    int speed;
    int dur,already;
    int meet;
    int time=0;
    scanf("%d %d %d",&dur,&already,&speed);
    while(1){
        time++;
        //remain=(dur-already)/(speed-1)*speed;//�ѴX��U��
        meet=already*(speed/(speed-1));
        if(meet<dur){
            already=meet;
        }
        else {
            break;
        }
    }
    printf("%d\n",time);
    return 0;
}


#include <stdio.h>
int main()
{
    long long int a[14] ;
    long long int d[14];
    for(long long int i = 0; i<14;i++) scanf("%lld",&a[i]);
    for(long long int i = 0; i<14;i++) d[i] = a[i];
    long long int c ; long long int c1 = 0; long long int c2 = 0;
    for(long long int i = 0; i<14;i++)
    {
        long long int b = a[i];
        if(b>0)
        {
            d[i] = 0;
            if(i!=13) c = i+1;
            else c = 0;
            for(long long int j = 1;j<=b;j++)
            {
                d[c] = d[c]+1;
                if(c!=13) c++;
                else c = 0;
            }
        }

        for(long long int j = 0; j<14; j++)
        {
            if(d[j]%2==0) c1 = c1+d[j];
        }
        if(c1>c2) c2 = c1 ;
        c1 = 0;
        for(long long int j = 0; j<14;j++) d[j] = a[j];
    }
    printf("\n%lld",c2);
}


#include<stdio.h>
#include<iomanip>
#include<string.h>
char s1[10],s2[10];
#define ll long long
int fact(int n);

int nCr(int n, int r)
{
    return fact(n) / (fact(r) * fact(n - r));
}

// Returns factorial of n
int fact(int n)
{
    int res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}

int main()
{
	scanf("%s",s1);
	scanf("%s",s2);
	int tot,db=0;
	int p1=0,n1=0,p2=0,n2=0;
	for(tot=0;s1[tot]!='\0';tot++);
	double res=0;
	for(int i=0;s1[i]!='\0';i++)
	{
		if(s1[i]=='+')p1++;
		else if(s1[i]=='-')n1++;

		if(s2[i]=='+')p2++;
		else if(s2[i]=='-')n2++;
		else if(s2[i]=='?')db++;
	}
	if(p2>p1 || n2>n1) res=0;
	else{
		ll div = (1<<db);
		res = (double)(nCr(db,p1-p2)) / div;
	}
// cout<<tot<<endl;
printf("%.12lf\n" , res);

}


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


# include <stdio.h>

int arr[100002];
void prime(){
	arr[1]=1;
	for (long int i=2;i<100002;i++){
		if (arr[i]==0){
			arr[i]=i;
			for (long int j=i*i;j<100002;j+=i){
				if (arr[j]==0) arr[j]=i;
			}
		}
	}
}

int main(void){
	prime();
	long long int n,count=0;
	scanf("%lld",&n);
	while (n>=0){
		if (n==0) break;
		n-=arr[n];
		count++;
	}
	printf("%lld\n",count);
	return 0;
}


#include <stdio.h>
int arr [1000000000];
int main()
{
//    printf("ertyg");
    long long int n;
    scanf("%lld",&n);
    if (n%2==0)
    {
        printf("%lld",n/2);
        return 0;
    }
    for (long long int i=3;i<=n;i++)
    {
//        printf("%lld",i);
        if (n%i==0)
        {
            n=n-i;
//            printf("%lld %lld ",i,n);
            break;
        }
    }
    printf("%lld",n/2+1);
    return 0;
}


#include <stdio.h>

#define MD	998244353

void mult(int aa[][2], int bb[][2], int cc[][2]) {
	int i, j;

	for (i = 0; i < 2; i++)
		for (j = 0; j < 2; j++)
			cc[i][j] = ((long long) aa[i][0] * bb[0][j] + (long long) aa[i][1] * bb[1][j]) % MD;
}

void power(int aa[][2], int pp[][2], int tt[][2], long long k) {
	if (k == 0) {
		int i, j;

		for (i = 0; i < 2; i++)
			for (j = 0; j < 2; j++)
				pp[i][j] = i == j;
		return;
	}
	if ((k & 1) == 0) {
		power(aa, tt, pp, k / 2);
		mult(tt, tt, pp);
	} else {
		power(aa, pp, tt, k / 2);
		mult(pp, pp, tt);
		mult(tt, aa, pp);
	}
}

int main() {
	static int aa[2][2], pp[2][2], tt[2][2];
	int n, m, l, r, e, o;

	scanf("%d%d%d%d", &n, &m, &l, &r);
	e = r / 2 - (l - 1) / 2, o = r - l + 1 - e;
	aa[0][0] = e, aa[0][1] = o;
	aa[1][0] = o, aa[1][1] = e;
	power(aa, pp, tt, (long long) n * m);
	printf("%d\n", pp[0][0]);
	return 0;
}


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

#define ll long long

ll solve(ll a, ll b) {
    ll i,k = 0;
    int* factors = malloc(sizeof(int)*1000*1000);
    //record the smaller factors of a
    for (i = 1; i*i <= a; i++) {
        if (a%i == 0) {
            factors[k++] = i;
            // printf("factor of a:%lli\n", i);
        }
    }
    //for each smaller factor of a+b
    ll answer = 2*(a+b+1);
    for (i = 1; i*i <= a+b; i++) {
        if ((a+b)%i == 0) {
            // printf("factor of a+b:%lli\n", i);
            //binary search a factor of a that is smaller than or equal to i
            int found = 0;
            ll hi = k;
            ll lo = 1;
            ll middle = 0;
            while (!found) {
                middle = (lo + hi)/2;
                if (middle == lo || middle == hi) {
                    break;
                } else if (factors[middle] < i) {
                    lo = middle;
                } else if (factors[middle] > i) {
                    hi = middle;
                } else { // middle = i
                    found = 1;
                    break;
                }
            }
            // printf("i found %lli for a, %lli for a+b\n", factors[middle],i);
            // printf("a/fact=%lli <= a+b/i=%lli?\n",a/factors[middle],(a+b)/i);
            if (a/factors[middle] <= (a+b)/i) {
                if (answer > 2*(i + (a+b)/i)) {
                    answer = 2*(i + (a+b)/i);
                    // printf("NEW answer: %lli\n", answer);
                }
            }
        }
    }
    return answer;
}

int main(int argc, char* argv[]) {
    ll a,b = 0;
    scanf("%lli %lli",&a,&b);
    // printf("%lli + %lli = %lli\n", a, b, a+b);
    ll answer_a = solve(a,b);
    ll answer_b = solve(b,a);
    if (answer_a < answer_b) {
        printf("%lli\n", answer_a);
    } else {
        printf("%lli\n", answer_b);

    }
    return 0;
}


#include<stdio.h>
int main()

{
    int a,b,g,n,s;
    scanf("%d%d%d", &b,&g,&n);
    if(b>=g)
    a=g;
    else a=b;
    s=b+g-n;
    if(s==0)
    printf("1\n");
    else if(s>=a)
    {
        if(a+1>=n+1)
        printf("%d\n", n+1);
        else
        printf("%d\n", a+1);

    }
    else
    printf("%d\n", s+1);
    return 0
}


    #include<stdio.h>

    int main(){
        long long int a,b,c;
        scanf("%lld %lld %lld",&a,&b,&c);
        if(a==0 && b==0 && c==0){
            printf("0");

        }
        else{
            long long int d=c-a;
            long long int e=c-b;
            if(a<b && a<c && a<e && a<d){
                printf("%lld",(a+1));
            }
            else if(a>b && c>b && b<e && b<d){
                printf("%lld",(b+1));

            }
            else if(c<a && c<b && && c<e && c<d){
                printf("%lld",(c+1));

            }
            else if(d<e){
                printf("%lld",d);

            }
            else printf("%lld",e);
        }
        return 0;
    }


#include <stdio.h>
#include <stdlib.h>
#include<string.h>
#include<ctype.h>
#define display(s,i) printf(#s   #i "=%d",s##i)
#define ll long long
ll f,h,n1,n2;
const  long long  mod=1e8;
ll dp[102][11][102][11];
ll result(ll f1,ll a, ll h1, ll b)
{
    if(f1==0 && h1==0) return 1;
    if(dp[f1][a][h1][b]!=-1) return dp[f1][a][h1][b];
    ll c=0,d=0,e=0,f=0;
    if(f1 && a) c=result(f1-1,a-1,h1,n2);
    if(h1 && b) d=result(f1,n1,h1-1,b-1);
    return dp[f1][a][h1][b]=(c+d)%mod;
}
ll main(ll argc, char *argv[])
{
    memset(dp,-1,sizeof dp);
    scanf("%d%d%d%d",&f,&h,&n1,&n2);
    ll ans=result(f,n1,h,n2);
    printf("%d",ans%mod);
}


#include <stdio.h>

int main()
{
	int i;
	long long a;
	long long b;
	long long n;
	long long p;
	long long q;
	long long s;

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

	s = 0;
	for (i = 1; i <= n; i++)
	{
		if ((i % a == 0) && (i % b != 0))
			s += p;

		else if ((i % a != 0) && (i % b == 0))
			s += q;

		else if ((i % a == 0) && (i % b == 0))
			s += (p > q ? p : q);

	}

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

	return 0;
}

/* 1512997955108 */


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

int main()
{ int n,t;

    scanf("%d",n);
    t=(1-6^n)/(1-6);
    printf("%d",t);
    return 0;
}


#include<stdio.h>

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

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


#include<stdio.h>
int main()
{
	long t,k,n;
	while(~scanf("%ld%ld%ld",&n,&k,&t)){
		if(t<=k){
			printf("%ld\n",t);
		}
		else if(t<=n){
			printf("%ld\n",k);
		}
		else{
			printf("%ld\n",2*n-k-t);
		}
	}


#include<stdio.h>
#include<stdlib.h>
char s[8][9]={"WBWBWBWB","BWBWBWBW","WBWBWBWB","BWBWBWBW","WBWBWBWB","BWBWBWBW","WBWBWBWB","BWBWBWBW"};
int test(char s[],char x[]);
main()
{
    //freopen("input","r",stdin);
   int i,j,k,l=0,t;
   char x[12][12];
   for(i=0;i<8;i++)
    scanf("%s",x[i]);
   for(i=0;i<8;i++)
   {
       t=test(x[i],s[i]);
       if(t)
        l++;
   }
   if(l==8)
    printf("YES\n");
   else
    printf("NO\n");

    return 0;
}
int test(char x[],char s[])
{
    int i,j,k,l=0,pos;
    for(i=0;i<8;i++)
    {
        if(s[0]==x[i])
        {
            pos=i;
            break;
        }
    }
    for(i=pos,j=0;i<8;i++,j++)
    {
        if(s[i]==x[j])
            l++;
    }
    for(i=0;i<pos;i++)
    {
        if(s[i]==x[j])
            l++;
    }
    if(l==8)
        return 1;
    else
        return 0;
}


#include <stdio.h>

void solve()
{
    unsigned long long a, b, c, i;
    scanf("%llu %llu", &a, &b);
    c = (a+b)*(a-b);
    for(i=2; i*i<=c; i++)
    {
        if(c%i==0)
        {
            printf("NO\n");
            return;
        }
    }
    printf("YES\n");
}

int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        solve();
    }
    return 0;
}


#include<stdio.h>
int main()
{
	int T;
	long long int a,b,num,j,i;
	scanf("%d",&T);
	for(i=0;i<T;i++)
	{
		scanf("%lld%lld",&a,&b);
		num=(a*a)-(b*b);
	int flag=0;
	for(j=2;j*j<=num;j++)
	{
		if(num%j==0)
		{
		flag=1;
		break;
		}
	}
	if(num==1)
	flag=1;
	if(flag==0)
	printf("YES\n");
	else
	printf("NO\n");
	}
}


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

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

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


#include <stdio.h>

#define MAX 200010
#define MOD 1000000007

using namespace std;

int n, m, h, sum[1010], dp[MAX][2];

void Pregenerate(){
    int i, j, l, res, x = 0;
    for (i = h; i >= 0; i--){
        sum[i] = x;
        x += i;
    }

    for (l = 0; l <= h; l++){
        for (i = n; i >= 0; i--){
            j = sum[l] - i;
            if (i > sum[l]) continue;
            if (j > m) continue;

            if (!l) res = 1;
            else{
                res = 0;
                if ((i + l) <= n) res = res + dp[i + l][(l - 1) & 1];
                if ((j + l) <= m) res = res + dp[i][(l - 1) & 1];
            }

            if (res >= MOD) res -= MOD;
            dp[i][l & 1] = res;
        }
    }
}

int main(){
    int i, j;

    while (scanf("%d %d", &n, &m) != EOF){
        for (h = 0; h <= 1000; h++){
            int x = (h * (h + 1)) >> 1;
            if (x > (n + m)){
                h--;
                break;
            }
        }

        Pregenerate();
        int res = dp[0][h & 1];
        printf("%d\n", res);
    }
    return 0;
}


#include<stdio.h>
#define pi 3.14

int main()
{
    int a , b , r ,ans ;

    while(scanf("%d%d%d",&a,&b,&r)!=EOF)
    {
        d = 2* r ;
        ans = (a/d)*(b/d);
        if(ans%2==0)
            printf("Second\n");
        else
            printf("First\n");

    }

    return 0 ;
}


#include<stdio.h>
int main()
{
    int a,b,r;
    while(scanf("%d%d%d",&a,&b,&r))
        if(a>=2*r&&b>=2*r)
            printf("First\n");
        else printf("Second\n");
        return 0;
}


#include<stdio.h>
int main()
{
int a,b,r,d,e,f,g,n,p=1;
scanf("%d %d %d",&a,&b,&r);
d=2*r;
if(a<d||b<d)
{
printf("Second");
return 0;
}
n=0;

while(p)
{
    e=((2*n+1)*d);
    f=(2*n+2)*d;
    g=(2*n+3)*d;

    if((a>e)&&(a<f))
    {

            n=0;
            {
                while(p)
                {
                if((b>e)&&(b<f))
                {

                    printf("First");
                    p=0;
                    return 0;
                }
                else if(b>f&&b<g)
                {
                    printf("Second");
                    p=0;
                    return 0;
                }
                else
                n++;
            }
        }
    }
    else if(b>f&&b<g)
    {

            n=0;

                while(p)
                {
                    if((b>e)&&(b<f))
                    {
                        printf("Second");
                        p=0;
                        return 0;
                    }
                    else  if(b>f&&b<g)
                    {
                        printf("First");
                        p=0;
                        return 0;
                    }
                    else
                    n++;
                }

    }
    else
    n++;
}
return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define MAX 1000000009;
int main() {
    int i,n,m,k,min=MAX,t,temp;
    scanf("%d %d %d",&n,&m,&k);
    for(i=1;i<=n;i++) {
        scanf("%d",&t);
        if(t>0 && t<=k) {
            temp = abs(m-i);
            if(temp<min) {
                min = temp;
            }
        }
    }
    printf("%d\n",(min*10));
    return 0;
}


#include <stdio.h>

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

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

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

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

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

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

	return (numer / denom) - 1;
}

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

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

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

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

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

	start = box((L-b1), a1) + 1;
	start -= ((L-b1) % a1) == 0 ? 1 : 0;
	end = box((R-b1), a1);

	q = box((start-p), alpha2) + 1;
	q -= ((start-p) % alpha2) == 0 ? 1 : 0;

	j = 0;
	for (i = q; i <= box((end-p), alpha2); i++)
	{
		if (p + i*alpha2 >=0 && p1 + i*alpha1 >= 0)
		{
			j++;
		}
	}

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


#include <stdio.h>

long long xy[2];

int gcdxy(int a, int b) {
	if (b == 0) {
		xy[0] = 1, xy[1] = 0;
		return a;
	} else {
		int g = gcdxy(b, a % b);
		int tmp;

		tmp = xy[0] - a / b * xy[1];
		xy[0] = xy[1];
		xy[1] = tmp;
		return g;
	}
}

int main() {
	int a1, b1, a2, b2, l, r, g, cnt, cnt1, cnt2;
	long long x, b, n, k_, l_;

	scanf("%d%d%d%d%d%d", &a1, &b1, &a2, &b2, &l, &r);
	/* (a1k + b1 = a2l + b2) = (a1k - a2l = b2 - b1) */
	g = gcdxy(a1, -a2);
	b = (long long) b2 - b1;
	if (b % g != 0)
		printf("0\n");
	else {
		k_ = xy[0] * b / g, l_ = xy[1] * b / g;
		if (g < 0)
			g = -g;
		cnt2 = a2 / g;
		cnt1 = a1 / g;
		cnt = (long long) a1 / g * a2;
		k_ = (k_ % cnt2 + cnt2) % cnt2;
		l_ = (l_ % cnt1 + cnt1) % cnt1;
		x = a1 * k_ + b1 > a2 * l_ + b2 ? a1 * k_ + b1 : a2 * l_ + b2;
		n = 0;
		if (x >= l && x <= r)
			n = (r - x + 1 + cnt - 1) / cnt;
		else if (x < l)
			n = (r - x + 1 + cnt - 1) / cnt - (l - 1 - x + 1 + cnt - 1) / cnt;
		printf("%lld\n", n);
	}
	return 0;
}


#include <stdio.h>

int main(int argc, char const *argv[])
{
    long long a;
    long long b;
    scanf("%d\n", &a);
    scanf("%d\n", &b);

    long long koef = 0;
    long long i;
    for (i = 1; i < b; i++) {
        koef += i;
    }
    // printf("koef: %d\n", koef);

    long long sum = 0;
    long long res;
    int mod = 1000000007;

    for (i = 1; i <= a; i++) {
        // sum += koef * (i * b + 1);                            // (a+b) % p = (a%p + b%p)%p
        res = (koef % mod * ((i % mod) * (b % mod) + 1) % mod) % mod;
        // printf("res: %lld\n", res);
        sum = (sum + res) % mod;
        // printf("i: %d, sum: %lld\n", i, sum);
    }

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

    return 0;
}


#include<stdio.h>
int main() {
    int a,b;
    scanf("%d%d",&a,&b);
    long long max=a*b*b;
    long long x;
    long long sum=0;
    for(x=1;x<=max;x++){
        if(x%b!=0 && (x/b) % (x%b)==0){
            if((x/b)/(x%b)>=1 && (x/b)/(x%b)<=a){
                sum+=x;
                //printf("x=%lld\n",x);
            }
        }
    }
    printf("%lld\n",sum);
	return 0;
}


#include<stdio.h>
int main()
{
    int b='a',c=0;
    char a[510];
    scanf("%s",a);
    while(a[c])
    {
        if(b==a[c])
        {
            b++;
            c++;
        }
        else if(b>a[c])
            c++;
        else
        {
            printf("NO");
            return;
        }
    }
    printf("YES");
}


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

int low[7][7], high[7][7];
int cost[7][7];
int n;
int flow[7][7];
int inFlow[7];
int outFlow[7];
int minFlow = 100, maxCost = -1;

int rec(int v, int to) {
    if(v == n - 1) {
        int isValid = 1;
        int i, j;
        int total = inFlow[n - 1];
        int ccost = 0;
        for(i = 0; i < n; i++) {
            for(j = i + 1; j < n; j++) {
                if(flow[i][j] < low[i][j] || flow[i][j] > high[i][j])
                    isValid = 0;
                if(flow[i][j] > 0)
                    ccost += flow[i][j] * flow[i][j] + cost[i][j];
            }
            if(inFlow[i] != outFlow[i] && (i > 0 && i < n - 1)) {
                isValid = 0;
            }
        }
        if(isValid) {
            if(minFlow == total) {
                if(ccost > maxCost)
                    maxCost = ccost;
            } else if(minFlow > total) {
                minFlow = total;
                maxCost = ccost;
            }
        }
    } else if(to == n)
        rec(v + 1, v + 2);
    else {
        int i;
        for(i = 0; i <= high[v][to]; i++) {
            inFlow[to] += i;
            outFlow[v] += i;
            flow[v][to] = i;
            rec(v, to + 1);
            inFlow[to] -= i;
            outFlow[v] -= i;
        }
    }
}

int main() {
    scanf("%d", &n);
    int i, from, to, j;
    for(i = 0; i < n * (n - 1) / 2; i++) {
        scanf("%d %d", &from, &to);
        from--;
        to--;
        scanf("%d %d %d", &low[from][to], &high[from][to], &cost[from][to]);
    }
    rec(0, 1);
    if(minFlow == 100)
        puts("-1 -1");
    else
        printf("%d %d\n", minFlow, maxCost);
    return 0;
}


\subsection{�������ϩ}
% ������(����Ȥ��ƽ�ŵ�����Ϥ���)
% ��ŵ�ʤ����ϡ�ͭ̾�Ȼפ���ʤ�ͭ̾���ꡢ�����Ǥʤ�����Ϻ�����ȵ����Ƥ���������
\begin{problem}{Codeforces Round57(����)}
$(0,0),(n,0),(0,n),(n,n)$��4����ĺ���Ȥ����������ͤ���($n$�ϼ�����)������������μ���γʻ��������Ϳ�����롣���λ��������������֡�������μ��������̤��û��ϩ�ε�Υ��׻�����ץ?����������衣
\end{problem}

% �����ϤˤĤ��ƽ�
\begin{inputformat}
$n$�ڤ�2�ʻ����κ�ɸ$(x_1,y_1),(x_2,y_2)$�κ�ɸ�����ν��֤�Ⱦ�Ѷ�����ڤ��Ϳ�����롣$n$��1000�ʲ��Ǥ��ꡢ�ʻ����κ�ɸ�Ϥ������$n$�ʲ��Ǥ��롣
\end{inputformat}
\begin{outputformat}
��������Τߤ��̤��û��ϩ��������Ĥǽ��Ϥ��衣
\end{outputformat}
\begin{multicols}{2}
\begin{inputsample}
2 0 1 2 1
\end{inputsample}
\begin{outputsample}
4
\end{outputsample}
\end{multicols}
% ������
\begin{explanation}
���Ƚ�Ǥ��Ѥ��ƽ񤤤Ƥ������Ȥˤʤ롣2���ΰ��ִط��Ǿ��Ƚ�Ǥ򤹤�������Ѥ路��(®���Τ�®��)�Τǡ��⤦������ñ����ˡ�Ϥʤ������Ȥ������Ȥˤʤ롣�����ǡ��������ľ���Ȥߤʤ���ΤȤ��롣$(0,0)$���ڤ�ΤǤ��롣�����ơ��ɤ��餫�μ�����������������ơ�$(0,0)$����ε�Υ��׻����롣���θ塢�׻�������Υ���礦���Ȥǡ���Υ���Ф롣�⤷�⤽�줬�����1����Ⱦʬ����Ĺ����С������1�����餽�ε�Υ���Ƥ��к�û��Υ�ˤʤ롣
\end{explanation}

% ��������
�������\verb|seigyo_bc_sano_9.c|

\newpage


#include <stdio.h>

int distance(int x, int y, int n)
{
int d;
if (x=0)
d = y;
else if(x!=n)
{
if (y=0) d = 4*n-x;
else d = n + x;
}
else d = 3*n-y;

return d;
}

int main()
{
int n,x1,y1,x2,y2;
int d1, d2,d;
scanf("%d %d %d %d %d",n,x1,y1,x2,y2);
d1 = distance(x1,y1,n);
d2 = distance(x2,y2,n);
if(d1>d2) d = d1-d2;
else d = d2-d1;
if(d>2*n)
d = 4*n-d;
printf("%d", d);

return 0;
}


#include<stdio.h>
int main(){
    int count=0,a,b,c,d,e,f;
    scanf("%d %d %d",&a,&b,&c);
    scanf("%d %d %d",&d,&e,&f);
    if(a!=d)
    count++;
    if(b!=e)
    count++;
    if(c!=f)
    count++;
    if(count>1)
    printf("NO");
    else
    printf("YES");

}


#include<stdio.h>
int main()
{
	int f=1,n,s,a[15],i,count=0,max=0;
	scanf("%d %d",&n,&s);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);

	}
	for(i=1;i<=n;i++)
	{
		count+=a[i];
		if(max<a[i])
	      max=a[i];
	}
	count-=max;
	if(count<=s)
	  printf("YES\n");
    else
      printf("NO\n");

  return 0;
}


#include <stdio.h>
#include <stdlib.h>
int main()
{
    long n,s,i,maxt=0,sum=0;
    int a[20]={0};
    scanf("%ld%ld",&n,&s);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]>maxt)maxt=a[i];
        sum+=a[i];
    }
    sum-=maxt;
    if(sum<=s)printf("YES\n");
    else printf("NO\n");
    return 0;
}


#include<stdio.h>
int main()
{
	int a,b,c,d,e;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a+8*c>=b)
	{
		printf("0\n");
		goto jump;
	}
	else if(c<d)
	{
		printf("-1\n");
		goto jump;
	}
	else
	{
		e=2*(b-a-8*c)/(c-d);
	}
	int f=e%24;
	if(f<=2)
	{
		printf("%d\n",e/24);
	}
	else
		printf("%d\n",e/24+1);
	jump:
	return 0;
}


#include<stdio.h>
#define mod 1000000007
typedef long long int ll;
ll expo(ll x,ll k)
{
	ll result=1;
	while(k>0)
	{
		if(k%2==1)
			result=result*x%mod;
		x=x*x%mod;
		k=k/2;
	}
	return result;
}
int main()
{
	long long int x,k,ans;
	scanf("%lld%lld",&x,&k);
	if(x==0)
	{
		printf("0\n");
		return 0;
	}
	x=x%mod;
	x=(2*x-1)%mod;
	k=expo(2,k);
	printf("%lld\n",(x*k+1)%mod);
	return 0;
}


#include <stdio.h>
int mod=(int)1e9+7;
int powmod(int a,int n)
{
    int ans=1;
    while(n)
    {
        if(n&1) ans=((long long)ans*a)%mod;
        a=((long long)a*a)%mod;
        n>>=1;
    }
    return ans;
}
int main()
{
    long long x,k;
    scanf("%lld%lld",&x,&k);
    x%=mod;
    k%=(mod-1);
    int temp=powmod(2,k);
    int ans=((long long)2*temp)%mod;
    ans=((long long)ans*x)%mod;
    if(temp) temp=mod-temp;
    ans=((long long)ans+temp+1)%mod;
    printf("%d\n",ans);
    return 0;
}


#include<stdio.h>

int main()
{
    int x;
    scanf("%d",&x);
    if(x%4==0)
        printf("1 A\n")
    else if(x%4==1)
        printf("0 A\n");
    else if(x%4==2)
        printf("1 B\n");
    else if(x%4==3)
        printf("2 A\n");

    return 0;
}


#include <iostream>
using namespace std;
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    int L[n1], R[n2];

    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    i = 0;
    j = 0;
    k = l;
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}
void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        int m = l+(r-l)/2;

        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

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

int main()
{
    int i,j,n,m;
    cin>>n>>m;
    int c[n],b[m];
    for(i=0;i<n;i++)
    {
        cin>>c[i];
    }
    for(i=0;i<m;i++)
    {
        cin>>b[i];
    }
    int st=0,count=0;
    for(i=0;i<m;i++)
    {
        for(j=st;j<n;j++)
        {
            if(b[i]>=c[j])
            {
                count++;
                st=j+1;
                break;
            }
        }
        if(j==n)
            break;
    }
    cout<<count;

}


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

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

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

}


#include<stdio.h>
int comp(const void * a,const void * b)
{
    return (*(int*)a  - *(int*)b);
}
int main()
{
    int n,m,i,j,arr[10000],k,xx,xy,l;
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++)
        scanf("%d",&arr[i]);
    qsort(arr,n,sizeof(int),comp);
    l=0;
    xx=0;
    xy=0;
    for(i=0;i<n-k+1;i++){
            l=0;
    m=0;
        for(j=i;j<n;j++){
                if(m==k)
                break;
        if(arr[i]==arr[j])
                m++;
                else{
                        xy=arr[j];
                    while(xy>arr[i]){
                        xy/=2;
                        l++;
                    }
                    if(xy==arr[i])
                        m++;
                }
        }
        if(i==0)
            xx=l;
        else if(xx>l)
            xx=l;
    }
    printf("%d",xx);

}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long
int comp(const void*p,const void*q)
{
return *(const int*)p-*(const int *)q;
}
int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);
	ll arr[n],count=0,x,y,flag=0,run=0;
	ll num[n][20],cnt[200001]={0};
	for(int i=0;i<n;i++){ scanf("%lld",&arr[i]);
	}
	qsort(arr,n,sizeof(arr[0]),comp);
	for(int i=0;i<n;i++){num[i][0]=arr[i];
	cnt[num[i][0]]++;
	for(int j=1;j<20;j++){ num[i][j]=num[i][j-1]/2;
	//printf("%lld ",num[i][j]);
	cnt[num[i][j]]++;
	}
	}
	for(int i=200000;i>=0;i--){
	if(cnt[i]>=k) {x=i;break;}
	}
	for(int i=0;i<n;i++){
	if(arr[i]>=(x)) {y=i;
	break;}
	}
	for(int i=y;i<n;i++){
	for(int j=0;j<20;j++){
	if(num[i][j]==x) {run++;
	count=count+j;
	//printf("%lld,%lld,%lld  ",count,run,k);
	if(run>=k){flag=1;
	//printf("%lld,",run);
	break;}
	break;
	}
	if(flag==1) break;
	}

	}

printf("%lld",count);

return 0;}


#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    if(n % 0 == 0){
        n/=2;

        printf("%d",2 << n);
    }
    else
        printf("0");
    return 0;
}


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


#include <stdio.h>
int main ()
{
    int gl;
    int gr;
    int bl;
    int br;

    scanf ("%d",&gl);
    scanf ("%d",&gr);
    scanf ("%d",&bl);
    scanf ("%d",&br);

    if ((bl!=gr) && (br!=gl))
    {

        if ((bl<gr && bl==gr-1) || ( bl > gr && (2*gr + 2 >= bl)))
        {
            printf ("YES");
        }
        else{
            printf ("NO");
            return;
        }
        if ((br<gl && br==gl-1) || (br>gl && 2*gl + 2 >= br))
        {
            printf ("YES");
        }

        else
            printf ("NO");

    }
    else
    {
        printf ("YES");
    }

}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
using namespace std;
int ans;
char c[11], tmpc[11];
int prod( char *ch)
{
	int pr = 1, id = 0;
	while (ch[id])
	{
		pr *= ch[id] - '0';
		id++;
	}
	return pr;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	scanf("%s", c);
	int l = 0;
	while (c[l])
		l++;
	ans = prod(c);
	for (int i = 0; i < l; i++) {
		if (c[l] - '0' == 0)
			continue;
		for (int j = 0; j < i; j++)
			tmpc[j] = c[j];
		tmpc[i] = (c[i] - '0' - 1) + '0';
		for (int j = i + 1; j < l; j++)
			tmpc[j] = '9';
		int tmppr = prod(tmpc);
		if (tmppr > ans)
			ans = tmppr;
	}
	printf("%d\n", ans);
	return 0;
}


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

//srand(time(NULL));
//nombre_aleatoire = rand();

typedef struct cel
{
	int number;
	int value;
}cell;

int main ()
{
	int a,j=1,i=10,s=1,aux,max;
	cell t[12];
	scanf("%d",&a);

	if(a==2000000000)
	{
		printf("387420489");
	}
	else
	{
		t[0].number=a;
		aux=a;
		while(aux>=1)
		{
			s=s*(aux%10);
			aux=aux/10;
		}
		t[0].value=s;
		while(a/i!=0)
		{

			s=1;
			aux=a;
			aux=aux-(aux%i+1);
			t[j].number=aux;

			while(aux>=1)
			{
				s=s*(aux%10);
				aux=aux/10;
			}
			t[j].value=s;
			j++;
			i=i*10;
		}
		max=t[0].value;

		for(i=0;i<j;i++)
		{
			if(t[i].value>max)
			{
				max=t[i].value;

			}

		}
		/*for(i=0;i<j;i++)
		{
			printf("%d  \n %d \n****************",t[i].number,t[i].value);
		}*/
		printf("%d",max);
	}

}


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

int product(int n);
int min(int n);
int test(int n);
int main()
{long int n,i,np,r=1;
scanf("%d",&n);
if(n<10){printf("%d",n);
return 0;}

int max=product(n);
if(max==product(min(n))){ printf("%d",max); return 0;
}
for(i=min(n);i<n;i+=10)
{
if(test(i))
{
	np=product(i);
	if(np>max){max=np;}
	}
}

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

int test(int n)
{int r;
	while(n>0)
	{
		r=n%10;
		n=n/10;
		if(r==0){return 0;}
		break;
	}
return 1;
}

int min(int n)
{
    int p=1,nv;
    n=n/10;
    while(n>0)
    {
        nv=n%10;
        n=n/10;
        p*=10;
    }

    return (p*nv)-1;

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


#include <stdio.h>
int dp[102][102];
int ktree(int n,int k,int d) {
  if(dp[n][d]!=-1) return dp[n][d];
  int i=1,b=0;
  if(k>=n) b+=1;
  if(n==d) dp[n][d]= 1;
  else if(n<d) dp[n][d]= 0;
else{
  while(i<d  && i<=k)
  {
	  b+=ktree(n-i,k,d);
	  i++;
  }
  while(i>=d && i<=k)
  {
	  b+=ktree(n-i,k,1);
	  i++;
  }
  dp[n][d]= b;
}
return dp[n][d];
}
int main()
{
	int i,j;
	for(i=0;i<102;i++)
		for(j=0;j<102;j++)
			dp[i][j]=-1;
int n,k,d;
scanf("%d%d%d",&n,&k,&d);
printf("%d",ktree(n,k,d));

  return 0;
}


#include <stdio.h>

using namespace std;

int main(){
	char fst, scn;
	int first, second;
	unsigned long long int n;
	unsigned long long int m;
	scanf("%c %c",&fst, &scn);
	scanf("%I64d",&n);
	first = (int)fst;
	second = (int)scn;
	int f,s;

	if((first == 94 && second == 118 )||(first == 62 && second == 60) || (first == 118 && second == 94 ) || (first == 60 && second == 62)){
		printf("undefined\n");
		return 0;
	}
	int a[4];
	a[0] = 94;
	a[1] = 62;
	a[2] = 118;
	a[3] = 60;
	for(int i = 0; i < 4; i++){
		if(a[i] == (int)first)
			f = i;
		if(a[i] == (int)second)
			s = i;
	}

	int l = s - f;
	if(l == 1 || l == -3){
		if(n % 4 == 1)
			printf("cw\n");
		else if(n % 4 == 3)
			printf("ccw\n");
		else{
			printf("undefined");
			return 0;
		}
	}

	if(l == -1 || l == 3){
		if(n % 4 == 3)
			printf("cw\n");
		else if(n % 4 == 1)
			printf("ccw\n");
		else{
			printf("undefined");
			return 0;
		}
	}
	return 0;
}


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

int main(){
    int c,l;

    while(c=getchar()) l=isalpha(c)?c:l;
    printf(strchr("AEIOUYaeiouy",l)?"YES\n":"NO\n");
    return 0;
}


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

#define ll long long
#define N 31807

int getPrime(int n,int p[]){int i,j,n2=n/2;rep(i,n2)p[i]=1;for(i=3;i*i<n;i+=2)if(p[i>>1])for(j=(i*i)>>1;j<n2;j+=i)p[j]=0;j=1;p[0]=2;REP(i,1,n2)if(p[i])p[j++]=i*2+1;return j;}
int ps, p[N];

ll res, pp;
int a,b,n;

void solve(ll now, int st, int num){
  int i,j,k;
  ll send, add;

  add = b / now - (a-1) / now;
  if(num%2) add *= -1;
  res += add;

  REP(i,st,pp){
    send = now * p[i];
    if(send > b) break;
    solve(send, i+1, num+1);
  }
}

int is_prime(int n){
  int i;
  rep(i,ps){
    if(in[i]*in[i] > n) break;
    if(n%in[i]==0) return 0;
  }
  return 1;
}

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

  ps = getPrime(N,p);

  while(scanf("%d%d%d",&a,&b,&n)==3){
    rep(i,ps) if(n==p[i]) break;
    if(i==ps){
      if(a<=n && n<=b && is_prime(n)) puts("1"); else puts("0");
      continue;
    }

    pp = i;
    res = 0;
    solve(n,0,0);

    printf("%d\n",(int)res);
  }

  return 0;
}


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


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    int n, k, d, q, i, j;
    scanf("%d\n", &q);
    while(q--)
    {
        scanf("%d%d%d",&n,&k,&d);
        static int a[101], b[101];
        for(i=0; i<n; i++)
            scanf("%d", &a[i]);
        int t, ans=10e5;
        for(i=0; i<n-d+1; i++)
        {
            for(j=i, t=0; j<d+i; j++)
            {
                if(b[a[j]]==0)
                {
                    t++;
                }
                b[a[j]]++;
            }
            if(ans > t)
                ans = t;
            memset(b,0,sizeof(b);
        }
        printf("%d\n", ans);
    }
    return 0;
}


#include <stdio.h>
#include <math.h>
void main()
{
int v=1,x,n,longeur=0;

while (n!=0 && v==1)
{
	x=n%10;
	if (x!=4 && x!=7)
	{
	  v=0;
	}
	n/=10;
	longeur+=1;
}

if (v==0)
printf("YES");
else
{
	if (longeur!=7 && longeur!=4)
	printf("NO");
	else
	printf("YES");
}
}


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


#include <stdio.h>

int main()
{
	int n;
	scanf("%d",&n);
	int i;
	while(n>=1)
	{
		int m=n%10;
		n/=10;
		if(m>=5)
		{
			printf("-O");
			printf("|");
			m=m-5;

			for(i=0;i<m;i++)
			printf("O");
			printf("-");
			for(;i<4;i++)
			printf("O");
			printf("\n");
		}
		else
		{
			printf("O-|");

			for(i=0;i<m;i++)
			printf("O");
			printf("-");
			for(;i<4;i++)
				printf("O");
			printf("\n");
		}
		if(n==0)
			printf('O-|-OOOO\n');
	}
	return 0;
}


#include<stdio.h>
int main()
{
    long long int n,i,sum=0,count=0,flag=0,rem;

    scanf("%I64d",&n);

    for(i=1;i<=n;i++)
    {
        rem=n-sum;
        if(i%2==1&&(n-sum)>=1)
        {
            sum=sum+1;
            flag=1;
            count++;
        }
        else if(i%2==0&&(n-sum)>=2)
        {
            sum=sum+2;
            flag=2;
            count++;
        }
        if(rem<2&&flag==1)
        {
            break;
        }
    }
    printf("%I64d",count);

}


#include <stdio.h>

int main() {
  int l, r, x, y, ef;
  scanf("%d %d %d %d %d", &l, &r, &x, &y, &ef);

  float xp_mid, c_mid, find = 0;
  for (float i = l; i <= r; i += ef - l) {
    int xx = x, yy = y;1 100000 1 100000 100000
    while (xx <= yy) {
      c_mid = (xx + yy) / 2;
      // printf("%f / %f = %f\n", i, c_mid, i / c_mid);

      if (ef > i / c_mid) {
        yy = c_mid - 1;
      } else if (ef < i / c_mid) {
        xx = c_mid + 1;
      } else {
        find = 1;
        break;
      }
    }
    if (find)
      break;
  }

  /*while (l <= r) {
    xp_mid = (l + r) / 2;
    int xx = x, yy = y;
    while (xx <= yy) {
      c_mid = (xx + yy) / 2;
      printf("%f / %f = %f\n", xp_mid, c_mid, xp_mid / c_mid);

      if (ef > xp_mid / c_mid) {
        yy = c_mid - 1;
      } else if (ef < xp_mid / c_mid) {
        xx = c_mid + 1;
      } else {
        find = 1;
        break;
      }
    }

    if (find)
      break;
    else {
      if (ef > xp_mid / c_mid) {
        l = xp_mid + 1;
      } else if (ef < xp_mid / c_mid) {
        r = xp_mid - 1;
      } else {
        find = 1;
        break;
      }
    }
  }*/

  printf(find ? "YES\n" : "NO\n");

  return 0;
}


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

int deco(int x){
  int a = x;
  int n=0;
  while(a>=10){
    n+= a%10;
    a = a/10;
  }
  n+=a%10;
  return n;
}

int main(){
  long int a;
  scanf("%ld",&a);
  long int max=0;
  long int x,y;
  long int b,d;
  for(long int c = 1;c<(a/2)+1;c++){
    x = deco(c);
    y = deco(a-c);
    if(x+y > max){
	  max = x+y;
	  b =c;
	  d =a-c;
	}
  }
  printf("%ld",max);
}


#include<stdio.h>
#define F for(i=1;i<=n;i++)
long long i,j,m,n,r,f[250107]={1};
int main(){
	scanf("%lli%lli",&n,&m);
	F f[i]=f[i-1]*i%m;
	F r=(r+f[i]*f[n-i+1]%m*(n-i+1)%m)%m;
	return printf("%lli",r);
}


#include <stdio.h>

long long fac[250005];

int main()
{
    int n, m;
    long long ans = 0;
    scanf("%d%d", &n, &m);

    fac[0] = 1;
    for(int i = 1; i <= n; i++){
        fac[i] = (fac[i - 1] * i) % m;
    }

    for(int i = 0; i < n; i++){
        ans += (fac[i + 1] * fac[n - i]) % m;
        ans %= m;
    }

    ans = (ans * (n + 1)) % m;
    if(ans % 2 == 1) ans = (ans + m) / 2;

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


#include <stdio.h>
int main(){
	int a1,a2,k1,k2,n;
	scanf("%d%d%d%d%d",&a1,&a2,&k1,&k2,&n);
	int min_players=0;
    int max_players=0;
    int larger_cards,lower_cards,lower_team,larger_team;
    if(k1>=k2){larger_cards=k1; larger_team=a1; lower_cards=k2; lower_team=a2;}
    else{lower_cards=k1; lower_team=a1;  larger_cards=k2; larger_team=a2;}

    if(n>(a1*(k1-1)+a2*(k2-2)))
      {min_players=n-(a1*(k1-1)+a2*(k2-1));}
      printf("%d ",min_players);
     while(n>=lower_cards)
    {
    	if(lower_team>0)
    	{n=n-lower_cards;
    	max_players++;
    	lower_team--;
    	}
    	else if((larger_team>0)&&(n>=larger_cards))
    	  {
    		n=n-larger_cards;
    		max_players++;
    		larger_team--;
    	  }

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


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

int main()
{

    int a1,a2,k1,k2,n;
while(1){
    scanf("%d",&a1);
    scanf("%d",&a2);
    scanf("%d",&k1);
    scanf("%d",&k2);
    scanf("%d",&n);

    int max,min;

    if(k1<k2){
        if(n>=a1*k1)
            max = a1+(n-a1*k1)/k2;

        else
            max = n/k1;
    }

    else if(k2<k1){
        if(n>=a2*k2)
            max = a2+(n-a2*k2)/k1;
        else
            max = n/k2;
    }

    else{
        if(a1>a2){
            if(n>=a1*k1)
            max = a1+(n-a1*k1)/k2;

            else
                max = n/k1;
        }
        else{
            if(n>=a2*k2)
            max = a2+(n-a2*k2)/k1;
            else
                max = n/k2;
        }
    }

    min = n-a1*(k1-1)-a2*(k2-1);
    if(min<0)
        min = 0;

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


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


import java.io.*;
import java.util.*;
import java.lang.Math;

public class CodeForces {

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) throws IOException {
        int w = scanner.nextInt();
        int h = scanner.nextInt();
        long ans = (long) (4*Math.pow(2,w-1)*Math.pow(2,h-1))%998244353;
        scanner.close();
        System.out.println(ans);
    }
}


#include<stdio.h>
int main()
{
    int h,w,c;
    scanf("%d %d",&h,&w);
    long long s1;
    s1 = h+w;
    for(i=1;i<=n;i++)
    s1 = (2*s1)%mod;
    printf("%I64d\n",s1);
}


#include<stdio.h>
#define mod 998244353
int main()
{
    int h,w;
    scanf("%d %d",&h,&w);
    long long ans = ((1<<h)%mod)*(1<<w)%mod)%mod);
    printf("%I64d\n",ans);
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
 char s[200],c,s1[100]; int i,a,len,f=0,p=0,ex,ind;

 gets(s);
 len = strlen(s);

 for(i=0;i<len;i++)
 {
  if(f==0&&(s[i]!='e')) { if(s[i]=='.') ind=i; continue; }

  if(s[i]=='e') { f=1; continue; }

  c=s[i];
  s1[p]=c; p++;

 }
 s1[p]='\0';

 ex = atoi(s1);

 for(i=0;s[i]!='e';i++)
 { if(s[i]=='.') continue;
   if((i-1)==(ind+ex)) {  printf("."); printf("%c",s[i]);}
   else printf("%c",s[i]);
 }
 printf("\n");

return 0;
}


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

return 0;
}


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

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

int main(){
    long long int a,b;
    int arr1[20],arr2[20],flag[20]={0},i=0,n1,n2,j,final[20],t,tatti=0;
    scanf("%lld %lld",&a,&b);
    while(a>0){
        arr1[i] = a%10;
        a=a/10;
        i++;
    }
    n1 = i;
    i=0;
    while(b>0){
        arr2[i] = b%10;
        b=b/10;
        i++;
    }
    n2 = i;
    i--;
    t=0;
    qsort(arr1,n1,sizeof(int),cmpfunc);
    if(n1<n2){
        for(i=n1-1;i>=0;i--)  printf("%d",arr1[i]);
    }
    else{
        while(t!=n1){
            for(j=n1-1;j>=0;j--){
                if(flag[j]==0 && arr1[j]<=arr2[i]){
                    if(arr1[j] < arr2[i])   tatti = 1;
                    final[t] = arr1[j];
                    flag[j]=1;
                    t++;
                    i--;
                    break;
                }
            }
            if(tatti==1){
                for(j=n1-1;j>=0;j--){
                    if(flag[j]==0){
                        final[t] = arr1[j];
                        t++;
                    }
                }
            }
        }
        for(i=0;i<n1;i++)   printf("%d",final[i]);
    }
    return 0;
}


#include<stdio.h>
int main()
{ int n,k=0,d,j,s,i;
int *t;
scanf("%d",&n);
for(i=1;i<n;i++)
{s=i;
d=i;
do
{s=s+(d%10);
d=d/10; }
while(d!=0);
if(s==n)
{t[k]=i;
k++;}}
printf("%d",k);
printf("\n");
for(j=0;j<k;j++)
printf("%d ",t[j]);
return 0;}


#include<stdio.h>
/*
long long int fact(long long int n);

long long int nCr(long long int n,long long int r)
{
    return fact(n) / (fact(r) * fact(n - r));
}

// Returns factorial of n
long long int fact(long long int n)
{
if (n >= 1)
        return n*fact(n-1);
    else
        return 1;
}
*/

main(){
	long long  int i,j,kmax,kmin=0,n,m,teams,m1,j1=0,temp,a;
	scanf("%lld %lld",&n,&m);

	m1=m;
	teams=n;
	while(m1>0){
		temp=teams/m1;
		teams=teams-temp;
		m1--;
		a=(temp*(temp-1))/2;
		kmin=kmin+a;
	}

	n=n-m+1;
	//printf("%d %d %d ---- check",kmax,n,m);
	kmax=(n*(n-1))/2;
	printf("%lld %lld",kmin,kmax);

	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
char a[20];
scanf("%s",a);
int sum=a[0]-'a',len=strlen(a),i;
if(sum>12)
    sum=26-sum;
for(i=1;i<len;i++)
{
    int t=a[i]-a[i-1];
    if(t<0)
        t=a[i-1]-a[i];
    if(t>12)
        t=26-t;
 sum=t+sum;
}
printf("%d",sum);
return 0;
}


#include<stdio.h>
int main()
{
    int n;
    scanf("%d",n);
    printf("%d",3*n/2);
    return 0;
}


#include <stdio.h>

typedef long long ll;

int main(){

ll n,m ;
int i,j,k;
char * a;

scanf("%",&);

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

}

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


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

	return 0;
}


#include <stdio.h>
#define MAXN 53
#define MAXW 500003
int dp[MAXW]={1};
int n,d,c[MAXN];
int ans,day;

int main()
{
	int i,j,k,sum=0;

	scanf("%d%d",&n,&d);
	for(i=0;i<n;i++)
	{
		scanf("%d",&c[i]);
		sum+=c[i];
		for(j=sum,k=sum-c[i];j>=c[i];j--,k--)
			if(dp[j]==0 && dp[k]==1)dp[j]=1;
	}

	ans=day=0;
	while(1)
	{
		for(i=ans+d;i>ans;i--)
		{
			//printf("now i %d %d\n",ans,i);
			if(dp[i]==1)break;
		}
		if(i==ans)break;
		ans=i;
		++day;
	}
	printf("%d %d\n",ans,day);
	return 0;
}


#include <stdio.h>
int dp[500100];
int main()
{
    int n,d,i,x,sum,ans,ans1,j;
    scanf("%d%d",&n,&d);
        sum=0;
        dp[0]=1;
        for(i=0;i<n;i++){
            scanf("%d",&x);
            sum+=x;
            for(j=sum;j>=x;j--){
                if(dp[j-x])
                    dp[j]=1;
            }
        }
        ans=ans1=0;
        while(1)
        {
            j=ans+d;
            while(j>ans&&!dp[j])
                j--;
            if(j==ans)
                break;
            ans=j;
            ans1++;
        }
        printf("%d %d\n",ans,ans1);

    return 0;
}


#include<stdio.h>
int main(){
	int t,s,x,i,flag=0;
	scanf("%d %d %d",&t,&s,&x);
	if(t==x){
		printf("YES");
		return 1;
	}
    if(x-t-1!=0){
		if((x-t)%(s)==0 || (x-t-1)%(s)==0){
			printf("YES");
		}
	}
	else{
		printf("NO");
	}

	return 0;
}


#include <stdio.h>

int main() {
    int c, hold, x = 0;
    scanf("%d", &c);
    hold = c;
    while (1) {
        if (c == 0) {
            if (x % 4 == 0) {
                break;
            } else {
                x = 0;
                hold+=1;
                c = hold;
            }
        }
        x = x + c % 10;
        c/=10;
    }
    printf("%d", x);
    return x;

}


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


#include <stdio.h>
#define mod 1000000007ll

long long n,k;
long long dp[2001][2001];

long long f(long long i,long long j)
{
	//printf("%I64d %I64d\n",i,j );

	if(dp[i][j] > 0)
		return dp[i][j];

	if(i<2)
		return 1;

	long long ret = 0ll;
	long long k;
	for(k = j;k>0;k--)
		if(j%k == 0)
			ret =  (ret%mod + f(i-1,k)%mod)%mod;

	dp[i][j] = ret;
	return dp[i][j];
}

int main()
{
	int i;
	for(i=0;i<k+1;++i)
		for(int j = 0;j<n+1;j++)
			dp[i][j] = -1;
	for (i = 0; i < n+1; ++i)
	{
		dp[1][i] = dp[0][i] = 1;
	}

	scanf("%I64d %I64d",&n,&k);
	//printf("%lld\n",k);
	long long ans = 0;
	for(i=n;i>0;i--)
	{
		dp[k][i] = f(k,(long long)i);
		//printf("%lld\n",(long long)i );
	}

	for(i=1;i<=n;i++)
		ans = (ans + dp[k][i]%mod)%mod;
	printf("%I64d\n",ans);
	return 0;
}


#include<stdio.h>
int mod=1000000007;
int dp[2001][2001];
int f(int n,int k);
int uf(int n,int k)
{
	return f(n,k)-f(n-1,k);
}
int f(int n,int k)
{

	if(dp[n][k]!=0)
	{
		return dp[n][k];
	}

	if(n==1)
		dp[n][k]=1;
	else if(k==1)
		dp[n][k]=n;
	else{
	int i,p=0,j=0;
	int div;
	for(i=n/2;i>=0;i--)
	{
		if(n%i==0)
		{
			div=i;
			break;
		}
	}
	int non[div];
	for(i=2;i<div;i++)
	{
		if(n%i!=0)
		{
			non[p]=i;
			p++;
		}
	}
	int c=0;
//	for(j=0;j<p;j++)
//	{
//		c+=(c%mod + uf(non[j],k-i)%m)%m
//	}
	int b=0;
	for(i=1;i<k;i++)
	{
		for(j=0;j<p;j++)
		{
			c+=(c%mod + uf(non[j],k-i)%mod)%mod;
		}

		b=(b%mod+(f(div,k-i))%mod-c)%mod;
	}

	dp[n][k]=((f(n-1,k))%mod+b%mod+1)%mod;
	}
	return dp[n][k];

}

int main()
{
	int n,k,div,i;
	scanf("%d%d",&n,&k);
	printf("%d\n",f(n,k));
/*	for(i=n/2+1;i>=0;i--)
	{
		if(n%i==0)
		{
			div=i;
			break;
		}
	}
	printf("%d",div);*/
	return 0;
}


#include <stdio.h>
int main()
{
 long long d,k,a,b,t,sum=0,cou;
 scanf("%lld%lld%lld%lld%lld",&d,&k,&a,&b,&t);
 if(k>=d) sum=d*a;
 else
 if(k*a+t<=k*b)
   {sum=sum+(d-d%k)*a+(d/k-1)*t;
   	if(d%k*b<d%k*a+t) sum=sum+d%k*b;
   	else sum=sum+d%k*a+t;
   }else {
   	cou=(d-d%k)*a+(d/k-1)*t;
   	if(d%k*b<d%k*a+t) cou=cou+d%k*b;
    if(cou<k*a+(d-k)*b) sum=cou;
    else sum=k*a+(d-k)*b;
   }
 printf("%d\n",sum);
 return 0;
}


#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n)
	if (n == 1) printf ("YES");
	if (n * (n + 1) / 2 % 2 == 1){
		printf ("NO");
	}else{
		printf("YES");
	}
	return 0;
}


#include<stdio.h>
int buocnhay(int a, int b,int n);
int main()
{	int d=0,a=0,b=0,n=0,i=0;
	int c[10000];
	scanf("%d",&n);
	a=1;
	b=1;c[b]=-2;
	for (a=1;a<n;a++)
	{
		b=buocnhay(a,b,n);
		c[b]=-2;
	}
	if(n == 1) printf("YES");
esle for (i=1;i<=n;i++)
		{if (c[i]!=-21) d=123;
		if (d!=123) printf("YES");
		else printf("NO");}
}
int buocnhay(int a,int b,int n)
{
	if (a+b<=n) return a+b;
	if (a+b>n) return a+b-n;
}


#include<stdio.h>
int A[100009];

long long pow1(int n, int i)
{
    long long sum=1,j;
    for(j=1;j<=i;j++) sum*=n;
    return sum;
}

int rdig(int n)
{
    int sum=0;
    while(n)
    {
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

int main()
{
    int a,b,c,i=1,j=0,sum=0,dig;
    scanf("%d %d %d",&a,&b,&c);

    while(sum<=1000000009)
    {   sum=b* pow1(i,a) +c;
        if(sum<=0) break;
        //printf("%d\n",sum);
        dig=rdig(sum);
        if(dig==i){
        A[j]=sum; j++; }

        i++;

    }

    printf("%d\n",j);
    if(j!=0)
    for(i=0;i<j;i++) printf("%d ",A[i]);

    return 0;
}


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

const char* f0  = "What are you doing at the end of the world? Are you busy? Will you save us?";
const char* fi1 = "What are you doing while sending \"";
const char* fi2 = "\"? Are you busy? Will you send \"";
const char* fi3 = "\"?";

static const int f0len = 75, fi1len = 34, fi2len = 32, fi3len = 2;

static char dfs(int64_t N, int64_t* K) {
    const int64_t k1 = *K;
    if(N == 0) {                    // leaf of the tree
        if(k1 >= f0len) {
            *K -= f0len; return '.';
        } else {
            *K = 0; return f0[k1];
        }
    }
    if(k1 < fi1len) {               // inside fi1
        *K = 0; return fi1[k1];
    }
    *K -= fi1len;

    const char c1 = dfs(N-1, K);    // dfs into the first recursive part
    if(c1 != '.') return c1;

    const int64_t k2 = *K;
    if(k2 < fi2len) {               // inside fi2
        *K = 0; return fi2[k2];
    }
    *K -= fi2len;

    const char c2 = dfs(N-1, K);
    if(c2 != '.') return c2;        // dfs into the second recurse part

    const int64_t k3 = *K;
    if(k3 >= fi3len) {
        *K -= fi3len; return '.';
    } else {                        // inside fi3
        *K = 0; return fi3[k3];
    }
}

int main() {
    int Q; scanf("%d\n", &Q); while(Q--) {
        int64_t N,K; scanf(" %"PRId64 " %"PRId64 "\n", &N, &K);
        --K; printf("%c", dfs(N,&K));
    }
    printf("\n");
    return 0;
}


#include<stdio.h>

int sock(int n,int m,int x)
{

}
int main()
{
  int n,m,temp=0,x=0;

 scanf("%d",&n);
 scanf("%d",&m);
 x= n%m;
 while(1)
   {
     if(n == 1)
       {
	 temp += 1;
	 printf("%d \n",temp);
	 return 0;
       }
     else if(x == 0)
       {
	 temp += n;
	 n=n/m;
	 x =n%m;
       }
     else if(m-x > n)
       {
	 temp += n;
	 printf("%d \n",temp);
	 return 0;
       }
     else if (m-x == n)
       {
	 temp+= (n+1);
	 printf("%d \n",temp);
	 return 0;
       }
     else
       {
	 temp+=n;
	 temp++;
	 n=(n-(m-x))/m;
	 x=n%m;
       }
   }

}


#include<stdio.h>
#define MAX 1000000
int main(){
	int n;
	int i;
	scanf("%d",&n);
	int g=1;
	int f=0;
	int arr[MAX]={0};
	while(g!=1000){
		for(i=1;i<=g;i++)
		{
			arr[f]=i;
			f++;
		}
		g++;
	}
	printf("%d",arr[n-1]);

}


#include <iostream>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) {

	long long int k,a,b,c;
	scanf("%lld%lld%lld",&k,&a,&b);
	if((a+b)/k==0)printf("-1");
	else printf("%lld",(a+b)/k);
	return 0;
}


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

int main()
{
    long long int n,m,i;
    scanf("%I64d %I64d",&n,&m);
    for(i=1;i<=n;i++)
    {
       if(m>=i)
        {
            m=m-i;
        }
        if(i==n)
        {
            i=0;
        }
        if(m<i)
        {
            break;
        }
    }
    printf("%I64d",m);
    return 0;
}


#include<stdio.h>
#define M 1000000007;
int main()
{
    int t,n,i,ans;
    long long int pow,fact;
        pow=fact=1;
        scanf("%d",&n);
        for(i=1;i<=n;i++)
        {
            fact = fact*i;
            fact = fact%M;
        }
        for(i=1;i<n;i++)
        {
            pow=pow*2;
            pow=pow%M;
        }
        ans=(fact-pow)%M;
        printf("%d\n",ans);
}


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


#include <stdio.h>
int main()
{
    int a ,old_a , b , old_b , w , x , c , old_c , count = 0 ;
    scanf("%d %d %d %d %d", &a, &b, &w, &x, &c);
    old_b = b ; old_a = a ; old_c = c ;
    while(c > a)
    {
        count++;
        c--;
        if(b >= x)
            b -= x;
        else
        {
            a--;
            b = w - (x - b);
        }
        if(b == old_b)
            break;
    }
    if(c <= a)
        printf("%d\n", count);
    else
    {
        int ax , cx , flag ;
        ax = old_a - a ;
        cx = old_c - c ;
        flag = (old_c-old_a)/(cx-ax) ;
        flag--;
        count = count*flag;
        a = old_a - flag*ax;
        c = old_c - flag*cx;
        while(c > a)
        {
            count++;
            c--;
            if(old_b >= x)
            old_b -= x;
            else
            {
                a--;
                old_b = w - (x - old_b);
            }
        }
        printf("%d\n", count);
    }
    return 0;
}


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

int main()
{
    int m=0,n=0,i=0;
    char a[101],*p;
    scanf("%c",&a[i]);
    while(a[i]!='\0')
    {
        scanf("%c",&a[++i]);
    }
    p=a;
    while(*p!='\0' && *p!=' ' && *p!='\n')
    {
        if(*p=='o')
            m++;
        else
            n++;
        p++;
    }
    if(n%m==0)
        printf("YES");
    else
        printf("NO");
//printf("%d  %d ",m,n);
    return 0;
}


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

int main()
{
    int m=0,n=0,i=0;
    char a[101],*p;
    scanf("%c",&a[i]);
    while(a[i]!='\0')
    {
        scanf("%c",&a[++i]);
    }
    p=a;
    while(*p!='\0' && *p!=' ' && *p!='\n')
    {
        if(*p=='o')
            m++;
        else
            n++;
        p++;
    }
if*n==0 || m==0)
{printf("YES");
return 0;}

if(n%m==0)
        printf("YES");
    else
        printf("NO");
    return 0;
}


#include<stdio.h>
int main()
{
    char s[100],i,o=0,d=0;
    scanf("%s",s);
    for(i=0;i!='\0';i++)
     {
         if(s[i]=='o')
          o++;
         elses
          d++;
     }
     if(o==0)
      printf("YES");
     else if(d==0)
      printf("YES");
     else if(d%o==0)
      printf("YES");
     else
      printf("NO");
      return 0;
}


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

int main()
{
    int X,Y,Z,x,y,z,i,j,num[10];
    while(1){
    scanf("%d %d %d",&x,&y,&z);
    scanf("%d %d %d",&X,&Y,&Z);
    for (i=0;i<6;i++)
    {
        scanf("%d",&num[i]);
    }
    j=0;
    if (x>X)
    {
        j+=num[5];
    }
    else if (x<0)
    {
        j+=num[4];
    }
    if (y>Y)
    {
        j+=num[1];
    }
    else if (y<0)
    {
        j+=num[0];
    }
    if (z>Z)
    {
        j+=num[3];
    }
    else if (z<0)
    {
        j+=num[2];
    }

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


#include <stdio.h>
#define maxn 1000000005
int bit[maxn];
int main()
{
    int w,m,b=0,i,f=0;
    scanf("%d%d",&w,&m);
    while (m)
    {
        bit[b++]=m%w;
        m/=w;
    }
    for (i=0;i<b;i++)
    {
        if (bit[i]>=w)
        {
            bit[i]-=w;
            bit[i+1]++;
        }
        if (bit[i]==w-1)
        {
            bit[i]=0;
            bit[i+1]++;
        }
        if (bit[i]>1)
        {
            f=1;
            break;
        }
    }
    if (f==0) printf("YES");
    else printf("NO");
    return 0;
}


#include<stdio.h>
//New Year and Days 611A
int d;
char s1[3],s2[6];
int main()
{
    while(scanf("%d%s%s",&d,s1,s2))
    {
        if(s2[0]=='w')
        {
            if(d==5||d==6)printf("53\n");
            else printf("52\n");
        }
        else
        {
            if(d<=29)printf("12\n");
            else if(d==30)printf("11\n");
            else if(d==31)printf("7\n");
        }
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define upfor(i,From,To) for(i=From;i<To;i++)
#define downfor(i,From,To) for(i=From;i>To;i--)
#define Opfile_in(s) freopen(s,"r",stdin)
#define Opfile_out(s) freopen(s,"w",stdout)
#define Read(T) scanf("%d",&T)
#define Print(T) printf("%d\n",T)
#define LL long long
#define MAXN 214748364
#define mod 100000000
int N1,N2,k1,k2;
int F[102][102],G[102][102];
void init();
void doit();
int main()
{
    //Opfile_in("BUAA_temp.in");
    init();
    doit();
    return 0;
}
void init()
{
    scanf("%d%d%d%d",&N1,&N2,&k1,&k2);
}
void doit()
{
    int i,j,k,l;
    F[0][0]=G[0][0]=1;
    upfor(i,0,N1+1)
    upfor(j,0,N2+1)
    {
        upfor(l,1,k1+1)
        {
            F[i+l][j] += G[j][i];
            F[i+l][j] %= mod;
        }
        upfor(l,1,k2+1)
        {
            G[j+l][i] += F[i][j];
            G[j+l][i] % mod;
        }
    }
    Print((F[N1][N2]+G[N2][N1]) % mod);
}


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

int ans, MOD = 100000000;
int k1, k2;

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

void rec(int remain1, int remain2, int turn) {
    if(remain1 + remain2 == 0) {
        ans++;
        if(ans == MOD)
            ans = 0;
    } else {
        int i, val;
        if(turn == 0) {
            val = (remain1 + k1 - 1) / k1;
            if(val > 1 && val - 1 > remain2)
                return;
            for(i = 1; i <= min(k1, remain1); i++) {
                rec(remain1 - i, remain2, 1);
            }
        } else {
            val = (remain2 + k2 - 1) / k2;
            if(val > 1 && val - 1 > remain1)
                return;
            for(i = 1; i <= min(k2, remain2); i++) {
                rec(remain1, remain2 - i, 0);
            }
        }
    }
}

int main() {
    int n1, n2;
    scanf("%d %d %d %d", &n1, &n2, &k1, &k2);
    rec(n1, n2, 0);
    rec(n1, n2, 1);
    printf("%d\n", (int)ans);
    return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 100, MOD = 1e8;

int k1, k2, dp[MAXN+1][MAXN+1][2];

int fn(int n1, int n2, bool flag)
{
    if(n1 == 0 && n2 == 0) return 1;

    if(dp[n1][n2][flag] != -1) return dp[n1][n2][flag];

    int ret = 0;

    if(flag == 0) {
        for(int man = 1; man <= k1 && n1-man >= 0; ++man)
            ret += fn(n1-man, n2, !flag), ret %= MOD;
    }
    else {      // flag == 1
        for(int man = 1; man <= k2 && n2-man >= 0; ++man)
            ret += fn(n1, n2-man, !flag), ret %= MOD;
    }

    return dp[n1][n2][flag] = ret;
}

int main()
{
    //freopen("in", "r", stdin);

    int n1, n2;

    while(scanf("%d %d %d %d", &n1, &n2, &k1, &k2) != EOF) {
        fill(&dp[0][0][0], &dp[MAXN+1][0][0], -1);

        printf("%d\n", (fn(n1, n2, 0) + fn(n1, n2, 1)) % MOD);
    }

    return 0;
}


#include <stdio.h>
#include <sys/time.h>

int ModExp(int n,int m,int p)
{
	int k=1;
	n%=p;
	while(m!=1)
	{
		if(m&1)
		{
			k=(k*n)%p;
		}
		n=(n*n)%p;
		m>>=1;

	}
	return (n*k)%p;
}

int Judge(int x,int p)
{
	int i;
	if(ModExp(x,p-1,p)!=1)
	{
		return 0;
	}
	for(i=1;i<p-2;++i)
	{
		if(ModExp(x,i,p)==1)
		{
			return 0;
		}
	}
	return 1;
}

int main()
{
	int P,x,Sum;
	scanf("%d",&P);
	for(Sum=0,x=1;x<P;++x)
	{
		Sum+=Judge(x,P);
	}
	printf("%d\n",Sum);
	return 0;
}


#include <stdio.h>
#include <time.h>
#include <string.h>
#define total 81
#define n 11
int main()
{
    srand(time(NULL));
    int i,j,cont=0;
    char *valor=(char*)calloc(n,sizeof(char));
    char *codigo=(char*)calloc(total,sizeof(char));
    char *numero=(char*)calloc(n-2,sizeof(char));
    char matriz[n-1][n]={};

    scanf("%s",codigo);
    for(i=0 ; i<n-1 ; i++)
    {
         for(j=0 ; j<n-1 ; j++)
         {
            matriz[i][j]=codigo[cont];
            cont++;
         }
    }
    int bandera;
    j=0;
    do
    {
        scanf("%s",valor);
        for(i=0 ; i<n ; i++)
        {
           bandera=strcmp(valor,matriz[i]);
           if(bandera==0)
           {
               numero[j]=i;
               j++;
               break;
           }
        }
    }while(j<n-2);
    printf("%s",numero);
    return 0;
}


#include<stdio.h>

int GCD(int a,int b)
{
    int t,gcd;
    if(a==0)
    {
        gcd=b;
    }
    else if(b==0)
    {
        gcd=a;
    }
    else
    {
        while(b!=0)
        {
            t=b;
            b=a%b;
            a=t;
        }
        gcd=a;
    }
}

int main()
{
    int a,b,max,m,n,d,x;
    scanf("%d %d",&a,&b);
    if(a>b)
        max=a;
    else
        max=b;
    m=6-max+1;
    x=GCD(m,6);
    n=m/x;
    d=6/x;
    printf("%d/%d",n,d);
    return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
    int cuantas_cajas_roba, almacenes, max, lugar_max, cant = 0, a, b;
    scanf("%i %i", &cuantas_cajas_roba, &almacenes);
    int cajas[almacenes][2]; //[][0] cuantas hay [][1] cuanto tienen
    for(a = 0; a < almacenes; a++)
    {
        scanf("%i %i", &cajas[a][0], &cajas[a][1]);
    }
    a = 0;
    while(a < cuantas_cajas_roba)
    {
        max = 0;
        for(b = 0; b < almacenes; b++)
        {
            if(cajas[b][1] > max)
            {
                max = cajas[b][1];
                lugar_max = b;
            }
        }
        if(cuantas_cajas_roba - a >= cajas[lugar_max][0])
        {
            cant = cant + cajas[lugar_max][1]*cajas[lugar_max][0];
            a = a + cajas[lugar_max][0];
//            printf("    %i %i\n", cant, a);
            cajas[lugar_max][1] = 0;
            cajas[lugar_max][0] = 0;
        }
        else
        {
            cant = cant + cajas[lugar_max][1]*(cuantas_cajas_roba - a);
            a = a + (cuantas_cajas_roba - a);
//            printf("      %i %i\n", cant, a);
        }
    }
    printf("%i", cant);

return 0;
}


#include<stdio.h>
int main ()
{
	int tab[10],n,c,i,max,pos;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&tab[i]);
	}
	c=n;
	while(n>0){
	max=tab[1];
	pos=1;
	for(i=1;i<=n;i++){
		if(tab[i]>max){
			max=tab[i];
			pos=i;
		}
	}
	for(i=pos;i<n;){
	tab[i]=tab[i+1]; }
	tab[n]=max;
	n--;
	 }
	 for(i=1;i<=c;i++)
	 {
	 	printf("%d",tab[i]);
		}
		return 0;
}


#include <stdio.h>

int main(){
	int count=0;
	int times=0;
	char current='\0';
	char input[200];
	int i;
	scanf("%s",input);
	current = input[0];
	count++;
	for(i = 1; input[i] != '\0'; i++){
		if(input[i]==current){
			if(count<5){
				count++;
				continue;
			}else{
				count=1;
				times++;
				current=input[i];
			}
		}else{
			current=input[i];
			count=1;
			times++;
		}
	}
	if(count) times++;
	printf("%d\n",times);
	return 1;
}


#include<stdio.h>
void swap(int *x,int *y){
    int t=*x;
    *x=*y;
    *y=t;
}
void SelSort(int* arr,int n){
    // printf("SIZE:%d",n);
    int max,j;
    for(int i=0;i<n-1;i++){
        max=i;
        for(int j=i+1;j<n;j++){
            if(arr[max]<arr[j]){
                max=j;
            }
        }
        swap(arr+max,arr+i);
    }
    return;
}
int main(){
    int n;
    int *arr;
    scanf("%d",&n);
    //printf("DONE%d\n",n);
    for(int i=0;i<12;i++){
        // printf("ok\n");
        scanf("%d",arr+i);
    }
    // printf("FAG");
    SelSort(arr,n);
    // for(int i=0;i<n;i++){
    //     printf("%d ",arr[i]);
    // }
    // printf("\n");
    int sum=0,count=0;
    while(n>sum){
        sum+=arr[count++];
    }
    printf("%d\n",count);
}


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

{
int m,n,y=0,k;
scanf("%d%d",&m,&n);
if(m%2!=0 && m>1)
{
    m=m-1;
    k=m/2;
    m=m+1;
}
else if (m%2==0)
{
    k=m/2;
}
else
k=1;
int s=k*n;

while (1)
{

   if (m%2!=0 || m==1)

   {
        n=n-2;
        if (n>=1)
        y++;

        else
            break ;
   }

}
if (m==1)
printf("%d",y);
else
printf("%d",s+y);

return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    long i,flag=0;
    char s[100];
    scanf("%s",s);
    for(i=0;i<strlen(s);i++)
    {
        if(s[i]=='.')
            s[i]=' '
    }
    if(strlen(s)<3)
        printf("No");
    else{
    for(i=0;i<strlen(s)-2;i++)
    {
        if(s[i]+s[i+1]+s[i+2]==198)
            {
             flag=1;
             break;
            }
        else
            flag=0;
    }
    if(flag==1)
        printf("Yes");
    else
        printf("No");

}
}


#include<stdio.h>
#include<string.h>
int main()
{
    int i,l;
    char s[51];
    scanf("%s",s);
    l=strlen(s);
    for(i=0;i<l-2;i++)
    {
        if(s[i]!='.')
        {
            if((s[i]+s[i+1]+s[i+2])==198&&(s[i]!=s[i+1]))
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
    return 0;
}


 #include <stdio.h>

int main(){

    int count = 0;
    int money = 0;

    scanf("%d", &money);

    while (money >= 0){
    if(money >= 100){
        money -= 100;
        count++;
    }

    if(money >= 20 && money < 100){
        money -= 20;
        count++;
    }

    if(money >= 10 && money < 20){
        money -= 10;
        count++;
    }

    if(money >= 5 && money < 10){
        money -= 5;
        count++;
    }

    if(money >= 1 && money < 5){
        money -= 1;
        count++;
    }
    }

    printf("%d", count);

}


/*
 * 1.这个程序做到的事情
 * ruble是俄国的货币
 * 四门课
 * 2.这个程序遇到的困难
 * 3.接下来要做的事情
 */
#include<stdio.h>
#define N 100000
int min2(int a,int b){
    if(a>b)return b;
    else return a;
}
int min3(int a,int b,int c){
    return min2(a,min2(b,c));
}
int main() {
    int n,a,b,c;
    scanf("%d%d%d%d",&n,&a,&b,&c);
    int min=0;
    int money[N];
    money[0]=0;
    money[1]=a;
    money[2]=min2(a*2,b);
    money[3]=min3(a*3,b+a,c);
    /*
    money[4]=min(money[1]+money[3],money[2]+money[2]);
    money[5]=min(money[1]+money[4],money[2]+money[3]);
    */
    int i,j;
    for(i=4;i<N;i++){
        money[i]=money[1]+money[i-1];
        for(j=2;j<=i/2;j++){
            money[i]=min2(money[i],money[j]+money[i-j]);
        }
    }
    int k=0;
    while(1){
        //只能购买恰好k本书，不能多买？
        if(k>=N){
            printf("不够\n");
            break;
        }
        if((n+k)%4==0){
            min=money[k];
            break;
        }
        k++;
    }
    printf("%d\n",min);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
int main(){
int a,b,f,k;
scanf("%d%d%d%d",&a,&b,&f,&k);
int counter=-1;
int position=0;
int fuel = b;
int wway=-1;
int fuelcounter=0;
int test=0;
while(counter<k)
{
    if(position==a || position==0){
        wway *= -1;
        counter++;
        if(counter==k)
            break;

    }
    if(position==f){
        if(wway==1){
            if(fuel>=2*(a-f)){
            }else{
                if(counter+1<k){
                    fuel=b;
                    fuelcounter++;
                }else{
                    if(fuel>=a-f){
                    }else{
                        fuel=b;
                        fuelcounter++;
                    }
                }
            }
        }else{
            if(fuel>=2*f){
            }else{
                if(counter+1<k){
                    fuel=b;
                    fuelcounter++;
                }else{
                    if(fuel>=f){
                    }else{
                        fuel=b;
                        fuelcounter++;
                    }
                }
            }

        }
    }
    if(fuel==0){
        test=1;
        break;
    }
    position += wway;
    fuel--;
}

    if(test==1){
        printf("-1");
    }else{
        printf("%d",fuelcounter);
    }

}


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

int main()
{
    int N, ActivePlayers[2]={1,2} , AllPlayers[3]={1,2,3}, Audience[1]={3}, i, VictoryCourse[100], temporary=3, j;

    //printf("How many matches did you guys have?\n");
    scanf("%d", &N);
    while ((N<0)|| (N>100))
    {
        //printf("We both know that it's not good to lie. Now, please be serious.\n");
        //printf("How many matches did you have?\n");
        scanf("%d", &N);
    }

    for (i=0; i<N ;i++)
    {
       // printf("Who won match #%d? Alice (1), Bob (2) or Carl (3)?\n", i);
        scanf("%d", &VictoryCourse[i]);
    }

    //printf("\nOriginal Active Players = {%d,%d}\n\n", ActivePlayers[0], ActivePlayers[1]);

    for (i=0;i<N;i++)
    {
        if (VictoryCourse[i]==ActivePlayers[0])
        {
            //printf("Isxyei h prwth periptwsh.\n");
            temporary=ActivePlayers[1];
            ActivePlayers[1]=Audience[0];
            Audience[0]=temporary;
           // printf("Active Players = {%d,%d}\tAudience={%d}\n", ActivePlayers[0],ActivePlayers[1], Audience[0]);
        }
        if (VictoryCourse[i]==ActivePlayers[1])
        {
           // printf("Isxyei h deuterh periptwsh.\n");
            temporary=ActivePlayers[0];
            ActivePlayers[0]=Audience[0];
            Audience[0]=temporary;
            //printf("Active Players = {%d,%d}\tAudience={%d}\n", ActivePlayers[0],ActivePlayers[1], Audience[0]);
        }
        if(!((VictoryCourse[i]==ActivePlayers[0]) || (VictoryCourse[i]==ActivePlayers[1])))
        {
            printf("NO\n");
            return 1;
        }

    }
    printf("YES\n");
    system("pause");
    return 0;

}


#include<stdio.h>

int main()
{
	int a,m,x;
	scanf("%d%d",&a,&m);
	if(a%m==0)
	{
		printf("Yes\n");
		return 0;
	}
	x=a;
	x+=x%m;

	while(x%m!=a%m)
	{
		if(x%m==0)
		{
			printf("Yes\n");
			return 0;
		}
		x+=x%m;
	}
	printf("No\n");
	return 0;
}


 #include<stdio.h>
int main()
 {
  int i=0,j=0,k;
  char s[50],t[50];
  printf("enter the 2 strings");
  scanf("%s%s",s,t);
  while(t[i]!='\0')
   {
    if(s[j]==t[i]);
     j++;i++;
    else
     i++;
   }
  print("%d",j);
  return 0;
 }


#include<iostream>
#include<cstdio>
#include<set>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long LL;

set<LL>s;
vector<LL>v;

void settable()
{
	s.insert(1);
	set<LL>::iterator iter=s.begin();
	int count=1;
	LL temp=*iter;
	while(temp<=2e9){//�˴�Ҫ��������
		LL t=*iter;
		s.insert(t*2);
		s.insert(t*3);
		temp=t*3;
		iter++;
	}
	iter=s.begin();
	while(iter!=s.end()){
		v.push_back(*iter++);
	}
/*	for(int i=0;i<10;i++){
		printf("%d ",v[i]);
	}
	printf("\n");*/
}

int main()
{
	settable();
	int l,r;
	scanf("%d%d",&l,&r);
	int num=upper_bound(v.begin(),v.end(),r)-lower_bound(v.begin(),v.end(),l);
	printf("%d\n",num);
	return 0;
}


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


#include <stdio.h>
const int a=1234567;
const int b=123456;
const int c=1234;
int main()
{
	int n,k,i,j;
	scanf("%i",&n);
	for(i=0;i<(n/a+1);i++)
		for(j=0;j<(n/b+1);j++)
			for(k=0;k<(n/c+1);k++)
				if(i*a+j*b+k*c==n){
					puts("YES");
					return 0;
				}
		puts("NO");
	return 0;
}


#include <stdio.h>
#include<math.h>
#include<string.h>
int main()
{
int n;
scanf("%d",&n);
int a[n];
int max=0;
int min=0;
int i;
for(i=0;i<n;i++){
scanf("%d",a[i]);
if(a[i]>=0)
  max+=a[i];
else
  min+=a[i];
}
printf("%d",max-min);
}


#include <stdio.h>
#include <string.h>
int main()
{int a,b,c=0,d,e,f,i,j,k,p=1,q,r,sum=1;
 char s[200];
 int z[102];
 scanf("%d",&d);
 scanf("%s",&s);

 for(i=0;i<d;i++)
 {if(s[i]=='*')
  {z[c]=i;
   c=c+1;}
   }
 for(j=0;j<c-1;j++)
    {   sum=0;

        for(k=j+1;k<c;k++)
              {e=z[j+k]-z[j];
              f=z[j+k];
              while(f<=d)
              {
               f=f+e;

              if(s[f]=='*')
              {
                  sum=sum+1;
              }
              else
              {
                  break;
              }

          }}
          if(sum>=4)
          {
              break;
          }
    }
    if(sum>=4)
    {
        printf("yes\n");
    }
    else
    {
        printf("no\n");
    }
return 0;}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int n;
    int a[110];
    int l[110];
    char ch;
    while (scanf("%d",&n)!=EOF)
    {
        memset(l,0,sizeof(l));
        for (int i=1;i<=n;i++)
        {
            scanf("%c",&ch);
            if (ch=='*')
                a[i]=1;
            else
                a[i]=0;
        }
        int i,j;
        for (i=1;i<=n;i++)
        {
            if (a[i])
            {
                for (j=i+1;j<=n;j++)
                {
                    if (a[j]==1)
                        l[j-i]++;
                }
            }
        }
        for (i=1;i<=100;i++)
        if (l[i]==4)
            {
            printf("yes\n");
            break;}
        if (i>100)
                printf("no\n");
    }
    return 0;
}


#include <stdio.h>

int main() {
	static int aa[14];
	int i, max;

	for (i = 0; i < 14; i++)
		scanf("%d", &aa[i]);
	max = 0;
	for (i = 0; i < 14; i++)
		if (aa[i] > 0) {
			static int bb[14];
			int j, sum;

			for (j = 0; j < 14; j++)
				bb[j] = aa[j];
			bb[i] = 0;
			for (j = i + 1; j <= i + aa[i]; j++)
				bb[j % 14]++;
			sum = 0;
			for (j = 0; j < 14; j++)
				sum += (bb[j] % 2 == 0 ? bb[j] : 0);
			if (max < sum)
				max = sum;
		}
	printf("%d\n", max);
	return 0;
}


#include<stdio.h>

int isluck(long long n)
{
	while (n)
	{
		if (n % 10 == 7 || n % 10 == 4)
			n /= 10;
		else
			return 0;
	}
	return 1;
}

long long nearby(long long n)
{
	while (isluck(n) != 1)
	{
		n++;
	}
	return n;
}

int main()
{
	long long  l, r;

	while (~scanf("%lld %lld", &l, &r))
	{
		long long sum = 0;

		while (l <= r)
		{
			int tmp = nearby(l);
			if (tmp > r)
			{
				sum += (r - l + 1) * tmp;
				break;
			}
			sum += (tmp - l + 1) * tmp;
			l = tmp + 1;
		}
		printf("%lld\n", sum);
	}

	return 0;
}


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

/*
 *
 */
int main() {

    int n, m, k, i, l=0;
    float sum=0.0;

    //printf("Give the colum, the row.\n");
    scanf("%d %d", &n, &m);

    do{
        //printf("Give the position to sit.\n");
        scanf("%d", &k);
    }while(k<0 || k>(2*n*m+1));

    for(i=1; i<=m; i++){
        if(k<=i*n*2-2*i){
            l++;
            //printf("l=%d\n",l);
        }
        if(i==m){
            l=m;
        }
    }
    for(i=1; i<=n; i++){
        if(k<=2*m*i){
            if(k%2==0){
                printf("%d %d R\n", i, l);
                return;
            }else{
                printf("%d %d L\n", i, l);
                return;
            }
        }
    }
}


#include<stdio.h>
#define min(a,b) a>b?b:a
long long int n,m,k,an;
long long int bin(long long int lo,long long int hi)
{
	if(lo>=hi)
		return lo;
	long long int i,mi=(lo+hi)/2,c=0;
	for(i=1;i<=n;i++)
		c+=min((mi-1)/i,m);
	if(c<k)
		return bin(mi+1,hi);
	return bin(lo,mi);
}
int main()
{
	scanf("%lld %lld %lld",&n,&m,&k);
	an=bin(0,n*m);
	printf("%lld\n",an-1);
	return 0;
}


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

int mcd(int a, int b)
{
   if (b == 0){
      return a;
   }else{
      return mcd(b, a % b);
   }
}


#include <stdio.h>

void swap(int *a,int *b)
{
    *a^=*b;
    *b^=*a;
    *a^=*b;
    return;
}
int main()
{
    int array[5];
    int i,sum=0;
    for(i=0;i<5;i++)
    {
        scanf("%d",&array[i]);
        sum+=array[i];
    }
    int j;
    for(i=0;i<5;i++)
        for(j=0;j<5-i;j++)
            if(array[j]>array[j+1])
                swap(&array[j],&array[j+1]);
    for(i=4;i>0;i--)
        if(array[i]==array[i-1])
            if(i>=2&&(array[i-1]==array[i-2]))
            {
                sum-=(array[i]+array[i-1]+array[i-2]);
                break;
            }
            else
            {
                sum-=(array[i]+array[i-1]);
                break;
            }
    printf("%d",sum);
    return 0;
}


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
	<FileVersion major="1" minor="6" />
	<Project>
		<Option title="numar" />
		<Option pch_mode="2" />
		<Option compiler="gcc" />
		<Build>
			<Target title="Debug">
				<Option output="bin/Debug/numar" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Debug/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-g" />
				</Compiler>
			</Target>
			<Target title="Release">
				<Option output="bin/Release/numar" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj/Release/" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-O2" />
				</Compiler>
				<Linker>
					<Add option="-s" />
				</Linker>
			</Target>
		</Build>
		<Compiler>
			<Add option="-Wall" />
		</Compiler>
		<Unit filename="main.c">
			<Option compilerVar="CC" />
		</Unit>
		<Extensions>
			<code_completion />
			<envvars />
			<debugger />
			<lib_finder disable_auto="1" />
		</Extensions>
	</Project>
</CodeBlocks_project_file>


#include <stdio.h>

int main() {
    int n, ctr = 0;
    char stones[50];
    scanf("%d", &n);

    scanf("%c", stones[0]);

    int i = 1;
    while (i < n) {
    	char t;
    	scanf("%c", &t);
    	if (t == stones[i - 1]) {
    		ctr++;
    		continue;
    	}
    	else {
    		stones[i] = t;
    	}
    	i++;
    }

    printf("%d", ctr);
}


#include<stdio.h>

int main()
{

int num,x,y,n;

scanf("%d%d%d",&num,&x,&y);
n=num/2;

if((x==n&&x=n+1) && (y==n&&y==n+1))
{
printf("NO");
}

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


#include <stdio.h>
#include <string.h>
int main(){
	int i,l;
	char s[100],t[100];
	scanf("%s",s);
	l=strlen(s);
	int count=0;
	for(i=0;i<l;i++)
	{
		scanf("%c",t[i]);
		if(t[i]!=s[l-i])
			break;
	}
	if(i<l-1)
		printf("NO");
	else
		printf("YES");
	return 0;
}


#include <stdio.h>
#include <stdbool.h>
bool f[100001];
void pre()
{
    int i;
    for(i=0;i<=100000;i++) f[i]=false;
    int pow=2;
    int num=1;
    while(num<=100000)
    {
        f[num]=true;
        pow*=2;
        num=(pow-1)*pow/2;
    }
}
int main()
{
    pre();
    int i,n;
    int ans=1;
    scanf("%d",&n);
    for(i=1;i*i<=n;i++)
    {
        if(f[i] && i>ans) ans=i;
        if(f[n/i] && (n/i)>ans) ans=n/i;
    }
    printf("%d\n",ans);
    return 0;
}


#include<stdio.h>
#define MOD 1000000009

int sqr(long long int x, int n)
{
	if(n==0)
		return 1;
	else if(n==1)
		return x;
	else if(n%2==0)
		return sqr( (x*x)%MOD, n/2 ) % MOD;
	else
		return (x * sqr( (x*x)%MOD, (n-1)/2 )) % MOD;
}

int main()
{
	int n, m, k;
	scanf("%d %d %d", &n, &m, &k);
	int x, y, z;
	z = n%k;
	y = n/k;
	if(y*(k-1)+z >= m)
	{
		printf("%d\n", m);
	}
	else
	{
		x = m - y*(k-1) - z;
		y -= x;
		long long int ans;
		int i;
		ans = sqr(2, x+1);
		ans -= 2;
		k %= MOD;
		ans *= k;
		ans %= MOD;
		ans += y*(k-1);
		ans %= MOD;
		ans += z;
		ans %= MOD;
		printf("%lld\n", ans);
	}
	return 0;
}


#include<stdio.h>
#define MOD 1000000009

int sqr(long long int x, int n)
{
	if(n==0)
		return 1;
	else if(n==1)
		return x;
	else if(n%2==0)
		return sqr( (x*x)%MOD, n/2 ) % MOD;
	else
		return (x * sqr( (x*x)%MOD, (n-1)/2 )) % MOD;
}

int main()
{
	int n, m, k;
	scanf("%d %d %d", &n, &m, &k);
	int x, y, z;
	z = n%k;
	y = n/k;
	x = m - y*(k-1) - z;
	y -= x;
	long long int ans;
	int i;
	ans = sqr(2, x+1);
	ans -= 2;
	k %= MOD;
	ans *= k;
	ans %= MOD;
	ans += y*(k-1);
	ans %= MOD;
	ans += z;
	ans %= MOD;
	printf("%lld\n", ans);
	return 0;
}


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

int main()
{
    char st[101];
    long long int nb, ns, nc, pb, ps, pc, r, i, b=0, s=0, c=0, ans=0;
    scanf("%s", st);
    scanf("%lld %lld %lld %lld %lld %lld %lld", &nb, &ns, &nc, &pb, &ps, &pc, &r);
    for(i=0; st[i]!='\0'; i++)
    {
        if(st[i]=='B')
            b++;
        else if(st[i]=='S')
            s++;
        else if(st[i]=='C')
            c++;
    }
    //printf("%lld %lld %lld\n", b, s, c);
    while(r)
    {
        if(nb<b)
        {
            long long int price=pb*(b-nb);
            if(r-price<0)
            {
                printf("%lld\n",ans);
                return 0;
            }
            else
                r-=price;
            nb=b;
        }
        if(ns<s)
        {
            long long int price=ps*(s-ns);
            if(r-price<0)
            {
                printf("%lld\n",ans);
                return 0;
            }
            else
                r-=price;
            ns=s;
        }
        if(nc<c)
        {
            long long int price=pc*(c-nc);
            if(r-price<0)
            {
                printf("%lld\n",ans);
                return 0;
            }
            else
                r-=price;
            nc=c;
        }
        if(nb>=b && ns>=s && nc>=c)
        {
            //printf("ans=%lld nb=%lld ns=%lld nc=%lld\n", ans, nb, ns, nc);
            ans++;
            nb-=b;
            ns-=s;
            nc-=c;
            //printf("ans=%lld nb=%lld ns=%lld nc=%lld\n", ans, nb, ns, nc);
            if(nb==0 && ns==0 && nc==0)
            {
                long long int price=pb*b+ps*s+pc*c;
                price=r/price;
                ans+=price;
                printf("%lld\n", ans);
                return 0;
            }
            if(r==0)
            {
                printf("%lld\n", ans);
                return 0;
            }
        }
    }
}


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

    return 0;
}


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

int main (){

    int n,d,m;
    int i;

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

    int g[110];
    for (i=0;i<n;i++){
        scanf ("%i",&g[i]);
    }
    scanf("%i", &m);

    // sorting
    for (i=0;i<n;i++){
        int j, mindex =i;
        for (j=i;j<n;j++){
            if(g[j]<g[mindex])
                mindex= j;
        }

        int temp = g[i];
        g[i] = g[mindex];
        g[mindex] = temp;
    }

    int p=0; // pribyl
    i=0;
    while (i<m){
        if (i > n){
            p = p - g[i];
        }
        else {
            p = p + g[i];
        }
    }

    printf ("%i", p);

    return 0;
}


#define M 2000000
#define MOD 1000000007
long long inv[M],fact[M],factr[M];
int main(){
	int i,N;
	for(i=0;i<M;i++)inv[i]=fact[i]=factr[i]=1;
	for(i=2;i<M;i++){
		inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
		fact[i]=i*fact[i-1]%MOD;
		factr[i]=inv[i]*factr[i-1]%MOD;
	}
	scanf("%d",&N);N++;
	int r=2*fact[2*N-1];
	r=(r*factr[N])%MOD;
	r=(r*factr[N-1])%MOD;
	printf("%d\n",r-1);
}


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

// n = 8, k = 5
//          *
// 0  1 2 3 4 5 6 7
// 10 9 8 7 7 7 5 5

// n = 5, k = 8
//       *
// 0 1 2 3 4 5 6 7
// 8 7 6 5 4 ? ? 0

int main(void) {
  int n, k, count = 0;
  scanf("%d %d", &n, &k);
  int* arr = (int*)malloc(sizeof(int)*k);
  if(k > n) arr[k - 1] = 0;
  for(int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    if((i <= k - 1 && arr[i] > 0)|| (i >= k && arr[i] >= arr[k - 1] && arr[i] > 0)) count++;
  }
  printf("%d\n", count);
  return 0;
}


#include<stdio.h>
int main()
{
  long long int n,k,count=0;
  scanf("%lld %lld",&n,&k);
  long long int i,m=-1;
  for(i=1;i<=k;i++)
  {
        if(m<n%i)
            {count++;
            m=n%i;}

  }
  if(count==k)
  printf("Yes" );
  else
    printf("No");
}


#include<stdio.h>
int main()
{
  long long int n,k,count=0;
  scanf("%lld %lld",&n,&k);
  long long int i,m=-1;
  for(i=1;i<=k;i++)
  {
        if(m<n%i)
            {count++;
            m=n%i;}
        else
          {printf("No");
            return 0:
          }

  }
  if(count==k)
  printf("Yes" );
  else
    printf("No");
}


#include <stdio.h>

int main(){
	int m,w;
	scanf("%d %d",&w,&m);
	while(m>0){
		if(m%w==0||m%w==1||m%w=w-1){
			m=m/w;
		}
		else{
			printf("NO");
			return 0;
		}
		}
		printf("YES");
		return 0;
	}


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


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


#include <stdio.h>
int main()
{
    int initial,remove,count=0;
    scanf("%d%d",&initial,&remove);

    if(initial==remove)
    {
        printf("%d",0);
    }
    else if(remove==0)
    {
        printf("%d",1);
    }
    else if(remove==1)
    {
        printf("%d",1);
    }
    else
    {
        if(initial%2==0)
        {
            for(int i=1 ; i<=initial ; i++)
            {
                if(i<=initial/2)
                {
                    count++;
                }
                else
                {
                    count--;
                }

                if(i==remove)
                {
                    printf("%d",count);
                    break;
                }
            }
        }
        else
        {
            for(int i=1 ; i<=initial ; i++)
            {
                if(i<=initial/2)
                {
                    count++;
                }
                else if(i=initial/2+1)
                {
                    count=count;
                }
                else
                {
                    count--;
                }

                if(i==remove)
                {
                    printf("%d",count);
                    break;
                }
            }

        }
    }

}


#include<stdio.h>
int main()
{
    int n,m;
    printf("Enter the number of cats/n");
    scanf("%d",&n);
    printf("Enter the number of cats leave\n");
    scanf("%d",&m);
    if(n>m)
    {
        if(m==0)
        {
            printf("geoup number is 1");
        }
        else if((n-m)==0)
        {
            printf("group number is 0");
        }
        else if((n-m)%2==0)
        {
            printf("group number is %d",(n-m)/2);
        }
        else
        {
            printf("group number is %d",(n-m));
        }
    }


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


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

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


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


#include <stdio.h>

#define W_L 1
#define W_K 2
#define B_K -4

void set_p(int board[8][8]){
   int i,j,k,l;

   for(i = 0; i<8; i++)
      for(j = 0; j<8; j++)
	 if(!(board[i][j]>0 || board[i][j]==B_K))
	    board[i][j]=0;

   for(i = 0; i<8; i++)
      for(j = 0; j<8; j++)
	 if(board[i][j]>0){
	    if(board[i][j]==W_L){
	       for(k = j-1; k>=0 && board[i][k]<=0;k--)
		  board[i][k]=-1;
	       for(k = j+1; k<9 && board[i][k]<=0; k++)
		  board[i][k]=-1;
	       for(k = i-1; k>=0 && board[k][j]<=0;k--)
		  board[k][j]=-1;
	       for(k = i+1; k<9 && board[k][j]<=0; k++)
		  board[k][j]=-1;
	    } else if(board[i][j]==W_K) {
	      for(k = i-1; k<=i+1; k++)
		 for(l = j-1; l<=j+1; l++)
		    if(k>=0 && k<8 && l>= 0 && l<8 && board[k][l]<=0)
		       board[k][l]=-1;
	    }
	 }

}

void cpy_board(int dest[8][8], int source[8][8]){
   int i,j;
   for(i = 0; i<8; i++)
      for(j = 0; j<8; j++)
	 dest[i][j] = source[i][j];
}

int main(){
   int x,y;
   char _x;
   int i, j;
   int other = 0;
   int board[8][8];
   int temp_board[8][8];

   for(i = 0; i<8; i++)
      for(j = 0; j<8; j++)
	 board[i][j] = 0;

   scanf("%c%d ",&_x,&y);
      x = _x-'a';
      y--;
   board[x][y] = W_L;
   scanf("%c%d ",&_x,&y);
      x = _x-'a';
      y--;
   board[x][y] = W_L;
   scanf("%c%d ",&_x,&y);
      x = _x-'a';
      y--;
   board[x][y] = W_K;
   scanf("%c%d",&_x,&y);
      x = _x-'a';
      y--;
   board[x][y] = B_K;

   set_p(board);

   if(board[x][y] == B_K)
      printf("OTHER\n");
   else {
      for(i = x-1; i<=x+1; i++)
	 for(j = y-1; j<=y+1; j++)
	    if(i>=0 && i<8 && j>=0 && j<8 && board[i][j]==W_L){
	       cpy_board(temp_board, board);
	       temp_board[x][y]=0;
	       temp_board[i][j]=B_K;
	       set_p(temp_board);
	       other = other || temp_board[i][j]==B_K;
	    }
      if(other)
	 printf("OTHER\n");
      else
	 printf("CHECKMATE\n");

   }
   return 0;
}


#include<stdio.h>
int main()
{
long long int n,i,a[100000],low,high,mid,j,c=0;
scanf("%I64d",&n);
for(i=0;;i++)
{a[i]=((i+1)*(i+2))/2;
if(a[i]>=n)break;}
for(j=0;j<=i;j++)
{low=0,high=i;
while(low<=high)
{if(a[j]+a[mid]==n)
{c++;
printf("YES");
break;}
else if(a[j]+a[mid]<n)
low=mid+1;
else
high=mid-1;}
if(c==1)
break;}
if(j==i+1)
printf("NO");
return 0;}


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

return 0;
}


#include<bits/stdc++.h>

using namespace std;

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


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


<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
	<FileVersion major="1" minor="6" />
	<Project>
		<Option title="A. Home Numbers" />
		<Option pch_mode="2" />
		<Option compiler="gcc" />
		<Build>
			<Target title="Debug">
				<Option output="bin\Debug\A. Home Numbers" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj\Debug\" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-g" />
				</Compiler>
			</Target>
			<Target title="Release">
				<Option output="bin\Release\A. Home Numbers" prefix_auto="1" extension_auto="1" />
				<Option object_output="obj\Release\" />
				<Option type="1" />
				<Option compiler="gcc" />
				<Compiler>
					<Add option="-O2" />
				</Compiler>
				<Linker>
					<Add option="-s" />
				</Linker>
			</Target>
		</Build>
		<Compiler>
			<Add option="-Wall" />
		</Compiler>
		<Unit filename="main.c">
			<Option compilerVar="CC" />
		</Unit>
		<Extensions>
			<code_completion />
			<debugger />
		</Extensions>
	</Project>
</CodeBlocks_project_file>


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


#include <stdio.h>

int main() {
    int a, n, b = 1, t = 1;
    scanf("%d%d", &n, &a);
    if(a % 2 != 0) {
        while(a != 1) {
            a -= 2;
            t++;
        }
        printf("%d", t);
        return 0;
    }
    else {
        while(n != a) {
            n -= 2;
            t++;
        }
        printf("%d", t);
        return 0;
    }


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

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

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


#include<stdio.h>

int main() {
	long long n, b;
	scanf("%lld%lld", &n, &b);
	long long ans = 1000000000000000000;
	for( long long i=2, p, l, tn, cans; b>1; ++i ) {
		if( b%i )
			continue;
		for( l=0, p=1; b%i == 0 ; b /= i )
			l++;
		cans = 0;
		for( tn=n/i; tn; tn /= i ) cans += tn;
		if( cans/l < ans )
			ans = cans/l;
	}
	printf("%lld\n", ans);
}


#include<stdio.h>

int main() {
	long long n, b;
	scanf("%lld%lld", &n, &b);
	long long ans = 1000000000000000000;
	for( long long i=2, p, l, tn, cans; i*i <= b; ++i ) {
		if( b%i )
			continue;
		for( l=0, p=1; b%i == 0 ; b /= i )
			l++;
		cans = 0;
		for( tn=n/i; tn; tn /= i ) cans += tn;
		if( cans/l < ans )
			ans = cans/l;
	}
	if( b != 1 ) {
		long long i=b, l=1;
		for( tn=n/i; tn; tn /= i ) cans += tn;
		if( cans/l < ans )
			ans = cans/l;
	}
	printf("%lld\n", ans);
}


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

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