#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int max=0;
int a[10];
int p[100];
typedef struct
{
	int val;
	int mvrg;
	int thrg;
}Ch;
typedef Ch CA[4];
int movethrow(CA,int);
int search(int pe)
{
	int i,t;
	for (i=1;i<45;i++)
	{
		if (p[i]>0)
		{
			t=p[i];
			while (t)
			{
				if ((t%10)==pe)
					return i;
				t=t/10;
			}
		}
	}
}
int change(int pe,int pos)
{
	int t;
	t=search(pe);
	p[t]=0;
	p[pos]=pe;

}
int tr(CA C,int pe)
{
	int i,j;
	int f,m,r,t[4];
	int temp;
	t[1]=search(1);
	t[2]=search(2);
	t[3]=search(3);
	m=t[pe];
	temp=t[pe];
	t[pe]=t[3];
	t[3]=temp;
	temp=p[m];
	f=m-C[pe].thrg;
	r=m+C[pe].thrg;
	if (r>max)
		max=r;
	if (f<=0)
		f=1;
	for (i=f;i<=r;i++)
	{
		if (i!=m&&p[i]==0&&
			(abs(i-t[1])<=2||abs(i-t[2]<=2)||i==r))
		{

			p[i]=temp/10;
			p[m]=temp%10;
			for (j=1;j<=9;j++)
			{

				if (a[j]==0)
				{
					a[j]=1;a[0]++;
					movethrow(C,j);
					a[j]=0;a[0]--;
				}
			}
			p[i]=0;
			p[m]=temp;
		}
	}
	return 0;
}
int mv(CA C,int pe)
{
	int i,j;
	int f,m,r,t[4];
	int temp;
	t[1]=search(1);
	t[2]=search(2);
	t[3]=search(3);
	m=t[pe];
	temp=t[pe];
	t[pe]=t[3];
	t[3]=temp;
	f=m-C[pe].mvrg;
	r=m+C[pe].mvrg;
	if (r>max)
		max=r;
	if (f<=0)
		f=1;
	for (i=f;i<=r;i++)
	{
		if (i!=m&&p[i]==0&&
			(abs(i-t[1])<=2||abs(i-t[2]<=2)||i==r))
		{
			change(pe,i);

			for (j=1;j<=9;j++)
			{
				if (a[j]==0)
				{
					a[j]=1;a[0]++;
					movethrow(C,j);
					a[j]=0;a[0]--;
				}
			}
		}
	}
	change(pe,m);
	return 0;
}

int movethrow(CA C,int fr)
{
	int i,j;
	int rt;
	if (fr%3==1)
	{
		rt=fr/3+1;
		if (a[fr+1]==1&&a[fr+2]==0)
		{
			return 0;
		}
		else if (p[search(rt)]>10)
		{
			return 0;
	 	}
		else
		{
			mv(C,rt);

			return 0;
		}

	}
	if (fr%3==2)
	{
		int px;
		rt=fr/3+1;
		px=search(rt);
		if (p[px]>10)
		{
			return 0;
		}
		else if (p[px-1]>0)
		{
			int temp;
			p[px]+=p[px-1]*10;
			temp=p[px-1];
			p[px-1]=0;
			for (j=1;j<=9;j++)
			{
				if (a[j]==0)
				{
					a[j]=1;a[0]++;
					movethrow(C,j);
					a[j]=0;a[0]--;
				}
			}
			p[px]=rt;
			p[px-1]=temp;
		}
		else if (p[px+1]>0)
		{
			int temp;
			p[px]+=p[px+1]*10;
			temp=p[px+1];
			p[px+1]=0;
			for (j=1;j<=9;j++)
			{
				if (a[j]==0)
				{
					a[j]=1;a[0]++;
					movethrow(C,j);
					a[j]=0;a[0]--;
				}
			}
			p[px]=rt;
			p[px+1]=temp;
			return 0;
		}
		else
		{
			return 0;
		}
	}
	if (fr%3==0)
	{
		rt=fr/3;
		int px;
		px=search(rt);
		if (a[fr-1]==0)
		{
			return 0;
		}
		else if (p[px]%10!=rt)
		{
			return 0;
		}
		else
		{
			tr(C,rt);
			return 0;
		}
	}
}
int main()
{
	CA C;
	int i,j;
	for (i=1;i<100;i++)
	{
		p[i]=0;
	}
	for (i=1;i<=3;i++)
	{
		scanf("%d %d %d",&C[i].val,&C[i].mvrg,&C[i].thrg);
		p[C[i].val]=i;
	}
	for (i=0;i<=9;i++)
	{
		a[i]=0;
	}
	for (i=1;i<=9;i++)
	{
		a[i]=1;a[0]++;
		movethrow(C,i);
		a[i]=0;a[0]--;
	}

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


#include<stdio.h>
int p1,p2,p3,p4,a,b,ans;
int main(){
	ios::sync_with_stdio(false);
	scanf("%d %d %d %d %d %d",&p1,&p2,&p3,&p4,&a,&b);
	for(int i=a;i<=b;i++){
		if(i%p1==i&&i%p2==i&&i%p3==i&&i%p4==i){
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define maxn 1000

long p[maxn+1][5],xl[maxn+1][maxn+1][5],point[maxn+1],count=0;
__int64 value[maxn+1][maxn+1];
bool vis[maxn+1];

    long n,i,j,k,l;
    __int64 v1,v2;

void work()
{
        for (j=1;j<n;j++)
            if (i!=j)
                for (k=j+1;k<=n;k++)
                    if (i!=k)
    {
        v1=0;
        for (l=0;l<5;l++)
            v1+=xl[i][j][l]*xl[i][k][l];
        if (v1==0)
            continue;
        v1=v1*v1;

        v2=value[i][j]*value[i][k];
        //0<__<=1 -1<=__<0
        if (v1<=v2)
        {
            vis[i]=false;
            return;
        }
    }
    vis[i]=true;
}

int main()
{
    scanf("%ld",&n);
    for (i=1;i<=n;i++)
        for (j=0;j<5;j++)
            scanf("%ld",&p[i][j]);
    for (i=1;i<=n;i++)
        for (j=1;j<=n;j++)
        {
            value[i][j]=0;
            for (k=0;k<5;k++)
            {
                xl[i][j][k]=p[j][k]-p[i][k];
                value[i][j]+=xl[i][j][k]*xl[i][j][k];
            }
        }

//    for (i=1;i<=n;i++)
//        vis[i]=true;
    for (i=1;i<=n;i++)
        work();
    for (i=1;i<=n;i++)
        if (vis[i]==true)
        {
            count++;
            point[count]=i;
        }
    printf("%ld\n",count);
    for (i=1;i<=count;i++)
        printf("%ld\n",point[i]);
    return 0;
}


/*
 * main.c
 *
 *  Created on: 03 ���. 2014 �.
 *      Author: ulgish
 */

/*
 * util.c
 *
 *  Created on: 30 ���� 2014 �.
 *      Author: ulgish
 */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define MAX(A,B) (((A) > (B))?(A):(B))
#define MIN(A,B) (((A) < (B))?(A):(B))

#define LN printf("\n")
#define TAB printf("\t")
#define SPACE printf(" ")

typedef unsigned long long uint64;
typedef long long int64;
typedef signed short int16;
typedef unsigned short uint16;
typedef char byte;

void int64_print(int64 n){
	int64 carry = 10;
	if (n == 0){
		printf("0");
		return;
	}
	char buf[20];
	buf[0] = '\0';
	int i = 0, j;
	while (n > 0){
		buf[i] = n % carry;
		n = n / carry;
		i += 1;
	}
	i--;
	for (j = i; j>= 0; j--){
		printf("%c", 48 + buf[j]);
	}
}
void uint64_print(uint64 n){
	uint64 carry = 10;
	char buf[20];
	buf[0] = '\0';
	int i = 0, j;
	while (n > 0){
		buf[i] = n % carry;
		n = n / carry;
		i += 1;
	}
	i--;
	for (j = i; j>= 0; j--){
		printf("%c", 48 + buf[j]);
	}
}

uint64 uint64_read(){
	char* s = (char*) calloc(20, sizeof(char));
	s[0] = '\0';
	scanf("%s", s);
	//printf("=======%s\n", s);
	uint64 ret = 0;
	uint64 carry = 1;
	int len = strlen(s), i;
	for (i = 0; i < len; i++){
		ret += carry * (s[len-1-i] - 48);
		carry*=10;
	};
	free(s);
	return ret;
}

int64 int64_read(){
	char* s = (char*) calloc(21, sizeof(char));
	s[0] = '\0';
	scanf("%s", s);
	//printf("=======%s\n", s);
	int64 ret = 0;
	int64 carry = 1;
	int len = strlen(s), i;
	for (i = 0; i < len; i++){
		ret += carry * (s[len-1-i] - 48);
		carry*=10;
	};
	free(s);
	return ret;
}

//#define DEBUG

int64 x;
int a[100001];
int b[100001];

int n,d;

void swap(int* a, int* b){
	int c;
	c = *a;
	*a = *b;
	*b = c;
	return;
}
int64 getNextX() {
    x = (x * 37 + 10007) % 1000000007;
    return x;
}
void initAB() {
	int i;
    for(i = 0; i < n; i = i + 1){
        a[i] = i + 1;
    }
    for(i = 0; i < n; i = i + 1){
        swap(&(a[i]), &(a[(int)(getNextX() % (i + 1LL))]));
    }
    for(i = 0; i < n; i = i + 1){
        if (i < d)
            b[i] = 1;
        else
            b[i] = 0;
    }
    for(i = 0; i < n; i = i + 1){
        swap(&(b[i]), &(b[(int)(getNextX() % (i + 1LL))]));
    }
}

int main(){
	scanf("%d %d", &n, &d);
	x = int64_read();
	int i,j;
	initAB();
	int max_a[100000];
	int index_a[100001];
	int sum_b[100000];
	int q[100001];
	q[0] = 0;
	sum_b[0] = b[0];
	max_a[0] = a[0];
#ifdef DEBUG
	printf("d:%d\na:\n", d);
	for (i = 0 ; i < n; i++){
		printf("%d\t", a[i]);
	}
	LN;
	for (i = 0 ; i < n; i++){
		printf("%d\t", b[i]);
	}
	LN;

#endif
	int tmp = -1;
	for (i = 0; i< n; i++){
		index_a[a[i]] = i;
		if (b[i]) q[++q[0]] = i;
		if (i > 0){
			sum_b[i] = b[i] + sum_b[i-1];
		}
		if (sum_b[i] == 0){
			tmp = i;
		}

	}
#ifdef DEBUG
	printf("tmp:%d\n", tmp);
	printf("sum_b[%d]:%d\n", tmp+1, sum_b[tmp+1]);
#endif
	for (i = 0; i <= tmp; i++){
		max_a[i] = MAX(a[i], max_a[i-1]);
		printf("0\n");
	}
	for (i = tmp+1; i < n; i++){
		int c = 0;
		max_a[i] = MAX(a[i], max_a[i-1]);
		if (sum_b[i] == i+1){
			printf("%d\n", max_a[i]);
			continue;
		}
		int s = 0;
		byte next = 0;
		for (j = max_a[i]; j >= 0 && s < 100; j--, s++){
			if (index_a[j] <= i){
				if (b[i - index_a[j]]){
					next = 1;
					printf("%d\n", j);
					break;
				}
			}
		}
		if (next){
			continue;
		}
		int k = 0;
		for (j = q[k]; j<= n && k <=q[0]; j++, k++){
				c = MAX(c, a[i-j]);
		}
		printf("%d\n",c);
	}

	return 0;
}


/*
 * main.c
 *
 *  Created on: 03 ���. 2014 �.
 *      Author: ulgish
 */

/*
 * util.c
 *
 *  Created on: 30 ���� 2014 �.
 *      Author: ulgish
 */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define MAX(A,B) (((A) > (B))?(A):(B))
#define MIN(A,B) (((A) < (B))?(A):(B))

#define LN printf("\n")
#define TAB printf("\t")
#define SPACE printf(" ")

typedef unsigned long long uint64;
typedef long long int64;
typedef signed short int16;
typedef unsigned short uint16;
typedef char byte;

void int64_print(int64 n){
	int64 carry = 10;
	if (n == 0){
		printf("0");
		return;
	}
	char buf[20];
	buf[0] = '\0';
	int i = 0, j;
	while (n > 0){
		buf[i] = n % carry;
		n = n / carry;
		i += 1;
	}
	i--;
	for (j = i; j>= 0; j--){
		printf("%c", 48 + buf[j]);
	}
}
void uint64_print(uint64 n){
	uint64 carry = 10;
	char buf[20];
	buf[0] = '\0';
	int i = 0, j;
	while (n > 0){
		buf[i] = n % carry;
		n = n / carry;
		i += 1;
	}
	i--;
	for (j = i; j>= 0; j--){
		printf("%c", 48 + buf[j]);
	}
}

uint64 uint64_read(){
	char* s = (char*) calloc(20, sizeof(char));
	s[0] = '\0';
	scanf("%s", s);
	//printf("=======%s\n", s);
	uint64 ret = 0;
	uint64 carry = 1;
	int len = strlen(s), i;
	for (i = 0; i < len; i++){
		ret += carry * (s[len-1-i] - 48);
		carry*=10;
	};
	free(s);
	return ret;
}

int64 int64_read(){
	char* s = (char*) calloc(21, sizeof(char));
	s[0] = '\0';
	scanf("%s", s);
	//printf("=======%s\n", s);
	int64 ret = 0;
	int64 carry = 1;
	int len = strlen(s), i;
	for (i = 0; i < len; i++){
		ret += carry * (s[len-1-i] - 48);
		carry*=10;
	};
	free(s);
	return ret;
}

//#define DEBUG

int64 x;
int a[100001];
int b[100001];

int n,d;

void swap(int* a, int* b){
	int c;
	c = *a;
	*a = *b;
	*b = c;
	return;
}
int64 getNextX() {
    x = (x * 37 + 10007) % 1000000007;
    return x;
}
void initAB() {
	int i;
    for(i = 0; i < n; i = i + 1){
        a[i] = i + 1;
    }
    for(i = 0; i < n; i = i + 1){
        swap(&(a[i]), &(a[(int)(getNextX() % (i + 1LL))]));
    }
    for(i = 0; i < n; i = i + 1){
        if (i < d)
            b[i] = 1;
        else
            b[i] = 0;
    }
    for(i = 0; i < n; i = i + 1){
        swap(&(b[i]), &(b[(int)(getNextX() % (i + 1LL))]));
    }
}

int main(){
	scanf("%d %d", &n, &d);
	x = int64_read();
	int i,j;
	initAB();
	int max_a[100000];
	int index_a[100001];
	int sum_b[100000];
	sum_b[0] = b[0];
	max_a[0] = a[0];
#ifdef DEBUG
	printf("d:%d\na:\n", d);
	for (i = 0 ; i < n; i++){
		printf("%d\t", a[i]);
	}
	LN;
	for (i = 0 ; i < n; i++){
		printf("%d\t", b[i]);
	}
	LN;

#endif
	int tmp = -1;
	for (i = 0; i< n; i++){
		index_a[a[i]] = i;
		if (i > 0){
			sum_b[i] = b[i] + sum_b[i-1];
		}
		if (sum_b[i] == 0){
			tmp = i;
		}

	}
#ifdef DEBUG
	printf("tmp:%d\n", tmp);
	printf("sum_b[%d]:%d\n", tmp+1, sum_b[tmp+1]);
#endif
	for (i = 0; i <= tmp; i++){
		max_a[i] = MAX(a[i], max_a[i-1]);
		printf("0\n");
	}
	for (i = tmp+1; i < n; i++){
		int c = 0;
		max_a[i] = MAX(a[i], max_a[i-1]);
		if (sum_b[i] == 0){
			printf("0\n");
			continue;
		}
		int s = 0;
		byte next = 0;
		for (j = max_a[i]; j >= 0 && s < 5000; j--, s++){
			if (index_a[j] <= i){
				if (b[i - index_a[j]]){
					next = 1;
					printf("%d\n", j);
					break;
				}
			}
		}
		if (next){
			continue;
		}
		for (j = 0; j<= i; j++){
			c = MAX(c, a[j]*b[i-j]);
		}
		printf("%d\n",c);
	}

	return 0;
}


#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <float.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
#include <complex.h>
#include <errno.h>
#include <time.h>
int i,d[25],f[25],l;
long long a[25],ans;
char s[25];

void dfs(int x)
{
	int i,sum;
	long long res;

	if (x>=10)
	{
		for (i=0,sum=0;i<=9;i++) sum+=d[i];
		res=(long long) a[sum-1]*(sum-d[0]);
		for (i=0;i<=9;i++)
		if (d[i]) res/=d[i];
		ans+=res;
		return;
	}
	if (!f[x]) dfs(x+1);
	else
	{
		for (i=1;i<=f[x];i++)
		{
			d[x]=i;
			dfs(x+1);
		}
	}
}

int main()
{
	memset(f,0,sizeof(f));
	memset(d,0,sizeof(d));
	scanf("%s",s);
	l=strlen(s);
	for (i=ans=0;i<l;i++) f[s[i]-'0']++;
	for (i=1,a[0]=1;i<=20;i++) a[i]=(long long) a[i-1]*i;
	dfs(0);
	printf("%lld\n",ans);
	return 0;
}


#include <stdio.h>
int main(){
int n;
scanf("%d",&n);
int s[n],i,l=0;
for(i=0;i<n;i++){
    scanf("%d",&s[i]);
}
i=0;
while(i<n-1){
   while(i<n-1){
    if(s[i]<s[i+1])i++;
    else if(s[i]==s[i+1])break;
    else{l=1;}
   }
   while(i<n-1){
    if(s[i]==s[i+1])i++;
    else if(s[i]>s[i+1])break;
    else{l=1;}
   }
    while(i<n-1){
      if(s[i]>s[i+1])  i++;
      else{l=1;}

    }

}
if(l==0)printf("YES");
else printf("NO");

return 0;
}


#include<stdio.h>
void cuprec(float arr[],int num,float amount,int height)
{
	if(arr[num]+amount<=1)
	{
		arr[num]=arr[num]+amount;
	}
	else
	{
		cuprec(arr,num+height+1,(amount-(1-arr[num]))/2,height+1);
		cuprec(arr,num+height,(amount-(1-arr[num]))/2,height+1);
	}
}
int main()
{
	float arr[56];
	int n,t,i,k,ncup,ans=0;
	scanf("%d%d",&n,&t);
	ncup=(n*(n+1))/2;
	for(i=0;i<56;i++)
	{
		arr[i]=0.000;
	}
	for(i=1;i<=t;i++)
	{
		cuprec(arr,1,1.00,1);
	}
	for(i=1;i<=ncup;i++)
	{
		if(arr[i]==1.00)
			ans++;
	}
	printf("%d\n",ans);
	return 0;
}


#include<stdio.h>
void main()
{
    int x,y,i;
    i=1;
    while(1)
    {
        if(x>=i)
        {
            x=x-i;
            i++;
        }
        else
        {
        printf("Vladik");
        break;
        }
        if(y>=i)
        {
            y=y-i;
            i++;
        }
        else
        {
            printf("Valera");
            break;
        }
    }
}


#include<stdio.h>
#define ll long long int
ll power(int x, int y)
{
    if( y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}

/* Program to test function power */

int main()
{
    ll n,ans;
    scanf("%lld\n",n);
    if(n%4==0)
        ans = n/4 - 1;
    else
        ans = n/4;

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

}


#include <stdio.h>

int main(void) {
    // your code goes here
    float r,h;
    int n;
    scanf("%f %f",&r,&h);
    if((h-r/2)%r==0&&r!=1&&h>=r){
        h=h/r;
        n=2+2*h;
    }
    else{
        n=1+2*h/r;
    }
    printf("%d",n);
    return 0;
}


#include <stdio.h>

void Swap(char a[6])
{
	char b;
	for (int i = 0; i < 3; i++)
	{
		b = a[i];
		a[i] = a[5 - i];
		a[5 - i] = b;
	}
}

int main()
{
	char number[6], ch, l = 0, r = 0, ans = 0, min, max, imin, imax;
	int i;

	for (i = 0; i < 3; i++)
	{
		ch = getchar();
		number[i] = ch - '0';
		l += number[i];
	}
	for (i = 3; i < 6; i++)
	{
		ch = getchar();
		number[i] = ch - '0';
		r += number[i];
	}
	if (l < r)
	{
		Swap(number);
		ch = l;
		l = r;
		r = ch;
	}
	while (l != r)
	{
		min = 10;
		max = -1;
		for (i = 0; i < 3; i++)
		{
			if (max < number[i])
			{
				max = number[i];
				imax = i;
			}
			if (min > number[5 - i])
			{
				min = number[5 - i];
				imin = i;
			}
		}
		if (max > 9 - min)
		{
			ch = number[imax];
			number[imax] -= l - r;
			if (number[imax] < 0)
				number[imax] = 0;
			l += number[imax] - ch;
		}
		else
		{
			ch = number[imin];
			number[imin] += l - r;
			if (number[imin] > 9)
				number[imin] = 9;
			r += number[imin] - ch;
		}
		ans++;
	}
	printf("%hhi\n", ans);

	return 0;
}


#include <stdio.h>

int main()
{
    int p;
    scanf("%d", &p);
    int n = p - 1;
    int count = n;
    for (int i = 2; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            do
            {
                n /= i;
            } while (n % i == 0);
            count = count / i * (i - 1);
        }
    }
    if (n != 1)
    {
        count = count / n * (n - 1);
    }
    printf("%d\n", count);
    return 0;


#include<stdio.h>
#include<string.h>
#define INF (unsigned long long)1000000000000000001
int q, n, flen, slen, e;
unsigned long long k, f[100001];
char s1[200] = "What are you doing at the end of the world? Are you busy? Will you save us?";
char s2[200] = "What are you doing while sending xx? Are you busy? Will you send xx?";
char s3[200] = "What are you doing while sending x";
char s4[200] = "x? Are you busy? Will you send x";
char s5[200] = "x?";
void find(int d, long long jump){
	if (d == 0){
		printf("%c", s1[jump]);
		e = 1;
		return;
	}
	if (flen >= jump){
		if (s3[jump] == 'x')printf("\"");
		else printf("%c", s3[jump]);
		e = 1;
	}
	else if (flen + f[d - 1] >= jump){
		find(d - 1, jump - flen);

	}
	else if (flen + f[d - 1] + slen >= jump){
		jump -= (flen + f[d - 1]);
		if (s4[jump] == 'x')printf("\"");
		else printf("%c", s4[jump]);
		e = 1;
	}
	else if (flen + f[d - 1] + slen + f[d - 1] >= jump){
		find(d - 1, jump - flen - f[d - 1] - slen);
	}
	else{
		jump -= (flen + f[d - 1] + slen + f[d - 1]);
		if (s5[jump] == 'x')printf("\"");
		else printf("%c", s5[jump]);
		e = 1;
	}
	if (e)return;
}

int main()
{
	scanf("%d", &q);
	int len = strlen(s1);
	int len2 = strlen(s2);
	flen = strlen(s3);
	slen = strlen(s4);
	f[0] = len;
	for (int i = 1; i <= 100000; i++){
		if (f[i - 1] == INF)f[i] = INF;
		f[i] = f[i - 1] * 2 + len2;
		if (f[i] >= INF)f[i] = INF;
	}
	while (q--){
		scanf("%d%lld", &n, &k);
		k--;
		e = 0;

		find(n, k);
	}
	printf("\n");
}


include<stdio.h>

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


#include <stdio.h>
int main(){
	int n,i,j,k,c=1,b=0,asal[3000],counter=0,result=0;
	scanf("%d",&n);
	asal[0]=2;
	for(i=3;i<=3000;i+=2){
		k=0;
		for(j=1;j<i;j++){
			if(i%j==0) k++;
		}
		if(k==1){
			asal[c]=i;
			c++;
		}
	}
	c=0;
	while(asal[c]<n)
		c++;
	for(i=6;i<=n;i++){
		for(j=0;j<c;j++){
			if(i%asal[j]==0) counter++;
		}
		if(counter==2)
			result++;
			counter=0;
	}
	printf("%d",result);
	return 0;
}


#include <stdio.h>

int main(int argc, const char * argv[]) {
    unsigned int price, m, sum;
    scanf("%u %u", &price, &m);
    if(price<10){
        if(!(m%price))
            return printf("%u", m/price);
        goto hui;
    }
hui:

    for(unsigned int i = 1; i<10; i++){
        if(((price*i)%10 == 0) || ((price*i-m)%10 == 0))
            return printf("%u", i) & 0;
    }

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
int sumx(int x)
{
	int r,i;
	r=0;
	while(x>0){
		r+=x%10;
		x=x/10;
	}
	return r;
}

int square(int sx, int a)
{
	int r,i;
	r=1;
	for(i=0;i<a;i++){
		r*=sx;
	}
	return r;
}

int main()
{
	int i, a,b,c,cnt,*res;
	scanf("%d %d %d",&a,&b,&c);
	cnt=0;
	res=NULL;
	for(i=1;i<1e9;i++){
		if(i==(b*square(sumx(i), a)+c)){
			res=(int *)realloc((void * )res, 4*(cnt+1));
			res[cnt]=i;
			cnt+=1;
		}
	}
	if(cnt==0) {printf("0\n");return 0;}
	printf("%d\n",cnt);
	for(i=0;i<cnt;i++){
		printf("%d ",res[i]);
	}
	printf("\n");
	return 0;
}


#include<stdio.h>
int gcd(long long int a,long long int b);
int main()
{
    long long int a,b,x,y,w,h,i=0;
    scanf("%lli%lli%lli%lli",&a,&b,&x,&y);
    w=x/gcd(x,y);
    h=y/gcd(x,y);

    for(i=1;w*i<=a&&h*i<=b;i++);

printf("%lli",i-1);
}
int gcd(long long int a, long long int b)
{
    long long int t;
  if(a>b)
  {
   a=a+b;
   b=a-b;
   a=a-b;
  }
  while(b%a!=0)
  {
     t=a;
     a=b%a;
     b=t;
  }
   return a;
}


#include<stdio.h>
#include<stdlib.h>
int main(void)
{
    int n,d,*arr,i,time,sum=0;
    scanf("%d %d",&n,&d);
    for(i=0;i<n;i++)
    {
        scanf("%d",(arr+i));
        sum+=*(arr+i);
    }
    time=(n-1)*10+sum;
    if(time>d) printf("-1");
    else if(time<=d)
    {
        if((time+5)<=d) printf("%d",(((n-1)*10)/5+1));
        else printf("%d",((n-1)*10)/5);
    }
    return 0;
}


#include<stdio.h>
int main()
{
    int n;
    while(scanf("%d",&n))
    printf("%d\n",n%2?1:2);
    return 0;
}


#include <stdio.h>

int main()
{
	int n,m,s,i;
	scanf("%d",&n);
	scanf("%d",&m);
	s=1;
	for (i=1; ;i++){
		s=s*n;
		if (s==m){
			printf("YES\n");
			printf("%d",i-1);
			break;
		}
		else if (s>m){
			printf("NO");
			break;
		}
	}
	//printf("%d",s);
	return 0;
}


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

struct Team {
    char name[25];
    int point;
    int score;
    int miss;
}team[4], tmp_team[4];

void swap(int *lhs, int *rhs) {
    int tmp = *lhs;
    *lhs = *rhs;
    *rhs = tmp;
}

void cpy_team() {
    int i;
    for (i = 0; i < 4; ++i) {
        tmp_team[i].point = team[i].point;
        tmp_team[i].score = team[i].score;
        tmp_team[i].miss = team[i].miss;
        strcpy(tmp_team[i].name, team[i].name);
    }
}

char hash_s[4][25];
int hash_idx = 0;
int hash(const char* str) {
    int i;
    for (i = 0; i < hash_idx; ++i) {
        if (!strcmp(str, hash_s[i])) {
            return i;
        }
    }
    strcpy(hash_s[hash_idx++], str);
    return hash_idx - 1;
}

int comp(const void *lhs, const void *rhs) {
    struct Team *sa = (struct Team *)lhs;
    struct Team *sb = (struct Team *)rhs;
    if (sa->point != sb->point) {
        return sa->point < sb->point;
    }
    if (sa->score - sa->miss != sb->score - sb->miss) {
        return sa->score - sa->miss < sb->score - sb->miss;
    }
    if (sa->score != sb->score) {
        return sa->score < sb->score;
    }
    return strcmp(sa->name, sb->name) > 0;
}

int main() {
    //freopen("in.txt", "r", stdin);
    int i, j, ia, ib, na, nb, b_id, opp_id, cnt[4];
    char sa[25], sb[25];

    memset(cnt, 0, sizeof(cnt));
    for (i = 0; i < 5; ++i) {
        scanf("%s %s %d:%d", sa, sb, &na, &nb);
        ia = hash(sa);
        ib = hash(sb);
        strcpy(team[ia].name, sa);
        strcpy(team[ib].name, sb);
        ++cnt[ia];
        ++cnt[ib];
        /*printf("%d %d %d %d\n", na, nb, ia, ib);*/
        if (nb > na) {
            swap(&na, &nb);
            swap(&ia, &ib);
        }
        /*printf("%d %d\n", na, nb);*/
        if (na > nb) {
            team[ia].point += 3;
        } else if (na == nb) {
            team[ia].point += 1;
            team[ib].point += 1;
        }
        team[ia].score += na;
        team[ia].miss += nb;
        team[ib].score += nb;
        team[ib].miss += na;
    }
    /*for (i = 0; i < 4; ++i) {*/
        /*printf("%d %d %d\n", team[i].point, team[i].score, team[i].miss);*/
    /*}*/
    /*return 0;*/
    for (i = 0; i < 4; ++i) {
        if (!strcmp(team[i].name, "BERLAND")) {
            b_id = i;
        } else if (cnt[i] != 3) {
            opp_id = i;
        }
    }

    cpy_team();
    qsort(tmp_team, 4, sizeof(struct Team), comp);
    /*for (i = 0; i < 4; ++i) {*/
        /*printf("%s\n", tmp_team[i].name);*/
    /*}*/
    /*printf("opp_id = %d, b_id = %d\n", opp_id, b_id);*/
    /*for (i = 0; i < hash_idx; ++i) {*/
        /*printf("%s\n", hash_s[i]);*/
    /*}*/
    for (i = 1; i < 100; ++i) {
        cpy_team();
        tmp_team[b_id].point += 3;
        tmp_team[b_id].score += i;
        tmp_team[opp_id].miss += i;
        /*for (j = 0; j < 4; ++j) {*/
            /*printf("%d %d %d\n", tmp_team[j].point, tmp_team[j].score, tmp_team[j].miss);*/
        /*}*/
        /*putchar('\n');*/
        qsort(tmp_team, 4, sizeof(struct Team), comp);
        if (!strcmp(tmp_team[0].name, "BERLAND") || !strcmp(tmp_team[1].name, "BERLAND")) {
            for (j = i - 1; j >= 0; --j) {
                cpy_team();
                tmp_team[b_id].point += 3;
                tmp_team[b_id].score += i;
                tmp_team[opp_id].miss += i;

                tmp_team[b_id].miss += j;
                tmp_team[opp_id].score += j;
                qsort(tmp_team, 4, sizeof(struct Team), comp);
                if (!strcmp(tmp_team[0].name, "BERLAND") || !strcmp(tmp_team[1].name, "BERLAND")) {
                    printf("%d:%d\n", i, j);
                    return 0;
                }
            }
        }
    }
    puts("IMPOSSIBLE");

    return 0;
}


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

struct Team {
    char name[25];
    int point;
    int score;
    int miss;
}team[4], tmp_team[4];

void swap(int *lhs, int *rhs) {
    int tmp = *lhs;
    *lhs = *rhs;
    *rhs = tmp;
}

void cpy_team() {
    int i;
    for (i = 0; i < 4; ++i) {
        tmp_team[i].point = team[i].point;
        tmp_team[i].score = team[i].score;
        tmp_team[i].miss = team[i].miss;
        strcpy(tmp_team[i].name, team[i].name);
    }
}

char hash_s[4][25];
int hash_idx = 0;
int hash(const char* str) {
    int i;
    for (i = 0; i < hash_idx; ++i) {
        if (!strcmp(str, hash_s[i])) {
            return i;
        }
    }
    strcpy(hash_s[hash_idx++], str);
    return hash_idx - 1;
}

int comp(const void *lhs, const void *rhs) {
    struct Team *sa = (struct Team *)lhs;
    struct Team *sb = (struct Team *)rhs;
    if (sa->point != sb->point) {
        return sa->point < sb->point;
    }
    if (sa->score - sa->miss != sb->score - sb->miss) {
        return sa->score - sa->miss < sb->score - sb->miss;
    }
    if (sa->score != sb->score) {
        return sa->score < sb->score;
    }
    return strcmp(sa->name, sb->name) > 0;
}

int main() {
    //freopen("in.txt", "r", stdin);
    int i, j, ia, ib, na, nb, b_id, opp_id, x, y, min = 10000, cnt[4];
    char sa[25], sb[25];

    memset(cnt, 0, sizeof(cnt));
    for (i = 0; i < 5; ++i) {
        scanf("%s %s %d:%d", sa, sb, &na, &nb);
        ia = hash(sa);
        ib = hash(sb);
        strcpy(team[ia].name, sa);
        strcpy(team[ib].name, sb);
        ++cnt[ia];
        ++cnt[ib];
        /*printf("%d %d %d %d\n", na, nb, ia, ib);*/
        if (nb > na) {
            swap(&na, &nb);
            swap(&ia, &ib);
        }
        /*printf("%d %d\n", na, nb);*/
        if (na > nb) {
            team[ia].point += 3;
        } else if (na == nb) {
            team[ia].point += 1;
            team[ib].point += 1;
        }
        team[ia].score += na;
        team[ia].miss += nb;
        team[ib].score += nb;
        team[ib].miss += na;
    }
    /*for (i = 0; i < 4; ++i) {*/
        /*printf("%d %d %d\n", team[i].point, team[i].score, team[i].miss);*/
    /*}*/
    /*return 0;*/
    for (i = 0; i < 4; ++i) {
        if (!strcmp(team[i].name, "BERLAND")) {
            b_id = i;
        } else if (cnt[i] != 3) {
            opp_id = i;
        }
    }

    cpy_team();
    qsort(tmp_team, 4, sizeof(struct Team), comp);
    /*for (i = 0; i < 4; ++i) {*/
        /*printf("%s\n", tmp_team[i].name);*/
    /*}*/
    /*printf("opp_id = %d, b_id = %d\n", opp_id, b_id);*/
    /*for (i = 0; i < hash_idx; ++i) {*/
        /*printf("%s\n", hash_s[i]);*/
    /*}*/
    for (i = 1; i < 100; ++i) {
        for (j = i - 1; j >= 0; --j) {
            cpy_team();
            tmp_team[b_id].point += 3;
            tmp_team[b_id].score += i;
            tmp_team[opp_id].miss += i;

            tmp_team[b_id].miss += j;
            tmp_team[opp_id].score += j;
            qsort(tmp_team, 4, sizeof(struct Team), comp);
            if (!strcmp(tmp_team[0].name, "BERLAND") || !strcmp(tmp_team[1].name, "BERLAND")) {
                if (i - j < min) {
                    min = i - j;
                    x = i;
                    y = j;
                }
            }
    }
    if (min != 10000) {
        printf("%d:%d\n", x, y);
    } else {
        puts("IMPOSSIBLE");
    }

    return 0;
}


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

typedef struct{
	int jour;
	int mois;
	int annee;
}date;

typedef struct{
	char nomComplet[80];
	date dNaissance;
	char pDorigin[20];
}STR_P;

typedef struct{
	STR_P infos;
	date dEmbauche;
	int nbEnfant;
	STR_P infoConjoint;
	STR_P listEnfant[5];
}commercial;

typedef struct{
 	STR_P infos;
	date dEmbauche;
	int nbEnfant;
	STR_P infoConjoint;
	STR_P listEnfant[5];
}client;

typedef struct{
	char rs[30];
	date dOuvert;
	char adresse[30];
	int nbCom;
	commercial listCom[5];
	int nbClient;
	commercial listClient[5];
}agence;

typedef struct{
	char rs[30];
	char rc[30];
	int patente;
	date anCreation;
	char tAcitvite[30];
	int chifDafaire;
	int nbAgence;
	agence listAgence[5];
}assurance;

typedef struct{
	assurance assur[5];
	int nbAssurance;
}grAssurance;

//QUestion 3 :
STR_P creationInfos(){
	STR_P info;
	printf("Entrez le nom complet : ");
	scanf("%s",info.nomComplet);
	printf("Entrez la date de naissance\n");
	printf("jour : ");
	scanf("%d",&info.dNaissance.jour);
	printf("le mois : ");
	scanf("%d",&info.dNaissance.annee);
	printf("Annee : ");
	scanf("%d",&info.dNaissance.annee);
	printf("Entrez le pays d'origine : ");
	scanf("%s",info.pDorigin);

	return info;
}

commercial creationCl_CM(){
	commercial com;
	int i;

	printf("Creation un(e) client(e) ou un(e) commercial(e)\n");
	com.infos=creationInfos();
	printf("Entrez la date d'embauche\n");
	printf("jour : ");
	scanf("%d",&com.dEmbauche.jour);
	printf("le mois : ");
	scanf("%d",&com.dEmbauche.mois);
	printf("Annee : ");
	scanf("%d",&com.dEmbauche.annee);
	printf("Entrez le nombre d'enfant : ");
	scanf("%d",&com.nbEnfant);
	printf("Enrez les donnees du conjoint(e)\n");
	com.infoConjoint=creationInfos();
		printf("Entrez les donnees des enfants\n");
	for(i=0 ; i<com.nbEnfant ; i++){
		printf("-L'enfant <%d>-\n",i+1);
		com.listEnfant[i]=creationInfos();
	}
	return com;
}

agence creaCmAgence(){
	agence agen;
	int i;

	printf("Entrez la raison sociale : ");
	scanf("%s",agen.rs);
	printf("Entrez la date d'ouverture\n");
	printf("jour : ");
	scanf("%d",&agen.dOuvert.jour);
	printf("le mois : ");
	scanf("%d",&agen.dOuvert.mois);
	printf("Annee : ");
	scanf("%d",&agen.dOuvert.annee);
	printf("Entrez l'adresse : ");
	scanf("%s",agen.adresse);
	printf("Entrez le nombre des comerciaux : ");
	scanf("%d",&agen.nbCom);
	printf("Entrez les donnees des comerciaux\n");
	for(i=0 ; i<agen.nbCom ; i++){
		agen.listCom[i]=creationCl_CM();
	}
	printf("Entrez le nombre des clients : ");
	scanf("%d",&agen.nbClient);
	printf("Entrez les donnees des clients\n");
	for(i=0 ; i<agen.nbClient ; i++){
		agen.listClient[i]=creationCl_CM();
	}

	return agen;
}

assurance crAssurances(){
	assurance assur;
	int i;

	printf("Entrez la raison sociale : ");
	scanf("%s",assur.rs);
	printf("Entrez le registre commercial : ");
	scanf("%s",assur.rc);
	printf("Entrez la patente : ");
	scanf("%d",&assur.patente);
	printf("Entrez la date de creation\n");
	printf("jour : ");
	scanf("%d",&assur.anCreation.jour);
	printf("le mois : ");
	scanf("%d",&assur.anCreation.mois);
	printf("Annee : ");
	scanf("%d",&assur.anCreation.annee);
	printf("Entrez le type d'activite : ");
	scanf("%s",assur.tAcitvite);
	printf("Entrez le chiffre d'affaire : ");
	scanf("%d",&assur.chifDafaire);
	printf("Entrez le nombre d'agence : ");
	scanf("%d",&assur.nbAgence);
	for(i=0 ; i<assur.nbAgence ; i++){
		assur.listAgence[i]=creaCmAgence();
	}

	return assur;
}

//la fonction pour ajouter des compagnies d'assurance dans le groupement des assurances
//Question 3
void group_Assurance(grAssurance *gr,int nb){
	int i,m=0;

	if(gr->nbAssurance>0){
		m=gr->nbAssurance;
	}

	gr->nbAssurance+=nb;
	for(i=m ; i<gr->nbAssurance ; i++){
		gr->assur[i]=crAssurances();
	}
}

//Question 4 : recherche l'agence par sa raison sociale
int chercher(grAssurance gr,char rs[]){
	int i;
	for(i=0 ; i<gr.nbAssurance ; i++){
		if(strcmp(gr.assur[i].rs,rs)==0)
			return i;
	}
	return -1;
}

void modifierAgence(grAssurance *gr,char rs[],int nbAgence){
	int indice,m,i;

	indice =chercher(*gr,rs);
	if(indice!=-1){
		gr->assur[indice].nbAgence=nbAgence;
		for(i=0 ; i<gr->assur[indice].nbAgence ; i++){
			gr->assur[indice].listAgence[i]=creaCmAgence();
		}
	}else
		printf("L'agence n'existe pas\n");
}

void affichage_Ag(agence ag){
	int i,j;

	printf("La raison sociale d'agence : %s\n",ag.rs);
	printf("La date d'overture : %d/%d/%d\n",ag.dOuvert.jour,ag.dOuvert.mois,ag.dOuvert.annee);
	printf("L'adresse : %s\n",ag.adresse);
	for(i=0 ; i<ag.nbCom ; i++){
		printf("Le nom complet : %s\n",ag.listCom[i].infos.nomComplet);
		printf("La date de naissance : %d/%d/%d\n",ag.listCom[i].infos.dNaissance.jour,ag.listCom[i].infos.dNaissance.mois,ag.listCom[i].infos.dNaissance.annee);
		printf("Pays d'origine : %s\n",ag.listCom[i].infos.pDorigin);
		printf("Date d'embauche : %d/%d/%d\n",ag.listCom[i].dEmbauche.jour,ag.listCom[i].dEmbauche.mois,ag.listCom[i].dEmbauche.annee);
		printf("les informations sur le conjoint\n");
		printf("Le nom complet : %s\n",ag.listCom[i].infoConjoint.nomComplet);
		printf("La date de naissance : %d/%d/%d\n",ag.listCom[i].infoConjoint.dNaissance.jour,ag.listCom[i].infoConjoint.dNaissance.mois,ag.listCom[i].infoConjoint.dNaissance.annee);
		printf("Pays d'origine : %s\n",ag.listCom[i].infos.pDorigin);
		printf("Les donnees des enfants\n");
		for(j=0 ; j<ag.listCom[i].nbEnfant ;j++){
			printf("-L'enfant <%d>-\n");
			printf("Le nom complet : %s\n",ag.listCom[i].listEnfant[j].nomComplet);
			printf("Date de naissance : %d/%d/%d\n",ag.listCom[i].listEnfant[j].dNaissance.jour,ag.listCom[i].listEnfant[j].dNaissance.mois,ag.listCom[i].listEnfant[j].dNaissance.annee);
			printf("Le pays d'origin : %s\n",ag.listCom[i].listEnfant[j].pDorigin);
		}
	}
	for(i=0 ; i<ag.nbClient ; i++){
		printf("Le nom complet : %s\n",ag.listClient[i].infos.nomComplet);
		printf("La date de naissance : %d/%d/%d\n",ag.listClient[i].infos.dNaissance.jour,ag.listClient[i].infos.dNaissance.mois,ag.listClient[i].infos.dNaissance.annee);
		printf("Pays d'origine : %s\n",ag.listClient[i].infos.pDorigin);
		printf("Date d'embauche : %d/%d/%d\n",ag.listClient[i].dEmbauche.jour,ag.listClient[i].dEmbauche.mois,ag.listClient[i].dEmbauche.annee);
		printf("les informations sur le conjoint\n");
		printf("Le nom complet : %s\n",ag.listClient[i].infoConjoint.nomComplet);
		printf("La date de naissance : %d/%d/%d\n",ag.listClient[i].infoConjoint.dNaissance.jour,ag.listClient[i].infoConjoint.dNaissance.mois,ag.listClient[i].infoConjoint.dNaissance.annee);
		printf("Pays d'origine : %s\n",ag.listClient[i].infos.pDorigin);
		printf("Les donnees des enfants\n");
		for(j=0 ; j<ag.listClient[i].nbEnfant ;j++){
			printf("-L'enfant <%d>-\n");
			printf("Le nom complet : %s\n",ag.listClient[i].listEnfant[j].nomComplet);
			printf("Date de naissance : %d/%d/%d\n",ag.listClient[i].listEnfant[j].dNaissance.jour,ag.listClient[i].listEnfant[j].dNaissance.mois,ag.listClient[i].listEnfant[j].dNaissance.annee);
			printf("Le pays d'origin : %s\n",ag.listClient[i].listEnfant[j].pDorigin);
		}
	}
}

void affichage_Agence(assurance a){
	int i;

	printf("la raison sociale : %s\n",a.rs);
	printf("Le registre commerical : %s\n",a.rc);
	printf("La patente%d\nannee de creation : %d/%d/%d\n",a.patente,a.anCreation.jour,a.anCreation.mois,a.anCreation.annee);
	printf("Type d'activite : %q\n",a.tAcitvite);
	printf("Le nombre d'agence : %d\n",a.nbAgence);
	printf("Les donnees sur les agences\n");
	for(i=0 ; i<a.nbAgence ; i++){
		affichage_Ag(a.listAgence[i]);
	}
}

//Question 5
void chercheComp(grAssurance gr,char activite[]){
	int i,cmp=0;

	for(i=0 ; i<gr.nbAssurance ; i++){
		if(strcmp(gr.assur[i].tAcitvite,activite)==0){
			cmp=1;
			assurance a=gr.assur[i];
			affichage_Agence(a);
		}
	}
	if(cmp==0)
		printf("Les compagnies d'assurance n'existent pas\n");
}

//Question 6 : affichages les agences dont les commerciaux ayant plus que 3 enfants et les clients ayant moins que 2 enfants
void afficheAssurance(assurance as){
	int i,j;

	for(i=0 ; i<as.nbAgence ; i++){
		for(j=0 ; j<as.listAgence[i].nbCom && j<as.listAgence[i].nbClient ; j++){
			if(as.listAgence[i].listClient[j].nbEnfant<2 && as.listAgence[i].listCom[j].nbEnfant>3){
				agence ag=as.listAgence[i];
				affichage_Ag(ag);
			}

		}
	}
}

//Question 7 : supprision
void supp(grAssurance *gr,char rs[]){
	int indice,i;
	indice=chercher(*gr,rs);
	if(indice!=-1){
		for(i=indice ; i<gr->nbAssurance-1 ; i++){
			gr->assur[i]=gr->assur[i+1];
		}
		gr->nbAssurance--;
	}else
		printf("La compagnie d'assurance n'existe pas\n");
}

int main(){
	grAssurance groupAssur;
	int nb,choix,nbAgence;
	char rs[30];
	groupAssur.nbAssurance=0;

/*	printf("Entrez le nombre des compangies d'assurance: ");
	scanf("%d",&nb);
	group_Assurance(&groupAssur,nb);
	system("cls");*/

	do{ printf("---------------------------------------------------------------------------------------------\n");
		printf("1-Pour ajouter des compagnies d'assurances dans le groupement d'assurance\n");
		printf("2-Pour modifier la liste des agences d'une compagnie\n");
		printf("3-Pour afficher les agences d'une compagnie d'assurance dont les commerciaux ayant plus que 3 enfants et les client ayant moins que 2 enfants\n");
		printf("4-Pour afficher les compagnies d'assurances exer�ant une activite\n");
		printf("5 Pour supprimer une compagnie d'assurance\n");
		printf("6-Quitter\n");
		printf("---------------------------------------------------------------------------------------------\n");
		printf("\t Entrez votre choix : ");
		scanf("%d",&choix);

		switch(choix){
			case 1 : printf("Entrez le nombre des compangies d'assurance: ");
					 scanf("%d",&nb);
				   	 group_Assurance(&groupAssur,nb);
					 break;

			case 2 :printf("Entrez la raison sociale : ");
					scanf("%s",rs);
					printf("Entrez le nombre d'agence : ");
					scanf("%d",&nbAgence);
					modifierAgence(&groupAssur,rs,nbAgence);
					break;

			case 3 : afficheAssurance(groupAssur.assur[0]);
					 break;

			case 4 : printf("Entrez l'activite : ");
					 scanf("%s",rs);
					 chercheComp(groupAssur,rs);
					 break;

			case 5 : printf("Entrez la raison sociale : ");
				     scanf("%s",rs);
					 supp(&groupAssur,rs);
					 break;

			case 6 : return 0;
		}
	}while(choix>=1 || choix<=6);

	return 0;
}


#include <stdio.h>

#define N	200000
#define MD	998244353

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

	if (k == 0)
		return 1;
	p = power(a, k >> 1);
	p = p * p % MD;
	if (k & 1)
		p = p * a % MD;
	return p;
}

int ff[N + 1], gg[N + 1];

void init() {
	int i, f;

	f = 1;
	for (i = 0; i <= N; i++) {
		gg[i] = power(ff[i] = f, MD - 2);
		f = (long long) f * (i + 1) % MD;
	}
}

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

int main() {
	int n, c, ans;
	long long k;

	init();
	scanf("%d%lld", &n, &k);
	ans = 0;
	if (k == 0)
		ans = ff[n];
	else {
		int x;

		x = 0;
		for (c = n - k; c >= 0; c--)
			x = (x + ((n - k - c) % 2 == 0 ? 1 : -1) * (ch(n - k, c) * power(c, n))) % MD;
		ans = (long long) ch(n, n - k) * x * 2 % MD;
		if (ans < 0)
			ans += MD;
	}
	printf("%d\n", ans);
	return 0;
}


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

long long int potenciacao(int base, int expoente){
    int i = 1;
    long long int resposta = base;
    while (i < expoente){
        resposta = resposta*base;
        i++;
    }
    return resposta;

}

int main()
{
    int n;
    unsigned long long int calculo, atual, mod, anterior, i;
    mod = 1000000007;
    scanf("%d", &n);
    anterior = 0;
    atual = 0;
    i = 2;
    while (i <=n){
       // printf("***************************************************\n");
        calculo = (unsigned long long int)potenciacao(3,(i-1));
        calculo = (unsigned long long int) (calculo - anterior);
        //calculo = abs(calculo - anterior);

        atual = calculo;
        i++;
        anterior = atual;
        //printf("*************************************************************\n\n");
    }
    printf("%I64d\n", (unsigned long long int)atual % mod);
    return 0;
}


#include <stdio.h>

max (long int *pp,long int *pb){
	long int t;
	if ((*pp)<(*pb)){
		t=*pp;
		*pp=*pb;
		*pb=t;

	}

}
int main (){
	long int n,m,i,j,a,b,p,q;
	scanf("%ld %ld %ld %ld %ld %ld",&n,&m,&i,&j,&a,&b);
	if (((n-i)%a==0) && ( (m-j)%b==0) )
{
	p=(n-i)/a;
	q=(m-j)/b;
	max(&p,&b);

	if ((p-q)%2==0){
		printf("%ld",p);
		exit;
		}
		else {
			printf("Poor Inna and pony!\n");
			exit;
		}
	}
else if (((n-i)%a==0) && ( (j-1)%b==0 ))
{
	p=(n-i)/a;
	q=(j-1)/b;
	max(&p,&q);
	if ((p-q)%2==0){
		printf("%ld",p);

	}
	else
	printf("Poor Inna and pony!");
}

else if (((i-1)%a==0) && ( (j-1)%b==0 ))
{
	p=(i-1)/a;
	q=(j-1)/b;
	max(&p,&q);
	if ((p-q)%2==0){
		printf("%ld",p);

	}
	else
	printf("Poor Inna and pony!");
}

else if (((i-1)%a==0) && ( (m-j)%b==0 ))
{
	p=(i-1)/a;
	q=(m-j)/b;
	max(&p,&q);
	if ((p-q)%2==0){
		printf("%ld",p);

	}
	else
	printf("Poor Inna and pony!");
}

	else
	{
	printf("Poor Inna and pony!\n");

}
return 0;
}


#include <stdio.h>
int main(void) {
	long int n, days_added = 0, ans;
	scanf("%ld", &n);
	ans = n;
	int N_LEAP = n % 4;
	do {
		if (ans % 4 != 0)
			days_added += 365;
		else if (ans % 100 != 0)
			days_added += 366;
		else if (ans % 400 != 0)
			days_added += 356;
		else
			days_added += 366;
		ans++;
	} while (days_added % 7 != 0 || ( N_LEAP != 0 || (N_LEAP == 0 && ans%4 != 0)) );
	printf("%ld", ans);
	return 0;
}


#include<stdio.h>
int main()

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

  stime=240-min;

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

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

        }

  }

printf("%d", count);

  return 0;

}


#include<stdio.h>
int main(void)
{
int w,h,u1,u2,d1,d2;
scanf("%d %d %d %d %d %d",&w,&h,&u1,&d1,&u2,&d2);
while(h>0)
{
w+=h;
if(h==d1)
w-=u1;
if(h==d2)
w-=u2;
}
printf("%d\n",w);

return 0;
}


#include<stdio.h>
int main()
{
  int x,y,z,i,j,k,l,sum=0,cout=0;
  scanf("%d%d%d",&x,&y,&z);
  for(i=1;i<=x;i++)
      {
        for(j=1;j<=y;j++)
            {
              for(k=1;k<=z;k++)
                  {
                   sum=i*j*k;
                   for(l=1;l<=sum;l++)
                   {
                       if(sum%l==0)
                        cout++;
                   }

                  }
             }
      }

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

}


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

int i,j;

int main(){
    int n;
    int m[200];
    for(i=0;i<200;i++)m[i]=0;
    scanf("%d",&n);
    if(n<1||n>200)return 0;
    char s[n+1];
    for(i=0;i<n;i++){
        scanf(" %c",&s[i]);
    }
    int c=0;int max;
    //for(i=0;i<n;i++){printf("%d\n",s[i]);}
  //  for(i=0;i<n;i++)if(s[i]<95)c+=1;
   // if(c==n){printf("0");return 0;}
    i=0;c=0;int count=0;
    while(1){
        while(s[i]>95){
            if(m[s[i]]<1){c+=1;m[s[i]]+=1;}
            i++;
            if(i==n)break;
        }
        memset(m,0,200);
        i++;
        //printf("%d\n",c);
        count+=1;
        if(count==1)max=c;
        else if(c>max)max=c;
        if(i==n)break;
    }
    printf("%d",max);

return 0;}


//+++++++++++++++++++++++++++++//
//      Karan Aggarwal         //
//       IIIT-Hyderabad        //
//+++++++++++++++++++++++++++++//
// Topic:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#include<math.h>
#define si(n) scanf("%d",&n)
#define rep(i,n) for(i=0;i<n;i++)
#define REP(i,a,b) for(i=a;i<b;i++)
#define pn printf("\n")
#define pw printf(" ")
#define pi(n) printf("%d",n)
#define pll(n) printf("%lld",n)
#define sll(n) scanf("%lld",&n)
#define ss(s) scanf("%s",s)
#define ps(s) printf("%s",s)
#define mod 1000000007
typedef long long LL;
//inline int readint(){int n=0;char c;while(1){ c=getchar_unlocked();if(c=='\n'||c==' '||c==EOF)break;n=(n<<3) + (n<<1) +c-'0';}return n;}
//inline long long readlonglong(){long long n=0;char c;while(1){ c=getchar_unlocked();if(c=='\n'||c==' '||c==EOF)break;n=(n<<3) + (n<<1) +c-'0';}return n;}
int abs(int a){ if(a<0)return -1*a; return a;}
int big(int a,int b){if(a>b)return a;return b;}
int small(int a,int b){if(a<b)return a;return b;}
int compare(const void *a, const void *b)
{
    int *p1=(int*)a;
    int *p2=(int*)b;
    return *p1-*p2;
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int aa,bb;
LL  f[1000005];
LL md(LL a)
{
    while(a>=0)a-=1000000007;
    while(a<0)a+=1000000007;
    return a;
}
int isgood(int x)
{
    int N = x;
    while(N)
    {
        if(N%10 == aa)
        {
            N/=10;
            continue;
        }
        if(N%10 == bb)
        {
            N/=10;
            continue;
        }
        else return 0;
    }
    return 1;
}
LL  inv(LL a)
{
    LL B,m,n,x,y,u,v,q,r;
    x=v=0;
    y=u=1;
    LL b = mod;
    B=mod;
    while(a)
    {
        q=b/a;
        r=b%a;
        m=x-u*q;
        n=y-v*q;
        b=a;a=r;
        x=u;y=v;
        u=m;v=n;
    }
    return md(x);
}

int main()
{
    int m,l,ans,sum,min,max,n,i,j,k,x,y,t;
    int counta,countb,mina,maxa;
    si(aa);
    si(bb);
    si(n);
    f[0]=1;
    REP(i,1,n+5)
        f[i] = (f[i-1]*(LL)i)%mod;

    LL anss=0;
    rep(i,n+1)
    {
        if(isgood(aa*i + bb*(n-i)))
            anss +=         md(f[n] * inv(f[i]*f[n-i]));
        anss = md(anss);
    }
    pll(md(anss));
    return 0;
}


#include<stdio.h>
#include<math.h>
int main( )
{
long long int a,b,c=0,i,j,k;
scanf("%lld %lld",&a,&b);
while(((a>0)&&(b>0)))
{
if((a==1)||(b==1))
{
break;
}
if(a<b)
{
b=b-a;
}
else
{
a=a-b;
}
c+=1;
}
if(a<b)
{
c+=b/a;
}
else
{
c+=a/b;
}
printf("%lld\n",c);
return 0;
}


#include <stdio.h>

int main () {
    int basis, value; scanf("%d%d", &basis, &value);
    int amount=0, value_temp=basis;
    if (value==basis) {
        printf(0);
    } else if (value<basis*2 && value<basis*3) {
        printf("-1");
    } else {
        while (value_temp!=value) {
            if (value%(value_temp*6)==0) {
                value_temp*=6;
                amount += 2;
            } else if (value%(value_temp*2)==0) {
                value_temp*=2;
                amount += 1;
            } else if (value%(value_temp*3)==0) {
                value_temp*=3;
                amount += 1;
            }
        }
        printf("%d", amount);
    }
	return 0;
}


#include<stdio.h>
main()
{
    double a, b, c, d, l, r, output;
    double r1, l1;
    scanf(" %lf %lf %lf %lf", &a, &b, &c, &d);
    l=b-a;
    for(r=1; r==r; r++)
        {
            if(l>=(c*r+d*r))
            {
                break;
            }

        }
        if(l==(c*r+d*r))
        {
            printf("%lf", r);
        }
        else
        {
            output=(l-(c*(r-1)+d*(r-1)));
            l=(output/(c+d));
            printf("%lf", l+(r-1));
        }
    return 0;

}


#include<stdio.h>

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


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

int main()
{
    int n,m,cn=0,k, i;
    int code[20], check[20]={0};
    scanf("%d %d",&n,&m);
    for(i=1;i<=n;i++) scanf("%d",&code[i]);
    for(i=1;i<=m;i++) {
        scanf("%d",&k);
        check[k]=1;
    }
    for(i=1;i<=n;i++){
        if(check[code[i]]) printf("%d ",code[i]);
    }
    return 0;

}


#include <stdio.h>

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

	char line[2 * m];
	for (int i = 0; i < n; ++i)
	{
		gets(line);
		for (int j = 0; j < m; ++j)
		{
			if (line[2 * j] == 'C' || line[2 * j] == 'M' || line[2 * j] == 'Y')
			{
				printf("#Color");
				return 0;
			}
		}
	}
	printf("#Black&White");

	return 0;
}


#include<stdio.h>

int n, m, highest = 0, highest_temp = 0, p[8+1], i, k, m_note, n_count, min;
void permutate(int, int);
void swap(int *x, int *y);

int main()
{
    while(scanf("%d", &n)!=EOF)
    {
        min = 9;
        scanf("%d", &m);
        for(i = 1; i<=n; i++)
        {
            p[i] = i;
        }
        for(i = 1; i<=n; i++)
        {
            highest += i * (n+1-i);
        }
        m_note = 1;
        if(m==1)
        {
            for(i = 1; i<=n; i++)
            {
                printf("%d ", p[i]);
            }
            printf("\n")
        }
        else
        {
            permutate(1, n);
        }
    }
    return 0;
}

void permutate(int start, int end)
{
    if(start == end)
    {

        for(k=1; k<=n; k++)
        {
            n_count = n;
            for(n_count; n_count>0; --n_count)
            {
                min = 9;
                for(i=k; i<=n_count; ++i)
                {

                    if(p[i]<min)
                    {
                        min = p[i];
                    }
                    else{}
                }
                for(i=k; i<=n_count; ++i)
                {
                    if(p[i]==min)
                    {
                        highest_temp += p[i];
                    }
                    else{}
                }
            }
        }
        if(highest_temp >= highest)
        {
            ++m_note;
            if(m_note-1==m)
            {
                for(i=1; i<=n; i++)
                {
                    printf("%d ", p[i]);
                }
                printf("\n");
            }
            else{}
        }
        else{}
    }
    else
    {
        int j;
        for(j = start; j <= end; ++j)
        {

            swap((p+start), (p+j));
            permutate(start+1, end);
            swap((p+start), (p+j));
        }
    }
}

void swap(int *x, int *y)
{
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}


#include<stdio.h>
int num[6],f,sum;
void dfs(int v){
    int cnt=0,t=0;
    for(int i=0;i<6;i++){
        if(v&(1<<i)){
            cnt++;
            t+=num[i];
        }
    }
    if(cnt==3){
        if(sum-t==t)f=1;
        return;
    }
    for(int i=0;i<6;i++){
        if(v&(1<<i))continue;
        dfs(i|v);
        if(f)return;
    }
}
int main()
{
    for(int i=0;i<6;i++){
        scanf("%d",num+i);
        sum+=num[i];
    }
    dfs(0);
    printf("%s\n",f?"YES":"NO");
    return 0;
}


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

int main(int argc, char *argv[])
{
    int scoreParticipant[6], i, j;
    int sommeScore = 0;
    scanf("%d %d %d %d %d %d", &scoreParticipant[0], &scoreParticipant[1], &scoreParticipant[2], &scoreParticipant[3],&scoreParticipant[4], &scoreParticipant[5]);
    for (i = 0; i < 6; i++)
        sommeScore += scoreParticipant[i];
    if(sommeScore % 2)
    {
        printf("NO");
        return 0;
    }
    for(i = 1; i < 5; i++)
    {
        for(j = i+1; j < 6; j++)
        {
            if(2*(scoreParticipant[0]+scoreParticipant[i]+scoreParticipant[j]) == sommeScore)
            {
                printf("YES");
                return 1;
            }
        }
    }
    printf("NO");
    return 1;
}


#include <stdio.h>
int main(){
    long long m,n;
    int a,b;
    scanf("%lld %lld %d %d",&m,&n,&a,&b);
    // tim 2 so gan n nhat
    if (m % n != 0){
        long long f1,f2;
        // find f1
        long long temp1 = m, temp2 = m;
        while(1){
            if (temp1 % n != 0) temp1--;
            if (temp1 % n == 0){
                f1 = temp1;
                break;
            }
        }
        // find f2
        f2 = f1 + n;
       // printf("(%lld %lld)",f1,f2);
        if ( (m-f1)*b < (f2-m)*a )
        printf("%lld",(m-f1)*b);
        else printf("%lld",(f2-m)*a);

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


#include<stdio.h>
int a[100],n;
int max(int i,int j)
{
    return i>j?i:j;
}
int q(int st,int odd,int even,int b)
{
    if((st==n-1)||(b<=0)) return 0;
    if(a[st]%2==0) even ++;
    else odd ++;
     int d;
        if(a[st]>a[st+1]) d=a[st]-a[st+1];
        else d=a[st+1]-a[st];
    if((odd+even>0)&&(odd==even)&&(b>=d))
    {
        return max(1+q(st+1,0,0,b-d),q(st+1,odd,even,b));
    }
    return q(st+1,odd,even,b);
}
int main()
{
    int i,b,c;
   scanf("%d %d",&n,&b);
   for(i=0;i<n;i++) scanf("%d",&a[i]);
   c=q(0,0,0,b);
   printf("%d",c);
    return 0;
}


#include<stdio.h>
int a[100],n,m[100];
int max(int i,int j)
{
    return i>j?i:j;
}
int q(int st,int odd,int even,int b)
{
    if((st==n-1)||(b<=0)) return 0;
    if(m[st]!=-1) return m[st];
    if(a[st]%2==0) even ++;
    else odd ++;
     int d;
        if(a[st]>a[st+1]) d=a[st]-a[st+1];
        else d=a[st+1]-a[st];
    if((odd+even>0)&&(odd==even)&&(b>=d))
    {
        m[st]=max(1+q(st+1,0,0,b-d),q(st+1,odd,even,b));
        return m[st];
    }
    m[st]=q(st+1,odd,even,b);
    return m[st];
}
int main()
{
    int i,b,c;
   scanf("%d %d",&n,&b);
   for(i=0;i<n;i++) m[i]=-1;
   for(i=0;i<n;i++) scanf("%d",&a[i]);
   c=q(0,0,0,b);
   printf("%d",c);
    return 0;
}


#include<stdio.h>
int fact(int x);
int main()
{
	long long n,i;
	while(scanf("%lld",&n)!=EOF)
	{
		int s=0,m,t,j,c,d;
		for(i=1;i*i<=n;i++)
		{
			c=(n-2*i);
			t=c/3;
			if(c%3==0&&t>=fact(i))
			{
				s++;
			}
		}

			printf("%d\n",s);
	}
}
int fact(int x)
{
	int i,s=0;
	for(i=1;i<x;i++)
	{
		s+=i;
	}
	return s;
}


#include<stdio.h>
//using namespace std;
int main(){
	int a1,a2,a3,b1,b2,b3,n;
	scanf("%d %d %d %d %d %d %d",a1,a2,a3,b1,b2,b3,n);
	int d,c,x1,x2;
	x1=a1+a2+a3;
	x2=b1+b2+b3;
	if(x1%5==0) d=x1/5;
	else d=x1/5+1;
	if(x2%10==0) c=x2/10;
	else c=x2/10+1;
	if(d+c<=n) printf("YES");
	else printf("NO");
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
int min(int a,int b)
{
  if(a>b)
    return b;
  return a;
}
int main()
{
  int a,b,c,d,e,f,small=0,i,cost=0;
  scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);

  if(f>e)
  {
    small=min(min(b,c),d);

  while(small--) {
      b--;
      c--;
      d--;
      cost = cost + f;
  }

  if(d != 0 && a != 0) {
    while(d != 0 || a != 0) {
        d--;
        a--;
        cost = cost + e;
    }
  }
  }

  printf("%d",cost);
}


#include<stdio.h>

int main ()
{
    int t,s,v,j,i,e,f,min;
    long long int sum;
    while (1)

        {

        scanf ("%d%d%d%d",&t,&s,&v,&j);
        scanf ("%d%d",&e,&f);
        min = s;
        if (min > v)
            min = v;
        if (min > j)
            min = j;
        j = j -min;
        sum = min*f;
        if (t>j)
            min = j;
        else min = t;
        sum = sum + min*e;
        printf ("%lld\n",sum);
    }
    return 0;
}


#include <stdio.h>

int main(){
    int a,b,c;
    int m;
    int tmp, ans, i;

    scanf("%d%d%d", &a, &b, &c);
    m = (a<b?a:b);
    m = (m<c?m:c);

    ans = 0;
    for(i=0; i<=m; i++){
        tmp = (a-i)/3+(b-i)/3+(c-i)/3+i;
        ans = (tmp>ans?tmp:ans);
    }
    printf("%d\n", ans);
    return 0;
}


/*
    �Ȃ��Α��Ȃ�Ƃ��Ȃ�I
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#define LLU unsigned long long int
#define LL long long int
#define LD long double

#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define debug printf("asd\n")
#define newline printf("\n")

#define amt(a) int a;scanf("%d",&a)
#define dlld(a,b) long long int a,b;scanf("%I64d %I64d",&a,&b)
#define scd(a) int a;scanf("%d",&a)
#define sclld(a) long long int a;scanf("%I64d",&a)
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define arr(a,b) int *a=(int *)malloc(n*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(n*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
	amt(n);
	int a[20000],b[20000];
	int c[7],d[7];
	for(int i=0 ; i<6 ; i++)
	{
		c[i]=0;
		d[i]=0;
	}
	for(int i=0 ; i<n ;i++)
	{
		scanf("%d",&a[i]);
		c[a[i]]++;
	}
	for(int i=0 ; i<n ; i++)
	{
		scanf("%d",&b[i]);
		d[b[i]]++;
	}

	int e=0;
	int f=0,g=0;
	if(n==1)
	{
		f+=a[0];
		g+=b[0];
	}
	else if(n>1)
	{
		/*for(int i=1 ; i<=5 ; i++)
		{
			printf("%d %d\n",c[i],d[i]);
		}*/
		for(int i=1 ; i<=5 ; i++)
		{
			while(c[i]!=d[i])
			{
				if(c[i]>d[i])
				{
					c[i]--;
					d[i]++;
				}
				else if(c[i]<d[i])
				{
					c[i]++;
					d[i]--;
				}
				e++;
			}
			f+=c[i]*i;
			g+=d[i]*i;
		}
		e/=2;
	}

	if(f==g)
	prd(e);
	else
	prd(-1);
	return 0;
}


int gcd(int a,int b)
{
	if (b==0)
		return a;
    	else
		return gcd(b,a%b);
}
int main()
{
	int a,b,n,g,x=1;
	scanf("%d%d%d",&a,&b,&n);
	while(1)
	{
		if(x)
			g=gcd(a,n);
		else
			g=gcd(b,n);
		if(g>n)
			break;
		x=(x+1)%2;
	}
	if(x)
		printf("0\n");
	else
		printf("1\n");
	return 0;
}


#include<stdio.h>
int main()
{
int a , b , i ;
for(i=1;;i++)
{
a=a*3 ;
b=b*2 ;
if(a>b)
 { printf("%d",i);
   break;
                   }
                            }

}


#include <stdio.h>

int main() {
	int n;
	scanf("%d", &n);
	int tail=0, head=n-1, arr[n], flag=1, c=0;
	for (int i=0;i<n;i++) scanf("%d", &arr[i]);
	while (flag) {
		if (arr[tail]==arr[head]) {
			arr[tail]=0;
		}
		tail++;
		if (tail==head) {
			tail=0;
			head--;
			if (head==0) break;
		}
	}
	for (int i=0;i<n;i++) {
		if (arr[i]!=0) c++;
	}
	printf("%d\n", c);
	for (int i=0;i<n;i++) {
		if (arr[i]!=0) printf("%d ", arr[i]);
	}
}


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


#include <stdio.h>
#include <string.h>
typedef signed char sint8;
typedef unsigned char uint8;
typedef signed short sint16;
typedef unsigned short uint16;
typedef unsigned long uint32;

#define NUMBER_OF_ALPHABETS   26

#define IS_EVEN(X)    (((X)%2)?(0):(1))

int main(){
    sint8 alphabetFreqArr[NUMBER_OF_ALPHABETS]={0};
    sint8 input;
    uint8 numberOfUniqueAlpa=0;
    memset(alphabetFreqArr , 0 , NUMBER_OF_ALPHABETS);
    do{
        scanf("%c" , &input);
        if(alphabetFreqArr[input-'a']==0)
        {
            printf("%d/n" , input);
            alphabetFreqArr[input-'a']++;
            numberOfUniqueAlpa++;
        }
    } while(input!='/n');
    printf("%d"  ,numberOfUniqueAlpa);
    if(!((numberOfUniqueAlpa-1)%2))
    {
        printf("CHAT WITH HER!");
    }
    else
    {
        printf("IGNORE HIM!");
    }
    return 0;
}


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

    {
        if((fb+n*a)==(d+n*c))
            {
                while(n++){
            printf("%d", b+n*a);}

        }
        else
        {

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


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

int n, glen;
char perm[65336][7];
char tran[128][128];

void
strgen (char *inp)
{
        char i;
        int  l = strlen (inp);

        if (l == n) {
                strcpy (perm[glen++], inp);
                return;
        } else {
                for (i = 'a'; i <= 'f'; ++i) {
                        char out[8];
                        strcpy (out, inp);
                        out[l++] = i;
                        out[l] = '\0';

                        strgen(out);

                }
        }
}

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

        strgen ("");
        for (i = 0; i < q; ++i) {
                char f[4], s[2];

                scanf ("%s%s", f, s);
                tran[f[0]][f[1]] = s[0];
        }
        for (i = 0; i < glen; i++) {
                int j;
                char o = perm[i][0];

                for (j = 1; j < n; ++j) {
                        o = tran[o][perm[i][j]];
                        if (o == 0) {
                                break;
                        }
                }
                if (o == 'a') {
                        ++ans;
                }
        }
        printf ("%d\n", ans);
        return 0;
}


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

int n,q;
int **mat;

void read()
{
	int i;

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

	mat=malloc(6*sizeof(int*));
	for(i=0;i<6;i++) mat[i]=calloc(6,sizeof(int));

	char a[3],b[2];

	for(i=0;i<q;i++)
	{
		scanf("%s%s",a,b);
		mat[b[0]-'a'][a[0]-'a']=1;
	}
}

int findAnswer(char c, int l)
{
	int i,temp=0;

	for(i=0;i<6;i++)
	{
		if(mat[c-'a'][i])
		{
			 if(l==n) temp++;
			 else temp+=findAnswer(i+'a',l+1);
		}
	}

	return temp;
}

void answer()
{
	printf("%d\n",findAnswer('a',2));
}

void dump()
{
	int i,j;

	for(i=0;i<6;i++)
	{
		for(j=0;j<6;j++) printf("%2d",mat[i][j]);
		printf("\n");
	}
}

int main()
{
	read();
	answer();
	//dump();

	return 0;
}


#include<stdio.h>
int main()
{
    char a[101];
    int i, p, j, count = 0;
    scanf("%s",a);
    for(i=0; a[i]!='\0'; )
    {
        p = i;
        p++;
        if(a[i]=='1')
        {
            for(j=p; a[j]!='\0'; j++)
            {
                if(a[j]=='0')
                 count++;
                if(count == 6)
                 break;
                 i = j+1;
                 //printf("%d ",count);
            }
        }
        else i++;
        if(count == 6)
            break;
    }
    if(count == 6)
        printf( "yes\n" );
    else
        printf( "no\n" );
    return 0;
}


# include <stdio.h>

int main()
{
    char d, c=0;
    while((d=getchar())!='1');
    while((d=getchar())!=EOF) {
        if(d=='0')
            c++;
    }
    if(c>=6)
        printf("yes");
    else
        printf("no");
    return 0;
}


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

		}
		c= largest -25;
		if(c>0){
			printf("%d", c);
		}
		else
		printf("0");

   return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include <string.h>
int permutar(int n,int p, int v[], int vo[] );
int comparar(int v2[],int  v3[],int c);
    main(){
        int n,k,u,w=0;
        char c;
        do{
            scanf("%d",&n);
        }while(n<1 || n>100);
        char v1[2*n];
        int v2[n];
        int v3[n];
        u=n;
        do{
            scanf("%s",v1);
        }while(strlen(v1)!=2*n);

        for(k=0;k< n;k++){
            c=v1[k];
            v2[k]= c-48;
        }
        for(k=0;k< n;k++){
            c=v1[u];
            v3[k]= c-48;
            u++;

        }
        w=permutar(n,0,v2,v3);

        if(w==10){
            printf("NO \n");
        }

    }

    int permutar(int n,int p, int v[], int vo[] ){
        int k,aux,z,j;
        if(p<n){
            for(k=p;k<n;k++){
                aux=v[k];
                v[k]=v[p];
                v[p]=aux;
                permutar(n,p+1,v,vo);
                aux=v[k];
                v[k]=v[p];
                v[p]=aux;
            }

        }else{
            z=comparar(v,vo,n);

            if(z==5){
                printf("YES \n");
                exit(0);
            }

        }
        return 10;
    }
   int comparar(int v2[],int  v3[],int c){

        int k,y=0,u=0;
        for(k=0;k< c;k++){
            if(v2[k]<v3[k]){
                y++;
            }else{
                y=0;
            }
            if(v2[k]>v3[k]){
                u++;
            }else{
                u=0;
            }
        }

       if(u==c || y==c){
           return 5;
        }else{
            return 6;
        }

    }


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

int main(){
    long long int k,b,n,t,z=1,s=0;
    scanf("%lld %lld %lld %lld",&k,&b,&n,&t);
    z=z*k+b;
    while(s<n&&z<=t){
        z=z*k+b;
        s+=1;
    }
    printf("%lld",n-s);
}


#include<stdio.h>
long long int main()
{
int i,n;
scanf("%lld",&n);
i=(3*n*(n+1))+1;
printf("%lld",i);
}


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

int main(){
  int n;
  scanf("%d\n", &n);
  int cards[100];
  char s[310];
  gets(s);
  int i;
  for(i=0; i<n; i++){
    int b;
    int a = s[3 * i + 1] - '0';
    switch(s[3 * i]){
      case 'R': b = 0; break;
      case 'G': b = 1; break;
      case 'B': b = 2; break;
      case 'Y': b = 3; break;
      case 'W': b = 4; break;
    }
    cards[i] = 5 * b + a;
  }
  int matrix[25];
  for(i=0; i<25; i++) matrix[i] = 0;
  for(i=0; i<n; i++){
    matrix[cards[i]]=1;
  }
  n = 0;
  for(i=0; i<25; i++){
    if(matrix[i] == 1){
      cards[n] = i;
      n++;
    }
  }
  int v, k;
  int res[100];
  int min = 100;
  for(v=0; v<1024; v++){
    for(i=0; i<n; i++) res[i] = 0;
    for(i=0; i<n; i++){
      for(k=0; k<5; k++){
        int a = (v >> k) & 1;
        if(cards[i] / 5 == k && a) res[i] += 1 << k;
      }
      for(k=0; k<5; k++){
        int a = (v >> (k + 5)) & 1;
        if(cards[i] % 5 == k && a) res[i] += 1 << (k + 5);
      }
    }
    int j;
    int test = 0;
    for(i=0; i<n; i++)
    for(j=0; j<n; j++)
      if(i!=j && res[i] == res[j]) test = 1;

    if(! test){
      int count = 0;
      int v1 = v;
      while(v1 > 0){
        count += v1 & 1;
        v1 >>= 1;
      }
      if(count < min){
        min = count;
      }
    }
  }
  printf("%d\n", min);
  return 0;
}


#include<stdio.h>
int main()
{
    int c,v0,v1,a,l,days=1,sum=0,sum1=0,d,i;

    scanf("%d %d %d %d %d %d",&c,&v0,&v1,&a,&l);
sum1 = v0;
    do
    {
        for(i=2; i<c; i++)
        {
            sum1 = sum1+days*a+l;

            if(sum1>=v1)
            {
                sum = sum+sum1;
                d=sum1-v1;
                sum = sum-d;
                sum1=v1;
            }
            else
            {
                sum = sum+sum1;
            }
            days++;
        }
    }
    while(sum!=c);

    printf("%d",days);

    return 0;
}


#include <stdio.h>
#define ll long long int

ll div = 1000000007;

ll power(ll base,ll n)
{
    ll ans;
    ll half = n/2;
    if(n==0)
    {
        ans = 1;
    }
    else
    {
        if(n%2 == 0)
            ans = (power(base,half)*power(base,half))%div;
        else
            ans = (((power(base,half)*power(base,half))%div)*base)%div;
    }
    return ans;
}

int main()
{
    ll n, m;
    scanf("%lld%lld",&n, &m);
    ll base = 1;
    for(long long int i=0; i<m; i++)
    {
        base = (base*2)%div;
    }
    printf("%lld",power(base-1, n));

    return 0;
}


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

long long int mod= 1000000007;

long long int power (long long int x, long long int y)
{
    long long int ans = 1;

    while (y!=0)
    {
        if (y%2==1)
            ans = (ans*x) % mod;

        y = y/2;
        x = (x*x) % mod;
    }

    return ans;
}

int main ()
{
        long long int n,m;

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

        long long int c=1,sum=0,t=0;

        while (t<=n)
        {
                sum = (sum + (( (c*power(2,(n-t)*m))%mod)+mod))%mod;
                c=(c*(n-t))/(t+1)*(-1);
                t++;
        }

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

        return 0;
}


#include <stdio.h>

int main(void) {
    char a = 'a';
    char str[51] = {0, }, *p = str;

    scanf("%s", str);
    while (*p) {
        if (*p > a) {
            printf("NO\n");
            break;
        } else if (*p == a) {
            a++;
        }
        p++;
    }

    if (!*p) {
        printf("YES\n");
    }

    return 0;
}


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

void main()
{
  int n;
    if (n%2==0)
    {
        if ((n)%4==0)
        {
                printf("0");
        }else
        {
                printf("1");
        }
    }else
    {
         if ((n-1)%4==0)
        {
                printf("1");
        }else
        {
                printf("0");
        }
    }
}


#include <stdio.h>
int main()
{
    long long int n,k,i,d,c,w,h;
    while(scanf("%lld %lld",&n,&k)!=EOF)
    {
        if(n<=k)
        {
            d=0;c=0;w=n;
            printf("%lld %lld %lld\n",d,c,w);
        }
        else
        {
        h=n/2;
        for(i=1,d=1;i<=h;i++)
        {
          c=d*k;
          w=n-(c+d);
          if(w<=h)
            break;
          else
            d++;
        }
        printf("%lld %lld %lld\n",d,c,w);
        }
    }
}


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

    int a,b=0;
    scanf("%d",a);
    while(a>0)
    {
        int t=a%10;
        if(t!=7||t!=4)
        {
          b++;break;
        }
        a=a/10;
    }
     if(b>0)
    printf("NO");
    else
    printf("YES");
    return 0;
}


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

//input 1st line
long long A,B;
scanf("%d %d",&A,&B);
long long y,g,b;
scanf("%d %d %d",&y,&g,&b);
long long x=y*2+g;
long long d=g+3*b;
if(A<x&&A!=x){mincry=x-A;}
if(B<d&&B!=d){mincry+=d-B;}

long long ans;
ans=abs(mincry);

printf("%d",ans);

}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main()
{
  int a,b;
  register i;
  scanf("%d",&a);
  scanf("%d",&b);
  int*p=(int*)malloc(4*b);
  for(i=0;i<a;i++)
  {
      scanf("%d",&p[i]);
  }
  int sum=0;
  for(i=0;i<a;i++)
  {

      if(p[i]>8)
      {
          sum=sum+p[i]-8;
          b=b-8;

          if(b<=0)
          {
              printf("%d",i+1);
              exit(0);
          }
          continue;
      }
      b=b-p[i];
      if(sum-8+p[i]<0)
      {
          b=b-sum;
          sum=0;
      }
      if(sum-8+p[i]>=0)
      {
         b=b-8+p[i];
         sum=sum-8+p[i];
      }
      if(b<=0)
        {
            printf("%d",i+1);
            exit(0);
        }
  }
  printf("%d",-1);
    return 0;
}


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

int main(){
    char s[105];
    scanf("%s", &s);
    int r = 0, g = 0, b = 0, y = 0, len = strlen(s);
    int count = 0;
    for (int i = 0; i < len; i++) if (s[i] == '!') count++;
    while (count != 0){
        for (int i = 0; i < len - 3; i++){
            int tmpR = 0, tmpG = 0, tmpB = 0, tmpY = 0, idx = 0;
            if (s[i] == 'R') tmpR++;
            else if (s[i] == 'B') tmpB++;
            else if (s[i] == 'G') tmpG++;
            else if (s[i] == 'Y') tmpY++;
            else idx = i;
            if (s[i + 1] == 'R') tmpR++;
            else if (s[i + 1] == 'B') tmpB++;
            else if (s[i + 1] == 'G') tmpG++;
            else if (s[i + 1] == 'Y') tmpY++;
            else idx = i + 1;
            if (s[i + 2] == 'R') tmpR++;
            else if (s[i + 2] == 'B') tmpB++;
            else if (s[i + 2] == 'G') tmpG++;
            else if (s[i + 2] == 'Y') tmpY++;
            else idx = i + 2;
            if (s[i + 3] == 'R') tmpR++;
            else if (s[i + 3] == 'B') tmpB++;
            else if (s[i + 3] == 'G') tmpG++;
            else if (s[i + 3] == 'Y') tmpY++;
            else idx = i + 3;

            if ((tmpR + tmpG + tmpB + tmpY) == 3){
                if (tmpR == 0){
                    s[idx] = 'R'; count--; r++;
                }
                if (tmpG == 0){
                    s[idx] = 'G'; count--; g++;
                }
                if (tmpB == 0){
                    s[idx] = 'B'; count--; b++;
                }
                if (tmpY == 0){
                    s[idx] = 'Y'; count--; y++;
                }
            }
        }
    }
    printf("%d %d %d %d\n", r, b, y, g);
    return 0;
}


#include<stdio.h>

long long a[1000006],b[1000006],ans,count1,count2,lc,count3,count4,count;

long long lcm(long long a,long long b)
{
	if(a>b)
	{
		if(a%b==0)
			return b;

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

		return lcm(a,b%a);
	}
}

int main()
{
	long long m,h1,h2,x1,x2,y1,y2,a1,a2,p,i,n;

	scanf("%lld",&m);

	scanf("%lld%lld",&h1,&a1);

	scanf("%lld%lld",&x1,&y1);

	scanf("%lld%lld",&h2,&a2);

	scanf("%lld%lld",&x2,&y2);

	p=1;

	for(i=0;i<m+2;i++)
		a[i]=b[i]=0;

	count1=count2=0;

	for(i=0;i<m+2;i++)
	{
		if(h1==a1)
		{
			p=0;
			break;
		}

		if(!a[h1])
			a[h1]=1;
		else
		{
			break;
		}

		count1++;
		h1=(h1*x1+y1)%m;
	}

	if(p)
	{
		printf("-1");
		return 0;
	}

	p=1;

	for(i=0;i<m+2;i++)
	{
		if(h2==a2)
		{
			p=0;
			break;
		}

		if(!b[h2])
			b[h2]=1;
		else
		{
			break;
		}

		count2++;
		h2=(h2*x2+y2)%m;
	}

	if(p)
	{
		printf("-1");
		return 0;
	}

	for(i=0;i<m+2;i++)
		a[i]=b[i]=0;

	h2=(h2*x2+y2)%m;
	h1=(h1*x1+y1)%m;

	count3=count4=1;

	for(i=0;i<m+2;i++)
	{
		if(h1==a1)
		{
			p=0;
			break;
		}

		if(!a[h1])
			a[h1]=1;
		else
		{
			break;
		}

		count3++;
		h1=(h1*x1+y1)%m;
	}

	for(i=0;i<m+2;i++)
	{
		if(h2==a2)
		{
			p=0;
			break;
		}

		if(!b[h2])
			b[h2]=1;
		else
		{
			break;
		}

		count4++;
		h2=(h2*x2+y2)%m;
	}

	if(count1==count2)
	{
		printf("%lld",count1);
		return 0;
	}

	count=(count1>count2)?count1:count2;
	i=0;

	while(1)
	{
		i++;
		if(((count-count1)%count3==0) && ((count-count2)%count4==0))
			break;
		count=count3*i+count1;
	}

	printf("%lld",count);

	return 0;
}


#include <stdio.h>

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

	unsigned long m = original_m;

	long r = 1;
	long t = 1;

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

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

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

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

    return 0;
}


#include <stdio.h>
#define max 200001
int prime[max],pal[max],digits[10];

int isPalindrome(int a){
    int temp=a,i=0;
    while(temp!=0){
        digits[i++]=temp%10;
        temp/=10;
    }
    int k=i-1;
    i=0;
    while(i<k && digits[i]==digits[k]){
        i++;
        k--;
    }
    if(i<k)
        return 0;
    else{
        return 1;
    }
}

void set(){
int i=2;
while(i<max){
    int j=2;
    int p=j*i;
    while(p<max){
        prime[p]=1;
        j++;
        p=i*j;
    }
    i++;
    while(prime[i]==1)
        i++;
}
int count=0;
for(i=2;i<max;i++){
    if(prime[i]==0)
        prime[i]=(++count);
    else
        prime[i]=count;
}

i=1;
//printf("test\n");
while(i<max){
        pal[i]=pal[i-1];
    if(isPalindrome(i))
        pal[i]+=1;
 i++;
}
}

int main(){
int p,q,i=1;
set();
int res=-1;
scanf("%d%d",&p,&q);
while(i<max){
    if(q*prime[i]<=p*pal[i]){
        res=i;
    }
    i++;
}
if(res==-1)
printf("Palindromic tree is better than splay tree");
else
    printf("%d\n",res);
    return 0;
}


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

#define MAX (1L << 22)

char iscomp[MAX];

void
do_comp (void)
{
	int i;

	iscomp[1] = 1;

        for (i = 2; i < MAX; i++) {
                int     jx;
                int     sx;

                if (iscomp[i]) {
                        continue;
                }

		if (i * i > MAX) {
			break;
		}
                for (jx = i; (jx * i) < MAX ;jx++) {
                        sx = jx * i;
                        if (!iscomp[sx]) iscomp[sx] = 1;
                }
        }
}

int
ispal (int inp)
{
	int	i, j;
	char	tmp[32];
	int	len;

	sprintf(tmp, "%d", inp);
	len = strlen(tmp)-1;

	for (i = 0, j = len; i <= j; i++, --j) {
		if (tmp[i] != tmp[j]) {
			return 0;
		}
	}

	return 1;
}

int
main ()
{
	int	i,n = 1;
	int	p, q;
	int	npr = 0, npa = 0;
	int	ans = 0;

	do_comp();
	scanf ("%d%d", &p, &q);

	for (i = 1; i < MAX; i++) {
		npa += ispal (i);
		npr += !(iscomp[i]);

		if (q * npr <= p * npa) {
			ans = i;
		}
	}
	if (ans) {
		printf ("%d\n", ans);
	} else {
		puts ("Palindromic tree is better than splay tree");
	}

	return 0;
}


#include <stdio.h>
#include<stdlib.h>
#include<algorithm>
int main(){
	int n;
	scanf("%d",&n);
	char a[109];
	for(int i=1;i<=n/2;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n/2;i++){
		for(int j=i;j<=n/2;j++){
			int t;
			if(a[i]>a[j]){
			t=a[i];
			a[i]=a[j];
			a[j]=t;
			}
		}
	}
	int sum1=0,sum2=0;
	for(int i=1;i<=n/2;i++){
		sum1+=abs(a[i]-(i*2-1));
		sum2+=abs(a[i]-(i*2));
	}
	printf("%d",sum1<sum2? sum1:sum2);

}


#include <stdio.h>

/* http://codeforces.com/contest/894/submission/34556698 (Dukkha) */

#define MD	1000000007

int power(int a, int b) {
	int p;

	if (b == 0)
		return 1;
	p = power(a, b / 2);
	p = (long long) p * p % MD;
	if (b % 2 == 1)
		p = (long long) p * a % MD;
	return p;
}

int main() {
	int n, m, k;

	scanf("%d%d%d", &n, &m, &k);
	printf("%d\n", k == -1 && n % 2 != m % 2 ? 0 : power(2, (long long) (n - 1) % (MD - 1) * (m - 1) % (MD - 1));
	return 0;
}


#include<stdio.h>
#define MOD 1000000007

int main() {
	long long n, m, temp, sum = 1, tt, sum2 = 1, nt, mt;
	int k;
	scanf("%lld %lld %d", &n, &m, &k);
	nt = n - 1; mt = m - 1;

	while (nt) {
		temp = 1;
		tt = 2;
		while (temp * 2 <= nt) {
			temp = (temp * 2);
			tt = (tt * tt) % MOD;
		}
		sum = (sum * tt) % MOD;
		nt -= temp;
	}

	while (mt) {
		temp = 1;
		tt = 2;
		while (temp * 2 <= mt) {
			temp = (temp * 2);
			tt = (tt * tt) % MOD;
		}
		sum2 = (sum2 * tt) % MOD;
		m -= temp;
	}

	if (k == -1) {
		if ((n % 2 == 0 && m % 2 == 1) || (n % 2 == 1 && m % 2 == 0)) {
			printf("0"); return 0;
		}
		else if (n % 2 == 0)
			printf("%lld", (sum * sum2 / 2) % MOD);
		else
			printf("%lld", (sum * sum2) % MOD);
	}
	else
		printf("%lld", ((sum - 1) * (sum2 - 1) + 1) % MOD);

}


#include <stdio.h>
#include <string.h>
int main()
{
    int len,i;
    char str[30];
    scanf("%s",str);
    len=strlen(str);
    for(i=0;i<len;i++)
    {
        if(str[i]=='Q'||str[i]=='H'||str[i]=='9' )
        {

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


#include<stdio.h>
#define N 15
int sum=0;
int counter=0;
int n,r,l,x;
int c[N];
int b[N];
void sort(int *a, int n) {
  int i,j;
  for(i=0;i<n-1;i++) {
    int k=i;
    for(j=i+1;j<n;j++) {
      if(a[j]<a[k]) {
        k=j;
      }
    ｝
    //there we only swap min with a[i];
    int tmp=a[k];
    a[k]=a[i];
    a[i]=tmp;
  ｝
｝
void dfs(int start,int deep) {
  int i;
  if(deep==0) {
    for(i=0;i<n-1;i++) {
      b[0]=c[i];
      sum+=c[i];
      dfs(i,deep+1);
      b[0]=0;
      sum-=c[i];
    }
  } else {
    for(i=start+1;i<n;i++) {
      b[deep]=c[i];
      sum+=c[i];
      //if sum is exceed, then next element we don't need.
      if(sum<=l) {
        //if x and r don't satisfy, add next element will satisfy, when all condition is satisfy, we will count once.
        if(b[deep]-b[0]>=x && sum>=r){counter++;
        ｝
        dfs(i,deep+1);
        b[deep]=0;
        sum-=c[i];
      }
    }
  }

int main() {
  scanf("%d%d%d%d",&n,&l,&r,&x);
  int i;
  for(i=0;i<n;i++) {
    scanf("%d",&c[i]);
  }
  sort(c,n);
  dfs(0,0);
  printf("%d",counter);

  return 0;
}


#include<stdio.h>
#define N 15
int counter=0;
int n,r,l,x;
int c[N];
int b[N];
int nb=0;
void print(int *a, int size) {
    int i;
    for(i=0; i<size; i++) {
        printf(" %d",a[i]);
    }
    printf("\n");
}
void sort(int *a, int size) {
    int i,j;
    for(i=0; i<size-1; i++) {
        int k=i;
        for(j=i+1; j<size; j++) {
            if(a[j]<a[k]) {
                k=j;
            }
        }
        //there we only swap min with a[i];
        int tmp=a[k];
        a[k]=a[i];
        a[i]=tmp;
    }
}
void (int set,int select,int total,int choose) {
  if(select==choose)
        int sum=0;
        int j;
        for(j=0; j<choose; j++) {
            sum+=b[j];
        }
        if((sum<=r) && (b[choose-1]-b[0]>=x) && (sum>=l)) {
            counter++;
        }
    } else {
        int i;
        for(i=set; i<total; i++) {
            b[select]=c[i];
            comb(set+1,select+1,total,choose);
        }
    }
}

int main() {
    scanf("%d%d%d%d",&n,&l,&r,&x);
    int i;
    for(i=0; i<n; i++) {
        scanf("%d",&c[i]);
    }
    sort(c,n);
    for(i=2;i<=n;i++) {
      comb(0,0,n,i);
    }
    printf("%d\n",counter);

    return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int i, j, k, x, c;
    char a[101];
    gets(a);
    c=0;
    x=strlen(x);
    for(i=0;i<x;i++)
    {
        if(a[i]=='Q')
        {
            for(j=i+1;j<x;j++)
            {
                if(a[j]=='A')
                {
                    for(k=j+1;k<x;k++)
                    {
                        if(a[k]=='Q') c++;
                    }
                }
            }
        }
    }
    printf("%d\n", c);
    return 0;
}


#include <stdio.h>
#define min(a,b) ((a)>(b))?(b):(a)
int a[101];
int main(void)
{
	int n, k;
	scanf("%d%d", &n, &k);
	int i = 0;
	while (i < k) {
		scanf("%d", &a[i]);
	}
	int fouralined = n;
	int twoalined = n * 2;
	for (i = 0; i < k; i++) {
		int putin = min(fouralined,a[i]/4);
		fouralined -= putin;
		a[i] -= putin;
	}
	twoalined += fouralined;
	for (i = 0; i < k; i++) {
		int putin = min(twoalined, a[i] / 2);
		twoalined -= putin;
		a[i] -= putin;
	}
	int onealined = twoalined + fouralined;
	for (i = 0; i < k; i++) {
		onealined -= a[i];
	}
	if (onealined >= 0)
		printf("YES");
	else
		printf("NO");
	return 0;
}


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

#define K 100

int sort(int *a, int n) {
	int k;
	for(int i=0; i<n; i++)
		for(int j=i+1; j<n; j++)
			if (a[j]>a[i]) k=a[j], a[j]=a[i], a[i]=k;
}

int n, k;
int a[K];

int solve() {
	int n4 = n, n2 = n*2;

	for(int i=0; n4 && i<k; i++) {
		int d = a[i]/4;
		if (d>n4) d = n4;
		n4 -= d;
		a[i] -= 4*d;
	}
	sort(a, k); while(k && a[k-1]==0) --k;

	for(int i=0; n4 && i<k; i++) if (a[i]==3) n4--, a[i]=0;
	sort(a, k); while(k && a[k-1]==0) --k;

	for(int i=0; n2>2 && i<k; i++) if (a[i]==3) n2-=2, a[i]=0;
	sort(a, k); while(k && a[k-1]==0) --k;

	int cnt[4]={0};
	for(int i=0; i<k; i++) cnt[a[i]]++;
	if (cnt[3]) return 0;
	cnt[2] -= n4;
	cnt[1] -= n4;

	if (cnt[1]<0) cnt[1]=0;
	if (cnt[2]<0) cnt[2]=0;

	return cnt[1]+cnt[2] <= n2;
}

int main() {
	while(scanf("%d %d", &n, &k)==2) {
		for(int i=0; i<k; i++) scanf("%d", &a[i]);
		int ok = solve();
		if (ok) printf("YES\n");
		else printf("NO\n");
		break;
	}
}


#include <stdio.h>

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

	printf(((b - a) % c == 0) ? "YES\n" : "NO\n");
}


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


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
main()
{ char f[100] ; const char* f1="Danil", *f3="Olya", *f2="Ann", *f4="Slava", *f5="Nikita";
	scanf("%s",&f);
	if (strstr(f,f1) or strstr(f,f2) or strstr(f,f3)or strstr(f,f4)or strstr(f,f5))
	printf("YES"); else printf("NO");
}


#include<stdio.h>
int main()
{
int i,n;
int a[n],key=0 ;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<=n;i++)
{
if


#include<stdio.h>
#include<string.h>
int check(char[],char[]);
int main(){
   char s[100];
   scanf("%s",s);
   int a,b,c,d,t=0,flag=1;
   if(strcmp(s,"Danil")==0||strcmp(s,"Olya")==0||strcmp(s,"Ann")==0||strcmp(s,"Slava")==0||strcmp(s,"Nikita")==0)t=1;
   else if(strcmp(s,"Vanya")==0&&strcmp(s,"A")==0)){t=0;}
   else{
      t=check(s,"Danil");
      a=check(s,"Olya");
      b=check(s,"Ann");
      c=check(s,"Slava");
      d=check(s,"Nikita");
      t=t+a+b+c+d;
   }
   if(t==1)printf("YES");
   else printf("NO");
   return 0;
}
int check(char s[],char m[]){
   int flag=1,i,j,t=0;
   for(i=0;i<=strlen(s)-strlen(m);i++){
      flag=1;
      j=0;
      for(;j<=strlen(m)-1;j++){
         if(m[j]!=s[j+i]){
            flag=0;
            break;
         }
      }
      if(flag==1){
         t=t+1;
      }
   }
   return t;
}


/*
    Tardes de Coding Sesión 3
    B - Friends
    A01208964 - Doménica Rentería
*/

#include <stdio.h>

int amigos = 5;

int main(){
int arr[amigos] = {};
int acq, a, b, i=0;

scanf("%i", &acq);

do {
	scanf("%i %i", &a, &b);
    arr[a-1]++;
    arr[b-1]++;
	i++;
} while (i < acq);

for(int i = 0; i<amigos; i++){
    if(arr[i] != 2){
        printf("WIN");
        return 0;
    }
}
printf("FAIL");

return 0;
}


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

int main()
{
    char arr[100];
    char c;
    int gap;
    int i=0;
    int lastPoint=-1;
    int max=0;
    while(1)
    {
    c=getchar();
    if (c!='A'&&c!='E'&&c!='I'&&c!='O'&&c!='U'&&c!='Y'&&c!='\0')
    {
    continue;}
    else if (c!='\0')
    if(i-lastPoint+1>max)
    max=i-lastPoint+1;
    else
    {
        if((i-lastPoint)>max)
        max=i-lastPoint;
        lastPoint=i;
    }
    i++;
    }
    printf("%d", max);
    }