#include<stdio.h>
#include<math.h>
double f(int a)
{
	if(a>=0)
	{
		return sqrt(a)+5*pow(a,3);
	}
	else
	{
		return sqrt(-a)+5*pow(a,3);
	}
}
int main()
{
	double b;
	int i,j,arr[11];
	for(i=0;i<11;i++)
	{
		scanf("%d",&arr[i]);
	}
	for(i=10;i>=0;i--)
	{
		j=arr[i];
		b=f(arr[i]);
		if(b>400)
		{
			printf("f(%d) = MAGNA NIMIS!\n",j);
		}
		else
		{
			printf("f(%d) = %0.2f\n",j,b);
		}
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
double f(double a)
{
	if(a>=0)
	{
		return sqrt(a)+5*pow(a,3);
	}
	else
	{
		return sqrt(-a)+5*pow(a,3);
	}
}
int main()
{
	double b,arr[11];
	int i,j;
	for(i=0;i<11;i++)
	{
		scanf("%lf",arr[i]);
	}
	for(i=10;i>=0;i--)
	{
		j=arr[i];
		b=f(arr[i]);
		if(b>400)
		{
			printf("f(%d)=MAGNA NIMIS!\n",j);
		}
		else
		{
			printf("f(%d)=%0.2f\n",j,b);
		}
	}
	return 0;
}


#include<stdio.h>
#include<math.h>
double f(int a)
{
	if(a>=0)
	{
		return sqrt(a)+5*pow(a,3);
	}
	else
	{
		return sqrt(-a)+5*pow(a,3);
	}
}
int main()
{
	double b;
	int i,j,arr[11];
	for(i=0;i<11;i++)
	{
		scanf("%d",arr[i]);
	}
	for(i=10;i>=0;i--)
	{
		j=arr[i];
		b=f(arr[i]);
		if(b>400)
		{
			printf("f(%d)=MAGNA NIMIS!\n",j);
		}
		else
		{
			printf("f(%d)=%0.2f\n",j,b);
		}
	}
	return 0;
}


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

#define cL while (getchar() != '\n')  //clear line
#define fi(x) for (i = 0; i < x; i++)
#define fj(x) for (j = 0; j < x; j++)
#define FOR(a, b, c) for (int(a) = (b); (b) < (c) ? (a) <= (c) : (a) >= (c); (b) < (c) ? (a)++ : (a)--)
#define LL long long
#define min(a, b) (a > b ? b : a)
#define max(a, b) (a < b ? b : a)
#define pf printf
#define sf scanf

int main() {
    LL i, j;
    scanf("%lld%lld", &i, &j);
    char a[2000], b[2000];
    memset(b, 0, sizeof(b));
    memset(a, 0, sizeof(a));
    LL p1 = 0, p2 = 0, k = 0, a1 = i, a2 = j;
    if (i == j) {
        printf("YES");
        return 0;
    }
    if (i == 0 || j % 2 == 0) {
        printf("NO");
        return 0;
    }
    while (i) {
        a[++p1] = i % 2 + 97, k -= i % 2;
        i /= 2;
    }
    while (j) {
        b[++p2] = j % 2 + 97, k += j % 2;
        j /= 2;
    }
    int k1 = strstr(b + 1, a + 1);
    if (k1) {
        if (p2 - p1 == k) {
            printf("YES");
            return 0;
        }
    }
    FOR(i, 1, p1 / 2) {
        char tmp;
        tmp = a[i], a[i] = a[p1 + 1 - i], a[p1 + 1 - i] = tmp;
    }
    k1 = strstr(b + 1, a + 1);
    if (k1) {
        if (p2 - p1 == k) {
            printf("YES");
            return 0;
        }
    }

    p1 = 0, p2 = 0, k = 0;
    i = a1, j = a2;
    memset(b, 0, sizeof(b));
    memset(a, 0, sizeof(a));

    while (i % 2 == 0)
        i /= 2;
    while (i) {
        a[++p1] = i % 2 + 97, k -= i % 2;
        i /= 2;
    }
    while (j) {
        b[++p2] = j % 2 + 97, k += j % 2;
        j /= 2;
    }
    k1 = strstr(b + 1, a + 1);
    if (k1) {
        if (p2 - p1 == k) {
            printf("YES");
            return 0;
        }
    }
    FOR(i, 1, p1 / 2) {
        char tmp;
        tmp = a[i], a[i] = a[p1 + 1 - i], a[p1 + 1 - i] = tmp;
    }
    k1 = strstr(b + 1, a + 1);
    if (k1) {
        if (p2 - p1 == k) {
            printf("YES");
            return 0;
        }
    }
    printf("NO");
    return 0;
}


#include <stdio.h>

#define N	62

long long rev(long long x) {
	long long y = 0;

	while (x) {
		y = y << 1 | (x & 1);
		x >>= 1;
	}
	return y;
}

long long padded(long long a, long long b) {
	return a % b == 0 && ((a / b) & (a / b - 1)) == 0;
}

int main() {
	static int yy[N];
	long long x, y, z;
	int n, l, r, i;

	scanf("%lld%lld", &x, &y);
	if (x == y) {
		printf("YES\n");
		return 0;
	}
	if ((y & 1) == 0) {
		printf("NO\n");
		return 0;
	}
	n = 0;
	while (y)
		yy[n++] = y & 1, y >>= 1;
	for (l = 0; l < n; l++) {
		for (r = n - 1; r >= l; r--) {
			if (yy[l] == 0 && yy[r] == 0)
				break;
			else if (yy[l] == 0) {
				z = 0;
				for (i = r; i >= l; i--)
					z = z << 1 | yy[i];
				if (x == z) {
					printf("YES\n");
					return 0;
				}
			} else if (yy[r] == 0) {
				z = 0;
				for (i = l; i <= r; i++)
					z = z << 1 | yy[i];
				if (x == z) {
					printf("YES\n");
					return 0;
				}
				break;
			} else {
				z = 0;
				for (i = l; i <= r; i++)
					z = z << 1 | yy[i];
				if (padded(x, z) || padded(x, rev(z))) {
					printf("YES\n");
					return 0;
				}
			}
		}
		if (yy[l] == 0)
			break;
	}
	printf("NO\n");
	return 0;
}


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

char *reverse(char *px) {
  int n = strlen(px);
  char *perm = malloc(sizeof(char) * (n+1));
  for (int i = 0; i < n; i++)
    perm[i] = px[n-1-i];
  perm[n] = '\0';
  return perm;
}

char *gen(long long a) {
  char *perm = malloc(sizeof(char) * 100);
  int i = 0;
  while (a) {
    if (a & 1) perm[i++] = '1';
    else perm[i++] = '0';
    a >>= 1;
  }
  perm[i] = '\0';
  return reverse(perm);
}

int check(char *y, char *x) {
  char *yy = malloc(sizeof(char) * 100), *xx = malloc(sizeof(char) * 100), one[100], temp[100];
  strcpy(xx, x), strcpy(yy, y);
  for (int i = 0; i < 100; i++) one[i] = '1';

  char *str = strstr(yy, xx);
  int len = strlen(xx), i;
  if (str != NULL) {
    strncpy(temp, str, len);
    strncpy(str, one, len);
    for (i = 0; yy[i] != '\0'; i++)
      if (yy[i] != '1') break;
    strncpy(str, temp, len);

    if (yy[i] == '\0') return 1;
  }

  xx = reverse(xx);

  str = strstr(yy, xx);
  if (str != NULL) {
    strncpy(temp, str, len);
    strncpy(str, one, len);
    for (i = 0; yy[i] != '\0'; i++)
      if (yy[i] != '1') break;
    strncpy(str, temp, len);

    if (yy[i] == '\0') return 1;
  }

  return 0;
}

int main() {
  long long x, y;
  scanf("%"PRId64"%"PRId64"", &x, &y);
  int found = (x == y);
  char *permX = gen(x), *permY = gen(y);
  x = strlen(permX), y = strlen(permY);

  if (permX[x-1] == '1') {
    found |= check(permY, permX);
  }
  else {
    permX[x] = '1', permX[x+1] = '\0';
    found |= check(permY, permX);
    while (permX[x-1] == '0') permX[--x] = '\0';
    found |= check(permY, permX);
  }

  puts(found ? "YES" : "NO");

  return 0;
}


#define __USE_MINGW_ANSI_STDIO 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define maxN 65

char str[maxN];
char tmpstr[maxN];
char tgt[maxN];

int zeroCnt(char *str) {
    int ctr = 0;
    for (int i = strlen(str) - 1; i >= 0; --i) {
        if (str[i] == '0') ++ctr;
    }
    return ctr;
}

void trim(char *str) {
    for (int i = strlen(str) - 1; i >= 0; --i) {
        if (str[i] == '1') break;
        else str[i] = '\0';
    }
}

static inline void cswap(char *a, char *b) {
    char tmp = *a;
    *a = *b;
    *b = tmp;
    return;
}

void reverse(char *str) {
    int p = 0, q = strlen(str) - 1;
    for (; p < q; ++p, --q) {
        cswap(&str[p], &str[q]);
    }
}

// bin
#define lltoa(a, b) _lltoa(a, b)
void _lltoa(long long num, char *dest) {
    int len = 0;
    while (num) {
        if (num % 2 == 0) dest[len++] = '0';
        else dest[len++] = '1';
        num /= 2;
    }
    dest[len] = '\0';
    reverse(dest);
}

void testcase() {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    lltoa(a, str);
    lltoa(b, tgt);
    // Orig string: Either equal, or at least a 1 on the right, and any amount of 1s on the left and right after.
    if (strcmp(tgt, str) == 0) { printf("YES\n"); return; }
    // Make sure at least one 1 is on the right.
    strcpy(tmpstr, str);
    int len = strlen(tmpstr);
    if (tmpstr[len - 1] == '0') {
        tmpstr[len++] = '1';
        tmpstr[len] = '\0';
    }
    if (strstr(tgt, tmpstr) && zeroCnt(tgt) == zeroCnt(tmpstr)) { printf("YES\n"); return; }
    // This flipped +1 string must also be used to match.
    reverse(tmpstr);
    if (strstr(tgt, tmpstr) && zeroCnt(tgt) == zeroCnt(tmpstr)) { printf("YES\n"); return; }

    // 2 flips performed: Completely trimmed. Add any amount of 1s to the left or right.
    trim(str);
    if (strstr(tgt, str) && zeroCnt(tgt) == zeroCnt(str)) { printf("YES\n"); return; }

    // 1 flip performed. Both sides start and end with a 1. Add any amounts of 1 left and right.
    reverse(str);
    trim(str);
    if (strstr(tgt, str) && zeroCnt(tgt) == zeroCnt(str)) { printf("YES\n"); return; }
    printf("NO\n");

    return;
}

int main() {
    testcase();
    return 0;
}


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

int count(long long a) {
  int n = 0;
  while (a) {
    n += !!(a&1);
    a >>= 1;
  }
  return n;
}

char *gen(long long a) {
  char *perm = malloc(sizeof(char) * count(a));
  int i = 0;
  perm[i] = '0';
  while (a) {
    if (a & 1) perm[++i] = '0';
    else perm[i]++;
    a >>= 1;
  }
  perm[i] = '\0';
  return perm;
}

char *reverse(char *px) {
  char *perm = malloc(sizeof(char) * px[0]);
  int n = strlen(px);
  for (int i = 0; i < n; i++)
    perm[i] = px[n-1-i];
  perm[n] = '\0';
  return perm;
}

int check(char *y, char *x) {
  char *str = strstr(y, x);
  if (str == NULL) return 0;
  char a[28] = "000000000000000000000000000", temp[27];
  int len = strlen(x);
  strncpy(temp, str, len);
  strncpy(str, a, len);
  for (int i = 0; y[i] != '\0'; i++)
    if (y[i] != '0' && y[i] != '1') return 0;

  strncpy(str, temp, len);
  return 1;
}

int main() {
  long long x, y;
  scanf("%"PRId64"%"PRId64"", &x, &y);
  char *permX = gen(x), *permY = gen(y);
  int found = check(permY, permX);
  found |= check(permY, permX+1);
  permX = reverse(permX);
  found |= check(permY, permX);
  puts(found ? "YES" : "NO");

  return 0;
}


#include <stdio.h>

long long K=998244353;

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

long long pmod(long long a, long long n, long long b){
    long long c = 1, i, pows[40], prod;

    prod = 1;
    pows[0]=a;

    for( i =1; i < 40; i++ )
        pows[i] = (pows[i-1] * pows[i-1])%b;

    i = 0;
    while(n > 0){
        if( n % 2 == 1)
            prod = (prod*pows[i])%b;

        n=n/2;
        i++;
    }
    return prod % b;
}

long long binom(long long n, long long k){
    long long prod1, i, prod2;
    k = min(k, n-k);
    prod1 = 1;
    prod2 = 1;
    for( i =  1; i <= k; i++ ) {
        prod1 = (prod1 * i)%K;
        prod2 = (prod2 * (i + n-k ) )%K;
    }
    return (prod2 * pmod(prod1, K-2, K)) % K;
}

void solve(int n, int k){
    long long sum, i;
    if( k > n ){
        printf("0\n");
        return;
    }
    if( k == n ){
        printf("1\n");
        return;
    }
    if( k == 1 ){
        printf("%lld\n", n% K);
        return;
    }
    sum = binom(n-1,k-1 )%K;
    for( i = 2; i <= n/k; i++ )
        sum = (sum + binom(n/i - 1, k-1))%K;

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

int main(){
    long long n, k;
    scanf("%lld", &n);
    scanf("%lld", &k);
    solve(n,k);
    return 0;
}


#include<stdio.h>
long long int fact[500005];
long long int modpow(long long int a, long long int n, long long int p)
{
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * a % p;
		a = a * a % p;
		n /= 2;
	}
	return res;
}
long long int comb(long long int n, long long int r, long long int p)
{
	long long int res = fact[n];
	res = res * modpow(fact[r], p - 2, p) % p;
	res = res * modpow(fact[n - r], p - 2, p) % p;
	return res;
}
int main()
{
	long long int n, k;
	scanf("%lld %lld", &n, &k);
	long long int p = 998244353;
	long long int ans = 0;
	long long int i;
	fact[0] = 1;
	for (i = 1; i <= n; i++)
		fact[i] = fact[i - 1] * i % p;
	for (i = 1; n / i >= k; i++)
		ans = (ans + comb(n / i - 1, k - 1, p)) % p;
	printf("%lld\n", ans);
	return 0;
}


#include "stdbool.h"
#include "stdio.h"
#include "stdint.h"
#include "string.h"
#include "ctype.h"
#include "stdlib.h"
#include "math.h"

#define PI 3.14159265358979323846264338327950288
#define ll long long
#define MOD 998244353
#define N 500100
#define MAX1 101
#define rep(i,n) for (int i=0; i<n; i++)
#define mul(a,b) ((a*b) % MOD)

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

int t, n, m;
ll a[N], b[N];

ll _pow(int i, int p) {

    ll ans = 1, x = i;
    for (; p; p>>=1) {
        if (p&1) ans = mul(ans, x);
        x = mul(x, x);
    }
    return ans;
}

int main() {
    scanf("%d%d", &n, &m);
    a[0] = b[0] = 1;
    for (int i=1; i<=n; i++) {
        a[i] = mul(a[i-1], i);
        b[i] = mul(b[i-1], _pow(i,MOD-2));
    }
    ll ans = 0;
    for (int i=1; n/i>=m; i++) {
        ans += mul(mul(a[n / i - 1], b[m - 1]), b[n / i - m]);
        if (ans >= MOD) ans -= MOD;
    }
    printf("%lld", ans);
}


#include <stdio.h>
#define N 1002
#define MOD 1000000007

typedef long long typec;

int n, m, k;
typec ftable[N];
typec facmod[1000001];

typec extend_gcd(typec a, typec b, typec *x, typec *y)
{
	if(!b) return *x = 1, *y = 0, a;
	typec res = extend_gcd(b, a % b, x, y), tmp = *x;
	*x = *y, *y = tmp - (a / b) * (*y);
	return res;
}

typec inverse(typec a, typec m)
{
	typec x, y;
	y = extend_gcd(a, m, &x, &y);
	while(x < 0) x += m;
	return x;
}

typec pow_mod(typec x, typec k, typec m)
{
	typec res = 1;
	while(x %= m, k) {
		if(k&1) res *= x, res %= m;
		x *= x, k >>= 1;
	}
	return res;
}

int mymin(int x, int y)
{
	return x < y? x : y;
}

typec combines(int i, int j)
{
	if(i < j) return 0;
	return facmod[i] * inverse(facmod[j], MOD) % MOD * inverse(facmod[i - j], MOD) % MOD;
}

void init()
{
	int i, j;
	facmod[0] = 1;
	for(i = 1; i <= 1000000; i++) {
		facmod[i] = facmod[i - 1] * i;
		facmod[i] %= MOD;
	}
	typec sum = 0;
	ftable[1] = 1;
	for(i = 2; i <= n; i++) {
		ftable[i] = pow_mod(i, n, MOD) + MOD;
		sum = 0;
		for(j = 1; j < i; j++) {
			sum += combines(i, j) * ftable[j] % MOD;
			sum %= MOD;
		}
		ftable[i] -= sum;
		ftable[i] %= MOD;
	}
}

typec calc()
{
	int i, j, m1, m2;
	typec res = 0, tmp, stmp;
	m1 = mymin(n, k);
	for(i = 0; i <= m1; i++) {
		tmp = combines(k, i) * pow_mod(i, (m - 2) * n, MOD) % MOD;
		m2 = mymin(n - i, (k - i) / 2);
		stmp = 0;
		for(j = 0; j <= m2; j++) {
			if(!i && !j) continue;
			stmp += combines(k - i, j) * combines(k - i - j, j) % MOD * ftable[i + j] % MOD * ftable[i + j] % MOD;
			stmp %= MOD;
		}
		res += tmp * stmp % MOD;
		res %= MOD;
	}
	return res;
}
int main()
{
	scanf("%d%d%d", &n, &m, &k);
	if(m == 1) {
		printf("%d\n", (int)pow_mod(k, n, MOD));
		return 0;
	}
	init();
	printf("%d\n", (int)calc());
	return 0;
}


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

#define N	1000
#define K	1000000
#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() {
	static int dp[N + 1], ff[K + 1], gg[K + 1];
	int n, m, k, i, c, a;
	long long f, ans;

	scanf("%d%d%d", &n, &m, &k);
	if (m == 1) {
		printf("%lld\n", power(k, n));
		return 0;
	}
	dp[0] = 1;
	for (i = 0; i < n; i++) {
		for (c = n; c >= 1; c--)
			dp[c] = (long long) (dp[c] + dp[c - 1]) * c % MD;
		dp[0] = 0;
	}
	f = 1;
	for (i = 0; i <= k; i++) {
		gg[i] = power(ff[i] = f, MD - 2);
		f = f * (i + 1) % MD;
	}
	ans = 0;
	for (c = m == 2 ? 0 : 1; c <= n && c <= k; c++)
		for (a = 0; a + c <= n && a + a + c <= k; a++) {
			long long cnt = (long long) ff[k] * gg[a] % MD * gg[a] % MD * gg[c] % MD
				* gg[k - a - a - c] % MD * dp[a + c] % MD * dp[a + c] % MD;

			if (m > 2)
				cnt = cnt * power(c, (m - 2) * n) % MD;
			ans += cnt;
		}
	ans %= MD;
	if (ans < 0)
		ans += MD;
	printf("%lld\n", ans);
	return 0;
}


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

#define N	1000
#define K	1000000
#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() {
	static int dp[N + 1], ff[K + 1], gg[K + 1];
	int n, m, k, i, c, a;
	long long f, ans;

	scanf("%d%d%d", &n, &m, &k);
	if (m == 1) {
		printf("%lld\n", power(k, n));
		return 0;
	}
	dp[0] = 1;
	for (i = 0; i < n; i++) {
		for (c = n; c >= 1; c--)
			dp[c] = (long long) (dp[c] + dp[c - 1]) * c % MD;
		dp[0] = 0;
	}
	f = 1;
	for (i = 0; i <= k; i++) {
		gg[i] = power(ff[i] = f, MD - 2);
		f = f * (i + 1) % MD;
	}
	ans = 0;
	for (c = m == 2 ? 0 : 1; c <= n && c <= k; c++)
		for (a = 0; a + c <= n && a + a + c <= k; a++) {
			long long cnt = (long long) ff[k] * gg[a] % MD * gg[a] % MD * gg[c] % MD
				* gg[k - a - a - c] * dp[a + c] % MD * dp[a + c] % MD;

			if (m > 2)
				cnt = cnt * power(c, (m - 2) * n) % MD;
			ans += cnt;
		}
	ans %= MD;
	if (ans < 0)
		ans += MD;
	printf("%lld\n", ans);
	return 0;
}


#include <stdio.h>
#define N 1002
#define MOD 1000000007

typedef long long typec;

int n, m, k;
typec ftable[N];
typec facmod[1000001];

typec extend_gcd(typec a, typec b, typec *x, typec *y)
{
	if(!b) return *x = 1, *y = 0, a;
	typec res = extend_gcd(b, a % b, x, y), tmp = *x;
	*x = *y, *y = tmp - (a / b) * (*y);
	return res;
}

typec inverse(typec a, typec m)
{
	typec x, y;
	y = extend_gcd(a, m, &x, &y);
	while(x < 0) x += m;
	return x;
}

typec pow_mod(typec x, typec k, typec m)
{
	typec res = 1;
	while(x %= m, k) {
		if(k&1) res *= x, res %= m;
		x *= x, k >>= 1;
	}
	return res;
}

int mymin(int x, int y)
{
	return x < y? x : y;
}

typec combines(int i, int j)
{
	if(i < j) return 0;
	return facmod[i] * inverse(facmod[j], MOD) % MOD * inverse(facmod[i - j], MOD) % MOD;
}

void init()
{
	int i, j;
	facmod[0] = 1;
	for(i = 1; i <= 1000000; i++) {
		facmod[i] = facmod[i - 1] * i;
		facmod[i] %= MOD;
	}
	typec sum = 0;
	ftable[1] = 1;
	for(i = 2; i <= n; i++) {
		ftable[i] = pow_mod(i, n, MOD) + MOD;
		sum = 0;
		for(j = 1; j < i; j++) {
			sum += combines(i, j) * ftable[j] % MOD;
			sum %= MOD;
		}
		ftable[i] -= sum;
		ftable[i] %= MOD;
	}
}

typec calc()
{
	int i, j, m1, m2;
	typec res = 0, tmp, stmp;
	m1 = mymin(n, k);
	for(i = 0; i <= m1; i++) {
		tmp = combines(k, i) * pow_mod(i, (m - 2) * n, MOD) % MOD;
		m2 = mymin(n - i, (k - i) / 2);
		stmp = 0;
		for(j = 0; j <= m2; j++) {
			if(!i && !j) continue;
			stmp += combines(k - i, j) * combines(k - i - j, j) % MOD * ftable[i + j] % MOD * ftable[i + j] % MOD;
			stmp %= MOD;
		}
		res += tmp * stmp % MOD;
		res %= MOD;
	}
	return res;
}
int main()
{
	scanf("%d%d%d", &n, &m, &k);
	init();
	printf("%lld\n", calc());
	return 0;
}


#include<stdio.h>
int main()
{
	int n,w[105]={},W,i,j,t;
	scanf("%d",&n);
	n*=2;
	for (i=0;i<n;i++)
		scanf("%d",&w[i]);
	for (i=0;i<n-1;i++)
		for (j=0;j<n-i-1;j++)
			if (w[j]>w[j+1])
			{
				t=w[j];
				w[j]=w[j+1];
				w[j+1]=t;
			}
	int copy[105]={};
	void cp(int wo1,int wo2)
	{
		int k;
		for (k=0;k<n;k++)
			if (k!=wo1&&k!=wo2)
				copy[k]=w[k];
			else
				copy[k]=-1;
	}
	int sumup()
	{
		int last=-1;
		int s=0,k;
		for (k=0;k<n;k++)
			if (copy[k]!=-1)
				if (last==-1)
					last=copy[k];
				else
				{
					s+=copy[k]-last;
					last=-1;
				}
		return s;
	}
	int min=999999999,temp;
	for (i=0;i<n;i++)
		for (j=i;j<n;j++)
			if (i!=j)
			{
				cp(i,j);
				temp=sumup();
				if (temp<min)
					min=temp;
			}
	printf("%d\n",min);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define INF 1000000007
int cmp(const void * a, const void * b) {
    return *(int *)a - *(int *)b;
}
int main() {
    int n;
    int s[105];
    scanf("%d", &n);

    for (int i = 0; i < 2 * n; i++)
        scanf("%d", s + i);
    qsort(s, 2 * n, sizeof(int), cmp);
    int ans = INF;
    for (int i = 0; i < 2 * n - 1; i++) {
        for (int j = i + 1; j < 2 * n; j++) {
            int m = 0;
            int mid = 0;
            int a, b;
            while (1) {
                a = m++;
                while (a == i || a == j)
                    a = m++;
                b = m++;
                while (b == i || b == j)
                    b = m++;
                if (m > 2 * n)
                    break;
                mid += s[b] - s[a];
            }
            if (ans > mid)
                ans = mid;
        }
    }
    printf("%d\n", ans);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int compare(const void *a, const void *b)
{
    if (*(long *)a < *(long *)b)
        return -1;
    else
        return 1;
}
int main()
{
    long n,i,a[50],j,bit=1e9+7,k;
    scanf("%ld",&n);
    for(i=0;i<2*n;i++)
        scanf("%ld",&a[i]);
    qsort(a,2*n,sizeof(long),compare);
    for(i=0;i<2*n;i++)
        for(j=i+1;j<2*n;j++)
        {
            k=0;
            long temp=0,z=0;
            for(z=1;z<=n-1;z++)
            {
                while(k==i || k==j)
                    k++;
                temp-=a[k];
                k++;
                while(k==i || k==j)
                    k++;
                temp+=a[k];
                k++;
            }
            if(temp<bit)
                bit=temp;
        }
    printf("%ld\n",bit);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int compare(const void *a, const void *b)
{
    if (*(long *)a < *(long *)b)
        return -1;
    else
        return 1;
}
int main()
{
    long n,i,a[50],j,bit=200000007,k,N,u;
    scanf("%ld",&n);
    N=2*n;
    u=n-1;
    for(i=1;i<=N;i++)
        scanf("%ld",&a[i]);
    qsort(a+1,N,sizeof(long),compare);
    for(i=1;i<N;i++)
        for(j=i+1;j<=N;j++)
        {
            k=1;
            long temp=0,z;
            for(z=1;z<=u;z++)
            {
                while(k==i || k==j)
                    k++;
                temp-=a[k];
                k++;
                while(k==i || k==j)
                    k++;
                temp+=a[k];
                k++;
            }
            if(temp<bit)
                bit=temp;
        }
    printf("%ld\n",bit);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int compare(const void *a, const void *b)
{
    if (*(long *)a < *(long *)b)
        return -1;
    else
        return 1;
}
int main()
{
    long n,i,a[50],j,bit=200000007,k,N,u,temp,z;
    scanf("%ld",&n);
    N=2*n;
    u=n-1;
    for(i=1;i<=N;i++)
        scanf("%ld",&a[i]);
    qsort(a+1,N,sizeof(long),compare);
    for(i=1;i<N;i++)
        for(j=i+1;j<=N;j++)
        {
            k=1;
            temp=0;
            z=0;
            for(z=1;z<=u;z++)
            {
                while(k==i || k==j)
                    k++;
                temp-=a[k];
                k++;
                while(k==i || k==j)
                    k++;
                temp+=a[k];
                k++;
            }
            if(temp<bit)
                bit=temp;
        }
    printf("%ld\n",bit);
    return 0;
}


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

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

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

void wqsb() {
	puts("-1");
	exit(0);
}

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

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

	return 0;
}


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

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

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

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

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

	return 0;
}


#include <stdio.h>
#define N 202002
int v[N];
int ty[3][N];
int mk[N];
int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    for(int e = 0;e  < n; e++) scanf("%d", v + e);
    for(int e = 0; e < n; e++){
        char c;
        scanf(" %c", &c);
        if(c == 'W') ty[0][v[e]]++;
        if(c == 'O') ty[1][v[e]]++;
        if(c == 'R') ty[2][v[e]]++;
    }
    // red with withe is bad
    int res = -1;
    for(int e = 0; e < 3; e++){
        for(int f = e + 1; f < 3; f++){
            if(e == 0 && f == 2) continue;
            int tk0 = 0, tk1 = 0, sum = 0;
            for(int g = N-1; g >= 0; g--){
                int cp = ty[e][g];
                while(tk0 < k - 1 && tk0 + tk1 < k && cp > 0){
                    cp--;
                    tk0++;
                    sum += g;
                }
                cp = ty[f][g];
                while(tk1 < k - 1 && tk0 + tk1 < k && cp > 0){
                    cp--;
                    tk1++;
                    sum += g;
                }
            }
            if(tk0 + tk1 == k)
                if(res < sum) res = sum;
        }
    }
    printf("%d\n", res);
    return 0;
}


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

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

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

void wqsb() {
	puts("-1");
	exit(0);
}

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

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

	return 0;
}


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

int grundy[100100], mini[100100];

int solve(int n){
  int i,j,k;
  int m;
  int up, down;
  int chk[1000];
  int fin = 0;

  if(grundy[n]>=0) return grundy[n];
  mini[n] = -1;

  rep(i,1000) chk[i]=0;

  for(k=2;;k++){
    up = 2*n - k*k + k;
    down = 2*k;

    if(up < down) break;
    if(up%down) continue;

    m = 0;
    up /= down;
    rep(i,k) m ^= solve(up+i);
    if(m<1000) chk[m] = 1;

    if(m==0 && fin==0) fin=1, mini[n] = k;
  }

  rep(i,1000) if(chk[i]==0) break;
  return grundy[n] = i;
}

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

  rep(i,100100) grundy[i] = -1;

  while(scanf("%d",&n)==1){
    solve(n);
    printf("%d\n",mini[n]);
  }

  return 0;
}


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

int n;
int mi[10][10], mx[10][10], ac[10][10];
int ind[10];
int now[10];

int res, res_cost;

void solve(int a,int b,int cost){
  int i,j,send;
  int aa = ind[a], bb = ind[b];

  if(a>=n){
    if(now[n-1] < 0) return;
    if(now[n-1] == res && cost > res_cost) res++;
    if(now[n-1] < res) res = now[n-1], res_cost = cost;
    return;
  }

  if(b>=n){
    if(aa!=0 && aa!=n-1 && now[aa]) return;
    solve(a+1,a+2,cost);
    return;
  }

  REP(i,-mx[aa][bb],mx[aa][bb]+1){
    if(-mi[aa][bb]<i && i<mi[aa][bb]) continue;
    if( (bb-aa)*i < 0 ) continue;

    send = cost;
    if(i) send += ac[aa][bb];
    send += i*i;

    now[aa]-=i; now[bb]+=i;
    solve(a,b+1,send);
    now[aa]+=i; now[bb]-=i;
  }
}

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

  while(scanf("%d",&n)==1){
    m = n*(n-1)/2;
    while(m--){
      scanf("%d%d%d%d%d",&i,&j,&a,&b,&c); i--; j--;
      mi[i][j] = mi[j][i] = a;
      mx[i][j] = mx[j][i] = b;
      ac[i][j] = ac[j][i] = c;
    }
    REP(i,1,n-1) ind[i-1] = i; ind[n-2]=0; ind[n-1]=n-1;
    rep(i,n) now[i] = 0;

    res = 1000000;

    solve(0,1,0);

    if(res == 1000000) res = res_cost = -1;
    printf("%d %d\n",res, res_cost);
  }

  return 0;
}


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

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

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

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


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


#include <stdio.h>
int main()
{
int m,n;
float res;
scanf("%d%d",&m,&n);
res = (1+(n-1)*(m-1)/(n*m-1))/n;
printf("%f",&res);
return 0;
}


#include <stdio.h>
#include <Windows.h>
int main()
{
float m,n,res;
scanf("%f%f",&m,&n);
res = (1+(n-1)*(m-1)/(n*m-1))/n;
printf("%f",res);
return 0;
}


#include <stdio.h>
#include <Windows.h>
int main()
{
float m,n,res;
scanf("%f%f",&m,&n);
if (n==1)
	res = 1;
else
	res = (1+(n-1)*(m-1)/(n*m-1))/n;
printf("%f",res);
return 0;
}


#include <stdio.h>

#define N 1000001

#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

int main() {
	int biggest_prime[N];
	int n, i, j, k,sum = 0;

	scanf("%i",&n);

	for(i = 1; i <= n; i++) biggest_prime[i] = i;

	for(i = 2; i <= n; i++){
		if(biggest_prime[i] != i) continue;
		for(j = i*2; j <= n; j+=i) biggest_prime[j] = i;
	}

	k = biggest_prime[n];

	int min = n;

	for(i = MAX(4,n-k+1); i <= n; i++){
		if(i == biggest_prime[i]) continue;
		min = MIN(min, i-biggest_prime[i]);
	}

	printf("%i",min+1); //no se como funciono pero funciono

	return 0;
}


#include <stdio.h>
#include <limits.h>

typedef long long ll;
typedef unsigned long long ull;

#define REP(i, n) for((i) = 0; (i) < (n); (i)++)
#define REP1(i, n) for((i) = 1; (i) <= (n); (i)++)

#define SIZE 1000002

static int s[SIZE], p[SIZE], np, min;

static void sieve(void)
{
    int i, j;

    for (i = 2; i < SIZE; i++) {
        if (s[i] == 0) {
            p[np++] = i;

            for (j = 2; i * j < SIZE; j++) {
                s[i * j] = 1;
            }
        }
    }
}

static void solve(int x, int l)
{
    int i, d, lf = -1;

    if (x < min) {
        min = x;
    }

    if (l == 0) {
        return;
    }

    for (i = 2; i * i <= x; i++) {
        if (x % i == 0) {
            if (s[x / i] == 0) {
                if (x / i > lf) {
                    lf = x / i;
                }
            } else if (s[i] == 0) {
                if (i > lf) {
                    lf = i;
                }
            }
        }
    }

    if (lf == -1) {
        return;
    }

    if (l == 1) {
        if (lf * (x / lf - 1) + 1 < min) {
            min = lf * (x / lf - 1) + 1;
        }
    } else {
        for (d = lf * (x / lf - 1) + 1; d < x; d++) {
            solve(d, l - 1);
        }
    }
}

int main(void)
{
    int x2;

    sieve();
    min = INT_MAX;

    scanf("%d", &x2);
    solve(x2, 2);
    printf("%d", min);

    return 0;
}


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

#define MAX 10000000

int p[MAX];

void Findprimes(){
    int n = 2;
    int x;

    while(n < MAX){
        x = n * 2;
        while(x < MAX){
            p[x] = n;
            x += n;
        }
        x = n + 1;
        while(p[x] != 0 && x < MAX){
            x++;
        }
        n = x;
    }
}

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

int main(){
    int i;
    int x0, x1, x2;

    x0 = MAX;
    scanf("%i%*c", &x2);
    Findprimes();
    //printf("%i\n", p[x2]);

    for(i = x2-p[x2]+1; i <= x2; i++){
        //printf("i: %i\n", i);
        x0 = min(i-p[i]+1, x0);
        //printf("x0: %i\n", x0);
    }

    printf("%i", x0);

    /*for(i = 0; i < MAX; i++){
        printf("%i ", p[i]);
    }*/
    return 0;
}


#include <stdio.h>

int max_prime_div[1000001];
bool sieve[1000001];

int main(int argc, char **argv)
{
    int x2;
    int tmp;
    int max_div;
    int min_x0 = 1000001;

    scanf("%d", &x2);
    for (int i = 0; i < x2 + 1; ++i) {
        max_prime_div[i] = 0;
        sieve[i] = true;
    }

    for (int i = 2; i < x2 + 1; ++i) {
        if (sieve[i]) {
            for (int j = 2 * i; j < x2 + 1; j += i) {
                sieve[j] = false;
                max_prime_div[j] = i;
            }
        }
    }

    for (int x = x2 - max_prime_div[x2] + 1; x < x2 + 1; ++x) {
        max_div = max_prime_div[x];
        tmp = x - max_div + 1;
        if (max_div && tmp < min_x0) {
            min_x0 = tmp;
        }
        if (max_div && tmp - 1 == max_div) {
            break;
        }
    }
    printf("%d", min_x0);
    return 0;
}


#include <stdio.h>
#include <math.h>
#define size 1000000

void llenaArr(int *primes){
  int i,j;
  for (i = 0; i < size; i++) {
    primes[i]=0;
  }

  for (i = 2; i < size; i++)
    if(!primes[i]){
      for (j = 2; (i*j)<size; j++)
          primes[i*j]=i;
    }
}

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

int main(){
  int x2, i;
  int x0=1000000;
  scanf("%i", &x2);
  int primes[size];
  llenaArr(primes);

  i=x2-primes[x2]+1;
  x0=min(x0,i);
  for(;i<=x2;i++){
    x0=min(x0, i-primes[i]+1);
  }
  printf("%i\n", x0);
}


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

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

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    char s[201], t[3];
    scanf("%s %s", s, t);
    int dp[n+1][k+1][n+1];      // answer in the interval [1...i], using j moves, has t0 occurrences of t[0]
    for(int i = 0; i <= n; i++) {
        for(int j = 0; j <= k; j++) {
            for(int t0 = 0; t0 <= n; t0++) {
                dp[i][j][t0] = -1;
            }
        }
    }
    dp[0][0][0] = 0;
    // initialize
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= k; j++) {
            for(int t0 = 0; t0 <= n; t0++) {
                if(dp[i-1][j][t0] == -1)
                    continue;

                int is_equal_first_char = s[i-1] == t[0];
                int is_equal_second_char = s[i-1] == t[1];      // asddsaf sd
                int is_t_equal = t[0] == t[1];

                // if we do not change the ith char
                dp[i][j][t0 + is_equal_first_char] = max(dp[i][j][t0 + is_equal_first_char], dp[i - 1][j][t0] + (is_equal_second_char ? t0 : 0));

                // if we make any change (j must be < k)
                if(j < k) {
                    // if change s[i] to t[0]
                    dp[i][j + 1][t0 + 1] = max(dp[i][j + 1][t0 + 1], dp[i - 1][j][t0] + (is_t_equal ? t0 : 0));
                    // if change s[i] to t[1]
                    // dp[i][j + 1][t0 + 1] = max(dp[i][j + 1][t0 + 1], dp[i][j][t0] + (!is_equal_second_char ? t0 : 0));
                    dp[i][j + 1][t0] = max(dp[i][j + 1][t0], dp[i - 1][j][t0] + t0);
                }
            }
        }
    }
    int ans = -1;
    for(int j = 0; j <= k; j++) {
        for(int t0 = 0; t0 <= n; t0++) {
            ans = max(ans, dp[n][j][t0]);
        }
    }
    printf("%d", ans);
    return 0;
}


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

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

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

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

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

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

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

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

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

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

int main(void){
  int n,v;
  char s[256],t[8];
  scanf("%d%d",&n,&v);
  scanf("%s%s",s,t);

  if(t[0]==t[1]){
    int cnt=0;
    for(int i=0;i<n;i++){
      if(s[i]==t[0]){cnt++;}
    }
    cnt+=v;
    cnt=min(n,cnt);
    printf("%d\n",nCr(cnt,2));
    return 0;
  }
  //dp[pos][lrep][fir]={mxm}
  int dp[256][256][256];
  for(int i=0;i<256;i++){
    for(int j=0;j<256;j++){
      for(int k=0;k<256;k++){
        dp[i][j][k]=-inf;
      }
    }
  }

  dp[0][v][0]=0;

  for(int i=0;i<n;i++){
    for(int j=0;j<=v;j++){
      for(int k=0;k<=i;k++){
        dp[i+1][j][k]=max(dp[i][j][k],dp[i+1][j][k]);
        if(s[i]==t[0]){
          dp[i+1][j][k+1]=max(dp[i][j][k],dp[i+1][j][k+1]);
        }
        else if(j!=0){
          dp[i+1][j-1][k+1]=max(dp[i][j][k],dp[i+1][j-1][k+1]);
        }
        if(s[i]==t[1]){
          dp[i+1][j][k]=max(dp[i][j][k]+k,dp[i+1][j][k]);
        }
        else if(j!=0){
          dp[i+1][j-1][k]=max(dp[i][j][k]+k,dp[i+1][j-1][k]);
        }
      }
    }
  }

  int res=0;
  for(int i=0;i<256;i++){
    for(int j=0;j<256;j++){
      res=max(res,dp[n][i][j]);
    }
  }
  printf("%d\n",res);
  return 0;
}


#include<stdio.h>
#include<string.h>
int n,k,dp[201][201][201];
char s[200],t[2];
int min(int a,int b){
    return a<b?a:b;
}
int max(int a,int b){
    return a>b?a:b;
}
int simi(int n,int k){
    int i,cnt=0;
    for(i=0;i<n;i++)
    {
        if(s[i]==t[0]) cnt++;
    }
    cnt=min(n,cnt+k);
    return cnt*(cnt-1)/2;

}
int diff(int i,int remK,int first){
    if(i==n) return 0;
    if(dp[i][remK][first]!=-1) return dp[i][remK][first];
    int ans=0;
    if(!remK){
        if(s[i]==t[1]) ans=first+diff(i+1,0,first);
        else if(s[i]==t[0]) ans=diff(i+1,0,first+1);
        else ans=diff(i+1,0,first);
    }
    else{
        if(s[i]==t[0]){
           int ans1,ans2;
            ans1=diff(i+1,remK,first+1);
            ans2=first+diff(i+1,remK-1,first);
            ans=max(ans1,ans2);
        }
        else if(s[i]==t[1]){
            int ans1,ans2;
            ans1=first+diff(i+1,remK,first);
            ans2=diff(i+1,remK-1,first+1);
            ans=max(ans1,ans2);
        }
        else{
            int ans1,ans2,ans3;
            ans1=diff(i+1,remK,first);
            ans2=diff(i+1,remK-1,first+1);
            ans3=first+diff(i+1,remK-1,first);
            ans=max(ans1,max(ans2,ans3));
        }
    }
    return dp[i][remK][first] = ans;
}

/*int main(){

   scanf("%d %d",&n,&k);
   scanf("%c%s",s);
   scanf("%s",t);
   if(t[0]==t[1]){
       printf("%d\n",simi(n,k));
       return 0;
   }
   for(int i=0;i<n;i++) for(int j=0;j<=k;j++) for(int k=0;k<n;k++) dp[i][j][k]=-1;
   printf("%d\n",diff(0,k,0));
    return 0;
}*/
int main() {
   scanf("%d %d", &n, &k);
   scanf("%s",s);
   scanf("%s",t);

    if(t[0] == t[1]) {
        printf("%d\n", simi(n,k));
        return 0;
    }

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

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


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

int ***sol;
int N, K;
const int kInvalidSol = -10000;
void new_sol() {
	sol = (int***)malloc(sizeof(int**) * (N + 1));
	for (int n = 0; n <= N; ++n) {
		sol[n] = (int**)malloc(sizeof(int*) * (K + 1));
		for (int k = 0; k <= K; ++k) {
			sol[n][k] = (int*)malloc(sizeof(int) * (N + 1));
			for (int i = 0; i <= N; ++i) {
				sol[n][k][i] = kInvalidSol;
			}
		}
	}
}
void free_sol() {
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= K; ++j) {
			free(sol[i][j]);
		}
		free(sol[i]);
	}
	free(sol);
}
void try_update_sol(int n, int k, int i, int value) {
	if (value >= 0 && sol[n][k][i] < value) {
		sol[n][k][i] = value;
	}
}
int main() {
	char s[201], t[3];
	scanf("%d%d\n%s\n%s", &N, &K, s, t);
	if (t[0] == t[1]) {
		int cc = 0;
		for (int i = 0; i < N; ++i) {
			if (s[i] == t[0]) {
				++cc;
			}
		}
		cc += K;
		if (cc > N) {
			cc = N;
		}
		printf("%d\n", cc * (cc - 1) / 2);
		return 0;
	}

	// t[0] != t[1]
	new_sol();
	int t0 = 0;
	for (int n = 1; n <= N; ++n) {
		if (s[n - 1] == t[0]) {
			++t0;
			if (t0 == 1) {
				sol[n][0][1] = 0;
			} else {
				try_update_sol(n, 0, t0, sol[n - 1][0][t0 - 1]);
			}
		} else if (s[n - 1] == t[1]) {
			try_update_sol(n, 0, t0, sol[n - 1][0][t0] + t0);
		} else {
			try_update_sol(n, 0, t0, sol[n - 1][0][t0]);
		}
	}
	for (int k = 1; k <= K; ++k) {
		try_update_sol(1, k, 1, 0);
		for (int n = 2; n <= N; ++n) {
			for (int i = 1; i <= n; ++i) {
				try_update_sol(n, k, i, sol[n][k - 1][i]);
				if (s[n - 1] == t[0]) {
					try_update_sol(n, k, i, sol[n - 1][k][i - 1]);
					try_update_sol(n, k, i, sol[n - 1][k - 1][i] + i);
				} else if (s[n - 1] == t[1]) {
					try_update_sol(n, k, i, sol[n - 1][k][i] + i);
					try_update_sol(n, k, i, sol[n - 1][k - 1][i - 1]);
				} else {
					try_update_sol(n, k, i, sol[n - 1][k - 1][i - 1]);
					try_update_sol(n, k, i, sol[n - 1][k - 1][i] + i);
					try_update_sol(n, k, i, sol[n - 1][k][i]);
				}
			}
		}
	}
	int max = 0;
	for (int i = 1; i <= N; ++i) {
		if (sol[N][K][i] > max) {
			max = sol[N][K][i];
		}
	}
	printf("%d\n", max);
	free_sol();
	return 0;
}


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

int num_var;
int vars[600];
int values[1024];

int num_order;
int order[600];

int max_var;

int num_cond;
int cond1[500];
int cond2[500];

bool contains_in_order(int var){
	int i;
	for(i = 0; i < num_order; i++){
		if(order[i] == var)
			return true;
	}
	return false;
}

void parse1(char *data){
	char *ptr = data;

	num_var = 0;
	max_var = 0;
	num_order = 0;

	int state = 0;
	int var = 0;
	while(*ptr != ')'){
		switch(state){
		case 0:
			if (*ptr == '_'){
				state = 1;
				var = 1;
			} else {
				//Invalid
				state = 0;
				var = 0;
			}
			break;
		case 1:
			if (*ptr == '_'){
				var++;
			} else {
				vars[num_var++] = var;
				if(var > max_var) max_var = var;
				if(!contains_in_order(var)) order[num_order++] = var;
				state = 0;
			}
			break;
		}
		ptr++;
	}
	if(var > 0){
		vars[num_var++] = var;
		if(!contains_in_order(var)) order[num_order++] = var;
	}
}

void parse2(char *data){
	char *ptr = data;
	int state = 0;
	int var1 = 0;
	int var2 = 0;
	int op = 0; // 0: >, 1: <

	num_cond = 0;

	while(*ptr != '.'){
		switch(state){
		case 0:
			if (*ptr == '_'){
				state = 1;
				var1 = 1;
			} else {
				//Invalid
				state = 0;
			}
			break;
		case 1:
			if (*ptr == '_'){
				var1++;
			} else if(*ptr == '>') {
				op = 0;
				state = 2;
			} else if(*ptr == '<') {
				op = 1;
				state = 2;
				var2 = 0;
			} else {
				//Invalid
				state = 0;
			}
			break;
		case 2:
			if (*ptr == '_'){
				var2++;
			} else if(*ptr == ',') {
				if(op == 0){
					cond1[num_cond] = var1;
					cond2[num_cond++] = var2;
				} else {
					cond1[num_cond] = var2;
					cond2[num_cond++] = var1;
				}
				state = 0;
			} else {
				//Invalid
				state = 0;
			}
			break;
		}
		ptr++;
	}
	if(state == 2){
		if(op == 0){
			cond1[num_cond] = var1;
			cond2[num_cond++] = var2;
		} else {
			cond1[num_cond] = var2;
			cond2[num_cond++] = var1;
		}
	}
}

void parse(char *data){
	char *ptr = data;
	ptr += 2;//skip ?(
	parse1(ptr);
	ptr += 3;//skip ):-
	parse2(ptr);
}

void init_values(){
	int i;
	for(i = 0; i <= max_var; i++){
		values[i] = -1;
	}
	for(i = 0; i < num_var; i++){
		values[vars[i]] = 0;
	}
}

bool check_cond(){
	int i;
	for(i = 0; i < num_cond; i++){
		if(values[cond1[i]] <= values[cond2[i]])
			return false;
	}
	return true;
}

bool next_values2(int loc){
	if(values[order[loc]] < 9){
		values[order[loc]]++;
		return true;
	} else if(loc > 0){
		values[order[loc]] = 0;
		return next_values2(loc - 1);
	} else {
		return false;
	}
}

bool next_values(){
	return next_values2(num_order - 1);
}

int main(){
	char buf[1100];
	int i;

	scanf("%s", buf);
	parse(buf);

	init_values();

	while(!check_cond()){
		if(!next_values()){
			printf("false\n");
			return 0;
		}
	}

	for(i = 0; i < num_var; i++){
		printf("%d", values[vars[i]]);
	}
	printf("\n");
}


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

int num_var;
int vars[600];
int values[1024];

int num_order;
int order[600];

int max_var;

int num_cond;
int cond1[500];
int cond2[500];

void parse1(char *data){
	char *ptr = data;

	num_var = 0;
	max_var = 0;
	num_order = 0;

	int i;
	for(i = 0; i < 1024; i++){
		values[i] = -1;
	}

	int state = 0;
	int var = 0;
	while(*ptr != ')'){
		switch(state){
		case 0:
			if (*ptr == '_'){
				state = 1;
				var = 1;
			} else {
				//Invalid
				state = 0;
				var = 0;
			}
			break;
		case 1:
			if (*ptr == '_'){
				var++;
			} else {
				vars[num_var++] = var;
				if(var > max_var) max_var = var;
				if(values[var] == -1) order[num_order++] = var;
				values[var] = 0;
				state = 0;
			}
			break;
		}
		ptr++;
	}
	if(var > 0){
		vars[num_var++] = var;
		if(values[var] == -1) order[num_order++] = var;
		values[var] = 0;
	}
}

void parse2(char *data){
	char *ptr = data;
	int state = 0;
	int var1 = 0;
	int var2 = 0;
	int op = 0; // 0: >, 1: <

	num_cond = 0;

	while(*ptr != '.'){
		switch(state){
		case 0:
			if (*ptr == '_'){
				state = 1;
				var1 = 1;
			} else {
				//Invalid
				state = 0;
			}
			break;
		case 1:
			if (*ptr == '_'){
				var1++;
			} else if(*ptr == '>') {
				op = 0;
				state = 2;
			} else if(*ptr == '<') {
				op = 1;
				state = 2;
				var2 = 0;
			} else {
				//Invalid
				state = 0;
			}
			break;
		case 2:
			if (*ptr == '_'){
				var2++;
			} else if(*ptr == ',') {
				if(op == 0){
					cond1[num_cond] = var1;
					cond2[num_cond++] = var2;
				} else {
					cond1[num_cond] = var2;
					cond2[num_cond++] = var1;
				}
				state = 0;
			} else {
				//Invalid
				state = 0;
			}
			break;
		}
		ptr++;
	}
	if(state == 2){
		if(op == 0){
			cond1[num_cond] = var1;
			cond2[num_cond++] = var2;
		} else {
			cond1[num_cond] = var2;
			cond2[num_cond++] = var1;
		}
	}
}

void parse(char *data){
	char *ptr = data;
	ptr += 2;//skip ?(
	parse1(ptr);
	ptr += 3;//skip ):-
	parse2(ptr);
}

void init_values(){
	int i;
	for(i = 0; i <= max_var; i++){
		values[i] = -1;
	}
	for(i = 0; i < num_var; i++){
		values[vars[i]] = 0;
	}
}

bool check_cond(){
	int i;
	for(i = 0; i < num_cond; i++){
		if(values[cond1[i]] <= values[cond2[i]])
			return false;
	}
	return true;
}

bool next_values2(int loc){
	if(values[order[loc]] < 9){
		values[order[loc]]++;
		return true;
	} else if(loc > 0){
		values[order[loc]] = 0;
		return next_values2(loc - 1);
	} else {
		return false;
	}
}

bool next_values(){
	return next_values2(num_order - 1);
}

int main(){
	char buf[1100];
	int i;

	scanf("%s", buf);
	parse(buf);

	init_values();

	while(!check_cond()){
		if(!next_values()){
			printf("false\n");
			return 0;
		}
	}

	for(i = 0; i < num_var; i++){
		printf("%d", values[vars[i]]);
	}
	printf("\n");
}


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

int num_var;
int vars[1000];
int values[1024];

int num_order;
int order[1000];

int max_var;

int num_cond;
int cond1[1000];
int cond2[1000];

void parse1(char *data){
	char *ptr = data;

	num_var = 0;
	max_var = 0;
	num_order = 0;

	int i;
	for(i = 0; i < 1024; i++){
		values[i] = -1;
	}

	int state = 0;
	int var = 0;
	while(*ptr != ')'){
		switch(state){
		case 0:
			if (*ptr == '_'){
				state = 1;
				var = 1;
			} else {
				//Invalid
				state = 0;
				var = 0;
			}
			break;
		case 1:
			if (*ptr == '_'){
				var++;
			} else {
				vars[num_var++] = var;
				if(var > max_var) max_var = var;
				if(values[var] == -1) order[num_order++] = var;
				values[var] = 0;
				state = 0;
			}
			break;
		}
		ptr++;
	}
	if(var > 0){
		vars[num_var++] = var;
		if(values[var] == -1) order[num_order++] = var;
		values[var] = 0;
	}
}

void parse2(char *data){
	char *ptr = data;
	int state = 0;
	int var1 = 0;
	int var2 = 0;
	int op = 0; // 0: >, 1: <

	num_cond = 0;

	while(*ptr != '.'){
		switch(state){
		case 0:
			if (*ptr == '_'){
				state = 1;
				var1 = 1;
			} else {
				//Invalid
				state = 0;
			}
			break;
		case 1:
			if (*ptr == '_'){
				var1++;
			} else if(*ptr == '>') {
				op = 0;
				state = 2;
			} else if(*ptr == '<') {
				op = 1;
				state = 2;
				var2 = 0;
			} else {
				//Invalid
				state = 0;
			}
			break;
		case 2:
			if (*ptr == '_'){
				var2++;
			} else if(*ptr == ',') {
				if(op == 0){
					cond1[num_cond] = var1;
					cond2[num_cond++] = var2;
				} else {
					cond1[num_cond] = var2;
					cond2[num_cond++] = var1;
				}
				state = 0;
			} else {
				//Invalid
				state = 0;
			}
			break;
		}
		ptr++;
	}
	if(state == 2){
		if(op == 0){
			cond1[num_cond] = var1;
			cond2[num_cond++] = var2;
		} else {
			cond1[num_cond] = var2;
			cond2[num_cond++] = var1;
		}
	}
}

void parse(char *data){
	char *ptr = data;
	ptr += 2;//skip ?(
	parse1(ptr);
	ptr += 3;//skip ):-
	parse2(ptr);
}

void init_values(){
	int i;
	for(i = 0; i <= max_var; i++){
		values[i] = -1;
	}
	for(i = 0; i < num_var; i++){
		values[vars[i]] = 0;
	}
}

bool check_cond(){
	int i;
	for(i = 0; i < num_cond; i++){
		if(values[cond1[i]] <= values[cond2[i]])
			return false;
	}
	return true;
}

bool next_values2(int loc){
	if(values[order[loc]] < 9){
		values[order[loc]]++;
		return true;
	} else if(loc > 0){
		values[order[loc]] = 0;
		return next_values2(loc - 1);
	} else {
		return false;
	}
}

bool next_values(){
	return next_values2(num_order - 1);
}

bool solve(){
	int i;
	int change = 1;

	while(change == 1){
		change = 0;
		for(i = 0; i < num_cond; i++){
			if(cond1[i] == cond2[i]){
				return false;
			}

			if(values[cond1[i]] <= values[cond2[i]]){
				change = 1;
				values[cond1[i]] = values[cond2[i]] + 1;
				if(values[cond1[i]] > 9)
					return false;
			}
		}
	}

	return true;
}

int main(){
	char buf[1100];
	int i;

	scanf("%s", buf);
	parse(buf);

	init_values();

	if(!solve()){
		printf("false\n");
		return 0;
	}

	for(i = 0; i < num_var; i++){
		printf("%d", values[vars[i]]);
	}
	printf("\n");
}


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

int num_var;
int vars[1000];
int values[1024];

int num_order;
int order[1000];

int max_var;

int num_cond;
int cond1[1000];
int cond2[1000];

void parse1(char *data){
	char *ptr = data;

	num_var = 0;
	max_var = 0;
	num_order = 0;

	int i;
	for(i = 0; i < 1024; i++){
		values[i] = -1;
	}

	int state = 0;
	int var = 0;
	while(*ptr != ')'){
		switch(state){
		case 0:
			if (*ptr == '_'){
				state = 1;
				var = 1;
			} else {
				//Invalid
				state = 0;
				var = 0;
			}
			break;
		case 1:
			if (*ptr == '_'){
				var++;
			} else {
				vars[num_var++] = var;
				if(var > max_var) max_var = var;
				if(values[var] == -1) order[num_order++] = var;
				values[var] = 0;
				state = 0;
			}
			break;
		}
		ptr++;
	}
	if(var > 0){
		vars[num_var++] = var;
		if(values[var] == -1) order[num_order++] = var;
		values[var] = 0;
	}
}

void parse2(char *data){
	char *ptr = data;
	int state = 0;
	int var1 = 0;
	int var2 = 0;
	int op = 0; // 0: >, 1: <

	num_cond = 0;

	while(*ptr != '.'){
		switch(state){
		case 0:
			if (*ptr == '_'){
				state = 1;
				var1 = 1;
			} else {
				//Invalid
				state = 0;
			}
			break;
		case 1:
			if (*ptr == '_'){
				var1++;
			} else if(*ptr == '>') {
				op = 0;
				state = 2;
			} else if(*ptr == '<') {
				op = 1;
				state = 2;
				var2 = 0;
			} else {
				//Invalid
				state = 0;
			}
			break;
		case 2:
			if (*ptr == '_'){
				var2++;
			} else if(*ptr == ',') {
				if(op == 0){
					cond1[num_cond] = var1;
					cond2[num_cond++] = var2;
				} else {
					cond1[num_cond] = var2;
					cond2[num_cond++] = var1;
				}
				state = 0;
			} else {
				//Invalid
				state = 0;
			}
			break;
		}
		ptr++;
	}
	if(state == 2){
		if(op == 0){
			cond1[num_cond] = var1;
			cond2[num_cond++] = var2;
		} else {
			cond1[num_cond] = var2;
			cond2[num_cond++] = var1;
		}
	}
}

void parse(char *data){
	char *ptr = data;
	ptr += 2;//skip ?(
	parse1(ptr);
	ptr += 3;//skip ):-
	parse2(ptr);
}

void init_values(){
	int i;
	for(i = 0; i <= max_var; i++){
		values[i] = 0;
	}
}

bool check_cond(){
	int i;
	for(i = 0; i < num_cond; i++){
		if(values[cond1[i]] <= values[cond2[i]])
			return false;
	}
	return true;
}

bool next_values2(int loc){
	if(values[order[loc]] < 9){
		values[order[loc]]++;
		return true;
	} else if(loc > 0){
		values[order[loc]] = 0;
		return next_values2(loc - 1);
	} else {
		return false;
	}
}

bool next_values(){
	return next_values2(num_order - 1);
}

bool solve(){
	int i;
	int change = 1;

	while(change == 1){
		change = 0;
		for(i = 0; i < num_cond; i++){
			if(cond1[i] == cond2[i]){
				return false;
			}

			if(values[cond1[i]] <= values[cond2[i]]){
				change = 1;
				values[cond1[i]] = values[cond2[i]] + 1;
				if(values[cond1[i]] > 9)
					return false;
			}
		}
	}

	return true;
}

int main(){
	char buf[1100];
	int i;

	scanf("%s", buf);
	parse(buf);

	init_values();

	if(!solve()){
		printf("false\n");
		return 0;
	}

	for(i = 0; i < num_var; i++){
		printf("%d", values[vars[i]]);
	}
	printf("\n");
}


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

int num_var;
int vars[1000];
int values[1024];

int num_order;
int order[1000];

int max_var;

int num_cond;
int cond1[1000];
int cond2[1000];

void parse1(char *data){
	char *ptr = data;

	num_var = 0;
	max_var = 0;
	num_order = 0;

	int i;
	for(i = 0; i < 1024; i++){
		values[i] = -1;
	}

	int state = 0;
	int var = 0;
	while(*ptr != ')'){
		switch(state){
		case 0:
			if (*ptr == '_'){
				state = 1;
				var = 1;
			} else {
				//Invalid
				state = 0;
				var = 0;
			}
			break;
		case 1:
			if (*ptr == '_'){
				var++;
			} else {
				vars[num_var++] = var;
				if(var > max_var) max_var = var;
				if(values[var] == -1) order[num_order++] = var;
				values[var] = 0;
				state = 0;
			}
			break;
		}
		ptr++;
	}
	if(var > 0){
		vars[num_var++] = var;
		if(values[var] == -1) order[num_order++] = var;
		values[var] = 0;
	}
}

void parse2(char *data){
	char *ptr = data;
	int state = 0;
	int var1 = 0;
	int var2 = 0;
	int op = 0; // 0: >, 1: <

	num_cond = 0;

	while(*ptr != '.'){
		switch(state){
		case 0:
			if (*ptr == '_'){
				state = 1;
				var1 = 1;
			} else {
				//Invalid
				state = 0;
			}
			break;
		case 1:
			if (*ptr == '_'){
				var1++;
			} else if(*ptr == '>') {
				op = 0;
				state = 2;
				var2 = 0;
			} else if(*ptr == '<') {
				op = 1;
				state = 2;
				var2 = 0;
			} else {
				//Invalid
				state = 0;
			}
			break;
		case 2:
			if (*ptr == '_'){
				var2++;
			} else if(*ptr == ',') {
				if(op == 0){
					cond1[num_cond] = var1;
					cond2[num_cond] = var2;
				} else {
					cond1[num_cond] = var2;
					cond2[num_cond] = var1;
				}
				num_cond++;
				state = 0;
			} else {
				//Invalid
				state = 0;
			}
			break;
		}
		ptr++;
	}
	if(state == 2){
		if(op == 0){
			cond1[num_cond] = var1;
			cond2[num_cond] = var2;
		} else {
			cond1[num_cond] = var2;
			cond2[num_cond] = var1;
		}
		num_cond++;
	}
}

void parse(char *data){
	char *ptr = data;
	ptr += 2;//skip ?(
	parse1(ptr);
	ptr += 3;//skip ):-
	parse2(ptr);
}

void init_values(){
	int i;
	for(i = 0; i <= max_var; i++){
		values[i] = 0;
	}
}

bool solve(){
	int i;
	int change = 1;

	while(change == 1){
		change = 0;
		for(i = 0; i < num_cond; i++){
			if(cond1[i] == cond2[i]){
				return false;
			}

			if(values[cond1[i]] <= values[cond2[i]]){
				change = 1;
				values[cond1[i]] = values[cond2[i]] + 1;
				if(values[cond1[i]] > 9)
					return false;
			}
		}
	}

	return true;
}

int main(){
	char buf[1100];
	int i;

	scanf("%s", buf);
	parse(buf);

	init_values();

	if(!solve()){
		printf("false\n");
		return 0;
	}

	for(i = 0; i < num_var; i++){
		printf("%d", values[vars[i]]);
	}
	printf("\n");
}


/* practice with Dukkha */
/* https://codeforces.com/blog/entry/58519 */
#include <stdio.h>

#define N	5000
#define MD	1000000007
#define INV2	500000004

int main() {
	static int aa[N - 1], pp[N][N * 2], qq[N][N * 2];
	int n, h, k;

	scanf("%d", &n);
	for (h = 0; h < n - 1; h++)
		scanf("%d", &aa[h]);
	for (h = 0; h < n; h++)
		pp[h][0] = 1;
	for (k = 1; k < n; k++)
		for (h = n - k - 1; h >= 0; h--)
			pp[h][k] = (long long) aa[h] * pp[h + 1][k - 1] % MD;
	for (h = 0; h < n; h++)
		qq[h][0] = 1;
	for (k = 1; k < n * 2; k++)
		for (h = 1; h < n; h++) {
			long long x = qq[h - 1][k - 1];

			if (k >= 2)
				x = (x + (long long) (aa[h - 1] - 1) * pp[h][k - 2]) % MD;
			qq[h][k] = x;
		}
	for (k = 1; k < n * 2 - 1; k++) {
		long long x = 0;

		for (h = 0; h < n; h++)
			x = (x + (long long) pp[0][h] * (pp[h][k] + qq[h][k])) % MD;
		printf("%lld ", x * INV2 % MD);
	}
	printf("\n");
	return 0;
}


/* practice with Dukkha */
/* https://codeforces.com/blog/entry/58519 */
#include <stdio.h>

#define N	5000
#define MD	1000000007
#define INV2	500000004

int d_, x_, y_;

void gcd_(int a, int b) {
	if (b == 0)
		d_ = a, x_ = 1, y_ = 0;
	else {
		int t;

		gcd_(b, a % b);
		t = x_ - a / b * y_, x_ = y_, y_ = t;
	}
}

int inv(int a) {
	gcd_(a, MD);
	return x_;
}

int main() {
	static int aa[N - 1], pp[N], pp_[N], qq[N][N * 2];
	int n, h, k;

	scanf("%d", &n);
	for (h = 0; h < n - 1; h++)
		scanf("%d", &aa[h]);
	pp[n - 1] = pp_[n - 1] = 1;
	for (h = n - 2; h >= 0; h--)
		pp_[h] = inv(pp[h] = (long long) aa[h] * pp[h + 1] % MD);
	for (h = 0; h < n; h++)
		qq[h][0] = 1;
	for (k = 1; k < n * 2; k++)
		for (h = 1; h < n; h++) {
			long long x = qq[h - 1][k - 1];

			if (k >= 2 && h + k - 2 < n) {
				long long p = (long long) pp[h] * pp_[h + k - 2] % MD;

				x = (x + (aa[h - 1] - 1) * p) % MD;
			}
			qq[h][k] = x;
		}
	for (k = 1; k < n * 2 - 1; k++) {
		long long x = 0;

		for (h = 0; h < n; h++) {
			long long cnt = (long long) pp[0] * pp_[h] % MD;
			long long p = h + k < n ? (long long) pp[h] * pp_[h + k] % MD : 0;
			long long q = qq[h][k];

			x = (x + cnt * (p + q)) % MD;
		}
		if (x < 0)
			x += MD;
		printf("%lld ", x * INV2 % MD);
	}
	printf("\n");
	return 0;
}


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

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

int main(int argc, char *argv[]) {
	int a;
	scanf("%d",&a);
	printf("%d 2\n1 2\n",2*(a - 1) + 1);
	return 0;
}


#include<stdio.h>

int main()
{
	int n;
	scanf("%d",&n);
	printf("%d 2\n1 2",2*n-1);
	return 0;
}


//Date : 30-09-17

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<float.h>
#include<math.h>
#include<inttypes.h>
#include<assert.h>
#include<ctype.h>
#include<limits.h>
#include<time.h>
#define ll long long
#define For(i,n)	for(i=0;i<n;i++)
#define rep(i ,a ,b)	for(i=(a);i<=(b);i++)
#define mset(a ,value)	memset(a ,value ,sizeof(a))
#define s(a)	scanf("%d" ,&a);
#define ls(a)	scanf("%ld" ,&a)
#define reg(i)	register int i
#define infinite INT_MAX
#define MAX 1000005
#define NIL -1
#define and &&
int max(int a,int b){	return (a > b ? a : b);		}
int min(int a,int b){	return (a < b ? a : b);	}
char s[101];
int main() {
	int i ,j ,k ,n;
	s(n);
	if(n == 1){
		printf("1 1\n1");
		return 0;
	}
	printf("%d 2\n" ,2*n - 2);
	printf("1 2");
	return 0;
}


#include<stdio.h>

int main()
{
	int n;
	scanf("%d",&n);
	printf("%d 2\n1 2",2*n-2);
	return 0;
}


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


#include <stdio.h>

int main()
{
  int array[1001], n, c, d, e,swap;
  scanf("%d", &n);
  for (c = 0; c < n; c++)
    scanf("%d", &array[c]);

  for (c = 0 ; c < ( n - 1 ); c++)
  {
    for (d = 0 ; d < n - c - 1; d++)
    {
      if (array[d] > array[d+1])
      {
        swap       = array[d];
        array[d]   = array[d+1];
        array[d+1] = swap;
      }
    }
  }

  for(e=0;e<1000006;e++)
    printf("");

  printf("%d",array[0]);
  for ( c = 1 ; c < n ; c++ )
     printf(" %d", array[c]);

  return 0;
}


/*  AUTHOR:AKASH JAIN
*   USERNAME:akash19jain
*   DATE:31/03/2019
*/
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
int cmp(const void * a,const void * b)
{
    return (*(int*)a - *(int*)b);
}
int main()
{
    long long t=1;
    //scanf("%lld",&t);
    while(t--)
    {
        double t=clock();
        long long n;
        scanf("%lld",&n);
        long long arr[n];
        for(long long i=0;i<n;i++)
            scanf("%lld",&arr[i]);
        qsort(arr,n,sizeof(arr[0]),cmp);
        while(clock()-t<=1500);
        for(long long i=0;i<1500;i++);
        for(long long i=0;i<n;i++)
            printf("%lld ",arr[i]);
    }

    return 0;
}


#include<stdio.h>

int x[100] = {0};
int cmp(const void *a,const void *b)
{
    return *( int *)a - *( int *)b;
}
int main()
{
    int n,i,c=0;
    scanf("%d",&n);
    for(i=0; i<n; i++) scanf("%d",&x[i]);
    for(i=0; i<10e6+11*10e5; i++) qsort(x,n,sizeof(int),cmp);
    for(i=0; i<n; i++) printf("%d ",x[i]);
    if(n==3)
    {
        for(i=0; i<10e6+11*10e5; i++) qsort(x,n,sizeof(int),cmp);
        for(i=0; i<10e6+11*10e5; i++) qsort(x,n,sizeof(int),cmp);

    }

    return 0;
}


/*  AUTHOR:AKASH JAIN
*   USERNAME:akash19jain
*   DATE:31/03/2019
*/
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
int cmp(const void * a,const void * b)
{
    return (*(int*)a - *(int*)b);
}
int main()
{
    long long t=1;
    //scanf("%lld",&t);
    while(t--)
    {
        long long n;
        scanf("%lld",&n);
        for(long long i=0;i<n;i++)
            scanf("%lld",&arr[i]);
        qsort(arr,n,sizeof(arr[0]),cmp);
        for(long long i=0;i<1500;i++);
        for(long long i=0;i<n;i++)
            printf("%lld ",arr[i]);
    }

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
double x[2],y[2],r[2],R[2],distance;
int answer;
scanf("%lf%lf%lf%lf",&x[0],&y[0],&r[0],&R[0]);
scanf("%lf%lf%lf%lf",&x[1],&y[1],&r[1],&R[1]);
distance=sqrt((x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0]));
if(R[0]>R[1])
	{
	R[1]=R[1]+R[0];
	R[0]=R[1]-R[0];
	R[1]=R[1]-R[0];
	r[1]=r[1]+r[0];
	r[0]=r[1]-r[0];
	r[1]=r[1]-r[0];
	}
if(distance>=R[0]+R[1])answer=4;
else
{
	if(distance+R[0]>R[1])//not completely inside outer circle
	{
		if(distance<r[1]+R[0] && distance+r[1]>R[0])//intersected inner circle
		{
		if(r[0]+R[1]<=distance)answer=1;
		else if(r[0]+distance<=r[1])answer=1;
		else answer=0;
		}
		else if(distance+r[1]<=R[0])
		{
		if(distance>=r[1]+r[0])answer=0;
		else if(distance<r[1]+r[0] && distance+r[1]>r[0])answer=0
		else if(distance<r[1]+r[0] && distance+r[0]>r[0])answer=0;
		else answer=1;
		}
		else// disjoint with inner circle
		{
		printf("Disjoint with inner circle\n");
		if(distance>=R[1]+r[0])answer=2;
		else answer=1;
		}
	}
	else//completely inside outer circle
	{
	if(distance>=r[1]+R[0])answer=2;//disjoint with inner circle
	else if(distance+r[1]<=R[0])
	{
	if(distance>=r[0]+r[1])answer=2;
	else if(distance+r[0]<=r[1])answer=2;
	else if(distance+r[1]<=r[0])answer=2;
	else answer=1;
	}
	else if(distance+R[0]>r[1])//not completely inside inner circle
	{
	if(distance+r[0]<=r[1])answer=2;
	else answer=1;
	}
	else  answer=4;
	}
}
printf("%d\n",answer);
return 0;
}


#include<stdio.h>
#include<math.h>
bool in_circle(int d,int r1,int r2)
{
    return d+r1<=r2;
}
bool out_circle(int d,int r1,int r2)
{
    if(d>=r1+r2)
        return 1;
    return in_circle(d,r2,r1);
}
int main()
{
    int n=0;
    int x1,x2,y1,y2,r1,r2,R1,R2;
    scanf("%d%d%d%d",&x1,&y1,&r1,&R1);
    scanf("%d%d%d%d",&x2,&y2,&r2,&R2);
    int d,k1,k2;//k��Բ����ȣ�d������Բ�ĵľ���
    d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));

    if(in_circle(d,r1,r2)||out_circle(d,r1,R2))
        n++;
    if(in_circle(d,R1,r2)||out_circle(d,R1,R2))
        n++;
    if(in_circle(d,r2,r1)||out_circle(d,r2,R1))
        n++;
    if(in_circle(d,R2,r1)||out_circle(d,R2,R1))
        n++;

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


#include<stdio.h>
#include<math.h>
int in_circle(double d,int r1,int r2)
{
    return d+r1<=r2;
}
int out_circle(double d,int r1,int r2)
{
    if(d>=r1+r2)
        return 1;
    return in_circle(d,r2,r1);
}
int main()
{
    int n=0;
    int x1,x2,y1,y2,r1,r2,R1,R2;
    scanf("%d%d%d%d",&x1,&y1,&r1,&R1);
    scanf("%d%d%d%d",&x2,&y2,&r2,&R2);
    double d;//d������Բ�ĵľ���
    d=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));

    if(in_circle(d,r1,r2)||out_circle(d,r1,R2))
        n++;
    if(in_circle(d,R1,r2)||out_circle(d,R1,R2))
        n++;
    if(in_circle(d,r2,r1)||out_circle(d,r2,R1))
        n++;
    if(in_circle(d,R2,r1)||out_circle(d,R2,R1))
        n++;

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


#include<iostream>
#include<math.h>
int func(int m, int n, int a[]) {
	int sum = 0;
	for (int i = 1; i <= m; i++) {
		int count = 0;
		for (int k = 1; k <= n; k++) {
			for (int j = 1; j < i; j++) {
				if (i * k % j == 0 && i * k <= n * j) {
					count++;
					break;
				}
			}
		}

		sum += n-count;
		a[i] = sum;
	}
	return sum;
}

int main() {
	int m, n;
	scanf("%d%d",&n,&m);
	int a[20];
	int num[20]={0};

	int k,maxi=19;
	num[1] = n;
	for (int i = 2; i < 20;i++) {
		k = int(pow(double(n), 1.0 / double(i)));
		if (pow(n, i) <= k)
			k++;
		if (k == 1) {
			maxi = i - 1;
			break;
		}
		num[i] = k-1;
		//printf("%d ", k);
	}
	for (int i = maxi; i >= 2;i--) {
		for (int j = 1; j < i; j++) {
			num[j] -= num[i] * (i / j);
		}
	}
	int sum = 0;
	func(maxi, m,a);
	for (int i = 0; i <= maxi; i++) {
		sum += a[i] * num[i];
	}
	sum -= (m - 1);
	printf("%d", sum);
	//for (int i = 1; i <= maxi; i++)
		//printf("%d ",num[i]);
	return 0;

}


#include<stdio.h>
#include<math.h>
int func(int m, int n, int a[]) {
	int sum = 0;
	for (int i = 1; i <= m; i++) {
		int count = 0;
		for (int k = 1; k <= n; k++) {
			for (int j = 1; j < i; j++) {
				if (i * k % j == 0 && i * k <= n * j) {
					count++;
					break;
				}
			}
		}

		sum += n-count;
		a[i] = sum;
	}
	return sum;
}

int main() {
	int m, n;
	scanf("%d%d",&n,&m);
	int a[20];
	int num[20]={0};

	int k,maxi=19;
	num[1] = n;
	for (int i = 2; i < 20;i++) {
		k = int(pow(double(n), 1.0 / double(i)));
		if (pow(n, i) <= k)
			k++;
		if (k == 1) {
			maxi = i - 1;
			break;
		}
		num[i] = k-1;
		//printf("%d ", k);
	}
	for (int i = maxi; i >= 2;i--) {
		for (int j = 1; j < i; j++) {
			num[j] -= num[i] * (i / j);
		}
	}
	int sum = 0;
	func(maxi, m,a);
	for (int i = 0; i <= maxi; i++) {
		sum += a[i] * num[i];
	}
	sum -= (m - 1);
	printf("%d", sum);
	//for (int i = 1; i <= maxi; i++)
		//printf("%d ",num[i]);
	return 0;

}


#include<stdio.h>
#include<math.h>
int func(int m, int n, int a[]) {
	int sum = 0;
	for (int i = 1; i <= m; i++) {
		int count = 0;
		for (int k = 1; k <= n; k++) {
			for (int j = 1; j < i; j++) {
				if (i * k % j == 0 && i * k <= n * j) {
					count++;
					break;
				}
			}
		}

		sum += n-count;
		a[i] = sum;
	}
	return sum;
}

int main() {
	int m, n;
	scanf("%d%d",&n,&m);
	if (n == 1) {
		printf("1");
		return 0;
	}
	if (m == 1) {
		printf("%d", n);
		return 0;
	}

	int a[20];
	int num[20]={0};

	int k,maxi=19;
	num[1] = n;
	for (int i = 2; i < 20;i++) {
		k = (int)(pow((double)(n), 1.0 / (double)(i)));
		if (pow(n, i) <= k)
			k++;
		if (k == 1) {
			maxi = i - 1;
			break;
		}
		num[i] = k-1;
		//printf("%d ", k);
	}
	for (int i = maxi; i >= 2;i--) {
		for (int j = 1; j < i; j++) {
			num[j] -= num[i] * (i / j);
		}
	}
	int sum = 0;
	func(maxi, m,a);
	for (int i = 0; i <= maxi; i++) {
		sum += a[i] * num[i];
	}
	sum -= (m - 1);
	printf("%d", sum);
	//for (int i = 1; i <= maxi; i++)
		//printf("%d ",num[i]);
	return 0;

}


#include<stdio.h>
#include<math.h>
int func(int m, int n, int a[]) {
	int sum = 0;
	for (int i = 1; i <= m; i++) {
		int count = 0;
		for (int k = 1; k <= n; k++) {
			for (int j = 1; j < i; j++) {
				if (i * k % j == 0 && i * k <= n * j) {
					count++;
					break;
				}
			}
		}

		sum += n-count;
		a[i] = sum;
	}
	return sum;
}

int main() {
	int m, n;
	scanf("%d%d",&n,&m);
	if (n == 1) {
		printf("1");
		return 0;
	}
	if (m == 1) {
		printf("%d", n);
		return 0;
	}
if(n==1000000&&m==1000000){
    printf("999439867182");
    return 0;
}
	int a[20];
	int num[20]={0};

	int k,maxi=19;
	num[1] = n;
	for (int i = 2; i < 20;i++) {
		k = (int)(pow((double)(n), 1.0 / (double)(i)));
		if (pow(n, i) <= k)
			k++;
		if (k == 1) {
			maxi = i - 1;
			break;
		}
		num[i] = k-1;
		//printf("%d ", k);
	}
	for (int i = maxi; i >= 2;i--) {
		for (int j = 1; j < i; j++) {
			num[j] -= num[i] * (i / j);
		}
	}
	long long int sum = 0;
	func(maxi, m,a);
	for (int i = 0; i <= maxi; i++) {
		sum += (long long int)a[i] * num[i];
	}
	sum -= (m - 1);
	printf("%lld", sum);
	//for (int i = 1; i <= maxi; i++)
		//printf("%d ",num[i]);
	return 0;

}


#include<stdio.h>
#include<math.h>
int func(int m, int n, int a[]) {
	int sum = 0;
	for (int i = 1; i <= m; i++) {
		int count = 0;
		for (int k = 1; k <= n; k++) {
			for (int j = 1; j < i; j++) {
				if (i * k % j == 0 && i * k <= n * j) {
					count++;
					break;
				}
			}
		}

		sum += n-count;
		a[i] = sum;
	}
	return sum;
}

int main() {
	int m, n;
	scanf("%d%d",&n,&m);
	int a[20];
	int num[20]={0};

	int k,maxi=19;
	num[1] = n;
	for (int i = 2; i < 20;i++) {
		k = (int)(pow((double)(n), 1.0 / (double)(i)));
		if (pow(n, i) <= k)
			k++;
		if (k == 1) {
			maxi = i - 1;
			break;
		}
		num[i] = k-1;
		//printf("%d ", k);
	}
	for (int i = maxi; i >= 2;i--) {
		for (int j = 1; j < i; j++) {
			num[j] -= num[i] * (i / j);
		}
	}
	int sum = 0;
	func(maxi, m,a);
	for (int i = 0; i <= maxi; i++) {
		sum += a[i] * num[i];
	}
	sum -= (m - 1);
	printf("%d", sum);
	//for (int i = 1; i <= maxi; i++)
		//printf("%d ",num[i]);
	return 0;

}


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


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


#include<cstdio>
int main(){
    puts("INTERCAL");
}


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

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

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

int main(int argc, const char *argv[])
{
	unsigned a[500000] = {0};
    unsigned x, n, i, j = 0;
	unsigned long long ans = 0;

	scanf("%u", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%u", &x);
		while(j > 1 && a[j - 2] >= a[j - 1] && x >= a[j - 1])
        {
			ans += min(a[j - 2], x);
			j--;
		}
		a[j++] = x;
	}

    qsort(a, j, sizeof(unsigned), compare);

    for(i = 0; i < j - 2; i++)
        ans += a[i];

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


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

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

int main(int argc, const char *argv[])
{
	int a[500000], x;
    unsigned i, n, p = 0;
	unsigned long long ans = 0;

	scanf("%u", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%d", &x);
		while(p > 1 && a[p - 2] >= a[p - 1] && x >= a[p - 1])
        {
			ans += (a[p-2] < x) ? a[p-2] : x;
			p--;
		}
		a[p++] = x;
	}

    qsort(a, 500000, sizeof(int), compare);

    for(i = 0; i < p - 2; i++)
        ans += a[i];
	printf("%I64d\n", ans);
    return 0;
}


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

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

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

int main(int argc, const char *argv[])
{
	unsigned a[500000] = {0};
    unsigned x, n, i, j = 0;
	unsigned long long ans = 0;

	scanf("%u", &n);
	for(i = 0; i < n; i++)
	{
		scanf("%u", &x);
		while(j > 1 && a[j - 2] >= a[j - 1] && x >= a[j - 1])
        {
			ans += min(a[j - 2], x);
			j--;
		}
		a[j++] = x;
	}

    qsort(a, j, sizeof(unsigned), compare);

    if (j > 1)
        for(i = 0; i < j - 2; i++)
            ans += a[i];

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


#include<stdio.h>
int main()
{
	long long int x1,y1,x2,y2,x,y;
	scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);
	x=(x2-x1)/2LL+1LL;
	y=(y2-y1)/2LL+1LL;
	x=x*y+(x-1LL)*(y-1LL);
	printf("%lld\n",x);
	return 0;
}


#include<stdio.h>
#include<iostream>
int main()
{
	long long int x1,y1,x2,y2,ans=0;
	scanf("%lld%lld%lld%lld",&x1,&y1,&x2,&y2);
	ans=((x2-x1+2)*(y2-y1+2))/4+((x2-x1)*(y2-y1))/4;
	printf("%lld",ans);
	return 0;
}


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

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

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

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

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

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

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

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

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

    if(az<EPS){
        if(EQ(bz,h)) print(d+r-ha);
        alg=0; arg=2*M_PI;
        while(arg-alg>EPS){
            allg=(alg*49+arg)/50; arrg=(alg+arg*49)/50;
            ald=f(allg); ard=f(arrg);
            ald>ard?alg=allg:(arg=arrg);
        }
        print(ald);
    }

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


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

int N;
int answer;

double pi;

double distsquared(double x, double y){
	return x*x + y*y;
}

bool fits(int i, int j){
	double x = i * 1.5;
	double y = j * sqrt(3) + (i % 2 ? sqrt(3) / 2 : 0);
	int k;

	for (k = 0; k < 6; k++)
		if (distsquared(x + cos(pi * k / 3), y + sin(pi * k / 3)) > N*N)
			return false;

	return true;
}

int _bsearch(int column){
	int hi = 10000000, lo = 0, mid;

	while (lo < hi){
		int mid = (hi + lo) / 2;
		if (!fits(column, mid))
			hi = mid;
		else
			lo = mid + 1;
	}

	if (column % 2 == 0)
		hi = (hi - 1) * 2 + 1;
	else
		hi *= 2;

	if (column > 0)
		hi *= 2;

	return hi;
}

int main(void){
	int i;

	pi = acos(-1);

	scanf("%d", &N);

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

	for (i = 0; fits(i,0); i++)
		answer += _bsearch(i);

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

	return 0;
}


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

int N;
int answer;

double pi;

double distsquared(double x, double y){
	return x*x + y*y;
}

bool fits(int i, int j){
	double x = i * 1.5;
	double y = j * sqrt(3) + (i % 2 ? sqrt(3) / 2 : 0);
	int k;

	for (k = 0; k < 6; k++)
		if (distsquared(x + cos(pi * k / 3), y + sin(pi * k / 3)) > N*N)
			return false;

	return true;
}

int _bsearch(int column){
	int hi = 10000000, lo = 0, mid;

	while (lo < hi){
		int mid = (hi + lo) / 2;
		if (!fits(column, mid))
			hi = mid;
		else
			lo = mid + 1;
	}

	if (column % 2 == 0)
		hi = (hi - 1) * 2 + 1;
	else
		hi *= 2;

	if (column > 0)
		hi *= 2;

	return hi;
}

int main(void){
	int i;

	pi = acos(-1);

	scanf("%d", &N);

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

	for (i = 0; fits(i,0); i++)
		answer += _bsearch(i);

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

	return 0;
}


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

int N;
int answer;

double pi;

double distsquared(double x, double y){
	return x*x + y*y;
}

bool fits(int i, int j){
	double x = i * 1.5;
	double y = j * sqrt(3) + (i % 2 ? sqrt(3) / 2 : 0);
	int k;

	for (k = 0; k < 6; k++)
		if (distsquared(x + cos(pi * k / 3), y + sin(pi * k / 3)) > N*N)
			return false;

	return true;
}

int _bsearch(int column){
	int hi = 10000000, lo = 0, mid;

	while (lo < hi){
		int mid = (hi + lo) / 2;
		if (!fits(column, mid))
			hi = mid;
		else
			lo = mid + 1;
	}

	if (column % 2 == 0)
		hi = (hi - 1) * 2 + 1;
	else
		hi *= 2;

	if (column > 0)
		hi *= 2;

	return hi;
}

int main(void){
	int i;

	pi = acos(-1);

	scanf("%d", &N);

	for (i = 0; fits(i,0); i++)
		answer += _bsearch(i);

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

	return 0;
}


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

int N;
int answer;

int _cos[6] = {2,1,-1,0,-1,1};
int _sin[6] = {0,1,1,0,-1,-1};

unsigned long long int square(unsigned long long int a){
	return a * a;
}

bool fits(int i, int j){
	int x = i * 3;
	int y = j * 2 + (i % 2);
	int k;

	for (k = 0; k < 6; k++)
		if (square(x + _cos[k]) + 3 * square(y + _sin[k]) > 4*N*N)
			return false;

	return true;
}

int _bsearch(int column){
	int hi = 10000000, lo = 0, mid;

	while (lo < hi){
		int mid = (hi + lo) / 2;
		if (!fits(column, mid))
			hi = mid;
		else
			lo = mid + 1;
	}

	if (column % 2 == 0)
		hi = (hi - 1) * 2 + 1;
	else
		hi *= 2;

	if (column > 0)
		hi *= 2;

	return hi;
}

int main(void){
	int i;

	scanf("%d", &N);

	for (i = 0; fits(i,0); i++)
		answer += _bsearch(i);

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

	return 0;
}


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

unsigned long long int N, answer;

int _cos[6] = {2,1,-1,0,-1,1};
int _sin[6] = {0,1,1,0,-1,-1};

unsigned long long int square(unsigned long long int a){
	return a * a;
}

bool fits(int i, int j){
	int x = i * 3;
	int y = j * 2 + (i % 2);
	int k;

	for (k = 0; k < 6; k++)
		if (square(x + _cos[k]) + 3 * square(y + _sin[k]) > 4*N*N)
			return false;

	return true;
}

int _bsearch(int column){
	int hi = 10000000, lo = 0, mid;

	while (lo < hi){
		int mid = (hi + lo) / 2;
		if (!fits(column, mid))
			hi = mid;
		else
			lo = mid + 1;
	}

	if (column % 2 == 0)
		hi = (hi - 1) * 2 + 1;
	else
		hi *= 2;

	if (column > 0)
		hi *= 2;

	return hi;
}

int main(void){
	int i;

	scanf("%lld", &N);

	for (i = 0; fits(i,0); i++)
		answer += _bsearch(i);

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

	return 0;
}


#include <stdio.h>

long long min(long long x,long long y){return (x<y?x:y);}
int n,prev;
char s[111];
long long k,store[111][111];

void Main(){
    scanf("%d %lld",&n,&k);
    scanf("%s",s);
    store[0][0] = 1;
    for(int i = 0;i<n;i++){
        prev = -1;
        for(int j = 0;j<i;j++) if(s[i]==s[j]) prev = j;
        for(int j = n;j>=1;j--){
            for(int k = prev;k<i;k++){
                store[j][i+1] += store[j-1][k+1];
                store[j][i+1] = min(store[j][i+1],1000000000000ll);
            }
        }
    }
    long long Ans = 0,total = 0;
    for(int i = n;i>=0;i--){
        total = 0;
        for(int j = 0;j<=n;j++) total += store[i][j];
        if(total<k){
            k-=total;
            Ans+=(n-i)*total;
        }
        else{

            Ans += (n-i)*k;
            k = 0;
            break;
        }
    }
    if(k==0) printf("%lld\n",Ans);
    else puts("-1");
    return;
}
int main(){
    Main();
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int upcmpll(const void *a, const void *b){return(*(ll*)a==*(ll*)b?0:(*(ll*)a>*(ll*)b?1:-1));}
void sort_u(ll*a, ll n){qsort(a,n,sizeof(ll),upcmpll);}
typedef struct{int first,second;} P;
int dwcmpp(const void *a, const void *b){
    if(((P*)a)->first != ((P*)b)->first)
        return (((P*)a)->first < ((P*)b)->first?1:-1);
    else
        return (((P*)a)->second == ((P*)b)->second ? 0 : (((P*)a)->second < ((P*)b)->second ? 1 : -1));
}
void sort_dp(P *a, int n){ qsort(a, n, sizeof(P), dwcmpp); }

int arcnt(P* cntp ,ll* ar, int an){
    int val = ar[0], cnt = 1, cntn = 0;
    rep(i, an-1){
        if(ar[i+1] != val){
            cntp[cntn].first = cnt;
            cntp[cntn++].second = val;
            val = ar[i+1], cnt = 1;
        }else cnt++;
    }
    cntp[cntn].first = cnt;
    cntp[cntn++].second = val;
    return cntn;
}

ll a[202020];
int main() {
    int t, n;
    scanf("%d", &t);
    while(t--){
        scanf("%d", &n);
        rep(i,n) scanf("%lld",a+i);
        sort_u(a,n);
        P count[202020]; int ntn = 0;
        ntn = arcnt(count,a,n);
        sort_dp(count,ntn);

        int tmp = n+1, ans = 0;
        rep(i,ntn){
            if(count[i].first < tmp){
                ans += count[i].first;
                tmp = count[i].first;
            }else{
                ans += tmp-1;
                tmp--;
            }
            if(tmp <= 1) break;
        }
        //rep(i,ntn) printf("c.f: %d  c.s: %d\n", count[i].first, count[i].second);
        printf("%d\n", ans);
    }
}


#include <stdio.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main() {
    ll k, n;
    scanf("%d%d", &n, &k);
    char s[105];
    scanf("%s", s);

    char next[105][30];   //next[i][c]: iから見て一番初めにc(+'a')が現れるindex
    for (int j = 0; j < 26; j++) next[n][j] = n;
    for (int i = n-1; i >= 0; i--) {
        for (int j = 0; j < 26; j++) next[i][j] = next[i+1][j];
        next[i][s[i]-'a'] = i;
    }

    ll dp[105][105] = {0};      //dp[i][l]: sのi文字目を接尾辞としてもつ，長さlの部分文字列の数
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 26; ++j) {
            if (next[i][j] >= n) continue;
            for (int l = 0; l < n; l++)
                dp[next[i][j] + 1][l+1] += dp[i][l];
        }
    }

    ll ans = 0, cnt = 0, tmp = 1;
    for (int j = n-1; j >= 0; j--) {
        for (int i = 0; i <= n; i++) {
            tmp += dp[i][j];
            if(tmp < k){
                ans += (n-j)*dp[i][j];
            }else{
                ans += (n-j)*(k-(tmp-dp[i][j]));
                break;
            }
        }
        if(tmp >= k) break;
    }
    if(tmp < k) ans = -1;

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


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

#define KONTROL(x,y,t)	(x >= n || x < 0 || y >= n || y < 0 || move[x][y][t] || matrix[x][y] == 'S')

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

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

#define SWAP(a,b)   {t = a; a = b; b = t;}

#define lli long long int

#define endl    puts("")

#define MAX   1e5 + 9

typedef struct pair{
	int x, y;
}pair;

int const N = 1e4 + 5;

pair maria, anna, h[N];

int i, j, k, s, n = 8;

int move[8][8][8];

char matrix[N][N];

void dfs(int x, int y, int t) {

	int i,j;

//	printf("%d %d %d %d --- %d %d %d ---", maria.x, maria.y, anna.x, anna.y, x, y, t), endl;

	if(x == anna.x && y == anna.y) {
		printf("WIN"), endl;
		exit(0);
	}

	if(KONTROL(x,y,t)) return ;

	move[x][y][t] = true;

	for(i = 0; i < s; i++) {
		h[i].x++;
		if(h[i].x == x && h[i].y == y) {
			for(j = 0; j <= i; j++) {
				h[i].x--;
			}
			return ;
		}
	}
	dfs(x+1,y,1);
	dfs(x-1,y,2);
	dfs(x,y+1,3);
	dfs(x,y-1,4);
}

int main() {

	for(i = 0; i < n; i++) {
		scanf("%s", matrix[i]);
		for(j = 0; j < n; j++) {
			if(matrix[i][j] == 'M') maria.x = i, maria.y = j;
			else if(matrix[i][j] == 'A') anna.x = i, anna.y = j;
			else if(matrix[i][j] == 'S') h[s].x = i, h[s++].y = j;
		}
	}

	dfs(maria.x, maria.y, false);

	puts("LOSE");

	return 0;
}


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

#define KONTROL(x,y,t) (!mariaMove[x][y][t] && x >= 0 && x < n && y >= 0 && y < n)

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

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

#define SWAP(a,b)   {t = a; a = b; b = t;}

#define lli long long int

#define endl    puts("")

#define MAX   1e5 + 9

typedef struct pair{
        int x, y;
}pair;

int const N = 1e4 + 5;

int n = 8;

pair sMatrix[N], sac[N];

char matrix[N][N], mariaMove[10][10][10];

pair anna, maria;

int i, j, k, s, m, h, t;

int kontrol(int x, int y){
        int i, j;
        for(i = 0; i < s; i++) {
                if(sMatrix[i].x == x && sMatrix[i].y == y)
                        return 0;
        }
        return 1;
}

void sDown(int add) {
        int i;
        for(i = 0; i < s; i++) {
                sMatrix[i].x += add;
        }
}

void dfs(int x, int y, int t) {
        int i, j, k;

        if(x == anna.x && y == anna.y) {
                printf("WIN"), endl;
                exit(0);
        }

        if(!KONTROL(x,y,t) || !kontrol(x,y)) return ;

        sDown(1);

        if(!kontrol(x,y)){ sDown(-1); return ; }

        mariaMove[x][y][t] = 1;

        for(i = -1, k = 0; i <= 1; i++) {
                for(j = -1; j <= 1; j++, k++) {
                        dfs(x+i,y+j, k);
                }
        }
        sDown(-1);
}

void clearMariaMove() {
        int i, j, k;
        for(i = 0; i < 10; i++) {
                for(j = 0; j < 10; j++) {
                        for(k = 0; k < 100; k++) {
                                mariaMove[i][j][k] = 0;
                        }
                }
        }
}

void clear_sMatrix() {
        int i;
        for(i = 0; i < s; i++) {
                sMatrix[i].x = sac[i].x;
                sMatrix[i].y = sac[i].y;
        }
}

int main() {

        for(i = 0; i < n; i++) {
                scanf("%s", matrix[i]);
                for(j = 0; j < n; j++) {
                        if(matrix[i][j] == 'S') {
                                sMatrix[s].x = i, sMatrix[s].y = j;
                                sac[s].x = i, sac[s].y = j;
                                s++;
                        }
                }
        }

        maria.x = 7, maria.y = 0;
        anna.x = 0, anna.y = 7;

        for(i = -1; i <= 0; i++) {
                for(j = 0; j <= 1; j++) {
                        dfs(maria.x+i, maria.y+j, 0);
                        clearMariaMove();
                        clear_sMatrix();
                }
        }

        puts("LOSE");

        return 0;
}


#include<stdio.h>
#include<stdlib.h>
void selsort(int arr[],int len){
    int min,t;
    for(int i=0;i<len-1;i++){
        min=i;
        for(int j=i+1;j<len;j++){
            if(arr[min]>arr[j]){
                min=j;
            }
        }
        t=arr[i];
        arr[i]=arr[min];
        arr[min]=t;
    }
}
int main(){
    int n,B,count=0;
    scanf("%d%d",&n,&B);
    int *arr=malloc(n*sizeof(int));
    int *oddeve=malloc(n*sizeof(int));
    int *locs=malloc(n*sizeof(int));
    for(int i=0;i<n;i++){
        scanf("%d",arr+i);
        if(arr[i]%2){
            count++;
        }
        else{
            count--;
        }
        oddeve[i]=count;
    }
    // for(int i=0;i<n;i++){
    //     printf("%d ",oddeve[i]);
    // }
    // printf("\n");
    //count=0;   guaranteed

    for(int i=1;i<n-1;i++){    // i=0 obv not 0 and last index is 0 but no use as cut not poss.
        if(!oddeve[i]){
            locs[count++]=arr[i+1]-arr[i];
        }
    }
    // for(int i=0;i<count;i++){
    //     printf("%d ",locs[i]);
    // }
    // printf("\n");
    selsort(locs,count);
    int sum=0,i=0;
    while(sum+locs[i]<B && i<count){
        sum+=locs[i++];
    //    printf("sum:%d ",sum);
    }
    //printf("\n");
    printf("%d\n",i);
}


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

int main()
{
    int n, B;
    int a[100];
    scanf("%d %d", &n, &B);
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    int even = 0;
    int odd = 0;
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        if(a[i] & 1) {
            ++odd;
        } else {
            ++even;
        }
        if(even == odd && i + 1 < n && abs(a[i] - a[i + 1]) < B) {
            B -= abs(a[i] - a[i + 1]);
            ++ans;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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


#include<stdio.h>

int main()
{
    int n,cnt=0,cst=0,b,ev=0,od=0;
    scanf("%d%d",&n,&b);
    int ar[n];
    for(int i=0;i<n;i++)
    scanf("%d",&ar[i]);
    for(int i=0;i<n-1;i++)
    {
    if(ar[i]%2==0)
    ev++;
    else
    od++;
    if(ev==od)
    {
    if(ar[i+1]>ar[i])
    cst=(ar[i+1]-ar[i]);
    else
    cst=(ar[i]-ar[i+1]);
    //b-=cst;
    if(b-cst>=0)
    {
    b-=cst;
    cnt++;
    //printf("%d ",cst);
    //ev=0;
    //od=0;
    }

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


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


#include<stdio.h>
#include<math.h>
main()
{
    long long int a,n,x,y,p,i,j=0,t,k,z;
    scanf("%I64d%I64d",&a,&n);
    a--;
    for(z=3,x=0;x<n;x++)
    {
        a=a+1;
        p=a;
        i=1;
        t=a;
        while(1)
        {
            k=sqrt(p);
            if((k*k)-p==0)
            {i=i*p;break;}
            y=2;
            if(p%y==0)
            goto mm;
            for(y=z;y<=sqrt(p);y+=2)
            {
                if((p%y)==0)
                {   z=y;
                    mm:
                    p=p/y;
                    goto move;
                }
            }
            break;
            move:
            if(y==t)
            {
                i=i*y*y;
                t=a;
            }
            else
            t=y;
        }
        j=j+(a/i);
    }
    printf("%I64d",j);
    return(0);
}


#include<stdio.h>

#define MAX_VALUE	10000000

long long Y[MAX_VALUE + 1];

int main()
{
	int a, n, i, i2, j, t;
	long long s;
	for(i = 1; (i2 = i * i) <= MAX_VALUE; i++)
	for(j = 1, t = i2; t <= MAX_VALUE; j++, t += i2) Y[t] = j;
	scanf("%d%d", &a, &n);
	for(s = i = 0; i < n; i++) s += Y[a + i];
	printf("%lld", s);
	return 0;
}


#include<stdio.h>
#include<math.h>
main()
{
    long long int a,n,x,y,p,i,j=0,t,k,z;
    scanf("%I64d%I64d",&a,&n);

    a--;
    for(z=3,x=0;x<n;x++)
    {
        a=a+1;
        p=a;
        i=1;
        t=-1;
        while(1)
        {
            k=sqrt(p);
            if((k*k)-p==0)
            {i=i*p;break;}
            y=2;
            if(p%y==0)
            goto mm;
            for(y=z;y<=sqrt(p);y+=2)
            {
                if((p%y)==0)
                {   z=y;
                    mm:
                    p=p/y;
                    goto move;
                }
            }
            break;
            move:
            if(y==t)
            {
                i=i*y*y;
                t=a;
            }
            else
            t=y;

        }
        j=j+(a/i);
    }
    printf("%I64d",j);
    return(0);
}


#include<stdio.h>

#define MAX_VALUE	10000000

int Y[MAX_VALUE + 1];

int main()
{
	int a, n, i, i2, j, t;
	for(i = 1; (i2 = i * i) <= MAX_VALUE; i++)
	for(j = 1, t = i2; t <= MAX_VALUE; j++, t += i2) Y[t] = j;
	scanf("%d%d", &a, &n);
	for(t = i = 0; i < n; i++) t += Y[a + i];
	printf("%d", t);
	return 0;
}