#include <stdio.h>
int main()
{
	int i, j, b=0, w=0;
	char arr[8][8];
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
		{
			scanf(" %c", &arr[i][j]);
		}
	}
	for(i=0;i<8;i++)
	{
		for(j=0;j<8;j++)
		{
			switch(arr[i][j])
			{
				case 'Q':
				{
					w+=9;
					break;
				}
				case 'q':
				{
					b+=9;
					break;
				}
				case 'R':
				{
					w+=5;
					break;
				}
				case 'r':
				{
					b+=5;
					break;
				}
				case 'B':
				case 'N':
				{
					w+=3;
					break;
				}
				case 'b':
				case 'n':
				{
					b+=3;
					break;
				}
				case 'P':
				{
					w+=1;
					break;
				}
				case 'p':
				{
					b+=1;
					break;
				}
			}
		}
	}
	if(b>w)
	{
		printf("Black");
	}
	else if(w>b)
	{
		printf("White");
	}
	else if(w==b)
	{
		printf("Draw");
	}
}


#include<stdio.h>
int main()
{
    int k,c[35],i,r,ck;
    while(scanf("%d",&k)==1){
        ck=0;
        for(i=0;i<k;i++){
            scanf("%d",&c[i]);
        if(c[i]>ck)
            ck=c[i];
        }
        if(ck>25){
            r=ck-25;
            printf("%d\n",r);
        }
        else
            printf("%d\n",0);
    }
    return 0;
}


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


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

int main()
{
    int a, m, tab[100001];
    scanf("%d %d", &a, &m);

    memset(tab,0,sizeof(int));

    while (1)
    {
        int b = a%m;
        if (tab[b] == 1)
            break;
        tab[b] = 1;

        a += b;

        if (a%m == 0)
        {
            printf("Yes\n");
            return 0;
        }
    }

    printf("No\n");

    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    int x,y;
    scanf("%d%d",&x,&y);
    if(x>=3&&y>=3){
        if(x>y) printf("<");
        else if(y>x) printf(">");
        else printf("=");
    }
    else{
        if(pow(x,y)>pow(y,x)) printf(">");
        else if(pow(x,y)<pow(y,x)) printf("<");
        else printf("=");
    }
    return 0;
}


#include<stdio.h>
int main()
{
int n;
long int j;
scanf("%d",&n);
if(n%2==0)
{
    j=n/2;
    printf("%ld",j*(j+1));
}
if(n%2!=0)
{
    j=n/2;
    printf("%ld",(j+1)*(j+1));
}
return 0;
}


#include<stdio.h>

int main(){
  int D;
  long long n, k, M, ans = 0;
  scanf("%lld%lld%lld%d", &n, &k, &M, &D);
  for(int i = 0; i < D; i++){
    long long cur = n / (k * i + 1);
    if(!cur) break;
    if(cur > M) cur = M;
    long long lmax = cur * (i + 1);
    ans = ans > lmax ? ans : lmax;
  }
  printf("%lld", ans);
  return 0;
}


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

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

int gcd(int u, int v){
    int t;

    while (v){
        t = u;
        u = v;
        v = t % v;
    }

    if (u < 0) u = 0 - u;
    return u;
}

int main(){
    int i, j, k, l, x, y, a, b, c, d, u, v, g;

    while (scanf("%d %d %d %d", &a, &b, &c, &d) != EOF){
        g = gcd(c, d);
        c /= g, d /= g;

        if (a < c || b < d) puts("0 0");
        else{
            x = a / c, y = b / d;
            if (y < x) x = y;

            c *= x, d *= x;
            printf("%d %d\n", c, d);
        }
    }
    return 0;
}


#include<stdio.h>
#include<stdbool.h>
#define sq(A) ((A)*(A))

int x[4], y[4], r[4];

bool intersect(int i, int j){
	int dist=sq(x[i]-x[j])+sq(y[i]-y[j]);
	if(dist>=sq(r[i]+r[j])) return false;
	if(r[i]<r[j] && dist<=sq(r[j]-r[i])) return false;
	if(r[j]<r[i] && dist<=sq(r[i]-r[j])) return false;
	return true;
}

bool in(int i, int j){
	int dist=sq(x[i]-x[j])+sq(y[i]-y[j]);
	if(r[i]<r[j] && dist<=sq(r[j]-r[i])) return false;
	return true;
}

int main(){
	int num=0;
	scanf("%d %d %d %d", x, y, r, r+1);
	x[1]=x[0]; y[1]=y[0];
	scanf("%d %d %d %d", x+2, y+2, r+2, r+3);
	x[3]=x[2]; y[3]=y[2];
	if(!intersect(0, 2) && !intersect(0, 3) && !(in(0, 2) ^ in(0, 3))) ++num;
	if(!intersect(1, 2) && !intersect(1, 3) && !(in(1, 2) ^ in(1, 3))) ++num;
	if(!intersect(2, 0) && !intersect(2, 1) && !(in(2, 0) ^ in(2, 1))) ++num;
	if(!intersect(3, 0) && !intersect(3, 1) && !(in(3, 0) ^ in(3, 1))) ++num;
	printf("%d\n", num);
	return 0;
}


int main()
{
    int a,b,counter=0,draw=0;
    scanf("%d %d",&a,&b);
    if(a==b)
    {
        printf("0 6 0");

    }else
    {
        int i;
        for(i=0;i<7;i++)
        {
            if(abs(a-i)<abs(b-i))
            {
                counter++;
            }
        }
        if((a+b)%2==0)
        {
            draw++;
        }
        printf("%d %d %d",(a>b)?counter:counter-1,draw,(a>b)?6-counter-draw:6-counter-draw+1);
    }
    return 0;
}


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


#include <stdio.h>
#include <string.h>
int main()
{
    char arr[500],arr2[500];
    gets(arr);
    gets(arr2);

    int i,j,k;

    int len=strlen(arr);
    char arr3[len];

    for(i=0,j=len-1 ; i<len ,j>=0 ; i++,j--)
    {
        arr3[i]=arr[j];

        if(i==len-1)
        {
            arr3[len]='\0';
        }
    }
    int cmp = strcmp(arr3,arr2);

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


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

int main(){
  char w[500], max = '`';
  scanf("%s", w);
  int n = strlen(w), i;
  for(i = 0; i < n; i++){
    if(w[i] > max){
      if(w[i] != max+1){
        printf("NO\n");
        return 0;
      }
      max++;
    }
  }
  printf("YES\n");
  return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
     int k,i;
     char s[10];
     char c[12][10]={"January","February","March","April","May","June","July","August","September","October","November","December"};
     scanf("%s %d",s,&k);
     for(i=0; i<12;i++)
     {
     if(strcmp(s,c[i])==0) break;
     }
     i=(i+k) % 12;
     printf("%s\n", c[i]);
     return 0;
}


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

int main(void)
{
	char n[15];
	int k;

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

	int i = strlen(n) - 1;
	int zeros = 0;
	int remove = 0;

	while(i >= 0 && zeros < k)
	{
		if(n[i] == '0')
			zeros++;
		else
			remove++;
		i--;
	}

	if(zeros == k)
		printf("%d\n", remove);
	else
		printf("%d\n", strlen(n) - 1);
}


/*
 * =====================================================================================
 *
 *       Filename:  Solitaire.c
 *
 *    Description:
 *
 *        Version:  1.0
 *        Created:  2012年07月25日 13时47分01秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (),
 *   Organization:
 *
 * =====================================================================================
 */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define MAXN 55
#define OP1 1
#define OP2 3
int dp[MAXN][MAXN][MAXN][MAXN];
typedef struct Card {
	char val;
	char suit;
} Card_t;
Card_t cards[MAXN];
/*
int dfs(Card_t *cards, int n, int op) {
	if(n == 1) return 1;
	if(n - op <=0 ) return 0;

	if(cards[n].val == cards[n - op].val) {
		int tmpSuit = cards[n - op].suit;
		cards[n - op].suit = cards[n].suit;
		if(dfs(cards, n-1, OP1) || dfs(cards, n-1, OP2))
			return 1;
		else
			cards[n - op].suit = tmpSuit;
	}
	if(cards[n].suit == cards[n - op].suit) {
		int tmpVal = cards[n- op].val;
		cards[n - op].val = cards[n].val;
		if(dfs(cards, n-1, OP1) || dfs(cards, n-1, OP2))
			return 1;
		else
			cards[n -op].val = tmpVal;
	}
	return 0;
}
*/

int calc(int n, int a, int b, int c) {
	if(n == 1) return 1;
	if(n == 2) {
		if(cards[a].val == cards[b].val || cards[a].suit == cards[b].suit) return 1;
		else return 0;
	}
	if(n == 3) {
	//	printf("n-%d a-%d b-%d c-%d\n",n,a,b,c);
		if(cards[c].val == cards[b].val || cards[c].suit == cards[b].suit) {
	//		printf("cards[%d].val=%c cards[%d].val=%c\n",c,cards[c].val,b,cards[b].val);
			if(cards[c].val == cards[a].val || cards[c].suit == cards[a].suit)
				return 1;
			else
				return 0;
		}
		else
			return 0;
	}
	return 0;
}

int main() {
	int i,j,k,l,n;
	char tmp;

	while(scanf("%d", &n) != EOF) {
		scanf("%c",&tmp);
		memset (cards, 0, sizeof cards);
		memset (dp, 0, sizeof dp);
		for(i=1; i <=n ; ++i)
			if (i < n)
				scanf("%c%c%c", &cards[i].val, &cards[i].suit, &tmp);
			else
				scanf("%c%c", &cards[i].val, &cards[i].suit);

		for(i=1; i<=n; ++i) {
			for(j=1; j<=n; ++j) {
				for(k=1; k<=n; ++k) {
					if(j == k) continue;
					for(l=1; l<=n; ++l)  {
						if(k == l) continue;
						if(i >= 4) {
							if(cards[i-3].val == cards[l].val || cards[i-3].suit == cards[l].suit)
								dp[i][j][k][l] = dp[i-1][l][j][k];
							if(cards[k].val == cards[l].val || cards[k].suit == cards[l].suit)
								dp[i][j][k][l] = dp[i][j][k][l] || dp[i-1][i-3][j][l];
						}
						else
							dp[i][j][k][l] = calc(i,j,k,l);
	//					printf("dp[%d][%d][%d][%d]:%d\n",i,j,k,l,dp[i][j][k][l]);
					}
				}
			}
		}

		if(n == 1) {
			if(calc(1, 1, 0, 0)) puts("YES");
			else puts("NO");
		}
		else if(n == 2) {
			if(calc(2, 1, 2, 0)) puts("YES");
			else puts("NO");
		}
		else {
			if(dp[n][n-2][n-1][n]) puts("YES");
			else puts("NO");
		}
	}
	return 0;
}


#include <stdio.h>

int
main ()
{
  int a, b, mod;
  long long i;
  scanf ("%d %d %d", &a, &b, &mod);
  if (b >= mod)
    {
      printf ("2\n");
      return 0;
    }
  for (i = 0; i <= a && i < mod; i++)
    if ((i * 1000000000) % mod != 0 && ((i * 1000000000) % mod + b) < mod)
      {
	printf ("1 %09d\n", (int)i);
	return 0;
      }
  printf ("2\n");
  return 0;
}


#include <stdio.h>

long long gcd (long long a, long long b) {
  if (a <= 0LL || b <= 0LL) {
    return -1LL;
  }

  if (a%b == 0LL) {
    return b;
  }

  return gcd(b, a%b);
}

int main () {
  int n = 0;

  int res = 0;

  long long ans = 0LL;
  long long mod_num = 1000000007LL;

  long long sum_c[50001] = {};

  res = scanf("%d", &n);

  for (int i = n/2; i > 0; i--) {
    long long k = (long long) (n/i);
    long long d = gcd((long long)n, (long long)i);
    if (n%i == 0) {
      k -= 1LL;
    }
    sum_c[i] = (((long long)n)*(k*(k-1LL))/2LL)%mod_num;
    sum_c[i] += mod_num-((((k*(k+1LL)*(k-1LL))/3LL)%mod_num)*((long long)i))%mod_num;
    for (int p = 2; i*p <= n/2; p++) {
      sum_c[i] += mod_num-sum_c[i*p];
    }
    sum_c[i] %= mod_num;
    ans += sum_c[i]*(((long long)i)/d);
    ans %= mod_num;
  }

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

  return 0;
}


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

//获取给定矩形内的中提琴家的数量
int get_violas_num(int **grid_array, int x_row, int y_clo, int row_num, int col_num)
{
	int i,j ;
	int violas_num = 0;
	for(i = x_row; i <=row_num; i++)
	{
		for(j = y_clo; j <=col_num; j++)
		{
			if(1 == grid_array[i][j])
			{
				violas_num++;
			}
		}
	}
	return violas_num;
}
//给定起始节点，获取节点内所有可能矩形区域的数目
int get_rec_num(int **grid_array, int x_value, int y_value, int row_value, int col_value, int mini_value)
{
	int i,j;
	int rec_num = 0;
	for(i = x_value; i < row_value; i++)
	{
		for(j = y_value; j < col_value; j++)
		{
			if(get_violas_num(grid_array, x_value, y_value, i, j) >= mini_value)
			{
				rec_num++;
			}
		}
	}
	return rec_num;
}
int main()
{
	  int row = 0, column = 0, number = 0; //中提琴家的数目
	  int min_number = 0,recta_num = 0;
	  int **grid_array;
	  int i, x, y, j;
	  scanf("%d%d%d%d",&row, &column, &number, &min_number);
	  //动态申请二维数组,并初始化
      grid_array = (int**)malloc(sizeof(int*) * row);
	  if(!grid_array)
	  {
		 exit(EXIT_FAILURE);
	  }
	  for(i = 0; i < row; i++)
	  {
		  *(grid_array + i) = (int*)malloc(sizeof(int) * column);
	  }

	  for(i = 0; i < number; i++)
	  {
		  scanf("%d%d",&x, &y);
		  grid_array[x-1][y-1] = 1;
	  }
	  for(i = 0; i < row; i++)
	  {
		  for(j = 0; j < column; j++)
		  {
			 recta_num += get_rec_num(grid_array, i, j, row, column, min_number);
		  }
	  }
	  printf("%d\n",recta_num);
  return EXIT_SUCCESS;
}


#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,ln,c=0,t=0;
    scanf("%d",&n);
    char a[n];
    scanf("%s",a);
    for(i=0;i<n;i++){
        if(a[i]=='+')
        c++;
    else
        if(c>0)
        c--;
    }
    if(c>=0)
        printf("%d",c);
      else  printf("0");

}


#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    while(b-a <1 || c-a<2)
    {
        a--;
    }
printf("%d",a+a+1+a+2);
}


#include<stdio.h>
#define big 1000000007
int main()
{
	int n;
	scanf("%d",&n);
	if(n==1)
	{
		printf("1\n");
		return 0;
	}
	else if (n==2)
	{
		printf("3\n");
		return 0;
	}
	else
	{
		long long int a = 1, b = 3 , temp;
		int i=1;
		for( ; i <= n-2 ; i++)
		{
			temp = b%big;
			b = (a+b+2)%big;
			a = temp%big;
		}
		printf("%I64d\n",b);
		return 0;
	}
}


#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#define NUM 1000000007LL

long long find(int k)
{
    long long a = 4, sum = 1;
    k--;
    while(k--){
        a = a*a;
        a %= NUM;
        sum *= a;
        sum %= NUM;
    }
    sum *= 6;
    sum %= NUM;
    return sum;
}

int main(void)
{
    int k; scanf("%d", &k);
    printf("%lld\n", find(k));
    return 0;
}


#include <stdio.h>
int res = 0;

int solve(int x){
	if(!x)
		return 0;
	if(x&1)
		res++ ;
	solve(x>>1);
	return res;
}

int main(void) {
	// your code goes here
	long int x;
	scanf("%ld",&x);
	printf("%d",solve(x));
	return 0;
}


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

#define N 100000
#define EPS 1E-6

int sign(double x) {
  return x < -EPS ? -1 : x > EPS;
}

double sqr(double x) {
  return x * x;
}

typedef struct point {
  double x, y;
} point;

double dist(point a, point b) {
  return hypot(a.x - b.x, a.y - b.y);
}

double cross(point a, point b, point c) {
  return (b.x - a.x) * (c.y - b.y) - (b.y - a.y) * (c.x - b.x);
}

/* PA * PB */
double dot(point p, point a, point b) {
  return (a.x - p.x) * (b.x - p.x) + (a.y - p.y) * (b.y - p.y);
}

/* delta angle of ABC */
double delta_angle(point a, point b, point c) {
  return acos(dot(b, a, c) / (dist(a, b) * dist(b, c)));
}

point *__o;

int angle_cmp(point *p, point *q) {
  int c;
  if (c = sign(cross(*__o, *p, *q)))
    return -c;
  return sign(dist(*p, *__o) - dist(*q, *__o));
}

point stack[N];

int convex_hull(point *ps, int n) {
  int i, k, top;
  point q;

  k = 0;
  for (i = 1; i < n; i++)
    if (sign(ps[i].y - ps[k].y) < 0 || sign(ps[i].y - ps[k].y) == 0 && ps[i].x < ps[k].x)
      k = i;

  q = ps[k];
  ps[k] = ps[0];
  ps[0] = q;

  __o = &ps[0];
  qsort(ps + 1, n - 1, sizeof(point), (int (*)(const void *, const void *))angle_cmp);

  top = 0;
  for (i = 0; i < n; i++) {
//    printf("%lf,%lf\n", ps[i].x, ps[i].y);
    while (top >= 2 && sign(cross(stack[top - 2], stack[top - 1], ps[i])) <= 0) top--;
    stack[top++] = ps[i];
  }
  memcpy(ps, stack, sizeof(point) * top);
  return top;
}

double cccr(point A, point B, point C) {
  double a, b, c, cos_B, sin_B, R;

  a = dist(B, C);
  b = dist(A, C);
  c = dist(A, B);
  cos_B = (a * a + c * c - b * b) / (2 * a * c);
  sin_B = sqrt(1.0 - cos_B * cos_B);
  return b / sin_B / 2.0;
}

int too_straight(point A, point B, point C, double r) {
//  printf("R=%lf vs r=%lf\n", R, r);
  return sign(dot(B, A, C)) < 0 && sign(cccr(A, B, C) - r) > 0;
}

double area_bow(double r, double l) {
  double tri = l * sqrt(sqr(r) - sqr(l / 2)) / 2;
  double theta = 2 * asin(l / (r + r));
  double sector = theta * r * r / 2;
  return sector - tri;
}

double area_polygon(const point a[], int n) {
  int i, j;
  double area = 0.0;
  for (j = 0, i = n - 1; j < n; i = j++)
    area += a[i].x * a[j].y - a[i].y * a[j].x;
  return fabs(area) / 2;
}

void die() {
  *(char *)NULL = 0;
}

int main() {
  static point ps[N];
  int n;
  double r;
  double ans, R, Rmin;
  int i, j, k, z, top, s, ch;

  scanf("%d %lf", &n, &r);
  for (i = 0; i < n; i++)
    scanf("%lf %lf", &ps[i].x, &ps[i].y);

  if (n == 1) {
    puts("0");
  } else if (n == 2) {
    ans = area_bow(r, dist(ps[0], ps[1])) * 2.0;
    printf("%.9lf\n", ans);
  } else {
    n = convex_hull(ps, n);
//    printf("n=%d\n", n);

    top = 0;
    for (i = 0; i < n; i++) {
      while (top >= 2 && too_straight(stack[top - 2], stack[top - 1], ps[i], r))
        top--;
      stack[top++] = ps[i];
    }

    s = 0;
    ch = 1;
    while (ch) {
      ch = 0;
      while (top - s >= 3 && too_straight(stack[top - 2], stack[top - 1], stack[s], r))
        top--, ch = 1;
      while (top - s >= 3 && too_straight(stack[top - 1], stack[s], stack[s + 1], r))
        s++, ch = 1;
    }
    memcpy(stack, stack + s, sizeof(stack[0]) * (top -= s));
//    printf("top=%d\n", top);

    ans = area_polygon(stack, top);
    for (i = 0, j = 1 % top; i < top; i++, j = (j + 1) % top) {
//      printf("%lf,%lf\n", stack[i].x, stack[i].y);
      ans += area_bow(r, dist(stack[i], stack[j]));
    }
    printf("%.9lf\n", ans);

    if (top >= 3)
      for (i = 0, j = 1 % top, k = 2 % top; i < top; i++, j = (j + 1) % top, k = (k + 1) % top)
        if (too_straight(stack[i], stack[j], stack[k], r))
          die();
  }

  return 0;
}


#include <stdio.h>

int main(void)
{
    int hy, ay, dy;
    int hm, am, dm;
    int ch, ca, cd;
    scanf("%d %d %d", &hy, &ay, &dy);
    scanf("%d %d %d", &hm, &am, &dm);
    scanf("%d %d %d", &ch, &ca, &cd);
    int mina = ay > dm ? ay : dm + 1;
    int maxa = ay > hm + dm ? ay : hm + dm;
    int maxd = dy > am ? dy : am;
    int a, d, val = -1;
    for (a = mina; a <= maxa; a++) {
        int decm = a - dm, t = (hm + decm - 1) / decm;
        for (d = dy; d <= maxd; d++) {
            int decy = am - d > 0 ? am - d : 0;
            int ht = hy - decy * t;
            int hp = ht > 0 ? 0 : 1 - ht;
            int c = (a - ay) * ca + (d - dy) * cd + hp * ch;
            if (val == -1 || c < val)
                val = c;
        }
    }
    printf("%d\n", val);
    return 0;
}


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

}


#include <stdio.h>

int isp (int points, int place )
	{
		int j = (points/50) % 475;
		int i;
		for ( i = 0; i < 25; i++)
			{
			j = (j*96+42) % 475;
			if ( j+ 26 == place)
				return 1;
			}
		return 0;
	}

int main()
{
//	int i,j;
//	int s;
	int p,x,y;     // 26<=p<500    // 1<=y<=x<20000
	int result = -1;
	int i,j,k;

	scanf("%i %i %i", &p, &x, &y);

	for ( i = x; i >= y; i-=50)
		{

			if (isp(i,p) )
			{
				result = 0;
				goto end;
			}

		}

	for ( i = x;  i < 40001; i+=50)
		{
				if (isp(i,p))
					{
						if ( (i-x) % 100 != 0)
							result = (i - x ) / 100 +1;
						else result = (i-x)/100;
						goto end;
					}

		}

end:
	printf("%i",result);
	return 0;
}


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

int main(){
    int x1,y1,x2,y2,d,p;

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

    if(abs(x1-x2)==abs(y1-y2)){
        d=abs(x1-x2);
    }
    else if(abs(x1-x2)>abs(y1-y2)){
        p=abs(x1-x2)-abs(y1-y2);
        d=abs(y1-y2)+p;
    }
    else{
        p=abs(y1-y2)-abs(x1-x2);
        d=abs(x1-x2)+p;
    }
    printf("%d",d);
    return 0;
}


#include <stdio.h>

int main(){
    double a,b;
    double div;
    scanf("%lf %lf", &a, &b);
    div = b/a;
    if(div == 1){
        printf("0");
    }
    else{
        if(div-(int)div != 0){
            printf("-1");
        }
        else{
            int count = 0;
            while(1){
                float tmp;
                tmp = div/2;
                if(tmp-(int)tmp != 0){
                    break;
                }
                else{
                    div = div/2;
                    count++;
                }
            }
            while(1){
                float tmp;
                tmp = div/3;
                if(tmp-(int)tmp != 0){
                    break;
                }
                else{
                    div = div/3;
                    count++;
                }
            }
            if(div == 1){
                 printf("%d", count);
            }
            else{
                printf("-1");
            }
        }
    }
}


//Erick Jair García Barradas A01740197
//Carlos Orozco Flores A01328800

#include <stdio.h>
#include <string.h>
#define TRUE 1
#define FALSE 0

 int main(int argc, char const *argv[]){
 	int num = 0;
 	scanf("%d",&num);
 	if (num % 2 == 0){
 		printf("%d\n", ((num / 2) + 1));
 	} else {
 		printf("%d\n", ((num + 1) / 2));
 	}

 }


/*
 * 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 + 1))]));
    }
    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 + 1))]));
    }
}

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]);
#ifdef DEBUG
		printf("max_a[%d]:%d\t index_a[%d:%d]\t", i, max_a[i], max_a[i], index_a[max_a[i]]);
#endif
		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 >= 1 && s < 100; j--, s++){
			if (index_a[j] <= i){
#ifdef DEBUG
				printf("j:%d\tb[%d]:%d\n", j, i-index_a[j], b[i - index_a[j]]);
#endif
				if (b[i - index_a[j]]){
					next = 1;
					printf("%d\n", j);
					break;
				}
			}
		}
		if (next){
			continue;
		}

		for (j = 1; j <= q[0] && q[j] <= i; j++){
			c = MAX(c, a[i - q[j]]);
		}
#ifdef DEBUG
		printf("brutforce:\t");
#endif
		printf("%d\n",c);
	}

	return 0;
}


#include <stdio.h>
int gcd(int a,int b);
int lcm(int a,int b);
int main()
{
   int a,b,c,d,lc,hcf;
   scanf("%d%d%d%d",&a,&b,&c,&d);
   if(a>b)
   {
   	a=a+b;
   	b=a-b;
   	a=a-b;
   	c=c+d;
   	d=c-d;
   	c=c-d;
   }
  lc=lcm(a,c);
  b=b*lc/a;
  d=d*lc/c;
  hcf=gcd(b,d);
  if(b-d>0)
  printf("%d/%d",(b-d)/hcf,b/hcf);
  else
  {
    b=b*a/lc;
    d=d*c/lc;
    lc=lcm(b,d);
    a=a*lc/b;
    c=c*lc/d;
    hcf=gcd(a,c);
    printf("%d/%d",(a-c)/hcf,a/hcf);

  }
  return 0;

}
int gcd(int a,int b)
{
	if(a==0)
		return b;
	else if(b==0)
		return a;
	else
		return(gcd(b,a%b));
}
int lcm(int a,int b)
{
	return(a*b/gcd(a,b));
}


#include <stdio.h>

void primera (){
	int i;
		printf ("+");
	for (i=0;i<24;i++){
		printf("-");
	}
	printf("+\n");
}
void pasajeros (int n, int s){
	int i;
	int a = n;
	int b = 0;
	int c = 4;
	printf("|");
	if (s == 1){
		if (n==1){
			for (i=1;i<12;i++){
				printf("#.");
			}
		}
		else {
				i = 1;
	do {
		if (a>0){
			if (b == 0){
				a=a-c;
				c--;
				b++;
			}
			else
				a = a - c;
			printf("O.");
		}
		else
			printf("#.");
		i++;
	} while (i<=11);
		}
	}
	else {
	i = 1;
	do {
		if (a>0){
			if (b == 0){
				a=a-c;
				c--;
				b++;
			}
			else
				a = a - c;
			printf("O.");
		}
		else
			printf("#.");
		i++;
	} while (i<=11);
	}

	printf("|");
}

void vacia (int n){
	printf("|");
	int i;
	if (n >= 3){
		printf("O.");
	}
	else
		printf("#.");
	for (i=1;i<23;i++){
		printf(".");
	}
	printf("|\n");
}

int main (){
	int n;
	int s = 0;
	scanf ("%i", &n);
	primera();
	pasajeros(n, s);
	printf("D|)\n");
	pasajeros(n-1, s);
	printf(".|\n");
	vacia(n);
	s = 1;
	pasajeros(n-2, s);
	printf(".|)\n");
	primera();

	return 0;
}


/* practice with Dukkha */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N	50
#define A	26
#define N_	(1 + N + A + 1)
#define M_	(N + N * A + A)
#define INF	0x3f3f3f3f

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

int oo[1 + M_ * 2], oh[1 + M_ * 2];

int link(int o, int h) {
	static int _ = 1;

	oo[_] = o, oh[_] = h;
	return _++;
}

int ii[M_], jj[M_], cc[M_ * 2], cost[M_], cost_[M_], m_;
int ae[N_], pi[N_], dd[N_], ff[N_], n_;
int pq[1 + N_], iq[N_], cnt;

void link_(int i, int j, int c, int co) {
	int h = m_++;

	ii[h] = i, jj[h] = j, cc[h << 1] = c;
	cost[h] = co;
	ae[i] = link(ae[i], h << 1);
	ae[j] = link(ae[j], h << 1 | 1);
}

int less(int u, int v) {
	return pi[u] < pi[v] || pi[u] == pi[v] && dd[u] < dd[v];
}

int i2(int i) {
	return (i *= 2) > cnt ? 0 : i < cnt && less(pq[i + 1], pq[i]) ? i + 1 : i;
}

void pq_up(int u) {
	int i, j, v;

	for (i = iq[u]; (j = i / 2) && less(u, v = pq[j]); i = j)
		pq[iq[v] = i] = v;
	pq[iq[u] = i] = u;
}

void pq_dn(int u) {
	int i, j, v;

	for (i = iq[u]; (j = i2(i)) && less(v = pq[j], u); i = j)
		pq[iq[v] = i] = v;
	pq[iq[u] = i] = u;
}

void pq_add_last(int u) {
	pq[iq[u] = ++cnt] = u;
}

int pq_remove_first() {
	int u = pq[1], v = pq[cnt--];

	if (v != u)
		iq[v] = 1, pq_dn(v);
	iq[u] = 0;
	return u;
}

int dijkstra(int s, int t) {
	memset(pi, 0x3f, n_ * sizeof *pi);
	pi[s] = 0, pq_add_last(s);
	while (cnt) {
		int i, d, o;

		i = pq_remove_first();
		d = dd[i] + 1;
		for (o = ae[i]; o; o = oo[o]) {
			int h_ = oh[o];

			if (cc[h_] > 0) {
				int h = h_ >> 1, j = i ^ ii[h] ^ jj[h];
				int p = pi[i] + ((h_ & 1) == 0 ? cost_[h] : -cost_[h]);

				if (pi[j] > p || pi[j] == p && dd[j] > d) {
					if (pi[j] == INF)
						pq_add_last(j);
					pi[j] = p, dd[j] = d, ff[j] = h_;
					pq_up(j);
				}
			}
		}
	}
	return pi[t] != INF;
}

int trace(int s, int t) {
	while (t != s) {
		int h_ = ff[t], h = h_ >> 1;

		cc[h_]--, cc[h_ ^ 1]++;
		t ^= ii[h] ^ jj[h];
	}
	return 1;
}

int edmonds_karp(int s, int t) {
	int h, f, ans;

	for (h = 0; h < m_; h++) {
		int i = ii[h], j = jj[h];

		pi[j] = min(pi[j], pi[i] + cost[h]);
	}
	for (h = 0; h < m_; h++) {
		int i = ii[h], j = jj[h];

		cost_[h] = cost[h] + pi[i] - pi[j];
	}
	f = 0;
	while (dijkstra(s, t)) {
		f += trace(s, t);
		for (h = 0; h < m_; h++) {
			int i = ii[h], j = jj[h];

			if (pi[i] != INF && pi[j] != INF) {
				/* pi[j] <= pi[i] + cost_[h] */
				/* cost_[h] + pi[i] - pi[j] >= 0 */
				cost_[h] += pi[i] - pi[j];
			}
		}
	}
	ans = 0;
	for (h = 0; h < m_; h++)
		ans += cc[h << 1 | 1] * cost[h];
	return ans;
}

int main() {
	static char cc[N * 2 + 1];
	static int bb[N * 2], kk[A];
	int n, i, a;

	scanf("%d%s", &n, cc), n /= 2;
	n_ = 1 + n + A + 1;
	for (i = 0; i < n * 2; i++)
		scanf("%d", &bb[i]);
	for (i = 0; i < n; i++)
		link_(0, 1 + i, 2, 0);
	for (i = 0; i < n; i++) {
		int j = n * 2 - 1 - i;
		int ai = cc[i] - 'a';
		int aj = cc[j] - 'a';

		for (a = 0; a < A; a++) {
			int b;

			if (a == ai && a == aj)
				b = max(bb[i], bb[j]);
			else if (a == ai)
				b = bb[i];
			else if (a == aj)
				b = bb[j];
			else
				b = 0;
			link_(1 + i, 1 + n + a, 1, -b);
		}
	}
	for (i = 0; i < n * 2; i++) {
		a = cc[i] - 'a';
		kk[a]++;
	}
	for (a = 0; a < A; a++)
		link_(1 + n + a, n_ - 1, kk[a], 0);
	printf("%d\n", -edmonds_karp(0, n_ - 1));
	return 0;
}


#include <stdio.h>
int main()
{
	long long int i,j,k=0,n,m,s=0;
	long long int fact[250001];
	fact[1]=1;fact[0]=1;
	scanf("%lld%lld",&n,&m);
	for(i=2;i<=250000;i++)
	fact[i]=(fact[i-1]*i)%m;
	for(i=1;i<=n;i++)
	{
		k=k+(n-i+1)*(fact[i]*fact[n-i+1]%m);
		k=k%m;
	}
	printf("%lld",k);
}


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

#define SQR 1097
#define MAX 1200000
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
#define chkbit(ar, i) (((ar[(i) >> 6]) & (1 << (((i) >> 1) & 31))))
#define setbit(ar, i) (((ar[(i) >> 6]) |= (1 << (((i) >> 1) & 31))))
#define isprime(x) (( (x) && ((x)&1) && (!chkbit(ar, (x)))) || ((x) == 2))

char str[12];
long long p, q;
unsigned int ar[(MAX >> 6) + 5] = {0};
int m = 0, counter[MAX] = {0}, P[12010];

void Sieve(){
    int i, j, k;
    setbit(ar, 0), setbit(ar, 1);

    for (i = 3; i < SQR; i++, i++){
        if (!chkbit(ar, i)){
            k = i << 1;
            for (j = (i * i); j < MAX; j += k) setbit(ar, j);
        }
    }

    k = 0, counter[2] = ++k;
    for (i = 3; (i + 1) < MAX; i++, i++){
        if (isprime(i)) k++;
        counter[i] = counter[i + 1] = k;
    }
}

void backtrack(int i, int j){
    if (i > j){
        int x = atoi(str);
        if (x < MAX) P[m++] = x;
        return;
    }

    int k;
    for (k = 0; k < 10; k++){
        if (!i && !k) continue;
        str[i] = str[j] = k + 48;
        backtrack(i + 1, j - 1);
    }
}

void Generate(){
    m = 0;
    int i, j;
    for (i = 1; i <= 7; i++){
        str[i] = 0;
        backtrack(0, i - 1);
    }
}

bool Check(int n, int i){
    long long x = q * counter[n];
    long long y = p * (i + 1);
    return (x <= y);
}

int main(){
    Sieve();
    Generate();
    int n, i, j, low, high, mid, res;

    while (scanf("%I64d %I64d", &p, &q) != EOF){

        res = -1;
        for (i = m - 2; i >= 0; i--){
            if (Check(P[i], i)){
                low = P[i], high = P[i + 1] - 1;

                while ((low + 1) < high){
                    mid = (low + high) >> 1;
                    if (Check(mid, i)) low = mid;
                    else high = mid;
                }

                if (Check(high, i)) res = high;
                else if (Check(low, i)) res = low;
                if (res != -1) break;
            }
        }

        if (res == -1) puts("Palindromic tree is better than splay tree");
        else printf("%d\n", res);
    }
    return 0;
}


#include <stdio.h>

int main()
{
    int n, m, i, max = -1, count;
    scanf("%d %d", &n, &m);
    int arr[n];

    for(i=0; i<n; i++){
        scanf("%d", &arr[i]);
        if(arr[i] > max)
            max = arr[i];
    }

    if(max % m == 0)
        count = max / m;
    else
        count = max / m + 1;

    for(i=n-1; i>=0; i--){
        if(arr[i] % m == 0){
            if(arr[i] / m == count){
                printf("%d", i + 1);
                return 0;
            }
        }
        else{
            if(arr[i] / m + 1 == count){
                printf("%d", i + 1);
                return 0;
            }
        }
    }
    printf("%d", n);

	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
   int n,i,r=0,z;
   long long out=0;
   scanf("%d",&n);
   char str[n];

   scanf("%s",str);

for(i=0;i<n;i++)
{
    if(str[i]=='B')
    {
        out+=pow(2,i);
    }
}

    printf("%I64d",out);

    return 0;

}


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

int main(void) {
	int x, y, z, t1, t2, t3;
	int jedno;
	int drugo;
	scanf("%d%d%d%d%d%d", &x, &y, &z, &t1, &t2, &t3);
	jedno = abs(x - y)*t1;
	if (z == x) {
		drugo = 2 * t3 + abs(x - y)*t2 + t3;
	}
	else {
		drugo = abs(x - z)*t2 + 2 * t3 + abs(x - y)*t2 + t3;
	}
	if (jedno < drugo) printf("NO");
	else printf("YES");
	return 0;
}


#include<stdio.h>
int main()
{
    int n;
    scanf("%d\n",&n);
    char str[n];
    scanf("%s",str);
    int ctr=0;
    for(int i=0;i<n-2;i++)
    {
        if(str[i]=='x'){
            while(i<n-2 && str[i+1]=='x' && str[i+2]=='x'){
                ctr++;
                for(int j=i+2;j<n-1;j++)
                {
                    str[j]=str[j+1];
                }
                n-=1;
            }
        }
    }
    if(ctr==0)
    printf("0");
    else{
    printf("%d",ctr);}
    return 0;
}


#include <stdio.h>

int main()
{
	int n;
	scanf("%d",&n);
	int i,a[n];
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	int seg[n];
	for(i=0;i<n;i++)
		seg[i] = 1;
	while(a[n-1]!=1)
		n--;
	i = 0;
	while(a[i]!=1)
		i++;
	int cnt =0;
	for(;i<n;i++)
	{
		if(a[i]==1 && i!=n-1)
		{

			int temp = 0;
			while(a[i+1]==0)
			{
				temp++;
				i++;
			}
			if(temp)
				temp +=1;
			else
				temp = 1;
			seg[cnt++] = temp;
		}
	}
	long long int ans = 1;
	for(i=0;i<n;i++)
		ans*=seg[i];

	int flag =0;
	for(i=0;i<n;i++)
		if(a[i]==1)
			flag = 1;
	if(flag==0)
		printf("%d",0);
	else
		printf("%lld",ans);

	return 0;
}


#include<stdio.h>
int arr[101],no[101],l[100];
int main()
{
	int n,m,source,desti,temp,flag,k,i;
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++)
	scanf("%d",&l[i]);
	for(i=0;i<=n;i++)
	{
		arr[i]=0;
		no[i]=0;
	}
	flag=0;
	for(i=0;i<(m-1);i++)
	{
		source=l[i];
		desti=l[i+1];
		if(desti<=source)
		desti=desti+n;
		temp=desti-source;
		if(arr[l[i]]==0)
		{
			if(no[temp]==1)
			{
				flag=1;
				break;
			}
			else
			{
				arr[l[i]]=temp;
				no[temp]=1;
			}
		}
		else if(arr[l[i]]==temp);
		else
		{
			flag=1;
			break;
		}
	}
	k=1;
	if(flag==1)
	printf("-1");
	else
	{
		for(i=1;i<=n;i++)
		{
			if(arr[i]==0)
			{
				while(no[k]==1)
				k++;
				arr[i]=k;
				no[k]=1;
				k++;
			}
		}
		for(i=1;i<=n;i++)
		printf("%d ",arr[i]);
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
#define MAX_NUM 1000000
// array will be initialized to 0 being global
int search;
int main()
{
	int t,i,w,l,k,c,cout,x,first,last,y,q,f,b,d,s,count=0,prime,min,p,m;
	//scanf("%d",&t);
	//for(i=0;i<t;i++)
	{	c=0;
		scanf("%d %d %d",&x,&y,&k);
		int p=2,i,b,initial;
		int j=0,primes[1000001]={0};
		for (p=2; p<=y; p++) // for all elements in array
		{
			if(primes[p] == 0) // it is not multiple of any other prime
			{primes[p] = 1;
				//printf("%d\n",p);
				j++;// mark it as prime
			}
			// mark all multiples of prime selected above as non primes
			int c=2;
			int mul = p * c;
			for(; mul <=y;)
			{
				primes[mul] = -1;
				c++;
				mul = p*c;
			}
		}
		for(i=2;i<=y;i++)
		{if(primes[i]==-1)
			{primes[i]=0;}
			primes[i]=primes[i]+primes[i-1];
			//printf("%d\n",primes[i]);
		}
		primes[0]=0;
		primes[1]=0;
		min=y-x+2;
		first=1;
		last=y-x+1;
		cout=-1;
		d=0;
		if(primes[y]-primes[x-1]<k)
		{printf("-1\n");
			d=1;}
		while(first<=last)
		{
			l=(first+last)/2;
			prime=0;
			for(q=x;q<=y-l+1;q++)
			{prime=0;
				m=0;
				if(primes[q+l-1]-primes[q-1]<k)
				{m=1;
					break;
				}
			}
			if(m==1)
			{first=l+1;	//printf("min -1\n");
			}
			else
			{last=l-1;
				cout=l;}
		}
		if(d!=1)
			printf("%d\n",cout);
	}
	return 0;
}


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

#define N	15
#define K	200000
#define L	19	/* L = ceil(log2(K * 2 + 1)) */
#define N_	(1 << L)
#define MD	998244353

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

	while (k) {
		if (k & 1)
			p = p * a % MD;
		a = a * a % MD;
		k >>= 1;
	}
	return p;
}

int vv_[L + 1], *wwu[L + 1], *wwv[L + 1];

void init() {
	int i, l, u, v;

	u = power(3, MD - 1 >> L), v = power(u, MD - 2);
	for (l = L; l > 0; l--) {
		int n = 1 << l, m = n >> 1;

		vv_[l] = power(1 << l, MD - 2);
		wwu[l] = (int *) malloc(m * sizeof *wwu[l]);
		wwv[l] = (int *) malloc(m * sizeof *wwv[l]);
		wwu[l][0] = wwv[l][0] = 1;
		for (i = 1; i < m; i++) {
			wwu[l][i] = (long long) wwu[l][i - 1] * u % MD;
			wwv[l][i] = (long long) wwv[l][i - 1] * v % MD;
		}
		u = (long long) u * u % MD;
		v = (long long) v * v % MD;
	}
	vv_[0] = 1;
}

void ntt_(int *aa, int l, int inverse) {
	if (l) {
		int n = 1 << l, m = n >> 1, *ww = inverse ? wwv[l] : wwu[l], i, j;

		ntt_(aa, l - 1, inverse), ntt_(aa + m, l - 1, inverse);
		for (i = 0; (j = i + m) < n; i++) {
			int a = aa[i], b = (long long) aa[j] * ww[i] % MD;

			if ((aa[i] = a + b) >= MD)
				aa[i] -= MD;
			if ((aa[j] = a - b) < 0)
				aa[j] += MD;
		}
	}
}

void ntt(int *aa, int l, int inverse) {
	int n = 1 << l, i, j;

	for (i = 0, j = 1; j < n; j++) {
		int b = n >> 1, tmp;

		while ((i ^= b) < b)
			b >>= 1;
		if (i < j)
			tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
	}
	ntt_(aa, l, inverse);
}

void multiply(int *aa, int *bb, int *cc, int n, int m) {
	static int aa_[N_], bb_[N_];
	int n_, l, i;

	l = 0;
	while (1 << l < n + m - 1)
		l++;
	n_ = 1 << l;
	for (i = 0; i < n_; i++) {
		aa_[i] = i < n ? aa[i] : 0;
		bb_[i] = i < m ? bb[i] : 0;
	}
	ntt(aa_, l, 0);
	ntt(bb_, l, 0);
	for (i = 0; i < n_; i++)
		aa_[i] = (long long) aa_[i] * bb_[i] % MD;
	ntt(aa_, l, 1);
	for (i = 0; i < n + m - 1; i++)
		cc[i] = (long long) aa_[i] * vv_[l] % MD;
}

int main() {
	static int dp[N][K + 1], dq[K * 2 + 1];
	int n, c_, k, i, c, x;

	init();
	scanf("%d%d%d", &n, &k, &c_);
	for (c = 0; c <= k; c++)
		dp[0][c] = 1;
	for (i = 0; i < n; i++) {
		multiply(dp[i], dp[i], dq, k + 1, k + 1);
		if (i + 1 == n)
			printf("%d\n", dq[c_]);
		else {
			x = 0;
			for (c = k + 1; c <= k * 2; c++)
				x = (x + dq[c]) % MD;
			for (c = k; c >= 0; c--) {
				x = (x + dq[c]) % MD;
				dp[i + 1][c] = (x + (long long) dq[c] * (k - c)) % MD;
			}
		}
	}
	return 0;
}


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

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

int next_permutation(int a[], int n)
{
    int m = a[n - 1], p = 1, i, j;
    int b[20];

    b[0] = m;

    for (i = n - 2; i >= 0; i--) {
	if (m > a[i]) {
	    qsort(b, p, sizeof(int), cmp_perm);

	    for (j = 0; ; j++) {
		if (b[j] > a[i]) {
		    m = a[i];
		    a[i++] = b[j];
		    b[j] = m;

		    break;
		}
	    }

	    for (p = 0; i < n; i++) {
		a[i] = b[p++];
	    }

	    return 1;
	} else {
	    b[p++] = a[i];

	    if (a[i] > m) m = a[i];
	}
    }

    return 0;
}

int main()
{
     int r1, r2, c1, c2, d1, d2;
     int a[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};

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

     do {
	  if (a[0] + a[1] != r1) continue;
	  if (a[2] + a[3] != r2) continue;
	  if (a[0] + a[2] != c1) continue;
	  if (a[1] + a[3] != c2) continue;
	  if (a[0] + a[3] != d1) continue;
	  if (a[1] + a[2] != d2) continue;

	  printf("%d %d\n", a[0], a[1]);
	  printf("%d %d\n", a[2], a[3]);

	  return 0;
     } while (next_permutation(a, 9));

     puts("-1");

     return 0;
}


/* upsolve using zigzag */
/* https://codeforces.com/blog/entry/73563 */
#include <stdio.h>
#include <string.h>

#define N	1024

int query(int i) {
	if (i == -1) {
		printf("R\n"), fflush(stdout);
		return 0;
	} else {
		static char s[2];

		printf("? %d\n", i + 1), fflush(stdout);
		scanf("%s", s);
		return s[0] == 'N';
	}
}

int main() {
	static char alive[N];
	int n, k, m, g, h, i, ans;

	scanf("%d%d", &n, &k), m = n / k;
	memset(alive, 1, n * sizeof *alive);
	for (g = 0; g < m; g++) {
		query(-1);
		for (h = 0; h < m; h++) {
			int g_ = (g + (h % 2 == 0 ? h / 2 : m - (h + 1) / 2)) % m, l = g_ * k, r = (g_ + 1) * k;

			for (i = l; i < r; i++)
				if (alive[i] && !query(i))
					alive[i] = 0;
		}
	}
	ans = 0;
	for (i = 0; i < n; i++)
		if (alive[i])
			ans++;
	printf("! %d\n", ans), fflush(stdout);
	return 0;
}


#include <stdio.h>

int f(int x,int n,int a[n]){
    int res=0;
    for (int i=0;i<n;i++){
        if (i+1<=x){
            res+=(a[i]*2*(x-1));
        }
        else res+=(a[i]*2*i);
    }
    return 2*res;
}

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

	int res=f(1,n,a);
	for (int j=1;j<=n;j++){
	    if (f(j,n,a)<res){
	        final=j;
	        res=f(j,n,a);
	    }
	}
	printf("%d",f(final,n,a));

	return 0;
}


#include<stdio.h>
#include"string.h"
int main()
{
    char string [100];
    scanf("%s",string);
    int counter_of_number=0;
    int length=strlen(string);
    for(int i=0;i<length;i++)
    {
        if(string[i]=='Q')
            for(int j=i+1;j<length;j++)

                if(string[j]=='A')

                    for(int m=j+1;m<length;m++)

                        if(string[m]=='Q')

                        counter_of_number++;
    }
    printf("%d",counter_of_number);
return 0;
}


#include <stdio.h>

#define MD	1000000007

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

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

int main() {
	int n, m;

	scanf("%d%d", &n, &m);
	printf("%lld\n", power(power(2, m) - 1, n));
	return 0;
}


//       In the name of         ˜”*°•.˜”*°•                      God                     •°*”˜.•°*”˜

/*

            JadedBeast                                             ~~Morocco~~

*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define N 100001

int main(void){
    bool *sieve=(bool *)malloc(N*sizeof(bool));
    sieve[0]=false,sieve[1]=false;
    for(int i=2;i<N;i++){
    sieve[i]=true;
        }
    for(int i=2;i<=N/2;i++){
        for(int j=2*i;j<N;j+=i){
            sieve[j]=false;
        }
    }
    long long *primes=(long long *)malloc(N*sizeof(long long));
    int counter=0;
    for(int i=2;i<N;i++){
        if(sieve[i]){
            primes[counter]=i;
            counter++;
        }
    }
    long long n,result=0;
    scanf("%I64d",&n);
    while(n>0){
    for(int i=0;i<counter;i++){
         if(n%primes[i]==0){
            result++;
            n=n-primes[i];
            if(n%2==0){
                result+=n/2;
                n=n%2;
                }
            break;
            }
        else if(i==counter-1 && result==0){
            result=1;
            n=0;
            break;
            }
        }
    }
   printf("%I64d\n",result);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#define  mod 1000000007
int main()
{
	long long int n,x,y,l,result;
	scanf("%lld %lld",&x,&y);
	scanf("%lld",&n);
	if (n%6==0){
		result=(x-y)%mod;
	}
	if (n%6==1){
		result=x%mod;
	}
	if (n%6==2){
		result=y%mod;
	}
	if (n%6==3){
		result=(y-x)%mod;
	}
	if (n%6==4){
		result=(-x)%mod;
	}
	if (n%6==5){
		result=(-y)%mod;
	}
	if (result>=0){
		printf("%lld\n",result);
	}
	else {
		l=abs(result);
		printf("%lld\n",mod-l);
	}

	return 0;
}


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

#define PI acos(-1)
#define eqs 0.01
double gcd(double a,double b)
{
return a < eqs ? b : gcd(fmod(b,a),a);
}
int main()
{
double x1 , y1 , x2 , y2 , x3 , y3 ;
double a , b , c , p , s , r , k ;
double A , B , C ;
scanf("%lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3) ;
a = sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) ) ;
b = sqrt( (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3) ) ;
c = sqrt( (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3) ) ;
p = ( a + b + c ) / 2.0 ;
s = sqrt( p * (p-a) * (p-b) * (p-c) ) ;
r = a * b * c / ( 4 * s ) ;
if( a > c )
{
k = a ; a = c ; c = k ;
}
if( b > c )
{
k = b ; b = c ; c = k ;
}
A = 2 * asin(a/(2*r)) ;
B = 2 * asin(b/(2*r)) ;
C = 2 * PI - A - B ;
//printf("%lf %lf %lf\n", A, B, C) ;
p = gcd(A,B);
p = gcd(p,C) ;
//printf("%lf %lf\n", r, p) ;
printf("%.6lf\n", (PI*r*r*sin(p))/p ) ;
return 0;
}


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

#define M	4167669	/* (23 choose 7) * 17 */
#define C	16
#define K	2000000000
#define T	7

void print(int k) {
	if (k == 0)
		return;
	print(k / C);
	printf("%c", k % C < 10 ? k % C + '0' : k % C - 10 + 'a');
}

int add(int a, int b) { return (long long) a + b < K ? a + b : K; }

int choose[C + T][C + T];

void init() {
	int n, r;

	choose[0][0] = 1;
	for (n = 1; n < C + T; n++) {
		choose[n][0] = 1;
		for (r = 1; r <= n; r++)
			choose[n][r] = choose[n - 1][r - 1] + choose[n - 1][r];
	}
}

int dp[M], m;

void branch(int *aa, int h) {
	int a, len, j;

	if (h == C) {
		for (len = 0; len <= C; len++) {
			if (len == 0)
				dp[m] = 1;
			else
				for (h = 0; h < C; h++) {
					if (aa[h] == 0)
						continue;
					if (h == 0 || aa[h - 1] != aa[h]) {
						a = aa[h] - 1;
						j = m / (C + 1) - choose[C - h - 1 + T - a][T - a];
						if (h < C - 1)
							j += choose[C - h - 2 + T - a][T - a];
						j = j * (C + 1) + len - 1;
					}
					dp[m] = add(dp[m], dp[j]);
				}
			m++;
		}
		return;
	}
	for (a = h == 0 ? 0 : aa[h - 1]; a <= T; a++) {
		aa[h] = a;
		branch(aa, h + 1);
	}
}

int idx(int *aa, int len) {
	int h, a, sum;

	sum = 0;
	for (h = 0; h < C; h++)
		for (a = h == 0 ? 0 : aa[h - 1]; a < aa[h]; a++)
			sum += choose[C - h - 1 + T - a][T - a];
	return sum * (C + 1) + len;
}

int compare(const void *a, const void *b) {
	int ia = *(int *) a;
	int ib = *(int *) b;

	return ia - ib;
}

int main() {
	static int aa[C], bb[C];
	int k, t, h, i, len, first;

	scanf("%d%d", &k, &t);
	if (t >= 8) {
		print(k);
		printf("\n");
		return 0;
	}
	init();
	branch(aa, 0);
	for (h = 0; h < C; h++)
		aa[h] = t;
	for (len = 1; ; len++) {
		int cnt = dp[idx(aa, len)];

		aa[0]--; cnt -= dp[idx(aa, len - 1)]; aa[0]++;
		if (k <= cnt)
			break;
		k -= cnt;
	}
	first = 1;
	while (len-- > 0) {
		for (h = first ? 1 : 0; h < C; h++) {
			memcpy(bb, aa, C * sizeof *aa);
			if (bb[h] == 0)
				continue;
			bb[h]--;
			qsort(bb, C, sizeof *bb, compare);
			if (k > dp[i = idx(bb, len)]) {
				k -= dp[i];
				bb[h]++;
			} else {
				printf("%c", h < 10 ? h + '0' : h - 10 + 'a');
				aa[h]--;
				break;
			}
		}
		first = 0;
	}
	printf("\n");
	return 0;
}


#include <stdio.h>
int main(int argc,char** argv){
    int a,b,c,d;
    int delta;
    float q;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    delta = b -a;
    if( (c-b) == delta && (d - c) == delta)
    {
        printf("%d\n",d+delta);
    }
    else
    {
        q = b/(float)a;
        if(q!= 0 && q!=1 && c/(float)b == q && d/(float)c == q){
            a = (int)((float)d*q*10) ;
            b = ((int)(d *q)) *10;
            if(a == b)
                printf("%d\n",(int)((float)d*q));
            else
                printf("42\n");
        }else{
            printf("42\n");
        }
    }
    return 0;
}


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

    long long a,b,n,m,k;
    scanf("%I64d %I64d %I64d",&n,&m,&k);
    if(k<n)printf("%d 1",k+1);
    else
    {a = (k-n)/(m-1);
    b = (k-n)%(m-1);
    if(a%2==0){printf("%I64d %I64d",n-a,b+2);}
    else printf("%I64d %I64d",n-a,m-b);

    }

    return 0;

}


#include<stdio.h>

int main()
{
    int n, x, y, min, max, i = 0;

    scanf("%d%d%d", &n, &x, &y);

    max = x > y ? x : y;
    min = x < y ? x : y;

    for(i = 0; ; i++) {
        if(!(n % min)) break;
        n -= max;
        if(n < 0) break;
    }

    if(n < 0) printf("NO");
    else {
        if(x > y) printf("YES\n%d %d", i, n / min);
        else printf("YES\n%d %d", n / min, i);
    }

    return 0;
}


#include<stdio.h>
int a[1000];
int isprime(int k)
{
    int j;
    for(j=2;j<=k/2;j++)
        {
            if(k%j==0)
            return 0;
        }
        return 1;
}

int main()
{
    int i,j,k,l=0,m,n,t=0;
    scanf("%d%d",&n,&k);
    if(k==0)
    {
        printf("YES");
        return 0;
    }
    for(i=2;i<=n;i++)
    {
                if(isprime(i)==1)
                {
                a[l]=i;

                l++;
                }
    }
    for(i=0;i<l-1;i++)
    {
        m=a[i]+a[i+1]+1;

        for(j=i+2;j<l;j++)
        {
            if(m==a[j])
            {
                t=t+1;
                if(t==k)
                {
                    printf("YES");
                break;
                }
            }
        }
        if(t==k)
        break;
    }
    if(t<k)
    printf("NO");
    return 0;
}


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

#define MOD 1000000007

int main()
{
    int i, j;
    int n, k, d;
    int dp[105];
    int tt[105];
    memset(dp, 0, sizeof(dp));
    memset(tt, 0, sizeof(tt));
    scanf("%d%d%d", &n, &k, &d);
    for ( tt[0] = 1, i = 1; i < 105; i++ )
    {
        tt[i] = 0;
        for ( j = 1; j <= i && j <= k; j++ )
            tt[i] = (tt[i]+tt[i-j])%MOD;
    }
    for ( i = d; i <= n; i++ )
    {
        for ( j = 1; j < d; j++ )
            dp[i] = (dp[i]+dp[i-j])%MOD;
        for ( j = d; j <= k && j <= i; j++ )
            dp[i] = (dp[i]+tt[i-j])%MOD;
    }
    printf("%d\n", dp[n]);
    return 0;
}


#include <stdio.h>

typedef unsigned long long int ll;

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

int main()
{
    ll t,a,b,min,c,q,x,n,l,r;
    scanf("%llu %llu %llu",&t,&a,&b);
    if(a==b)
    {
        printf("1/1\n");
        return 0;
    }
    if(b<a)
        min=b;
    else
        min=a;
    if(t>min)
    {
        c=0;
        q=(t/a)*gcd(a,b);
        q=q/b;
            c=c+min-1;
        n=(q*a*(b/gcd(a,b)));
        if((t-n)<=(min-1))
        {
            if(q>=1)
                c=c+(q-1)*min+t-n+1;
            else
                c=c+t-n+1;
        }
        else
        {
            c=c+(q)*min;
        }
    }
    else
    {
        if(t==min)
            c=min-1;
        else
        {
            c=t;
        }
    }
    r=gcd(c,t);
    printf("%llu/%llu\n",(c/r),(t/r));
    return 0;
}


#include<stdio.h>
int main()
{
    int n,k,x,arr[105],sum=0,i;
    scanf("%d%d%d",&n,&k,&x);
    for (i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);

    }
    for (i=0;i<(n-k);i++)
    {
        sum+=arr[i];
    }
    sum=sum+ (k*x);
    printf("%d",sum);

}


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

int main()
{   int x,b,s;
    s=0;
    b=0;
    while(~scanf("%d",&x))
    {b=x/5;
    s=b;
    if(x%5!=0)
    s=s+1;
    printf("%d\n",s);
    }
    return 0;
}


#include <stdio.h>
typedef long long unsigned llu;
typedef unsigned u;
u M[55][55];
int main()
{
	u m,b,i,j;llu k,r=0llu;
	scanf("%u%u",&m,&b);
	for(i=-1;++i<=b;)
	{
		j=m*(b-i);
		k =(j+1)*(i*(llu)(i+1)>>1);
		k+=(i+1)*(j*(llu)(j+1)>>1);
		if(r<k)r=k;
	}
	printf("%I64u\n",r);
	return 0;
}


#include<stdio.h>
#include<math.h>
#include<string.h>
#define max(a,b) ((a>b)?a:b))
#define min(a,b) ((a<b)?b:a))
#define Read(T) scanf("%d\n",&T)
#define LL long long
#define OpFile_in(s) freopen(s,"r",stdin)
int N,M,K;
int cnt[103],Nxt[102];
char st1[102],st2[102];
void init();
void doit();
int main()
{
    //OpFile_in("CF_temp.in");
    init();
    doit();
    return 0;
}
void init()
{
    scanf("%d%d\n",&N,&M);
    gets(st1);
    gets(st2);
}
void doit()
{
    int i=0,j=0,cur,L1,L2;
    LL ans=0;
    L1=strlen(st1);
    L2=strlen(st2);
    for(i=0;i<L2;i++)
    {
        cur=i;
        for(j=0;j<L1;j++)
        {
            if(st2[cur]==st1[j])
            {cur++;
            if(st2[cur]=='\0') cnt[i]++,cur=0;
            }
        }
        Nxt[i]=cur;
    }
    for(cur=i=0;i<N;i++)
    {
        ans+=cnt[cur];
        cur=Nxt[cur];
    }
    printf("%I64d\n",ans/M);
}


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

int main()
{
    long long a, b;
    scanf("%I64d %I64d", &a, &b);
    long long counter = 0ll;
    for(long long i = (long long)1; i < b * 100; i *= 2)
    {
        for(long long j = (long long)1; j < b * 100; j *= 3)
        {
            if(i * j >= a && i * j <= b)
                counter++;
        }
    }
    printf("%I64d", counter);
    return 0;
}


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

#define rep2(i,k,n)                 for(i=(k);i<(n);++i)
#define rep(i,n)                    rep2(i,0,n)

typedef unsigned long long          ull;
typedef long long                   ll;
typedef int                         TKey;

#define MAX_NUM                     2003

const ll MOD_MAX = (1e9 + 7);

ull inv[MAX_NUM];
ull wt[MAX_NUM];

void calcInv(int m)
{
    int i;
    inv[0] = 1;
    inv[1] = 1;
    for (i = 2; i < m; i++)
    {
        inv[i] = ((MOD_MAX - MOD_MAX / i) * inv[MOD_MAX % i]) % MOD_MAX;
    }
}

ull getC(ull n, ull m)
{
    ull i;
    ull ans = 1;
    //addLog("Need C(" << n << "," << m << ")");
    if (n < m) return 0;
    //cala the min
    if (m > n - m) m = n - m;
    //n %= MOD_MAX;
    for (i = 1; i <= m; i++)
    {
        ans = (ans * inv[i] % MOD_MAX * (n - i + 1)) % MOD_MAX;
        ////addLog("ans=" << ans);
    }
    //addLog("C(" << n << "," << m << ")=" << ans);
    return ans;
}

//lucas定理：C(n,m)%p = C(n/p,m/p) * C(n%p,m%p)
//C(n,m)模p等于p进制数上各位的C(ni,mi)模p的乘积
ull getLucas(ull n, ull m)
{
    //C(n,0) = 1
    if (0 == m) return 1;
    return (getC(n % MOD_MAX, m % MOD_MAX) *  getLucas(n / MOD_MAX, m / MOD_MAX)) % MOD_MAX;
}

ull solve(int n, ll s)
{
    //允许盒子为空一开始要人为加入一个球
    //花同，盒子不同，且允许为空的数量为 C(n+m-1, m-1)，相当于找 m-1 个挡板
    ull ans = 0;
    int sign;
    ll sum;
    int i, j;
    for (i = 0; i < (1 << n); i++)
    {
        sign = 1;//__buildin_popcount(i)&1?-1:1;
        sum = s;
        //addLog("i=" << bitset<6>(i));
        for (j = 0; j < n; j++)
        {
            if (i & (1 << j))
            {
                sign = 0 - sign;
                //将当前的盒子全部取光（包括多放进去的 1个初始球）
                sum -= wt[j] + 1;
                //addLog("j=" << j << ",sign=" << sign << ",sum=" << sum);
            }
        }
        if (sum < 0)
        {
            //枚举的盒子的花已经超过总个数，这种情况已经在前面计算过了
            //addLog("[sum<0]i=" << bitset<6>(i) << ",sum=" << sum);
            continue;
        }
        //剩余的盒子当中还需要找花，相当于从 sum 朵花和 n 个盒子找 n-1 个挡板
        //容斥原理
        if (sign < 0)
            ans = (ans + MOD_MAX + sign * getLucas(sum + n - 1, n - 1)) % MOD_MAX;
        else
            ans = (ans + sign * getLucas(sum + n - 1, n - 1)) % MOD_MAX;
        //addLog("sign=" << sign << ",sum=" << sum << ")=" << ans);
    }
    return (ans + MOD_MAX) % MOD_MAX;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("iofiles/cf#451e.in", "rt", stdin);
    freopen("iofiles/cf#451e.out", "wt", stdout);
#endif // DEBUG

    int n;
    ull s;
    int i;

    scanf("%d %I64d", &n, &s);
    //printf("%d, %llu\n", n, s);

    calcInv(n);

    rep(i, n)
    {
        scanf("%I64d", &wt[i]);
        ////addLog("wt=" << wt[i]);
    }

    printf("%I64d\n", solve(n, s));

    return 0;
}


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


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

#define MAX( a, b ) ( ( a > b) ? a : b )
#define MIN( a, b ) ( ( a < b) ? a : b )
#define FOR(ii,aa,bb) for(ii=aa;ii<bb;ii++)
#define and &&
#define or ||
int main () {

int x=0,n=0,s=0,i=0,j=0,c=0,a[105],max=0;
scanf("%d %d",&n,&c);
FOR(i,0,n)
  scanf("%d",a+i);
FOR(i,0,n-1){
  x=a[i]-a[i+1]-c;
  if(max<x)
    max=x;}
printf("%d",max);

  return 0;
}


#include "stdio.h"
#include "math.h"
#include "string.h"
long long s(long long a)
{
   return (long long)log10((double)a)+1;
}
long long min(long long a,long long b)
{
    return a<b?a:b;
}
int main()
{long long p[20],i,j;
  long long w,m,k,len,cnt,mi;
  p[0]=1;
  for(i=1;i<=19;i++)
        p[i]=p[i-1]*10;
  while(scanf("%I64d%I64d%I64d",&w,&m,&k)==3)
  {w/=k;
    len=s(m);
     cnt=0;
     while(w)
     {mi=min(p[len]-m,w/len);
      if(!mi)
              break;
      w-=mi*len;
      m=p[len];
      len++;
      cnt+=mi;
      }
      printf("%I64d\n",cnt);
      }
      return 0;
}


#include <stdio.h>
#define mod 1000000007
long long pow(long long a, long long n)
{
    long long result = 1;
    while(n != 0)
    {
        if(n & 1)
        {
            result *= a;
            result %= mod;
        }
        a *= a;
        a %= mod;
        n >>= 1;
    }
    return result;
}
int main()
{
    int t;
    long long n, k;
    scanf("%d", &t);
    while (t--)
    {
        scanf("%lld%lld", &n, &k);

        if(n & 1)
        {
            printf("%lld\n", pow(1 + pow(2, n - 1), k));
        }
        else
        {
            long long tmp = pow(2, n - 1);
            printf("%lld\n",
                (pow(tmp - 1, k) * tmp % mod +
                pow(tmp << 1, k)) * (pow(tmp + 1, mod - 2))
                % mod);
        }
    }
}


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

#define MDI 1000000009
#define MOD(a) ((a) % MDI)
#define MOO(a) ((a) > 0 ? (a) % MDI : MDI + (a))
#define LL long long

void putlld(LL a)
{
  if(a > 9)
    putlld(a / 10);
  putchar(a % 10 + '0');
}

int nn[499999];

int main(void)
{
  int i, n;
  LL h = 0, g, t;
  scanf("%d", &n);
  t = (n >> 1) - 1;
  for(i = 0, nn[0] = 4; i < t - 1; i++)
    nn[i + 1] = MOD(nn[i] << 1);
  for(i = t - 1; i >= 0; i--){
    g = nn[i] - 3;
    h = MOD((h + 4) * g);
  }
  h = MOD(((h * h + (h << 2)) << 1) + 10);
  putlld(h);
  putchar('\n');
  return 0;
}


#include <stdio.h>

void output ( long long  x , long long y );
void solve ( long long x , long long y );

int  w , d;
long long n , p;

int main()
{
    scanf ("%I64d %I64d %i %i", &n , &p , &w , &d);
    if (w%d==0 && p%d!=0)
    {
        output ( -1 , -1 );
    }
    else
    {
        solve ( 0 , 0 );
    }
}

void solve ( long long x , long long y )
{
    static long long point = 0 ;
    long long temp;
    if ( x + y > n  || x<0 )
    {
        output ( -1 , -1 );
    }
    else
    {
        if ( point == p )
        {
            output( x , y );
            return;
        }
        if ( point + w <= p )
        {
            temp = ( p - point ) / w ;
            point += ( temp * w );
            solve ( x + temp , y );
            return ;
        }
        if ( point + d <= p )
        {
            temp = ( p - point ) / d ;
            point += ( temp * d );
            solve ( x , y + temp );
            return ;
        }
        point -= w;
        temp = ( p - point ) / d ;
        point += (temp * d );
        solve ( x-1 , y+temp );
        return ;
    }
}

void output ( long long  x , long long y )
{
    long long z;
    if ( x == -1 )
    {
        printf ("%i",-1);
    }
    else
    {
        z = n - x - y;
        printf ("%I64d %I64d %I64d", x , y , z);
    }
}


#include <stdio.h>

int main(){
  int w, m, l = -1, x;
  char rez = 1;
  scanf("%d%d", &w, &m);
  while(m > 0 && rez){
    x = m % w;
    if(l == 2){
      if(x != w - 1)
        x++;
    }
    if(x == w - 1)
      l = 2;
    else  if(x != 0 && x != 1)
      rez = 0;
    else
      l = -1;
    m /= w;
  }
  if(rez)
    printf("YES");
  else
    printf("NO");
  return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
   long k,a,b;
   scanf("%ld %ld %ld",&k,&a,&b);
   long sum=0;
   if(a+b==0)
   {printf("-1");
    return 0;}
   sum=a/k+b/k;
   if(a/k==0&&b/k!=0&&b%k!=0)
    {printf("-1");
    return 0;}
   if(b/k==0&&a/k!=0&&a%k!=0)
    {printf("-1");
    return 0;}
   if(sum>=1)
   printf("%ld",sum);
   else
    printf("-1");
    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		long long int a,b;
		scanf("%lld%lld",&a,&b);
		if(a-b!=1)
		printf("NO\n");
		else
		{
			if((a+b)%2==0)
			printf("NO\n");
			else
			{
				long long int f=0,n=3,r;
				r=sqrt(a+b);
				while(n<=r)
				{
					if((a+b)%n==0)
					{
						f=1;
						break;
					}
					n+=2;
				}
				if(f==0)
				printf("YES\n");
				else
				printf("NO\n");
			}
		}
	}
}


#include <stdio.h>

#define MAXN 101

main() {
    int n, m;
    scanf("%d %d\n", &n, &m);
    int pts[MAXN];
    int ans[MAXN];
    int i, temp;
    for (i = 0; i < MAXN; i++) {
        pts[i] = 0;
    }
    for (i = 1; i <= n; i++) {
        scanf("%d", &temp);
        pts[temp] = i;
    }
    int mod = 0;
    for (i = 0; i < MAXN; i++) {
        if(pts[i] != 0) {
            ans[pts[i]] = mod%2;
            mod++;
        }
    }
    for (i = 1; i < n; i++) {
        printf("%d ", ans[i]);
    }
    printf("%d \n", ans[n]);
}


#include <stdio.h>

int main(void)
{

    int n,i=0;
    char s[101];
    scanf("%d %s",&n,s);

   while(s[i]!='0'&&i<n)
        i++;
    if(i!=n)
    printf("%d",i+1);
   else
    printf("%d",i);
 return 0;
}


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

int main()
{
    int a,b,c,d,time,hour,mins,new_time;

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

    time=((c*60)+d)-((a*60)+b);

    time=time/2;
    new_time=(a*60)+b+time;

    hour=new_time/60;
    mins=new_time%60;

    if(hour<10 && mins<10)
        printf("0%d:0%d\n",hour,mins);
    else if(hour<10)
        printf("0%d:%d\n",hour,mins);
    else if(mins<10)
        printf("%d:0%d\n",hour,mins);
    else
        printf("%d:%d\n",hour,mins);

    return 0;
}


#include<stdio.h>
int fact(int n)
{
    if(n==0||n==1)
    return 1;
    return n*fact(n-1);
}

int main()
{
   long long int i,j,k,l;
    scanf("%lld%lld",&i,&j);
    k=fact(i);
    l=fact(j);
    if(i>=j)
    printf("%lld\n",l);
    else
    printf("%lld\n",k);
}


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


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

long long int x,y;

//long long int dif[11];
//long long int base[12];

//int comparetor (const void * a, const void * b)
	//{
	//	return ( *(int*)a - *(int*)b );
	//

int chke(long long int a)
{
//printf("%I64d\n",a);
    long long int i;
    for(i=2;i<=(int)(sqrt(a))+1;i++)
    {
        if(a%i==0 && i!=a)
        {//printf("%I64d\n",i);
            x=i;
            return 2;
        }
    }

    return 3;

}

int main()
{
long long int n,sum,i,found;

//long long int a[2];
found=0;
sum=0;
scanf("%I64d",&n);
if(n==1){

    printf("1\n");
    printf("0");
    exit(0);

}

if(n==2){

    printf("1\n");
    printf("0");
    exit(0);

}

for(i=2;i<=(int)(sqrt(n))+1;i++){

        //printf("%I64d\n",i);
    if(n%i==0 && n!=i)
    {found=1;
//printf("%I64d\n",i);
        if(chke(n/i)==2){

                printf("1\n");
                printf("%I64d",i*x);
        exit(0);

        }

    else {
        printf("2");
        exit(0);}

}}

printf("1\n");
printf("0");

}


//by ahmeterdem™
#include <stdio.h>
#include <string.h>
#include <math.h>
#define min(a,b) (a<b)?a:b
#define max(a,b) (a<b)?b:a
#define FOR (i,a,b) for(i=a;i<b;i++)
#define ROF(i,a,b) for(i=b;i>=0;i--)
long long int n;
int main() {
scanf("%lld",&n);
printf("%lld",n*(n-1)*(n-2)*(n-3)*(n-4)/120*n*(n-1)*(n-2)*(n-3)*(n-4));

	return 0 ;
}


#include <stdio.h>

int main()
{
    double x,y,i,j,cont,a,b;
    scanf("%lf %lf", &x, &y);
    cont = 0;
    if(x >1 && y >1)
    {
        for(j = 1 ; j < x ; j++ )
        {
            for(i = 1; i< y ; i++)
            {
                a = j;
                b = i;
                if(y - b < b)
                {
                    b = y-b;
                }
                if(x-a < a)
                {
                    a = x-a;
                }
                cont = cont + a*b;
            }
        }
    }
    printf("%.0lf\n", cont);
    return 0 ;
}


#include<stdio.h>
void mergesort(long int a[],long int i,long int j);
void merge(long int a[],long int i1,long int j1,long int i2,long int j2);
int main()
{
long int n;
scanf("%li",&n);
long int a[n],i;
for(i=0;i<n;i++)
scanf("%li",&a[i]);
mergesort(a,0,n-1);
//for(i=0;i<n;i++)
//printf("%li\n",a[i]);
for(i=0;i<=n-3;i++)

if(a[i]+a[i+1]>a[i+2] && a[i+2]+a[i]>a[i+1])
break;
if(i>(n-3))
printf("NO");
else
printf("YES");
}
void mergesort(long int a[],long int i,long int j)
{
    long int mid;
    if(i<j)
    {
        mid=(i+j)/2;
        mergesort(a,i,mid);        //left recursion
        mergesort(a,mid+1,j);    //right recursion
        merge(a,i,mid,mid+1,j);    //merging of two sorted sub-arrays
    }
}

void merge(long int a[],long int i1,long int j1,long int i2,long int j2)
{
    long int temp[j2];    //array used for merging
    long int i,j,k;
    i=i1;    //beginning of the first list
    j=i2;    //beginning of the second list
    k=0;

    while(i<=j1 && j<=j2)    //while elements in both lists
    {
        if(a[i]<a[j])
            temp[k++]=a[i++];
        else
            temp[k++]=a[j++];
    }

    while(i<=j1)    //copy remaining elements of the first list
        temp[k++]=a[i++];

    while(j<=j2)    //copy remaining elements of the second list
        temp[k++]=a[j++];

    //Transfer elements from temp[] back to a[]
    for(i=i1,j=0;i<=j2;i++,j++)
        a[i]=temp[j];
}


#include <stdio.h>
#include <stdlib.h>
 int main(){
    int len;
    char introd[101];
    scanf("%s",introd);
    len= strlen(introd);
    if((len==3&&strcmp(introd,"127")<=0) || len<3)
        printf("byte\n");
    else if((len==5&&strcmp(introd,"32767")<=0) || len<5)
        printf("short\n");
    else if((len==10&&strcmp(introd,"2147483647")<=0) || len<10)
        printf("int\n");
    else if((len==19&&strcmp(introd,"9223372036854775807")<=0) || len<19)
        printf("long\n");
    else printf("BigInteger\n");
    return 0;
 }


#include<stdio.h>

int main()
{
    int k, i, j, l;
    int a[5];
    scanf(" %d", &k);
    for(i=1; i<k; i++)
    {
        for(j=1; j<k; j++)
        {
            int temp = i*j;
            l = 0;
            while(temp > 0)
            {
                a[l] = temp % k;
                if((temp = temp/k) > 0)
                    l++;
            }
            while( l >= 0 )
            {
                printf("%d", a[l]);
                l--;
            }
            printf("\t");
        }
        printf("\n");
    }
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main(){
    int v1,v2,t,d,sum=0;
    scanf("%d%d%d%d",&v1,&v2,&t,&d);
    while(t--){
        if(v1>v2){
            int temp=v1;
            v1=v2;
            v2=temp;
        }
        sum+=v1;
        v1+=d;
    }
    printf("%d",sum);
    return 0;
}


//Bismillahir rahmanir rahim

#include <stdio.h>
#define lim 62

long long ans=0,ncr[63][63],i,j;

int main(void) {
	// your code goes here
	long long n,m,t;
	scanf("%lld %lld %lld",&n,&m,&t);
	ncr[0][0]=1;
	for(i=1;i<=lim;++i){
	    for(j=0;j<=lim;++j){
	        if(j>i) ncr[i][j]=0;
	        else if(j==i || j==0)   ncr[i][j]=1;
	        else ncr[i][j] = ncr[i-1][j-1] + ncr[i-1][j];
 	    }
	}
	for(i=4;t>i;++i){ 	//printf("%lld\n",ans);
			ans+=ncr[n][i]*ncr[m][t-i];
	}
	printf("%lld",ans);
	return 0;
}


#include <stdio.h>

#define MD	1000000007
#define L	50
#define K	10000

long long dp[L + 1][L + 1];

void init(int k) {
	static long long dq[L + 1][L + 1];
	static int inv[L + 2];
	int i1, i2, i, j;

	for (i = 1; i <= L + 1; i++) {
		long long x = 1;

		while (x % i != 0)
			x += MD;
		inv[i] = x / i % MD;
	}
	for (i = 0; i <= L; i++)
		dp[i][i] = dq[i][i] = 1;
	for (i1 = 0; i1 <= L; i1++)
		for (i2 = i1 + 1; i2 <= L; i2++)
			dq[i1][i2] = (dq[i1][i2] + dq[i1][i2 - 1]) % MD;
	for (j = 1; j <= k; j++)
		for (i1 = 0; i1 <= L; i1++)
			for (i2 = i1; i2 <= L; i2++) {
				dq[i1][i2] = dp[i1][i2] = dq[i1][i2] * inv[i2 + 1] % MD;
				if (i2 > i1)
					dq[i1][i2] = (dq[i1][i2] + dq[i1][i2 - 1]) % MD;
			}
}

int solve(long long a, int cnt) {
	int i, sum;
	long long p;

	a %= MD;
	p = 1;
	sum = 0;
	for (i = 0; i <= cnt; i++) {
		sum = (sum + p * dp[i][cnt]) % MD;
		p = p * a % MD;
	}
	return sum;
}

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

	scanf("%lld%d", &n, &k);
	init(k);
	ans = 1;
	for (a = 2; a <= n / a; a++)
		if (n % a == 0) {
			int cnt = 0;

			while (n % a == 0) {
				n /= a;
				cnt++;
			}
			ans = ans * solve(a, cnt) % MD;
		}
	if (n > 1)
		ans = ans * solve(n, 1) % MD;
	printf("%lld\n", ans);
	return 0;
}


#include<stdio.h>
#include<conio.h>
int main(){
	int w1,h1,w2,h2;
	scanf("%d %d %d %d",&w1,&h1,&w2,&h2);
	printf("%d",2*(w1+h1+h2+2));
	return 0;
}


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

int main()
{
    int a1,a2, a3, a4, a5,n, i;
    scanf("%d %d %d %d %d", &a1, &a2, &a3, &a4, &a5);
    int a= a1+ a2+ a3+ a4+ a5;
    if(((a%5)==0) && (a>0)) printf("%d", (a/5));
    else if (a==0) printf("-1");
    else printf("-1");
    return 0;
}


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

// if we write f(x) = Sum([0,n+1], bi * x^i) and q(x) = Sum([0,n], ai * x^i) and then so multiplication and equate left and right sides:
// b[n+1] = a[n]
// b[i]   = K*a[i] + a[i-1]
// b[0]   = K*a[0] + P
// from here it is easy to see that all ai should be integer (going n+1 -> 0 and knowing that bi are integers)

// TODO: ???
#define MAX_D 5000
static int64_t _a[MAX_D+2] = {}, _b[MAX_D+2] = {};

int main() {
    int64_t P,K; scanf("%" PRId64 " %" PRId64 "\n", &P,&K);

    // offset, to include P as a[-1]
    _a[0] = P; int D = 0;
    for( ; D <= MAX_D ; ++D) {
        // b[i] = K*a[i] + a[i-1] < K
        // say, a[i-1] = x*K+y (y < K), then we can write
        // b[i] = K*(a[i] + x) + y < K, and from there a[i] = -x, and b[i] = y
        // NB we want non-c modulo, but math (where rem is non-negative)
        int64_t x = _a[D] / K, y = _a[D] % K;
        if(y < 0) { y += K, --x; }
        _a[D+1] = -x, _b[D] = y;
        // TODO:
        if(_a[D] == 0) break;
    }

    printf("%d\n", D);
    for(int i = 0 ; i < D ; ++i) printf("%" PRId64 " ", _b[i]);
    printf("\n");
    return 0;
}


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

int main()
{
        char s[100];
        scanf("%s",&s);
        int p=0;
        for(int i=0;s[i]!='\0';i++)
        {
                if(s[i]>p)
                p=s[i];
        }
        for(int i=0;s[i]!='\0';i++)
        {
                if(s[i]==p)
                printf("%c",s[i]);
        }
        return 0;
}


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


#include<stdio.h>
long long dp(int,int,char);
long long dar[1003][102],MOD,powmod[1003],modmod[1003];
int n,k;
int main(){
	int i,j,l;
	scanf("%d %d %d",&n,&k,&i);
	MOD=(long long)i;
	powmod[0]=1%k;
	modmod[0]=1%MOD;
	for(i=1;i<=n;i++){
		powmod[i]=(powmod[i-1]*10)%k;
		modmod[i]=(modmod[i-1]*10)%MOD;
	}
	for(i=0;i<1003;i++){
		for(j=0;j<102;j++){
			dar[i][j]=-1;
		}
	}
	dar[n][0]=1;
	for(i=n-1;i>0;i--){
		dar[i][0]=(9*modmod[n-1-i])%MOD;
	}
	printf("%d\n",(int)dp(0,0,0));
	return 0;
}

long long dp(int dig,int mod,char fl){
	long long toret;
	int i;
	if(dig>n){
		return 0;
	}
	if(fl&&mod==0){
		return dar[dig][0];
	}
	if(fl==0||dar[dig][mod]==-1){
		toret=0;
		toret+=dp(dig+1,mod,fl);
		for(i=1;i<10;i++){
			toret=(toret+dp(dig+1,(mod+i*powmod[dig])%k,1))%MOD;
		}
		if(fl!=0){
			dar[dig][mod]=toret;
		}
	}
	else{
		toret=dar[dig][mod];
	}
	return toret;
}


#include "stdio.h"
#include "string.h"

int main(int argc, char* argv[])
{
    char s[102];
    char s1[]="CODEFORCES";
    scanf("%s",s);
    int len=strlen(s);
    if(len<10)
    {
        printf("NO\n");
        return 0;
    }

    int i,j=0;
    for(i=0;i<len;i++){//从第一个开始匹配,cut掉最后的子串
        if(s[i]!=s1[j])
            break;
        j++;
        if(j==10)
            break;
    }
    if(j==10){
        printf("YES\n");
        return 0;
    }
    j=0;
    for(i=len-10;i<len;i++){//cut掉前面的子串，从最后开始匹配；
        if(s[i]!=s1[j])
            break;
        j++;
        if(j==10)
            break;
    }
    if(j==10)
    {
        printf("YES\n");
        return 0;
    }
    j=0;
    for(i=0;i<len;i++){//cut掉中间的子串；
        if(s[i]==s1[j])
            j++;
        else
            break;
    }
    int leave=10-j;
    if(len-j-leave<=0){
        printf("NO\n");
        return 0;
    }
    for(i=len-leave;i<len;i++){
        if(s[i]!=s1[j]){
            printf("NO\n");
            return 0;
        }
        j++;
    }
    printf("YES\n");

    return 0;
}


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

#define MAX_CHAR 1501

typedef struct node_struct
{
	struct node_struct* map[26];
	int cost;
}node_t;

node_t* add(node_t* current, char c, int isGood, int* result, int k)
{

	if(current->map[c - 'a'] == NULL)
	{
		current->map[c - 'a'] = (node_t*)(malloc(sizeof(node_t)));
		for(int i = 0; i < 26; i++)
			current->map[c - 'a']->map[i] = NULL;

		if(!isGood)
			current->map[c - 'a']->cost = current->cost + 1;
		else
			current->map[c - 'a']->cost = current->cost;

		if(current->map[c - 'a']->cost <= k)
			*result = *result + 1;

		return current->map[c - 'a'];
	}
	else
	{
		return current->map[c - 'a'];
	}
}

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

	n = n * 6;
	if(a * b >= n)
	{
		printf("%lld\n%lld %lld\n", (a*b), a, b);
		return 0;
	}

	if(n%a == 0)
	{
		printf("%lld\n%lld %lld\n", n, a, (n/a));
		return 0;
	}

	if(n%b == 0)
	{
		printf("%lld\n%lld %lld\n", n, (n/b), b);
		return 0;
	}

	long long int naive_guess, a_, b_;
	naive_guess = a * ((n/a) + 1);
	a_ = a;
	b_ = (n/a) + 1;
	if(b * ((n/b) + 1) < naive_guess)
	{
		naive_guess = b * ((n/b) + 1);
		a_ = (n/b) + 1;
		b_ = b;
	}

	int result = 0;
	long long int ans = naive_guess;

	long long int max_ab = a < b ? b : a;
	long long int min_ab = a < b ? a : b;
	for(long long int guess = n; guess < naive_guess; guess++)
	{
		if(result == 1)
			break;

		for(long long int factor = min_ab; factor <= sqrt(guess) + 1; factor++)
		{
			if( guess % factor != 0)
				continue;

			long long int other_factor = guess/factor;
			if(factor >= a && other_factor >= b)
			{
				ans = guess;
				a_ = factor;
				b_ = other_factor;
				result = 1;
				break;
			}
			else if (factor >= b && other_factor >= a)
			{
				ans = guess;
				b_ = factor;
				a_ = other_factor;
				result = 1;
				break;
			}
		}
	}

	printf("%lld\n%lld %lld\n", ans, a_, b_);
}


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

int main(void)
{
    char str[15]={0}, rev[15]={0};
    int i=0, d=0,l=0;

    scanf("%s",str);
    l=strlen(str);
    rev[l]='\0';
    for(i=0;i<l/2;i++){
        rev[i]=str[l-i-1];
        if ( rev[i] != str[i]) d++;
    }
    if(d==1) printf("YES");
    else if(d==0){
        if(l%2 != 0) printf("YES");
        else printf("NO");
    }
    else printf("NO");

    return 0;
}


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

int main(){
int n,v, i, price, cmp;
scanf("%d %d", &n,&v);
price =v; cmp=v+1; i=2;
if(v>=n) price =n-1;
while(cmp <= n){
	if(cmp==n) break;
	price += i;
	cmp++;
	i++;

}
printf("%d", price);

return 0;
}


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

typedef long long ll;

typedef struct {
  ll a,b;
  int c;
} t_t;

/*  n days, m subjects */
int n,m,K;
t_t emne[150];

/*  [i][j][k]: at beginning of day i (0-indexed), j is last course taken
    (1-indexed, 0=no course taken yet), k:last number of exercises=a_j+k */
ll dp[51][52][101];   /*  max exercises so far */
int dp1[51][52][101]; /*  prev j */
int dp2[51][52][101]; /*  prev k */

void solve() {
  int i,j,k,l,nextj,nextk;
  ll diff,nextd,cur,next;
  memset(dp,-1,sizeof(dp));
  memset(dp2,-1,sizeof(dp2));
  memset(dp2,-1,sizeof(dp2));
  dp[0][0][0]=0;
  dp1[0][0][0]=-1;
  dp2[0][0][0]=-1;
  for(i=0;i<n;i++) {
    for(j=0;j<=m;j++) for(k=0;k<101;k++) if(dp[i][j][k]>-1) {
      cur=dp[i][j][k];
      /*  pick next exercise */
/*      if(!j) printf("at day %d, no last course\n",i);
      else printf("at day %d, last course %d, last ex %I64d\n",i,j-1,k+emne[j-1].a);*/
      if(i==0 && j==0) {
        /*  first day, can pick everything */
        for(nextj=0;nextj<m;nextj++) for(nextk=0;nextk<=(int)(emne[nextj].b-emne[nextj].a);nextk++) {
          dp[i+1][nextj+1][nextk]=nextk+emne[nextj].a;
          dp1[i+1][nextj+1][nextk]=k;
          dp2[i+1][nextj+1][nextk]=j;
        }
      } else for(l=0;l<m;l++) if(emne[l].c>emne[j-1].c) {
        /*  difficulty: add k */
        diff=k+emne[j-1].a;
        nextd=diff+K;
        next=cur+nextd;
        if(nextd>=emne[l].a && nextd<=emne[l].b && next>dp[i+1][l+1][(int)(nextd-emne[l].a)]) {
          dp[i+1][l+1][(int)(nextd-emne[l].a)]=next;
          dp1[i+1][l+1][(int)(nextd-emne[l].a)]=k;
          dp2[i+1][l+1][(int)(nextd-emne[l].a)]=j;
/*          printf("  (add) can pick => %d %d %I64d\n",i+1,l,nextd);*/
        }
        /*  difficulty: mul k */
        nextd=diff*K;
        next=cur+nextd;
        if(nextd>=emne[l].a && nextd<=emne[l].b && next>dp[i+1][l+1][(int)(nextd-emne[l].a)]) {
          dp[i+1][l+1][(int)(nextd-emne[l].a)]=next;
          dp1[i+1][l+1][(int)(nextd-emne[l].a)]=k;
          dp2[i+1][l+1][(int)(nextd-emne[l].a)]=j;
/*          printf("  (mul) can pick => %d %d %I64d\n",i+1,l,nextd);*/
        }
      }
    }
  }
}

int fag[100];
ll ex[100];

/*  x: last course (1-indexed), y:last k-value */
void timeplan(int x,int y) {
  int dag=n;
  int i,j;
  while(dag) {
    fag[dag-1]=x;
    ex[dag-1]=y+emne[x-1].a;
    i=dp2[dag][x][y];
    j=dp1[dag][x][y];
    dag--;
    x=i;
    y=j;
  }
  for(i=0;i<n;i++) printf("%d %I64d\n",fag[i],ex[i]);
}

int main() {
  int i,j;
  ll maks=-1;
  int besti=-1,bestj=0;
  scanf("%d %d %d",&n,&m,&K);
  for(i=0;i<m;i++) scanf("%I64d %I64d %d",&emne[i].a,&emne[i].b,&emne[i].c);
  solve();
  for(i=0;i<=m;i++) for(j=0;j<=100;j++) if(dp[n][i][j]>maks) {
    maks=dp[n][i][j];
    besti=i;
    bestj=j;
  }
  if(besti<0) puts("NO");
  else {
    puts("YES");
    timeplan(besti,bestj);
    return 0;
  }
  return 0;
}


#include<stdio.h>
#define maxn 5005
typedef long long ll;
const ll mod=998244353;
int a,b,cc;
ll fac[maxn];
ll c[maxn][maxn];
ll solve(int x,int y)
{
	ll res=0;
	for(int i=0;i<=x && i<=y;i++)
		res=(res+(((fac[i]*c[x][i])%mod)*c[y][i])%mod)%mod;
	return res;
}
int main()
{
	scanf("%d%d%d",&a,&b,&cc);
	fac[0]=1;
	for(int i=1;i<=5000;i++)
	{
		fac[i]=(fac[i-1]*i)%mod;
		c[i][0]=1;c[i][i]=1;
		for(int j=1;j<=i-1;j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod;
	}
	ll ans=1;
	ans=(ans*solve(a,b))%mod;
	ans=(ans*solve(b,cc))%mod;
	ans=(ans*solve(cc,a))%mod;
	printf("%I64d\n",ans);
}


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

#define N	100000

int md;

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

	while (k) {
		if (k & 1)
			p = p * a % md;
		a = a * a % md;
		k >>= 1;
	}
	return p;
}

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

void init() {
	int i;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - md % i] * (md / i + 1) % md;
		ff[i] = (long long) ff[i - 1] * i % md;
		gg[i] = (long long) gg[i - 1] * vv[i] % md;
	}
}

int choose(int n, int k) {
	return k < 0 || k > n ? 0 : (long long) ff[n] * gg[k] % md * gg[n - k] % md;
}

int aa[N], cnt;

void brute(int i, int n) {
	if (i == n) {
		int b, c, d, i, j;

		for (b = 0; b < 1 << n; b++) {
			c = (1 << n) - 1;
			for (i = 0; i < n; i++)
				if ((b & 1 << i) != 0) {
					if ((c & 1 << aa[i]) == 0)
						goto out;
					c &= ~(1 << aa[i]);
				}
			for (i = 0; i < n; i++)
				if ((c & 1 << i) != 0 && (c & 1 << aa[i]) != 0)
					goto out;
			c = 0;
			for (i = 0; i < n; i++) {
				if ((c & 1 << i) != 0)
					continue;
				j = i, d = 0;
				while (((c | d) & 1 << j) == 0)
					d |= 1 << j, j = aa[j];
				if ((c & 1 << j) != 0) {
					c |= d;
					continue;
				}
				c |= d, d = 0;
				while ((d & 1 << j) == 0)
					d |= 1 << j, j = aa[j];
				if ((b & d) == d)
					goto out;
			}
			cnt++;
out:;
		}
		return;
	}
	for (aa[i] = 0; aa[i] < n; aa[i]++)
		if (aa[i] != i)
			brute(i + 1, n);
}

int slow(int n) {
	int k, l, ans;

	ans = 0;
	for (k = 1; k <= n; k++)
		for (l = k; l + k <= n; l++)
			ans = (ans + (long long) choose(n, l + k)
					* ff[l + k] % md
					* gg[k] % md
					* choose(l - 1, k - 1) % md
					* power(n - 1, k) % md
					* power(l, n - l - k)) % md;
	return ans;
}

int main() {
	int n, n1;

	scanf("%d%d", &n1, &md), init();
	for (n = n1; n <= n1; n++) {
#if 0
		cnt = 0, brute(0, n);
		printf("%d\n", cnt);
#else
		printf("%d\n", slow(n));
#endif
	}
	return 0;
}


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


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

// we will consider numbers with <= 10^6 digits. Hence, maximal sum of digits is 9*10^6 < 10^7.
// we can generate all possible sums for excellent numbers:
//   2^n for n digits of a,b and then we need to sum for n = 1..7, meaning that 2^8 - 2 different possible sums:
//   1+2+..+2^[n-1] = 2^n - 1, hence 2+..+2^[n-1] = 2^n - 2
// now for every possible sum we need to solve:
// ax + by = S
// x + y = N
// and this will add binomial(N,x) numbers
// trivially, writing x = N - y, (b - a)y = S - aN

// to calculate binomial coefficients: it is easy to see that we need not that many of them so it will be easier to calculate them independently

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

static int _sd[254] = {};
static void generate_sd(int a, int b) {
    int sd_count = 0;
    for(int i = 1 ; i <= 7 ; ++i) {                // fix number of digits
        for(int j = 0, jn = 1<<i ; j < jn ; ++j) { // enumerate masks
            int n = 0, m = j;
            for(int k = 0, p10 = 1 ; k < i ; ++k, p10 *= 10, m >>= 1)
                n += p10 * (m & 0x1 ? b : a);
            assert(sd_count < 254); _sd[sd_count++] = n;
        }
    }
}

#define MOD 1000000007LL

static inline int64_t factorial_mod(int n) {
    int64_t ret = 1;
    for(int i = 1 ; i <= n ; ++i) ret = (ret*i) % MOD;
    return ret;
}

typedef struct ExtGCD { int64_t a_mul, b_mul, gcd; } ExtGCD;
static inline ExtGCD extended_gcd(uint64_t a, uint64_t b) {
    int64_t u[] = {1,0,a}, v[] = {0,1,b};
    while(v[2] > 0) {
        const int64_t q = u[2]/v[2], t[] = { u[0] - v[0]*q, u[1] - v[1]*q, u[2] - v[2]*q };
        u[0] = v[0], v[0] = t[0], u[1] = v[1], v[1] = t[1], u[2] = v[2], v[2] = t[2];
    }
    return (ExtGCD) {.a_mul = u[0], .b_mul = u[1], .gcd = u[2]};
}
static int64_t inverse_mod(uint64_t n, uint64_t mod) {
    ExtGCD gcd = extended_gcd(n, mod); assert(gcd.gcd == 1);
    return gcd.a_mul < 0 ? gcd.a_mul + mod : gcd.a_mul;
}

static int64_t _NF = 0;
static inline int64_t binomial_mod(int k, int nk) {
    const int64_t kf = factorial_mod(k), nkf = factorial_mod(nk), denom = (kf*nkf) % MOD;
    return (_NF * inverse_mod(denom, MOD)) % MOD;
}

int main() {
    int A,B,N; scanf("%d %d %d\n", &A,&B,&N);
    generate_sd(A,B); _NF = factorial_mod(N);

    int64_t count = 0;
    for(int si = 0 ; si < 254 ; ++si) {
        const int ss = _sd[si] - A*N;
        if(ss % (B-A) == 0) {
            const int y = ss / (B-A), x = N - y;
            if(x >= 0 && y >= 0) {
                count = (count + binomial_mod(y,x)) % MOD;
            }
        }
    }
    printf("%d\n", (int)count);
}


#include<stdio.h>
#include<string.h>
int cmpfunc (const void * a, const void * b)
{
    return ( *(int*)a - *(int*)b );
}

int main()
{
    int n,p=0,m=0,i;
    scanf("%d", &n);
    getchar();
    char a[n];
    for(i=0;i<n;i++)scanf("%c",&a[i]);
    for(i=0;i<n;i++)
    {
        if(a[i]>='A'&&a[i]<='Z')
        {
            p++;
        }
        if(a[i]==' '||i==n-1)
        {
            if(p>m)m=p;
            p=0;
        }
    }printf("%d", m);
}


#include <stdio.h>

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

    int swap;

    for(i = 0;i < m;i++){
        for(j = i;j < m;j++){
            if (v[i] > v[j]) {
                swap = v[j];
                v[j] = v[i];
                v[i] = swap;
            }
        }
    }

    int min = 1000,t;
    int start = 0,end = n-1;
    for(i = n; i <= m; i++) {
        t = v[end] - v[start];
        if (min > t) {
            min = t;
        }
        end++;
        start++;
    }
    printf("%d",min);
    return 0;
}


#include <stdio.h>
#define m 1000000007u
#define lim 5555555
typedef long long unsigned llu;
typedef unsigned u;
u F[lim],G[lim];
int main()
{
	u i,j,k,r=0;
	for(i=1;++i<lim;)
	{
		if(!F[i])for(j=0;(j+=i)<lim;)if(!F[j])F[j]=i;
		j=i/F[i];
		G[i]=(G[j]+j*(llu)((F[i]*(llu)(F[i]-1)>>1)%m))%m;
	}
	for(scanf("%u%u%u",&k,&i,&j);j>=i;--j)r=(G[j]+r*(llu)k)%m;
	printf("%u\n",r);
	return 0;
}


#include <stdio.h>
const long long MOD = 1e9 + 7;
struct A{int first; int second;};
struct A fibp(long long n) {
    long long a = 1, b = 0;
    long long s = 0, r = 1;
    for ( ; n; n >>= 1) {
        if (n & 1) {
            long long na = (a*s + b*r) % MOD;
            long long nb = (a*r + b*s + b*r) % MOD;
            a = na;
            b = nb;
        }
        long long ns = (s*s + r*r) % MOD;
        long long nr = (2*s*r + r*r) % MOD;
        s = ns;
        r = nr;
    }
    struct A res;
    res.first = a;
    res.second = b;
    return res;
}

int powmod(long long a, long long b) {
    long long r = 1;
    for (a %= MOD; b; b >>= 1) {
        if (b & 1) {
            r *= a;
            r %= MOD;
        }
        a *= a;
        a %= MOD;
    }
    return r;
}

int f(long long n, int k) {
    int A[50];
    for (int i = 0; i <= k; ++i) {
        A[i] = powmod(n + i, k);
    }
    struct A ab = fibp(n + 1);
    int a = ab.first, b = ab.second;
    int r = 0;
    for (int lA = k + 1; lA; --lA) {
        a += b; if (a >= MOD) {a -= MOD;}
        b += a; if (b >= MOD) {b -= MOD;}
        r += (long long)A[0] * a % MOD; if (r >= MOD) {r -= MOD;}
        for (int i = 0; i < lA - 1; ++i) {
            A[i] -= A[i + 1]; if (A[i] < 0) {A[i] += MOD;}
        }
    }
    return r;
}

int main(void) {
    long long n;
    int k;
    scanf("%lld%d", &n, &k);
    int ans = f(n + 1, k) - f(1, k); if (ans < 0) {ans += MOD;}
    printf("%d\n", ans);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
long long arr[2000001],brr[2000001],mod=1000000000+7;
char str[2000001],s1[2000001];
int func(const void *a, const void *b)
{
	return (*(int*)a-*(int*)b);
}
long long max(long long a, long long b)
{
	return (a>b)?a:b;
}
long long min(long long a, long long b)
{
	return (a>b)?b:a;
}
long long power(long long  x, long long  int y, long long p)
{
	long long int res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res*x) % p;
		y = y>>1; // y = y/2
		x = (x*x) % p;
	}
	return res;
}
int main()
{
	long long int sum=0,a,b,x,y,n, m,temp,flag=0,index,len, i, j, k, count=0, ans=0;
	scanf("%lld", &n);
	printf("%lld 2\n",2*n-1);
	printf("1 2\n");

	return 0;
}


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

int main()

{
    char col ; long long int row , ans = 0, final= 0, segment = 0;
    scanf("%I64d%ch",&row,&col);
    if( col == 'f')
        final = 1;
    else if(col == 'e')
        final = 2;
    else if(col == 'd')
        final = 3;
    else if(col == 'a')
        final = 4;
    else if(col == 'b')
        final = 5;
    else if(col == 'c')
        final = 6;
    segment = row / 4 ;
    if( row == 4 || ( (segment * 4)  == row ) )
        segment --;

    if(row % 2 == 0 && row % 4 != 0 )
    {
        ans = (segment)*12 + final + (row - 1)*1 + 6;
    }
    else if(row %2 == 0 && (row % 4 == 0 ) )
    {
        ans = (segment)*12 + final + (row - 3)*1 + 6;
    }
    else if(row %2 != 0 && (row + 1) % 4 != 0)
    {
        ans = segment * 12 + final + (row - 1)*1;
    }
    else
        ans = segment * 12 + final + (row - 3)*1;
    printf("%I64d",ans);

}


#include<stdio.h>
int main()
{
    long int a,b,ta,tb,js1,js2,t;
    while(scanf("%ld %ld",&a,&b)!=EOF)
    {
        ta=a;
        tb=b;
        js1=0;
        js2=0;
        while(tb!=0)
        {
            t=ta%tb;
            ta=tb;
            tb=t;
        }
        a/=ta;
        b/=ta;
        js1=b-1;
        js2=a-1;
        if(a>b)js1++;
        else js2++;
        if(js1>js2)printf("Dasha\n");
        else if(js1<js2)printf("Masha\n");
        else if(js1==js2)printf("Equal\n");
    }
    return 0;
}
/*之前总是答案错误，后来发现a和b必须最大公约数是1才行*/


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


#include<stdio.h>
#include<stdlib.h>
#include<String.h>
int main(){
    int num,i,k,j,temp,f=0;
    scanf("%d ",&num);
    temp=num;
    char a[num+1][8];
    for(i=0;i<=num;i++){
  gets(a[i]);
    }
  char b[3],c[3];
strcpy(b,a[0]);

c[0]=a[temp][5];
c[1]=a[temp][6];
c[2]=a[temp][7];

if(temp%2==0)
{
    printf("home");
}

else printf("contest");
}


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

typedef int iii[3];

int main() {
	int i, j, n, m, cnt;
	static iii *ee;
	static int *aa;
	static char *s;

	scanf("%d%d", &n, &m);
	ee = calloc(n + 1, sizeof(*ee));
	aa = malloc(sizeof(*aa) * 4 * n);
	s = malloc((n + 2) * sizeof(*s));
	memset(s + 1, '0', n);
	s[n + 1] = '\0';
	while (m-- > 0) {
		int u, v;

		scanf("%d%d", &u, &v);
		for (j = 0; j < 3; j++)
			if (ee[u][j] == 0) {
				ee[u][j] = v;
				break;
			}
		for (j = 0; j < 3; j++)
			if (ee[v][j] == 0) {
				ee[v][j] = u;
				break;
			}
	}
	for (i = 0; i < n; i++)
		aa[i] = i + 1;
	cnt = n;
	while (cnt > 0) {
		int a, k;

		a = aa[--cnt];
		k = 0;
		for (j = 0; j < 3; j++)
			if (ee[a][j] > 0 && s[a] == s[ee[a][j]])
				k++;
		if (k > 1) {
			s[a] = s[a] == '1' ? '0' : '1';
			for (j = 0; j < 3; j++)
				if (ee[a][j] > 0)
					aa[cnt++] = ee[a][j];
		}
	}
	printf("%s\n", s + 1);
	return 0;
}


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

int compare_function(const void *a,const void *b) {
    int *x = (int *) a;
    int *y = (int *) b;
    return *x - *y;
}

void print_array(int a[], int size) {
    printf("[");
    for (int i = 0; (i < size); i++) {
        printf("%d ", a[i]);
    }
    printf("]\n");
}

int main(void) {
    int len;
    int input;
    int number_paints = 0;
    int in = 0;

    scanf("%d", &len);
    int colors[len];
    int check[len];

    for(int i = 0; i < len; i++) {
        scanf("%d", &input);
        colors[i] = input;
        //printf("EEEE: %d", colors[i]);
    }

    //print_array(colors, len);

    qsort(colors, sizeof(colors)/sizeof(colors[0]), sizeof(colors[0]), compare_function);

    //print_array(colors, len);

    check[0] = colors[0];
    number_paints += 1;

    for (int color_iter = 0; color_iter < len; color_iter++) {
        for (int check_iter = 0; check_iter < number_paints; check_iter++) {
            if (colors[color_iter] % check[check_iter] == 0) {
                 in = 1;
                break;
            }

            else {
                in = 0;
            }

        }
        if (!in) {
            //printf("THIS RUNS\n");
            check[number_paints] = colors[color_iter];
            number_paints += 1;
            in = 1;

        }
        //print_array(check, number_paints);
    }

    printf("%d" , number_paints);

    return 0;

}


//Lagrange kth power sum
//Educational CF R7-F
//https://codeforces.com/contest/622/problem/F
//https://ja.wikipedia.org/wiki/%E3%83%A9%E3%82%B0%E3%83%A9%E3%83%B3%E3%82%B8%E3%83%A5%E8%A3%9C%E9%96%93

#include<stdio.h>
#define mod 1000000007
#define maxdeg 1048576

long long power(long long a,long long b){
  long long x=1,y=a;
  while(b>0){
    if(b&1ll){
      x=(x*y)%mod;
    }
    y=(y*y)%mod;
    b>>=1;
  }
  return x%mod;
}

long long modular_inverse(long long n){
  return power(n,mod-2);
}

long long factorial[maxdeg];
long long invfact[maxdeg];

void cfact(){
  long long i;
  factorial[0]=1;
  factorial[1]=1;
  for(i=2;i<maxdeg;i++){
    factorial[i]=factorial[i-1]*i;
    factorial[i]%=mod;
  }
  invfact[maxdeg-1]=modular_inverse(factorial[maxdeg-1]);
  for(i=maxdeg-2;i>=0;i--){
    invfact[i]=invfact[i+1]*(i+1);
    invfact[i]%=mod;
  }
}

// k...polynominal degree (there must be k+1 data)
// f(i) = a[i] (0 <= i <= k)
// a[i] must be 0 <= a[i] < mod
// return : f(x)
// complexity = O(k log mod)
long long lagrange_liner(long long x,long long k,long long a[]){
  if(x<=k){return a[x];}
  long long i,bsnmr=1,nmr,dmn,res=0,rev=modular_inverse(mod-1),lv;
  for(i=0;i<=k;i++){bsnmr*=(mod+x-i);bsnmr%=mod;}
  for(i=0;i<=k;i++){
    nmr=(bsnmr*modular_inverse((mod+x-i)%mod))%mod;
    dmn=invfact[i]*invfact[k-i];dmn%=mod;
    if((k-i)&1ll){dmn*=rev;dmn%=mod;}
    lv=(nmr*dmn)%mod;
    res+=lv*a[i];
    res%=mod;
  }
  return res;
}

//0^k + 1^k + 2^k + ... + n^k
long long kth_power_sum(long long n,long long k){
  long long i,deg=k+1,a[maxdeg];
  a[0]=0;
  for(i=1;i<=deg;i++){a[i]=a[i-1]+power(i,k);a[i]%=mod;}
  return lagrange_liner(n,deg,a);
}

int main(){
  cfact();
  long long n,k;
  scanf("%lld%lld",&n,&k);
  printf("%lld\n",kth_power_sum(n,k));
  return 0;
}


#include<stdio.h>
int judge(int n)
{
	for(;;)
	{
		if(n%2!=0)
			break;
		n/=2;
	}
	if(n==1)
		return 1;
	else
		return 0;
}
int main()
{
	int n;
	while(scanf("%d",&n) != EOF)
	{
		if(judge(n))
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}


#include<stdio.h>
main()
{

long long int p,q,x,y,movep,movev;

scanf("%I64d%I64d%I64d%I64d",&p,&q,&x,&y);
movep=p+q;
movev=x>=y?x:y;
if(p>=x && q>=y)
    printf("Vasiliy");

else if(x>=p && y>=q)
    printf("Polycarp");

else if(movev>=movep)

       printf("Polycarp");

else if(movev<movep)

       printf("Vasiliy");

}


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

long long int solve(int N)
{
	int i;
	long long int x;
	long long int mod = 1000000007;
	long long int f = 1;
	long long int p = 1;

	for(i=1;i<=N;i++)
	{
		f *= i;
		f %= mod;
	}

	for(i=1;i<N;i++)
	{
		p *= 2;
		p %= mod;
	}

	return (f-p+mod)%mod;
}

int main()
{
	// variable in description
	//int T;
	int N;
	// variable to support
	long long int ans;

	// variable to judge
	int i;
	int j;
	int k;

	scanf("%d",&N);

	ans = solve(N);

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

	return 0;
}


/* practice with Dukkha */
#include <stdio.h>

#define K	2000000
#define MD	1000000007

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 main() {
	static int cc[K + 1], pp[K + 1], dd[K + 1];
	int n, k, a, a2, b, i, ans;

	scanf("%d%d", &n, &k);
	for (a = 2; a <= k; a++) {
		if (cc[a])
			continue;
		for (b = a; b <= k; b += a)
			cc[b]++;
	}
	for (a = 2; (a2 = a * a) <= k; a++)
		for (b = a2; b <= k; b += a2)
			cc[b] = 0;
	for (i = 1; i <= k; i++)
		pp[i] = power(i, n);
	for (a = 2; a <= k; a++) {
		if (cc[a] == 0)
			continue;
		for (i = 1; i * a <= k; i++) {
			int l = i * a, r = (i + 1) * a;
			int p = cc[a] % 2 == 0 ? pp[i] : -pp[i];

			dd[l] = (dd[l] + p) % MD;
			if (r <= k)
				dd[r] = (dd[r] - p) % MD;
		}
	}
	ans = 0;
	for (i = 1; i <= k; i++) {
		int x;

		dd[i] = (dd[i] + dd[i - 1]) % MD;
		x = (pp[i] + dd[i]) % MD;
		if (x < 0)
			x += MD;
		ans = (ans + (x ^ i)) % MD;
	}
	printf("%d\n", ans);
	return 0;
}


#include<stdio.h>
#define m 10*hundreds+tens

int main()
{
    int hundreds, tens, i, x, y;
    scanf("%d %d", &hundreds, &tens);
    for(i=1; (tens>=22) || (hundreds>0 && tens>=12) || (hundreds>=2 && tens>=2); i++)
    {
        if(i%2)
        {
            if(hundreds>=2)
            {
                hundreds-=2;
                tens-=2;
            }
            else if(hundreds>=1)
            {
                hundreds-=1;
                tens-=12;
            }
            else
            {
                tens-=22;
            }
        }
        else
        {
            if(tens>=22)
            {
                tens-=22;
            }
            else if(tens>=12)
            {
                tens-=12;
                hundreds-=1;
            }
            else
            {
                tens-=2;
                hundreds-=2;
            }
        }
    }
    if(i%2) printf("Hanako");
    else printf("Ciel");
    return 0;
}


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

int main(void)
{
    long long x, y, z, k;

    scanf("%I64d%I64d%I64d%I64d", &x, &y, &z, &k);

    long long a = 1, b = 1, c = 1;
    int i = 0;
    while(i < k)
    {
        if(i < k && x > 1)
        {
            x--;
            a++;
            i++;
        }
        if(i < k && y > 1)
        {
            y--;
            b++;
            i++;
        }
        if(i < k && z > 1)
        {
            z--;
            c++;
            i++;
        }
        if(x == 1 && y == 1 && z == 1)
            i = k;
    }

    printf("%I64d", a * b * c);

    return 0;
}


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

#define LMT 105

char work[LMT];
int len, n, dp[2][LMT << 1][LMT][52];

int
max (int x, int y)
{
  return x > y ? x : y;
}

int
dfs (int dre, int pos, int i, int cn)
{
  if (cn < 0)
    return 0;

  if (!work[i])
    return cn > 0 ? 0 : abs (pos);

  if (dp[dre][pos + 100][i][cn] != -1)
    return dp[dre][pos + 100][i][cn];

  int mv = dre ? 1 : -1;
  int x = dfs (dre, pos + mv, i + 1, cn - (work[i] != 'F'));
  int y = dfs (!dre, pos, i + 1, cn - (work[i] != 'T'));
  dp[dre][pos + 100][i][cn] = max (x, y);
  return dp[dre][pos + 100][i][cn];
}

int
main ()
{
  int ans = 0;
  scanf ("%s%d", work, &n);
  memset (dp, -1, sizeof (dp));
  for (; n >= 0; n -= 2)
    ans = max (ans, dfs (1, 0, 0, n));
  printf ("%d\n", ans);
  return 0;
}


#include<stdio.h>

int determine(int set1, int set2, int set4,int n)
{
	int temp = set2 - 2 * n;
	int x;
	if (temp > set1)
		x = set4 + set1 + (temp - set1 + 1) * 2 / 3;
	else
		x = set4 + temp + (set1 - temp + 1) / 2;
	if (x <= n)
		return 1;
	else
		return 0;
}

int main()
{
	int n, k, i, set1, set2, set4, temp;
	scanf("%d %d", &n, &k);
	set1 = 0;
	set2 = 0;
	set4 = 0;
	for (i = 0; i < k; i++) {
		scanf("%d", &temp);
		set4 += temp / 4;
		temp %= 4;
		set2 += temp / 2;
		temp %= 2;
		set1 += temp;
	}
	if (set1 * 2 + set2 * 2 + set4 * 4 <= n * 8 && determine(set1, set2, set4, n))
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


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

#define NUMSIZE 15

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

int main()
{
	/* 4 -- ����� ����� ������� ������ ������ (��� 8 � 9) */
	char a[NUMSIZE + 1], x[4 * NUMSIZE + 1] = "", strchg[][8] = {"", "", "2", "3", "322", "5", "53", "7", "7222", "7332"};
	int i;

	scanf ("%*d\n");
	gets (a);

	for (i = 0; a[i]; i++)
		strcat (x, strchg[a[i] - '0']);

	qsort (x, strlen(x), 1, cmp);

	puts (x);

	return 0;
}