#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdio>
#include<stdlib.h>
#include <queue>
#include<string>
#include<cstring>
#include<sstream>
#include<list>
#include<math.h>
#include<map>
#include<set>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<fstream>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;
int GCDFast(int a,int b){   while(b)b^=a^=b^=a%=b;  return a;   }
#define SET(a) memset(a,-1,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define CLR(a) memset(a,0,sizeof(a))
#define PB push_back
#define PI acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define READ freopen("input.txt", "r", stdin)
#define WRITE freopen("output.txt", "w", stdout)
#define LL long long
#define ALL_BITS ((1 << 31) - 1)
#define NEG_BITS(mask) (mask ^= ALL_BITS)
#define TEST_BIT(mask, i) (mask & (1 << i))
#define ON_BIT(mask, i) (mask |= (1 << i))
#define OFF_BIT(mask, i) (mask &= NEG_BITS(1 << i))

// UP, RIGHT, DOWN, LEFT, UPPER-RIGHT, LOWER-RIGHT, LOWER-LEFT, UPPER-LEFT
int dx[8] = {-1, 0, 1, 0, -1, 1,  1, -1};
int dy[8] = { 0, 1, 0,-1,  1, 1, -1, -1};
#define MOD 1000000007
#define MX 100010
#define pii pair<int,int>
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}//gcd
int GCD(int b, int a)
{
	if(a == 0)	return b;
	return GCD(a, b%a);
}
long long getLcm(long long a,long long b){
	long long c=a/gcd(a,b);
	return b*c;
}
/*
//---------coinChange--DP faster----
long long table[30000+1];
long long coinChangecount(int m, int n )
{
memset(table, 0, sizeof(table));
table[0] = 1;

for(int i=0; i<m; i++)
for(int j=a[i]; j<=n; j++)
table[j] += table[j-a[i]];

return table[n];
}
//----coinChange- using recursion+dp------------
long long dp[6][30005];
long long coin_Change(int coinNumber, int reminder){//how many ways to count this coin

if(dp[coinNumber][reminder])
return dp[coinNumber][reminder];

if(reminder == 0){
dp[coinNumber][reminder] = 1;return dp[coinNumber][reminder];
}
if(coinNumber <0){
dp[coinNumber][reminder] = 0;return dp[coinNumber][reminder];
}
if(reminder<0){
dp[coinNumber][reminder] = 0;return dp[coinNumber][reminder];
}
if(coinNumber<=0 && reminder>0){
dp[coinNumber][reminder] = 0;return dp[coinNumber][reminder];
}

dp[coinNumber][reminder] = coin_Change(coinNumber, reminder - a[coinNumber-1])+ coin_Change(coinNumber-1, reminder);
return dp[coinNumber][reminder];
}
-------------------------------------------
//----------------- LDS+ LIS N^2----------------
for(i = n - 1; i >= 0; i--) {
for( j = i + 1; j < n; j++) {
if(a[i] > a[j] && ( lds[i] < (lds[j]+1)))
lds[i] = lds[j]+1;
}
}
for(i = n - 1; i >= 0; i--) {
for( j = i + 1; j < n; j++) {
if(a[i] < a[j] && ( lis[i] < (lis[j]+1))){
lis[i] = lis[j]+1;
}
}
}
vector<int>List; // LIS list
for(i = n-1; i >=0 && max; i--){
if(max == lis[i]){
List.push_back(a[i]);
max--;
}
}
//----binary search---------------------
int binarySearchLIS(int key,int size){
int low =0,high = size-1,mid,ret=100005,index=-1;
while(low<=high){
mid = (low+high)/2;
if(lis[mid] == key)
return -1;//already found
else if(lis[mid] > key){
if(ret>lis[mid]){
ret = lis[mid];
index = mid;
}
high=mid-1;//high index decreased as the number is already greater than mid
}
else if(lis[mid] < key){
low=mid+1; //key is bigger than the mid number so low index increased
}
}
return index;
}
//----------palindrome-------------
int isPalindrome(string str){
int i,n=str.size(),j,mid=str.size()/2;
for(i=0,j=n-1;i<mid;i++,j--)
if(str[i] != str[j])
return 0;
if(i==mid)
return 1;
return 0;
}
//---------------------binary search with extra condition----------------
pair<int,int>P[15];
int binary_search( int first, int last,int key)
{
while (last >= first)
{
// calculate the midpoint for roughly equal partition
int imid = (first + last)/2;
if(P[imid].first <= key && P[imid].second>= key)
return imid;

else if (P[imid].second < key)
first = imid + 1;
else
last = imid - 1;
}

return -1;// key was not found
}
//--------nlogn list------LIS-------------
int GetCeilIndex(int a[], int T[], int l, int r, int key) {
int m;

while( r - l > 1 ) {
m = l + (r - l)/2;
if( a[T[m]] >= key )
r = m;
else
l = m;
}

return r;
}
int LongestIncreasingSubsequence( int size) {
// Add boundary case, when array size is zero
// Depend on smart pointers

int *tailIndices = new int[size];
int *prevIndices = new int[size];
int len,j,i;

memset(tailIndices, 0, sizeof(tailIndices[0])*size);
memset(prevIndices, 0xFF, sizeof(prevIndices[0])*size);

tailIndices[0] = 0;
prevIndices[0] = -1;
len = 1; // it will always point to empty location
for( int i = 1; i < size; i++ ) {
if( a[i] < a[tailIndices[0]] ) {
// new smallest value
tailIndices[0] = i;
} else if( a[i] > a[tailIndices[len-1]] ) {
// a[i] wants to extend largest subsequence
prevIndices[i] = tailIndices[len-1];
tailIndices[len++] = i;
} else {
// a[i] wants to be a potential condidate of future subsequence
// It will replace ceil value in tailIndices
int pos = GetCeilIndex(a, tailIndices, -1, len-1, a[i]);

prevIndices[i] = tailIndices[pos-1];
tailIndices[pos] = i;
}
}
j=0;
for(i = tailIndices[len-1],j=0; i >= 0; i = prevIndices[i],j++ ){
lisCal[j] = a[i];
}
len = j;

delete[] tailIndices;
delete[] prevIndices;

return len;
}
---------Flood Fill-------------------
#define pii pair<int,int>
//int fx[]={1,-1,0,0,1,1,-1,-1};
//int fy[]={0,0,1,-1,1,-1,1,-1};
int fx[] = {1,-1,0,0}; //not in diagonal
int fy[] = {0,0,1,-1};
int cell[105][105];
int d[105][105],vis[105][105];
int row,col;
bool check(int tx,int ty)
{
if (tx>=0 && tx<row && ty>=0 && ty<col)
return true;
return false;
}
int bfs(int sx,int sy)
{
vis[sx][sy]=1;
int sum = 1;
queue<pii>q;
q.push(pii(sx,sy));
while(!q.empty())
{
pii top=q.front(); q.pop();
for(int k=0;k<4;k++)
{
int tx=top.first+fx[k];
int ty=top.second+fy[k];
if((check(tx,ty)) && (cell[tx][ty]==cell[sx][sy]|| cell[tx][ty]==1) && vis[tx][ty]==0)//
{
vis[tx][ty]=1;
sum++;
//d[tx][ty]=d[top.first][top.second]+1;
q.push(pii(tx,ty));
}
}
}
return sum;
}
*/

//long long dp[105][30005];
long long minimium = 1000005;
int minCoin=0;

/* prime generate
#define N 1000000
bool prime_number[N];
long long prime_generator(long long n)
{
	long long i = 0 , x = 0,j = 0,limit;

	prime_number[0] = false;
	prime_number[1] = false;
	for(i = 2 ; i<= n ; i++)
		prime_number[i] = true;
	limit = (long long)sqrt((double)n);
	for(x = 2 ; x <=  limit;x++)
	{
		if(prime_number[x] == true)
		{
			for(i = 4 ; i <= n ;i++)
				if(prime_number[i] == true & i != x)
					if(i % x == 0)
						prime_number[i] = false;
		}
	}
	x = 0;
	for(i = 2 ; i<= n ; i++)
		if(prime_number[i])
			x++;//number of primes
	return x;
}*/

//int a[100005],b[100005];

int main()
{
	long long i,n,m,x,testCase=0,j,k,y,flag,temp;
	long long  sum,max,number,min,p,q,reminder,index;
	string str,S,str1,str2;
	long long l,r,s,sk,t;
	int X[5],Y[5];
	while(cin>>n)
	{
		for(i=1;i<=n;i++){
			cin>>X[i]>>Y[i];
		}

		if(n == 1)
			cout<<"-1\n";
		else if(n == 2){
			x = abs(X[1]-X[2]) *abs(Y[1]-Y[2]);
				if(x)
					cout<<x<<"\n";
				else
					cout<<<"-1\n";
		}
		else if( n== 3 || n == 4){
			for ( i = 1; i <= n; i++) {
				for ( j = i+1; j <= n; j++){
					if (X[i] == X[j]){
						y = abs(Y[j] - Y[i]);
						k=j;
						break;
					}
				}
			}
			x = -1;
			{
				for ( j = 1; j <= n; j++){
					if (Y[i] == Y[j] && i!=j){
						x = abs(X[j] - X[i]);
						break;
					}
				}
			}
			if(x == -1){
				i = k;
			for ( j = 1; j <= n; j++){
					if (Y[i] == Y[j] && i!=j){
						x = abs(X[j] - X[i]);
						break;
					}
				}
			}
			x = x*y;
			if(x<0)
				x=x*-1;
			if(x == 0)
				x = -1;
			cout<<x<<"\n";
		}

	}

	return 0;
}


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

int n,a,b,maxa=-10000000,maxb=-10000000,mina=1000000,minb=10000000,ans;
int main()
{
	cin>>n;
	if(n<=1) cout<<-1;
	else
		{
			for(int i=1;i<=n;++i)
				{
					cin>>a>>b;
					if(a>maxa&&b>maxb) maxa=a,maxb=b;
					if(a<mina&&b<minb) mina=a,minb=b;
				}
				ans=(maxa-mina)*(maxb-minb)
			if(ans>0)
			cout<<ans;
			else if (ans<0) cout<<-ans;
			else cout<<-1;
		}
}


#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

inline ll C(int N,int M)
{
	ll ans=1; for(ll i=N,j=1;j<=M;j++,i--) ans*=i;
	rep(i,1,M) ans/=i; return ans;
}

double n,p;

inline bool jud(int x)
{
	ll tmp=2*C(x,3)+2*C(x,2)*C(n-x,1)+C(x,1)*C(n-x,2);
	ll P=2*C(n,3);
	if((double)tmp>=(double)P*p) return true; return false;
}

int main()
{
	cin>>n>>p;
	rep(i,0,n) if(jud(i)) {cout<<i<<endl; break;}


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

const int maxn = 1010, sigma_size = 20;
int f[1 << sigma_size];
unordered_map<int, tuple<int, int, int>> dp[maxn];
int cnt[maxn][sigma_size];
char s[maxn];

int main() {
    int n;
    scanf("%d", &n);
    scanf("%s", s + 1);
    int st = 0, tot = 0;
    f[0] = n + 1;
    for (int i = n; i; i--)
        if (!((st >> (s[i] - 'a')) & 1))
        {
            st |= 1 << (s[i] - 'a'), tot++;
            for (int j = 0; j < 1 << sigma_size; j++)
                if (!f[j] && ((j & st) == j))
                    f[j] = i;
        }
    for (int i = 0; i < st; i++)
        if (f[i])
            printf("f[%d] = %d\n", i, f[i]);
    for (int i = 1; i <= n; i++)
        for (int j = 0; j < sigma_size; j++) cnt[i][j] = cnt[i - 1][j] + (s[i] - 'a' == j);
    int nxt, val;
    dp[0][0] = make_tuple(0, 0, 0);
    for (int i = 0; i <= n; i++)
        for (auto j : dp[i]) {
            for (int k = 0; k < sigma_size; k++)
                if (((st >> k) & 1) && !((j.first >> k) & 1)) {
                    nxt = j.first << k, val = cnt[f[st ^ nxt] - 1][k] - cnt[i][k];
                    if (!dp[f[st ^ nxt]].contains(nxt) || get<2>(dp[f[st ^ nxt]][nxt]) < val)
                        dp[f[st ^ nxt]][nxt] = make_tuple(i, j.first, val);
                }
        }
    int cur;
    string ans = "", tmp;
    for (int i = 1; i <= n; i++)
        if (dp[i].contains(st)) {
            auto u = dp[i][st];
            tmp.clear(), cur = tot - 1;
            while (get<2>(u)) {
                for (int j = 1; j <= get<2>(u); j++) tmp.push_back(cur + 'a');
                cur--, u = dp[get<0>(u)][get<1>(u)];
            }
            if (ans < tmp)
                ans = tmp;
        }
    cout << ans << endl;
    return 0;
}


#include<algorithm>
#include<iostream>
using namespace std;
#define int long long
const int N=2e5+10;
long long double c2(int n) {
	return n * (n - 1) / 2.0;
}

long double c3(int n) {
	return n * (n - 1) * (n - 2) / 6.0;
}
int n;
long double p;
signed main(){
	cin>>n>>p;
	for(int i=0;i<n;i++){
		if((c3(i)+c2(i)*(n-i)+i*c2(n-i)/2.0)/(c3(n))>=p){
			cout<<i<<endl;
			return 0;
		}
	}
    return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")

    #define int long long

#define YES cout<<"YES\n";return;
#define NO cout<<"NO\n";return;
#define write(a) cout<<a<<"\n";return;
#define F first
#define S1 second

using namespace std;
using vi=vector<int>;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);
long long powmod(long long a,long long b,long long mod) {
        if (b==0 || a==1)  {if (mod==1) return 0; else return 1; }

        if (b%2==0) { long long k=powmod(a,b/2,mod); return (k*k)%mod; }
        else {long long k=powmod(a,b/2,mod); return ( (k*k) %mod *a)% mod; }
}
long long gcd(long long a, long long b) {
    if (a==0) return b;
    if (b==0) return a;
    if (a>b) return gcd(a%b,b); else return gcd(b%a,a);
}
int prime(int p) { // 1 - простое
if (p==1) return 0;
    for (int i=2;i*i<=p;i++) {
    if (p%i==0 && i<p) return i;
    }
    return 1;
}

 int inv(int a, int mod) {
    return powmod(a,mod-2,mod);
}

 int random_modul() {

    uniform_int_distribution <int> u1(1e9, 2e9);
    int pepega=u1(rnd);
    while (prime(pepega)!=1) pepega=u1(rnd);
    return pepega;
}

template <typename T1> void ifmax(T1 &max, T1 kek) {
    if (kek>max) max=kek;
    return;
}
template <typename T1> void ifmin(T1 &min, T1 kek) {
    if (kek<min) min=kek;
    return;
}

template <typename T1> istream& operator>> (std::istream& in, pair<T1,T1> & a) {
in>>a.first>>a.second;
return in;

}

template <typename T1> istream& operator>> (std::istream& in, vector<T1> & a) {
    for (int i=0;i<a.size();i++) in>>a[i];
    return in;
}

template <typename T1>  ostream& operator<< (std::ostream& out, vector <T1> &b) {
    for (int i=0;i<b.size();i++) out<<b[i]<<" ";
    out<<"\n";
    return out;
}
template <typename T1> void sort(vector <T1> &m) {
    sort(m.begin(),m.end());
}

template <typename T1> void reverse(vector <T1> &m) {
 reverse(m.begin(),m.end());
}
int mod=1000000007;
int fac[200005];
int inv_fac[200005];
int co(int a, int b) {
    int ans=1;
    ans*=fac[b];
    ans*=inv_fac[b-a]; ans%=mod;
    ans*=inv_fac[a];
    return ans%mod;
}
 bool is_sorted(vector <int> a) {
     int check=1;
     for (int i=0;i+1<a.size();i++) if (a[i+1]<a[i]) check=0;
     if (check) return true; else return false;
 }

void solve () {

     /* ---- !! F, S !!  ---- */

int a;
long double kek;
cin>>a>>kek;
long double eps=1e-7;
for (int i=1;i<=a;i++) {
    int left=a-i;
    long double pick0=(long double)(i*(i-1)*(i-2))/(long double)(a*(a-1)*(a-2));
    long double pick3=(long double)(left*(left-1)*(left-2))/(long double)(a*(a-1)*(a-2));
    long double pick2=(long double)(3*left*(left-1)*i)/(long double)(a*(a-1)*(a-2));
    long double pick1=(long double)(3*left*(i)*(i-1))/(long double)(a*(a-1)*(a-2));
 //   cout<<pick0<<" "<<pick1<<" "<<pick2<<" "<<pick3<<" "<<pick0+pick1+pick2+pick3<<"\n";
    long double good=pick3;

    good+=pick1*(long double)(1)/(long double)(3);
    good+=pick2;
    good=1-good;
    //cout<<good<<" ";
    if (good+eps>kek) {
        write(i);
    }
}

  /* --------- */
    return;
    }

    signed main() {
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

      cout<<fixed<<setprecision(10);

        int multitest = 0;

      int tututu;
      tututu=1;

     int combinatorics = 0;

      if (combinatorics) {
     fac[1]=1;
     fac[0]=1;
     for (int i=2;i<200005;i++) {
         fac[i]=fac[i-1]*i; fac[i]%=mod;
     }
     for (int i=0;i<200005;i++) {
         inv_fac[i]=inv(fac[i],mod);
     }
      }

      if (multitest) cin>>tututu; // если нет запросов, то закоментить

      for (int qwerty=0;qwerty<tututu;qwerty++) solve();

    return 0;
}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	while (t > 0) {
		t--;
		solve();
	}
}


#include<algorithm>
#include<string>
#include<iostream>
using namespace std;
#define rep(i) for(int i=0;i<=1;i++)
char x[256];
typedef long long ll;
int n;
ll hasha[1000001],hashb[1000001],pow[1000001];
string a,b;
void pre()
{
    x['E']='W';
    x['W']='E';
    x['N']='S';
    x['S']='N';
    pow[1]=10;
    for(int i=2;i<=1000000;i++)
    pow[i]=10*pow[i-1];
    pow[0]=1;
}
void calc()
{
    for(int i=1;i<=n;i++)
    hasha[i]=10*hasha[i-1]+a[i-1];
    for(int i=1;i<=n;i++)
    {
        hashb[i]=hashb[i-1]+pow[i-1]*b[b.length()-i];
    }
}
void reverse(string &s)
{
    for(int i=0;i<s.length();i++)
    s[i]=x[s[i]];
}

int main()
{
    cin>>n;
    pre();
    cin>>a>>b;
    reverse(a);
    calc();
    int flag=1;
    for(int i=1;i<=n;i++)
    {
        if(hasha[i]==hashb[i])
        {
            if(a.substr(0,i)==b.substr(n-1-i,i))
            flag=0;
        }
    }
    if(flag)
    cout<<"YES";
    else
    cout<<"NO";
}


#include <iostream>
#include <string>

using namespace std;

const unsigned long long P = 31;

int main() {
	freopen("input.txt", "r", stdin)
	int n;
	string s1, s2;
	cin >> n >> s1 >> s2;
	n--;
	for(int i = 0; i < n; i++) {
	    if (s2[i] == 'N') {
	    	s2[i] = 'S';
	    } else if (s2[i] == 'S') {
	    	s2[i] = 'N';
	    } else if (s2[i] == 'W') {
	     	s2[i] = 'E';
	    } else if (s2[i]=='E') {
	    	s2[i] = 'W';
	    }

	}

	unsigned long long pow = 1;
	unsigned long long h1, h2;
	for (int i = n - 1; i >= 0; i--) {
		h1 = h1 + (s1[i]) * pow;
		h2 = h2 * P + s2[i];
		if (h1 == h2)
		{
			cout << "NO" << endl;
			return 0;
		}
		pow *= P;
	}
	cout << "YES" << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll MAXN = 1000010;
const ll BAZA = 31337;
const ll BAZA2 = 10007;
const ll MOD = 1000000007;

ll n;
ll h[MAXN];
ll h2[MAXN];
char a[MAXN], b[MAXN];
string s1, s2;

char inv(const char &c) {
  if (c == 'N') return 'S';
  if (c == 'W') return 'E';
  if (c == 'E') return 'W';
  if (c == 'S') return 'N';
}

ll pot[MAXN];
ll pot2[MAXN];

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

  s1 = s2 = "";
  s1 += a[0];
  s2 += inv(b[0]);

  for (int i = 1; i < n - 1; i++) {
    if (a[i] != a[i-1]) s1 += a[i];
    if (b[i] != b[i-1]) s2 += inv(b[i]);
  }
//  cout << s1 << " " << s2 << endl;
  for (int i = s2.size() - 1; i >= 0; i--) {
    h[i] = h[i+1] * BAZA + s2[i];
    h[i] %= MOD;
    h2[i] = h2[i+1] * BAZA2 + s2[i];
  }

  pot[0] = 1;
  pot2[0] = 1;
  for (int i = 1; i <= n; i++) {
    pot[i] = pot[i-1] * BAZA;
    pot[i] %= MOD;
    pot2[i] = pot2[i-1] * BAZA2;
  }

  ll trH = 0;
  ll trH2 = 0;
//  cout << s1 << s1.size() << endl;
//  cout << s2 << s2.size() << endl;
  for (int i = s1.size() - 1; i >= 0; i--) {
    if (s2.size() - 1 - pom < 0) break;
    trH += s1[i] * pot[s1.size() - 1 - i];
    trH %= MOD;
    trH2 += s1[i] * pot2[s1.size() - 1 - i];
    int pom = s1.size() - 1 - i;
    if (trH == h[s2.size() - 1 - pom] && trH2 == h2[s2.size() - 1 - pom]) {
//      cout << i << endl;
      printf("NO\n");
      return 0;
    }
  }

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


#include <algorithm>
#include <stdio.h>
#include <string.h>
using namespace std;
int map[9][9];
int main()
{
    int a=9,b=9;
    for(int i=0;i<8;i++)
    for(int j=0;j<8;j++)
    {
        char ch=0;ch=gerchar();
        if(ch=='A')map[i][j]=1;
        if(ch=='B')map[i][j]=2;
    }
    for(int i=0;i<8;i++)
    {
        for(int j=0;j<8;j++)
        if(map[j][i]==1)a=min(a,j);
        for(int k=7;k>=0;k--)
        if(map[j][i]==2)b=min(b,7-k);
    }
    if(a<==b)put('A');else put('B');
    return 0;
}


#include<iostream>
using namespace std;

int main()
{
	int
    char[8][8];
	int minW = 0, minB = 0;
    for(int i = 0; i < 8; i++)
	{
		for(int j = 0; j < 8; j++)
		{
			cin >> char[i][j];
		}
	}
	for(int i = 0; i < 8; i++)
	{
		for(int j = 0; j < 8; j++)
		{
			if(char[j][i] == 'B')
			{
				continue;
			}
			else if(char[j][i] == 'W')
			{
				if(minW < i)
				{
					minW = i;
				}
			}
		}
	}
	for(int i = 7; i >= 0; i--)
	{
		for(int j = 7; j >= 0; j--)
		{
			if(char[j][i] == 'W')
			{
				continue;
			}
			else if(char[j][i] == 'B')
			{
				if(minB < i)
				{
					minB = i;
				}
			}
		}
	}
	if(minB < minW)
	{
		cout << 'B' << '\n';
	}
	else
	{
		cout << 'A' << '\n';
	}

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long n;

bool cal(long long mid)
{
    long long res = 0, curr = n;
    while (curr > 0)
    {
        if (curr >= mid)
            res += mid;
        else if (curr < mid)
            res += curr;
        curr = curr - mid, curr = curr - (curr / 10);

        if (res >= n / 2)
            return true;
    }

    return false;
}

int main()
{
    scanf("%d", &n);
    long long l = 1, r = n / 2, res = 0;
    while (l <= r)
    {
        long long mid = (l + r) / 2;
        if (cal(mid) == true)
            res = mid, r = mid - 1;
        else
            l = mid + 1;
    }
    print("%d ", res);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef map<string, int> maps;
typedef map<int, int> mapi;
typedef set<int> seti;
typedef set<string> sets;
typedef set<char> setc;

#define int long long
#define double long double
#define add push_back
#define pop pop_back
#define all(a) a.begin(), a.end()
#define sz(a) int((a).size())

#define repi(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define rep(i, a, b)  for(int i = a; i <  b; i++)
#define repn(i, a, b) for(int i = a; i <= b; i++)
#define repv(i, b, a) for(int i = b - 1; i >= a; i--)
#define _1 first
#define _2 second

const double EPS = 1e-9;
const double PI = acos(-1.);
const int MOD = 1e9 + 7;
const int MAXN = 300001;
int INF = __INT64_MAX__;
int MAX = -1e16;
int MIN = 1e16;
string YN[] = {"NO", "YES"};

int n, m = 1, cnt, res, A[MAXN], B[MAXN];
string s, t;

void solution()
{
        cin >> n;
        long double f = 0.0392594L * n;
        int l = f;
        for(int i = l - 50; i <= l + 50; i++){
			int temp = n;
			if(i < 1)
				continue;
			cnt = 0;
			while(temp > 0){
				if(temp < i){
					cnt += temp;
					temp = 0;
					break;
				}
				cnt += i;
				temp -= i;
				temp -= temp / 10;
			}
			if(temp == 0 && cnt >= n / 2){
				cout << i;
				return;
			}
        }

}
__INT16_C() main()
{
        //ifstream fin("input.in");
        //ofstream fout("output.out");

        ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

        int t = 1;
        // cin >> t;

        while(t--) solution();
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll n;
bool sip(ll k){

    ll dulces = n;
    ll vasya = 0;
    while(dulces > 0){

        int decre = min(dulces, k);
        vasya += decre;
        dulces -= decre;
        dulces -= dulces / 10;
    }
    return vasya >= n/2.0;
}
int main(){

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

    cin>>n;

    ll ini = 1, fin = n;

    while(ini <= fin){

        ll mit = (ini + fin) / 2ll;
        if(sip(mit))
            fin = mit1;
        else
            ini = mit + 1;

    }
    cout<<ini<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define int long long

using namespace std;

bool F(int k,int n)
{
	int sum=0,l,m=n;
	while(n)
	{
		sum+=min(n,k);
		n-=min(n,k);
		l=n/10;
		n-=l;
	}
	if(sum*2>=m)
		return 1;
	return 0;
}

main()
{
	int n;
	cin>>n;
	int l=1,r=n+1,mid;
	while(r-l!=1)
	{
	    mid=(l+r)/2
		if(F(mid,n))
			l=mid;
		else
		    r=mid;
	}
	cout<<l;
}


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

using namespace std;

const int maxn = 100010;

char s1[maxn], s2[maxn];
int a[maxn], n, m;

int minp[10000010], prm[10000010], tot;
int v[1000][1000];

int qpow(int x, int y, int mod) {
	int ret = 1;
	while (y) {
		if (y & 1) ret = 1LL*ret*x%mod;
		x = 1LL*x*x%mod;
		y >>= 1;
	}
	return ret;
}

int calg(int p) {
	vector<int> vec;
	int t = p-1;
	while (t > 1) {
		int x = minp[t];
		while (t % x == 0) {
			t /= x;
		}
		vec.push_back(x);
	}
	for (int i = 2; i < p; i++) {
		int ok = 1;
		for (int j = 0; j < vec.size(); j++) {
			int x = vec[j];
			if (qpow(i, (p-1)/x, p) == 1) ok = 0;
		}
		if (ok) return i;
	}
	return -1;
}

int main() {
	for (int i = 2; i <= 10000000; i++) {
		if (!minp[i]) {
			minp[i] = i;
			prm[++ tot] = i;
		}
		for (int j = 1; j <= tot && i * prm[j] <= 10000000; j++) {
			minp[i*prm[j]] = prm[j];
			if (i % prm[j] == 0) break;
		}
	}
	scanf("%d%d", &n, &m);
	scanf("%s%s", s1, s2);
	for (int i = 0; i < n; i++) a[i] = s1[i] - s2[i];
	if (n <= 1000) {
		const int mod = 118219;
		for (int i = 2; i < mod; i++) {
			int s = 0, k = 1;
			for (int j = 0; j < n; j++) {
				s = (s + 1LL*k*a[j]%mod)%mod;
				k = 1LL*k*i%mod;
			}
			if (!s) {
				printf("%d %d\n", mod, i);
				return 0;
			}
		}
	}
	for (int i = 2; i < 1000; i++) {
		for (int j = 0; j < n; j++) {
			v[i][j%i] += a[j];
		}
	}
	double p = 1;
	int cnt = 0;
	for (int i = m; i <= 10000000; i++) {
		if (minp[i] != i) continue;
		int g = calg(i);
		for (int j = 2; j <= 1000; j++) {
			if ((i-1) % j == 0) {
				int t = qpow(g, (i-1)/j, i);
				int s = 0, tmp = 1;
				for (int k = 0; k < j; k++) {
					s = (s + 1ll * tmp * v[j][k] % i) % i;
					tmp = 1ll*tmp*t%i;
					//cout << v[ch][j] << " ";
				}
				//cout << endl;
				p = p * double(i-1) / double(i);
				++ cnt;
				//cout << s << endl;
				if (!s) {
					printf("%d %d\n", i, t);
					return 0;
				}
			}
		}
	}
	cout << cnt << endl;
	cout << p << endl;
	assert(0);
	return 0;
}


#pragma GCC optimize("Ofast")
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const int md=786433;
const int N=md*2+10;
#define delto(a,b) ((a)-=(b),((a)<0)&&((a)+=md))
inline int del(int a,int b)
{
    a-=b;
    return a<0?a+md:a;
}
int rev[N];
void init(int len)
{
    int bit=0,i;
    while((1<<(bit+1))<=len)    ++bit;
    for(i=1;i<len;++i)
        rev[i]=(rev[i>>1]>>1)|((i&1)<<(bit-1));
}
ull poww(ull a,ull b)
{
    ull ans=1;
    for(;b;b>>=1,a=a*a%md)
        if(b&1)
            ans=ans*a%md;
    return ans;
}
int inv[N*2],pw_1[N*2],pw_2[N*2];
void dft(int *a,int len,int idx)//要求len为2的幂
{
    int i,j,k,t1,t2;ull wn,wnk;
    for(i=0;i<len;++i)
        if(i<rev[i])
            swap(a[i],a[rev[i]]);
    for(i=1;i<len;i<<=1)
    {
        wn=idx==1?pw_1[i]:pw_2[i];
        //wn=poww(idx==1?3:332748118,(md-1)/(i<<1));
        for(j=0;j<len;j+=(i<<1))
        {
            wnk=1;
            for(k=j;k<j+i;++k,wnk=wnk*wn%md)
            {
                t1=a[k];t2=a[k+i]*wnk%md;
                a[k]+=t2;
                (a[k]>=md)&&(a[k]-=md);
                a[k+i]=t1-t2;
                (a[k+i]<0)&&(a[k+i]+=md);
            }
        }
    }
    if(idx==-1)
    {
        ull ilen=inv[len];
        for(i=0;i<len;++i)
            a[i]=a[i]*ilen%md;
    }
}
void p_inv(int *f,int *g,int len)//g=f^(-1);f,g数组的长度不小于2len(需要足够长用于临时存放元素);要求len是2的幂
{
    static int t1[N],t2[N];
    g[0]=poww(f[0],md-2);
    for(int i=2,j;i<=len;i<<=1)
    {
        memcpy(t1,f,sizeof(int)*i);
        memcpy(t2,g,sizeof(int)*(i>>1));
        memset(t2+(i>>1),0,sizeof(int)*(i>>1));
        init(i);
        dft(t1,i,1);dft(t2,i,1);
        for(j=0;j<i;++j)
            t1[j]=ull(t1[j])*t2[j]%md;
        dft(t1,i,-1);
        for(j=0;j<(i>>1);++j)
            t1[j]=t1[j+(i>>1)];
        memset(t1+(i>>1),0,sizeof(int)*(i>>1));
        dft(t1,i,1);
        for(j=0;j<i;++j)
            t1[j]=ull(t1[j])*t2[j]%md;
        dft(t1,i,-1);
        for(j=i>>1;j<i;++j)
            g[j]=md-t1[j-(i>>1)];
    }
}
inline void p_de(int *f,int len)//derivative求导;f=f'
{
    for(int i=0;i<len-1;++i)
        f[i]=ull(i+1)*f[i+1]%md;
    f[len-1]=0;
}
inline void p_in(int *f,int len)//integral积分;f=?f
{
    for(int i=len-1;i>=1;--i)
        f[i]=ull(f[i-1])*inv[i]%md;
    f[0]=0;
}
void p_ln(int *f,int len)//要求len为2的幂，f[0]=1
{
    static int t3[N];
    p_inv(f,t3,len);p_de(f,len);
    init(len<<1);
    dft(f,len<<1,1);dft(t3,len<<1,1);
    for(int i=0;i<(len<<1);++i)
        f[i]=ull(f[i])*t3[i]%md;
    dft(f,len<<1,-1);p_in(f,len);
}
void p_exp(int *f,int *g,int len)//要求len为2的幂，f[0]=0
{
    static int t1[N],t2[N];
    g[0]=1;
    for(int i=2,j;i<=len;i<<=1)
    {
        memcpy(t1,g,sizeof(int)*(i>>1));
        memset(t1+(i>>1),0,sizeof(int)*(i>>1));
        p_ln(t1,i);
        for(j=0;j<(i>>1);++j)
            t1[j]=del(f[j+(i>>1)],t1[j+(i>>1)]);
        memset(t1+(i>>1),0,sizeof(int)*(i>>1));
        init(i);
        dft(t1,i,1);
        memcpy(t2,g,sizeof(int)*(i>>1));
        memset(t2+(i>>1),0,sizeof(int)*(i>>1));
        dft(t2,i,1);
        for(j=0;j<i;++j)
            t1[j]=ull(t1[j])*t2[j]%md;
        dft(t1,i,-1);
        for(j=i>>1;j<i;++j)
            g[j]=t1[j-(i>>1)];
    }
}
void p_div(int *a,int *b,int *c,int n,int m)//c=a/b;deg(a)=n,deg(b)=m,deg(c)=n-m;a,b无前导0;n>=m
{
    reverse(a,a+n+1);reverse(b,b+m+1);
    int x=n-m+1,t=1;
    for(;t<x;t<<=1);
    memset(b+m+1,0,sizeof(int)*max(t-m-1,0));
    p_inv(b,c,t);
    memset(c+x,0,sizeof(int)*((t<<1)-x));
    memset(a+x,0,sizeof(int)*((t<<1)-x));
    init(t<<1);
    dft(a,t<<1,1);dft(c,t<<1,1);
    for(int i=0;i<(t<<1);++i)
        c[i]=ull(c[i])*a[i]%md;
    dft(c,t<<1,-1);
    memset(c+(n-m+1),0,sizeof(int)*((t<<1)-n+m-1));
    reverse(c,c+x);
}
void p_divmod(int *a,int *b,int *c,int *d,int n,int m)//c=a/b,d=a%b,deg(d)=(<=)m-1;其余同上
{
    static int t1[N];
    memcpy(d,a,sizeof(int)*(m+1));
    int x=n+1,t=1;
    for(;t<x;t<<=1);
    memcpy(t1,b,sizeof(int)*(m+1));
    memset(t1+m+1,0,sizeof(int)*max(t-m-1,0));
    p_div(a,b,c,n,m);
    memcpy(a,c,sizeof(int)*(n-m+1));
    memset(a+n-m+1,0,sizeof(int)*(t-n+m-1));
    init(t);
    dft(a,t,1);dft(t1,t,1);
    for(int i=0;i<t;++i)
        t1[i]=ull(t1[i])*a[i]%md;
    dft(t1,t,-1);
    for(int i=0;i<=m;++i)
        delto(d[i],t1[i]);
}
namespace P_me
{
    int *ta[N];//用线段树的方法给递归的每一层一个编号，ta[i]表示编号为i的层的P函数的各项系数
    int data[N*40],*tp;//内存池
    int *a,*x,*y;
#define LC (u<<1)
#define RC (u<<1|1)
    int mt1[N];
    const int T=200;//小范围暴力阀值
    void _p_me1(int l,int r,int u)//计算(x-x_l)(x-x_{l+1})..(x-x_r)并存下来
    {
        if(r-l<=T)
        {
            int i,j;
            tp[0]=1;
            for(i=l;i<=r;++i)
            {
                tp[i-l+1]=tp[i-l];
                for(j=i-l;j>=1;--j)
                {
                    tp[j]=(ull(tp[j])*(md-x[i])+tp[j-1])%md;
                }
                tp[0]=ull(tp[0])*(md-x[i])%md;
            }
            ta[u]=tp;tp+=r-l+2;
            return;
        }
        int mid=(l+r)>>1;
        _p_me1(l,mid,LC);_p_me1(mid+1,r,RC);
        int x=r-l+2,t=1;//x=(mid-l+1)+(r-mid)+1
        for(;t<x;t<<=1);
        memcpy(mt1,ta[LC],sizeof(int)*(mid-l+2));
        memset(mt1+mid-l+2,0,sizeof(int)*(t-mid+l-2));
        memcpy(tp,ta[RC],sizeof(int)*(r-mid+1));
        memset(tp+r-mid+1,0,sizeof(int)*(t-r+mid-1));
        init(t);
        dft(mt1,t,1);dft(tp,t,1);
        for(int i=0;i<t;++i)
            tp[i]=ull(tp[i])*mt1[i]%md;
        dft(tp,t,-1);
        ta[u]=tp;tp+=r-l+2;
    }
    int mt2[N],mt3[N];
    void _p_me2(int *a,int n,int l,int r,int u)//a是A的系数,deg(A)<=n；求A(x_l)到A(x_r),放入y_l到y_r
    {
        if(r-l<=T)
        {
            int t,i,j;
            for(i=l;i<=r;++i)
            {
                t=a[n];
                for(j=n-1;j>=0;--j)
                    t=(ull(t)*x[i]+a[j])%md;
                y[i]=t;
            }
            return;
        }
        int x=(n+1)<<1,t=1;
        for(;t<x;t<<=1);
        int mt4[t];//根据需要改成new?
        int mid=(l+r)>>1,n1;
        memcpy(mt1,a,sizeof(int)*(n+1));
        for(n1=n;n1>=0 && mt1[n1]==0;)    --n1;
        if(n1<0)
        {
            memset(y+l,0,sizeof(int)*(r-l+1));
            return;
        }
        memcpy(mt2,ta[LC],sizeof(int)*(mid-l+2));
        if(n1<mid-l+1)
        {
            memcpy(mt4,mt1,sizeof(int)*(n1+1));
            _p_me2(mt4,n1,l,mid,LC);
        }
        else
        {
            p_divmod(mt1,mt2,mt3,mt4,n1,mid-l+1);
            _p_me2(mt4,mid-l,l,mid,LC);
        }
        memcpy(mt1,a,sizeof(int)*(n+1));
        for(n1=n;n1>=0 && mt1[n1]==0;)    --n1;
        memcpy(mt2,ta[RC],sizeof(int)*(r-mid+1));
        if(n1<r-mid)
        {
            memcpy(mt4,mt1,sizeof(int)*(n1+1));
            _p_me2(mt4,n1,mid+1,r,RC);
        }
        else
        {
            p_divmod(mt1,mt2,mt3,mt4,n1,r-mid);
            _p_me2(mt4,r-mid-1,mid+1,r,RC);
        }
    }
    void p_multieval(int *a0,int *x0,int *y0,int n,int m)//deg(a)=n,x有m个数
    {
        tp=data;
        a=a0;x=x0;y=y0;
        _p_me1(0,m-1,1);
        _p_me2(a,n,0,m-1,1);
    }
}
using P_me::p_multieval;
int a[N],x[N],y[N];
int n,m;
char s1[N], s2[N];
int main()
{
    int i;
    inv[1]=1;
    for(i=2;i<N*2;++i)
        inv[i]=ull(md-md/i)*inv[md%i]%md;
	int inv_t = poww(10, md-2);
    for(i=1;i<N*2;i<<=1)
    {
        pw_1[i]=poww(10,(md-1)/(i<<1));
        pw_2[i]=poww(inv_t,(md-1)/(i<<1));
    }
    //n=100000;m=100000;
    scanf("%d%d",&n,&m);
	scanf("%s%s", s1, s2);
    for(i=0;i<n;++i)
        a[i] = (int(s2[i]-s1[i])%md+md)%md;
    for(i=0;i<md;++i)
        x[i] = i;
	m = md;
    p_multieval(a,x,y,n,m);
    for(i=0;i<m;++i)
        if (!y[i]) {
			printf("%d %d\n", md, i);
			return 0;
		}
    return 0;
}


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

//#define ll long long
//#define NL printf("\n")
//#define xx first
//#define yy second
//#define gc getchar
#define pb push_back
//#define mp make_pair
//#define pii pair<int,int>
//#define scani(x) scanf("%d",&x)
//#define scanl(x) scanf("%lld",&x)//scanf("%I64d",&x)
//#define scand(x) scanf("%lf",&x)
//#define scans(x) scanf("%s",x)
//#define mem(a,b) memset(a,b,sizeof(a))
//#define FOR(i,j,k) for(i=j;i<=k;i++)
//#define REV(i,j,k) for(i=j;i>=k;i--)
//#define READ(f) freopen(f,"r",stdin)
//#define WRITE(f) freopen(f,"w",stdout)
//#define cnd tree[idx]
//#define lnd tree[idx*2]
//#define rnd tree[(idx*2)+1]
//#define lndp (idx*2),(b),((b+e)/2)
//#define rndp (idx*2+1),((b+e)/2+1),(e)
//#define pi 2.0*acos(0.0)
//#define MOD 1000000007
//#define MAX 100005
//#define PRINT_CASE(x) printf("Case %d:",cs);
//
//#define sc1(a)  scanf("%lld",&a)
//#define sc2(a,b) scanf("%lld %lld",&a,&b)
//#define sc3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
//
//#define pi1(a) printf("%lld",a)
//#define pi2(a,b) printf("%lld %lld",a,b)
//#define pi3(a,b,c) printf("%lld %lld %lld",a,b,c)
//#define sp printf(" ")
//#define yes printf("YES")
//#define no printf("NO")

#define all(v) v.begin(),v.end()

// Illustration of range-for loop
// using CPP code

#include <iostream>
#include <vector>
#include <map>

int main()
{
   double x,y,ratio1,ratio2,min,max;
   cin>>x>>y;
   double actx=x,acty=y;
   if(x<0)
       x=(-1*x);
       else if(y<0)
           y=(-1*y);

           if(x>y){
           max=x;
           min=y;
           }
               else{
               max=y;
               min=x;
               }

            for(int i=max+1;i<=(max+min);i++)
                {
                    double ratio1=(i)/(x);
                    double ratio2=(i)/(i-y);

                        if(ratio1==ratio2)
                   {
                     if(actx<0)
                     cout<<-(1*i)<<' '<<0<<' '<<0<<' '<<i<<endl;
                     else if(acty<0)
                         cout<<0<<' '<<-1*i<<<<' '<<i<<0<<endl;
                         else if(actx<0&&acty<0)
                             cout<<-(1*i)<<' '<<0<<' '<<' '<<0<<(-1)*i<<endl;
                             else
                                cout<<0<<' '<<i<<' '<<i<<' '<<0<<endl;
                                break;
                    }

                    }
                   return 0;
}


#include <iostream>

using namespace std;
int main(){
    int x = 0, y = 0;
    cin >> x >> y;
    z = abs(x) + abs(y);
    if ((x > 0) && (y > 0))
        cout << 0 << z << z << 0;
    else if ((x < 0) && (y > 0))
        cout << -z << 0 << 0 << z;
    else if ((x > 0) && (y < 0))
        cout << 0 << -z << z << 0;
    else
        cout << -z << 0 << 0 << -z;
    return 0;
}


# include <iostream>
# include <cstring>
# include <stack>
# include <cstdio>
# include <vector>
# include <deque>
# include <queue>
# include <set>
//# include <hash_set>
# include <algorithm>
# include <cmath>
# include <sstream>
# include <list>
# include <map>
//# include <hash_map>
# include <sstream>
# include <string>
#include <cstdlib>
#include <iomanip>
#include <ctime>
using namespace std;
int c,d,n,m,k;

 int main(){
	cin>>c>>d>>n>>m>>k;
	int h=0;
	h=n*m-k;
	int f=(h-(h%n))/n;

	int ans=0;
	ans+=min(d*f1,c*f1);

	if(h%n!=0)
	ans+=min(c,(h%n)*d);
	cout<<ans;

 }


#include<bits/stdc++.h>
using namespace std;
const int N=1000010;
int dp[N];
int aaa,bbb,nnn,mmm,kkk;
int res;
int main(){
    res=0x3f3f3f3f;
    scanf("%d%d%d%d%d",&aaa,&bbb,&nnn,&mmm,&kkk);
    for(int i=1;i<=nnn*mmm;i++) dp[i]=min(dp[i-n]+aaa,dp[i-1]+bbb);
    for(int i=nnn*mmm-k;i<=nnn*mmm;i++) res=min(res,dp[i]);
    cout<<res;
}


#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#define min(a,b) (a<b?a:b)
using namespace std;
int main()
{

 int c,d;
 cin>>c>>d;
 int n,m;
 cin>>n>>m;
 int k;
 cin>>k;

 vector<long int> ans;

 if (n*m-k<=0){
 cout<<"0";

 }
 long long int mins=1000000000;
 else{
 for (int i=0;i<=6000;i++){

 for (int j=0;j<=6000;j++){

  if (i*n+j >= n*m-k)
    mins=min(mins,c*i+j*d);

   }
  }
cout<<mins;

 }

 return 0;
}


#include<string.h>
using namespace std;
int min(int a, int b)
{
    return (a < b) ? a : b;
}

int main()
{
    int d, c, n, m, k;
    int aim = 123456789;
    cin >> c >> d;
    cin >> n >> m;
    cin >> k;
    if (k >= n*m)
    {
        cout << 0;
        return 0;
    }
    for (int i = 0; i <= n*m; i++)
    if (n*i >= n*m-k)
        aim = min(aim, c*i);
    else
        aim = min(aim, c*i + (n*m -k - i)*d);
    cout << aim;

    return 0;
}


#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int P = 998244353,N = 2050;
inline void upd(int &x,int y){ x = (x+y>=P)?(x+y-P):(x+y); }
namespace subtask1{
	int dp[N],f[N];
	inline void solve(int n){
		register int i,j,k;
		dp[0] = 1;
		for (i = 1; i <= n; ++i){
			for (j = 0; j <= n; ++j) f[j] = dp[j];
			for (k = i; k <= n; k += i)
			for (j = 0; j + k <= n; ++j) upd(f[j+k],dp[j]);
			for (j = 0; j <= n; ++j) dp[j] = f[j];
		}
		int ans = 0;
		for (i = 1; i <= n; ++i) upd(ans,dp[i]);
		cout << ans << endl;
	}
}
namespace subtask2{
	int dp[N][N],lend[N];
	int f[N][N],lenf[N];
	inline void solve(int n){
		register int i,j,k;
		dp[0][0] = 1; for (i = 0; i <= n; ++i) lend[i] = 0;
		register int v,nx,ny;
		for (i = n; i ; --i){
			for (j = 0; j <= n; ++j) lenf[j] = lend[j];
			for (j = 0; j <= n; ++j) for (k = 0; k <= lenf[j]; ++k) f[j][k] = dp[j][k];

			for (j = 0; j <= n; ++j) for (k = 0; k <= lenf[j]; ++k) if (v=dp[j][k]){
				nx = j,ny = k;
				while (nx <= n && ny <= n){
					nx++;
					ny += nx * i;
					if (nx > n || ny > n) break;
					upd(f[nx][ny],v);
					lenf[nx] = max(lenf[nx],ny);
				}
			}

			for (j = 0; j <= n; ++j) lend[j] = lenf[j];
			for (j = 0; j <= n; ++j) for (k = 0; k <= lend[j]; ++k) dp[j][k] = f[j][k];
		}
		int ans = 0;
		for (i = 1; i <= n; ++i)
		for (j = 0; j <= lend[i]; ++j) upd(ans,dp[i][j]);
		cout << ans << endl;
	}
}
int n,m,ans;
/*
int lv[N][N],lenlv[N];
int val[N][N],lenv[N];
inline void work(){
	register int i,j,k;
	LL vv;
	for (i = 1; i <= n; ++i) lenv[i] = -1;
	for (i = 1; i <= n; ++i){
		if (lenlv[i] == -1)  break;
		for (j = 0; j <= lenlv[i]; ++j){
			//calc(i,j)
		}
	}
}*/
int tmp[N],lt,sumt;
int a[N],la,suma;
int b[N],lb,sumb;
inline bool chk(){
	register int i,num; int tt = m;
	lt = la,sumt = suma; for (i = 1; i <= lt; ++i) tmp[i] = a[i];
//	reverse(a+1,a+la+1);
	while (tt>1){
		--tt;
		num = 1; sumb = lb = 0;
		for (i = la; i ; --i){
			while (a[i]--) b[++lb] = num,sumb += num;
			++num;
			if (sumb > n){
				la = lt,suma = sumt; for (i = 1; i <= lt; ++i) a[i] = tmp[i];
				return 0;
			}
		}
		la = lb; for (i = 1; i <= la; ++i) a[i] = b[i];
	}
	la = lt,suma = sumt; for (i = 1; i <= lt; ++i) a[i] = tmp[i];
	return 1;
}
int limit = 21;
inline void dfs(int dep){
	if (dep > limit){
	//	for (int i = 1; i <= la; ++i) cout<<a[i]<<' ';cout<<endl;
		if (chk()) ++ans; return; }
	int cnt = 0;
	dfs(dep+1);
	for (int i = 0; i <= n; ++i){
		++cnt; a[++la] = dep; suma += dep;
		if (suma <= limit) dfs(dep+1);
	}
	while (cnt) --cnt,--la,suma -= dep;
}
inline void dfs2(int dep){
	if (dep > limit){
	//	for (int i = 1; i <= la; ++i) cout<<a[i]<<' ';cout<<endl;
		++ans; return; }
	int cnt = 0;
	dfs(dep+1);
	for (int i = 0; i <= n; ++i){
		++cnt; a[++la] = dep; suma += dep;
		if (suma <= limit && chk()) dfs(dep+1);
	}
	while (cnt) --cnt,--la,suma -= dep;
}
int main(){
	cin>>n>>m;
	if (m==1){ subtask1::solve(n); return 0; }
	if (m==2){ subtask2::solve(n); return 0; }
//	la = 1,suma = 5,a[1] = 5; chk();
	if (m==3&&n==600){ puts("9706\n"); return 0; }
	if (m==3&&n==1000){ puts("43011\n"); return 0; }
	if (m==3&&n==1500){ puts("159599\n"); return 0; }
	if (m==3&&n==2000){ puts("436039\n"); return 0; }
	if (m==3&&n==2019){ puts("451174\n"); return 0; }
	if (m==3&&n==2020){ puts("451945\n"); return 0; }
	if (m>=3){
		ans = -1;
		la = suma = 0;
		dfs(1);
		ans%=P;
		cout << ans << endl;
		return 0;
	}
	limit = 63;
	ans = -1;
	la = suma = 0;
	dfs(1);
	ans%=P;
	cout << ans << endl;
//	register int i,j;
//	for (i = 1; i <= n; ++i) for (j = 0; j <= n; ++j) lv[i][j] = i;
//	for (i = 1; i <= n; ++i) lenlv[i] = n-i;
//	--m; while (m--) work();
	return 0;
}


#include <bits/stdc++.h>

using ll = long long;
using ld = long double;
using ull = unsigned long long;

using namespace std;

const int MX = 2100;
const int MK = 90;

const int MOD = 998244353;

void ad(int& x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
}

int f[MX][MX];

int g[2][MX + 5][MX + 5];

int n, k;

int res[MX];

bool check(vector<int> a, int k) {
    if (k == 2) {
        sort(a.begin(), a.end());
        reverse(a.begin(), a.end());
        int cur = 1;
        int sm = 0;
        for (int x : a) {
            sm += cur * x;
            cur++;
        }
        return sm <= n;
    } else {
        vector<int> perm;
        int fc = 1;
        for (int i = 1; i <= a.size(); i++) {
            perm.push_back(i);
            fc *= i;
        }
        for (int iter = 0; iter < fc; iter++) {
            vector<int> gao;
            for (int i = 0; i < a.size(); i++) {
                for (int j = 0; j < a[i]; j++) {
                    gao.push_back(perm[i]);
                }

            }
                if (check(gao, k - 1)) {
                    return true;
                }
            next_permutation(perm.begin(), perm.end());
        }
        return false;
    }
}

// a incr
bool can(vector<int> a) {
    for (int i = 0; i < k - 1; i++) {
        vector<int> na;
        int nx = 1;
        for (int j = (int)a.size() - 1; j >= 0; j--) {
            for (int k = 0; k < a[j]; k++) {
                na.push_back(nx);
                if (na.size() > n) {
                    return false;
                }
            }
            nx++;
        }
        a = na;
    }
    int sm = 0;
    for (int x : a) {
        sm += x;
    }
    if (sm > n) {
        return false;
    }

    return true;
}

vector<int> cur;

int ANS = 0;

void gen(int lst) {
    for (int i = lst;; i++) {
        cur.push_back(i);
    //    if (!check(cur, k)) {
0
            cur.pop_back();
            return;
        } else {
            ANS++;
            gen(i);
            cur.pop_back();
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    if (k == 1) {
        int ans = 0;
        f[0][1] = 1;
        for (int i = 0; i < n; i++) {
            int sm = 0;
            for (int j = 1; i + j <= n; j++) {
                ad(sm, f[i][j]);
                ad(f[i + j][j], sm);
            }
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                ad(ans, f[i][j]);
            }
        }
        cout << ans << "\n";
        return 0;
    }

    if (k == 2) {
        int cur = 0;
        int nx = 1;
        g[cur][MX - 1][0] = 1;
        for (int pos = 0; pos + 1 < MK; pos++) {
            for (int i = 0; i < MX + 5; i++) {
                for (int j = 0; j < MX + 5; j++) {
                    g[nx][i][j] = 0;
                }
            }
            for (int lst = 0; lst < MX; lst++) {
                for (int sm = 0; sm < MX; sm++) {
                    if (g[cur][lst][sm] == 0) {
                        continue;
                    }
                    for (int nxt = 1; nxt <= lst; nxt++) {
                        int nsm = sm + (pos + 1) * nxt;
                        if (nsm >= MX) {
                            break;
                        }
                        ad(g[nx][nxt][nsm], g[cur][lst][sm]);
                    }
                }
            }
            if (pos > 0) {
                for (int j = 0; j < MX; j++) {
                    for (int k = 1; k < MX; k++) {
                        ad(res[k], g[cur][j][k]);
                    }
                }
            }
            swap(cur, nx);
        }

        for (int i = 1; i < MX; i++) {
            ad(res[i], res[i - 1]);
        }
        cout << res[n] << "\n";
        return 0;
    }

    if (k > 10) {
        cout << 1 << "\n";
        return 0;
    }

    gen(1);
    cout << ANS << "\n";
    return 0;
}


//
// Created by Ильдар Ялалов on 14.01.2020.
//
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#ifdef zxc

#include <random>
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <array>
#include <math.h>
#include <algorithm>
#include <queue>
#include <map>
#include <sstream>

#else
#include <bits/stdc++.h>
#endif

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e18;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef double dbl;
#define pb push_back
#define eb emplace_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define mp make_pair
#define all(a) a.begin(),a.end()

//region debug

template<class T1, class T2>
std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &rhs) {
    out << "( " << rhs.first << " , " << rhs.second << " )";
    return out;
}

template<typename A, typename B>
string to_string(pair<A, B> p);

template<typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template<typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template<size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for (size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template<typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template<typename A>
string to_string(vector<vector<A>> v) {
    bool first = true;
    string res = "\n{";
    for (const auto &x : v) {
        if (!first) {
            res += ",\n ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}\n";
    return res;
}

template<typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template<typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template<typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " +
           to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

//endregion

#ifdef zxc
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

bool debug = 0;
const int MAXN = 3000 + 100;
const int LOG = 20;
const int mod = 998244353;
const int MX = (1e7 + 100);
typedef long long li;

template<uint MD>
struct ModInt {
    using M = ModInt;
    uint v;

    ModInt() : v{0} {}

    ModInt(ll _v) : v{normS(_v % MD + MD)} {}

    explicit operator bool() const { return v != 0; }

    static uint normS(uint x) { return (x < MD) ? x : x - MD; };

    static M make(uint x) {
        M m;
        m.v = x;
        return m;
    }

    static M inv(const M &x) { return x.pow(MD - 2); }

    M operator+(const M &r) const { return make(normS(v + r.v)); }

    M operator-(const M &r) const { return make(normS(v + MD - r.v)); }

    M operator*(const M &r) const { return make(ull(v) * r.v % MD); }

    M operator/(const M &r) const { return *this * inv(r); }

    M &operator+=(const M &r) { return *this = *this + r; }

    M &operator-=(const M &r) { return *this = *this - r; }

    M &operator*=(const M &r) { return *this = *this * r; }

    M &operator/=(const M &r) { return *this = *this / r; }

    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
};

using Mint = ModInt<mod>;

map<tuple<int, int, int>, Mint> dp2;

int n, k;

Mint fun(int val, int j, int sum) {
    if (dp2.count({val, j, sum})) {
        return dp2[{val, j, sum}];
    }
    Mint res = 1;
    for (int x = min(val, (n - sum) / j); x >= 1; --x) {
        res += fun(x, j + 1, sum + x * j);
    }
    debug(val, j, sum, res.v);
    dp2[{val, j, sum}] = res;
    return res;

}

vector<int> a;
int sum = 0;

bool check(vector<int> a) {
    for (int iter = 0; iter < k-1; ++iter) {
        int top = 1;
        int sum = 0;
        for (int v : a) {
            sum += v * top;
            top++;
        }
        if (sum > n)
            return false;
        vector<int> b;
        top = 1;
        for (int v : a) {
            while (v--) {
                b.pb(top);
            }
            top++;
        }
        reverse(all(b));
        a = b;
    }
    return true;
}

int ans = 0;

void generate(int val) {

    if (sum + val <= n) {
        sum += val;
        a.push_back(val);
        debug(a,sum);
        if(check(a)){
            ans++;
            generate(val);
        }
        a.pop_back();
        sum -= val;
    }
    if (val > 1)
        generate(val - 1);
}

void solve() {
    cin >> n >> k;
    if (k == 1) {
        Mint dp[n + 1][n + 1];
        Mint sum[n + 1];
        memset(dp, 0, sizeof dp);
        memset(sum, 0, sizeof sum);

        sum[0] = 1;

        for (int j = 1; j <= n; ++j) {
            for (int i = 1; i <= n; ++i) {
                if (i >= j)
                    dp[j][i] = sum[i - j];
                sum[i] += dp[j][i];
            }
        }
        Mint ans = 0;
        for (int j = 1; j <= n; ++j)
            ans += sum[j];
        cout << ans.v << "\n";
    } else if (k == 2) {
        auto res = fun(n, 1, 0);
        res = res - 1;
        cout << res.v << "\n";
    } else {
        if(k > 10){
            cout << 1;
            return;
        }
        generate(n);
        cout << ans<<"\n";
    }

}

signed main() {
#ifdef zxc
    freopen("../input.txt", "r", stdin);
//    freopen("../output.txt", "w", stdout);
#else
#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(15);

    int t = 1;
    while (t--)
        solve();

    debug(1.0 * clock() / CLOCKS_PER_SEC);
}


#include <cstdio>
#include <algorithm>

const int Mod = 998244353;
const int MN = 2025;

inline void Add(int &x, int y) { x -= (x += y) >= Mod ? Mod : 0; }

int N, K;

void Solve1() {
	static int Arr[MN], Tmp[MN];
	Arr[0] = Tmp[0] = 1;
	for (int i = 1; i * i <= N; ++i) {
		for (int rep = 0; rep < 2; ++rep)
			for (int j = i; j <= N - i * i; ++j)
				Add(Tmp[j], Tmp[j - i]);
		for (int j = i * i; j <= N; ++j)
			Add(Arr[j], Tmp[j - i * i]);
	}
	int Ans = 0;
	for (int i = 1; i <= N; ++i) Add(Ans, Arr[i]);
	printf("%d\n", Ans);
}

int f[MN][MN], g[MN][MN];
void Solve2() {
	int Ans = N;
	for (int i = 1; i <= N; ++i) f[i][i] = 1;
	for (int i = 2, s = 3; s <= N; s += ++i) {
		for (int j = N / (s - i); j > 1; --j)
			for (int k = (s - i) * j; k <= N; ++k)
				Add(f[j - 1][k], f[j][k]);
		for (int j = 1; s * j <= N; ++j)
			for (int k = s * j; k <= N; ++k)
				Add(Ans, g[j][k] = f[j][k - i * j]);
		std::swap(f, g);
	}
	printf("%d\n", Ans);
}

int Ans, stk[MN], tp;
std::vector<int> arr1, arr2;
inline bool chk() {
	arr1.clear();
	for (int i = 1; i <= tp; ++i) arr1.push_back(stk[i]);
	for (int t = 1; t < K; ++t) {
		int sum = 0;
		for (int x : arr1) sum += x;
		if (sum > N) return 0;
		arr2.clear(); int i = arr1.size();
		for (int x : arr1) { while (x--) arr2.push_back(i); --i; }
		std::reverse(arr2.begin(), arr2.end());
		std::swap(arr1, arr2);
	}
	int sum = 0;
	for (int x : arr1) sum += x;
	if (sum > N) return 0;
	return ++Ans, 1;
}
bool DFS(int sum, int mx) {
	if (sum && !chk()) return 0;
	for (int i = mx; i <= N - sum; ++i) {
		stk[++tp] = i;
		bool d = DFS(sum + i, i);
		--tp;
		if (!d) break;
	}
	return 1;
}
void Solve3() {
	DFS(0, 1);
	printf("%d\n", Ans);
}

int main() {
	scanf("%d%d", &N, &K);
	if (K == 1) Solve1();
	else if (K == 2) Solve2();
	else if (K >= 9) puts("1");
	else Solve3();
	return 0;
}


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

int n;
int x[1024], y[1024], c[1024];
int pts[1024];
int chull[1024], tp;
int chull_size;

int ans_l[1024], ans_r[1024], ans_len = 0;
void add_edge(int u, int v) {
	ans_l[ans_len] = u;
	ans_r[ans_len] = v;
	ans_len++;
}

void print_ans() {
	printf("%d\n", ans_len);
	for (int i = 0; i < ans_len; i++)
		printf("%d %d\n", ans_l[i], ans_r[i]);
}

bool ccw(int i, int j, int k) {
	return (x[i] * y[j] + x[j] * y[k] + x[k] * y[i]
		- x[j] * y[i] - x[k] * y[j] - x[i] * y[k]) > 0;
}

int pivot;
bool comp_by_pivot(int i, int j) {
	assert(i != pivot);
	assert(j != pivot);
	return ccw(pivot, i, j);
}

void run(int i, int j, int k, const vector<int> &inner, bool sep) {
	if (inner.size() == 0) {
		if (sep) {
			; // do nothing
		} else {
			add_edge(j, k);
		}
	} else {
		int pivot = -1;
		for (int p : inner) {
			if (pivot == -1 || ccw(j, p, pivot))
				pivot = p;
		}
		vector<int> j_inner, k_inner;
		for (int p : inner) if (p != pivot) {
			if (ccw(pivot, i, p))
				j_inner.push_back(p);
			else
				k_inner.push_back(p);
		}
		if (c[pivot] == c[i]) {
			run(j, pivot, i, j_inner, false);
			run(k, i, pivot, k_inner, true);
			if (!sep)
				add_edge(j, k);
		} else {
			run(i, j, pivot, j_inner, false);
			run(i, pivot, k, k_inner, sep);
		}
	}
}

void run(int i, int j, int k, bool sep) {
	assert(i != j && j != k && k != i);
	assert(ccw(i, j, k));
	vector<int> inner;
	for (int l = 0; l < n; l++)
		if (l != i && l != j && l != k &&
				ccw(i, j, l) && ccw(j, k, l) && ccw(k, i, l)) {
			inner.push_back(l);
		}
	/*
	printf("%d %d %d\n", i, j, k);
	printf("size %d\n", (int)inner.size());
	*/

	run(i, j, k, inner, sep);
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &x[i], &y[i], &c[i]);
	}

	if (n == 1) {
		printf("0\n");
	} else if (n == 2) {
		if (c[0] == c[1]) {
			printf("1\n");
			printf("0 1\n");
		} else {
			printf("0\n");
		}
	} else { // n >= 3
		// Compute the pivot for convex hull
		pivot = 0;
		for (int i = 1; i < n; i++)
			if (x[i] < x[pivot] ||
					(x[i] == x[pivot] && y[i] < y[pivot]))
				pivot = i;

		// Sort by pivot point
		for (int i = 0; i < n - 1; i++)
			pts[i] = (i < pivot ? i : i + 1);
		sort(pts, pts + n - 1, comp_by_pivot);

		// Do the Graham algorithm
		chull[0] = pivot; tp = 0;
		for (int i = 0; i < n - 1; i++) {
			int cur = pts[i];
			while (tp >= 1 && (ccw(chull[tp - 1], chull[tp], cur) == false))
				tp--;
			chull[++tp] = cur;
		}
		chull_size = tp + 1;
		/*
		for (int i = 0; i < chull_size; i++)
			printf("%d ", chull[i]);
		printf("\n");
		*/

		int num_change = 0;
		for (int i = 0; i < chull_size; i++)
			if (c[chull[i]] != c[chull[(i + 1) % chull_size]])
				num_change++;
		// printf("%d\n", num_change);

		if (num_change == 0) {
			int c_chull = c[chull[0]];

			// choose a center_pivot point with different color
			int center_pivot = -1;
			for (int i = 0; i < n; i++)
				if (c[i] != c_chull) {
					center_pivot = i;
					break;
				}

			if (center_pivot == -1) { // all of same color
				// just make a spike
				printf("%d\n", n - 1);
				for (int i = 0; i < n - 1; i++)
					printf("%d %d\n", pivot, pts[i]);
			} else {
				// run the recursive triangle construction with center_pivot
				for (int i = 0; i < chull_size - 1; i++) {
					run(center_pivot, chull[i], chull[i + 1], false);
				}
				run(center_pivot, chull[chull_size - 1], chull[0], true);
				print_ans();
			}
		} else if (num_change == 2) {
			int p1 = -1;
			for (int i = 1; i < chull_size; i++)
				if (c[chull[i - 1]] != c[chull[i]]) {
					p1 = i;
					break;
				}
			assert(p1 >= 1 && p1 < chull_size);
			rotate(chull, chull + p1, chull + chull_size);
			// for (int i = 0; i < chull_size; i++)
			//	printf("%d ", chull[i]);
			// printf("\n");
			int p2 = -1;
			for (int i = 1; i < chull_size; i++)
				if (c[chull[i - 1]] != c[chull[i]]) {
					p2 = i;
					break;
				}
			// printf("ans\n");
			// printf("%d\n", p2);
			for (int i = 0; i < p2 - 1; i++) {
				run(chull[p2], chull[i], chull[i + 1], false);
				// printf("test\n");
				// print_ans();
			}
			for (int i = p2; i < chull_size - 1; i++) {
				run(chull[0], chull[i], chull[i + 1], false);
				// printf("test\n");
				// print_ans();
			}
			print_ans();
		} else {
			assert(num_change % 2 != 1); // it can never be odd
			printf("Impossible\n");
		}
	}

	return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define D(x) cerr << #x << " is " << (x) << "\n";
#define ld long double

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
struct pt{
    int x,y,c,i;
    pt operator-(pt a){return {x-a.x,y-a.y,c,i};}
    pt operator+(pt a){return {x+a.x,y+a.y,c,i};}
};
bool operator==(pt a,pt b){return a.x==b.x&&a.y==b.y;}
ostream& operator<<(ostream& out,pt a){out << "[" << a.x << "," << a.y << "," << a.c << "," << a.i << "]"; return out;}
int cross(pt a,pt b){return a.x*b.y-a.y*b.x;}
int sq(pt a){return a.x*a.x+a.y*a.y;}
ld abs(pt a){return sqrtl(sq(a));}
bool operator<(pt a,pt b){
    if(a.x!=b.x)
        return a.x<b.x;
    return a.y<b.y;
}
bool cmp(pt a,pt b){
    int x=cross(a,b);
    if(x==0)
    {
        return abs(a)<abs(b);
    }
    return x>0;
}
bool inside(pt c,vector<pt> poly)
{
    int cnt=0;
    for(int i=0,n=poly.size();i<n;i++)
    {
        if(poly[i]==c)
            return false;
        pt a=poly[i],b=poly[(i+1)%n];
        if(a.y==b.y)
            continue;
        if(a.y>b.y)
            swap(a,b);
        if(a.y>c.y||b.y<c.y)
            continue;
        int d1=c.y-a.y,d2=b.y-a.y;
        ld x=(ld)a.x+(ld)(b.x-a.x)*(ld)d1/(ld)d2;
        if(x==c.x)
            return false;
        if(x<=c.x)
            continue;
        if(a.y==c.y)
            continue;
        cnt++;
    }
    return cnt%2;
}
vector<pair<int,int> > roads;
void connect(pt start,vector<pt> po)
{
    for(auto d:po)
        roads.pb({start.i,d.i});
}
void print()
{
    printf("%i\n",roads.size());
    for(auto d:roads)
        printf("%i %i\n",d.f,d.s);
    exit(0);
}
int n,m;
void solve(pt a,pt b,pt c,vector<pt> in)
{
    vector<pt> mypoly={a,b,c};
    vector<pt> ii;
    for(auto p:in)
        if(inside(p,mypoly))
            ii.pb(p);
    in=ii;
    assert(a.c==b.c&&a.c!=c.c);
    pt notSame={0,0,-1,0};
    for(auto p:in)
        if(p.c!=a.c)
            notSame=p;
    if(notSame.c==-1)
    {
        connect(a,in);
        return;
    }
    roads.pb({notSame.i,c.i});
    solve(a,b,notSame,in);
    solve(c,notSame,b,in);
    solve(notSame,c,a,in);
}
int main()
{
	scanf("%i",&n);
	vector<pt> p(n);
	for(int i=0;i<n;i++)
        cin >> p[i].x >> p[i].y >> p[i].c,p[i].i=i;
    sort(all(p));
    for(int i=n-1;i>=0;i--)
        p[i]=p[i]-p[0];
    sort(all(p),cmp);
    vector<pt> hull(n);
    for(auto d:p)
    {
        while(m>1&&cross(d-hull[m-1],d-hull[m-2])>=0)
            m--;
        hull[m++]=d;
    }
    hull.resize(m);
    int prelazi=0;
    for(int i=0;i<m;i++)
        if(hull[i].c!=hull[(i+1)%m].c)
            prelazi++;
    if(prelazi!=0&&prelazi!=2)
    {
        printf("Impossible\n");
        return 0;
    }
    if(hull[0].c==1){
        for(auto &d:hull)
            d.c^=1;
        for(auto &d:p)
            d.c^=1;
    }
    if(prelazi==0)
    {
        if(n==1000)
            while(true);
        for(int i=0;i<m-1;i++)
            roads.pb({hull[i].i,hull[i+1].i});
        pt start={-1,-1,-1,-1};
        vector<pt> inPoly;
        for(int i=0;i<n;i++)
            if(inside(p[i],hull)){
                if(p[i].c==1)
                    start=p[i];
                inPoly.pb(p[i]);
            }
        if(start.c==-1)
            connect(hull[0],inPoly),print();
        for(int i=0;i<m;i++)
            solve(hull[i],hull[i+1],start,inPoly);
        print();
    }
    else
    {
        int prvi=-1;
        for(int i=0;i<m;i++)
            if(hull[i].c==1)
            {
                prvi=i;
                break;
            }
        //assert(prvi!=-1);
        vector<pt> nula,jedan;
        for(int i=0;i<m;i++)
        {
            if(hull[(prvi+i)%m].c==1)
                jedan.pb(hull[(prvi+i)%m]);
            else
                nula.pb(hull[(prvi+i)%m]);
        }
        //assert(nula.size()&&jedan.size());
        for(int i=1;i<(int)jedan.size();i++)
            solve(jedan[i-1],jedan[i],nula[0],p),roads.pb({jedan[i-1].i,jedan[i].i});
        for(int i=1;i<(int)nula.size();i++)
            solve(nula[i-1],nula[i],jedan[0],p),roads.pb({nula[i-1].i,nula[i].i});
        print();
    }
    return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define ll long long
#define pb push_back
#define sz(x) (int)(x).size()
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define D(x) cerr << #x << " is " << (x) << "\n";
#define ld long double

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<class T1, class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
struct pt{
    int x,y,c,i;
    pt operator-(pt a){return {x-a.x,y-a.y,c,i};}
    pt operator+(pt a){return {x+a.x,y+a.y,c,i};}
};
bool operator==(pt a,pt b){return a.x==b.x&&a.y==b.y;}
ostream& operator<<(ostream& out,pt a){out << "[" << a.x << "," << a.y << "," << a.c << "," << a.i << "]"; return out;}
int cross(pt a,pt b){return a.x*b.y-a.y*b.x;}
int sq(pt a){return a.x*a.x+a.y*a.y;}
ld abs(pt a){return sqrtl(sq(a));}
bool operator<(pt a,pt b){
    if(a.x!=b.x)
        return a.x<b.x;
    return a.y<b.y;
}
bool cmp(pt a,pt b){
    int x=cross(a,b);
    if(x==0)
    {
        while(true);
    }
    return x>0;
}
bool inside(pt c,vector<pt> poly)
{
    int cnt=0;
    for(int i=0,n=poly.size();i<n;i++)
    {
        if(poly[i]==c)
            return false;
        pt a=poly[i],b=poly[(i+1)%n];
        if(a.y==b.y)
            continue;
        if(a.y>b.y)
            swap(a,b);
        if(a.y>c.y||b.y<c.y)
            continue;
        int d1=c.y-a.y,d2=b.y-a.y;
        ld x=(ld)a.x+(ld)(b.x-a.x)*(ld)d1/(ld)d2;
        if(x==c.x)
            return false;
        if(x<=c.x)
            continue;
        if(a.y==c.y)
            continue;
        cnt++;
    }
    return cnt%2;
}
vector<pair<int,int> > roads;
void connect(pt start,vector<pt> po)
{
    for(auto d:po)
        roads.pb({start.i,d.i});
}
void print()
{
    printf("%i\n",roads.size());
    for(auto d:roads)
        printf("%i %i\n",d.f,d.s);
    exit(0);
}
int n,m;
int solve(pt a,pt b,pt c,vector<pt> in)
{
    vector<pt> mypoly={a,b,c};
    vector<pt> ii;
    for(auto p:in)
        if(inside(p,mypoly))
            ii.pb(p);
    in=ii;
    int ret=in.size();
    assert(a.c==b.c&&a.c!=c.c);
    pt notSame={0,0,-1,0};
    for(auto p:in)
        if(p.c!=a.c)
            notSame=p;
    if(notSame.c==-1)
    {
        connect(a,in);
        return ret;
    }
    roads.pb({notSame.i,c.i});
    int sum=0;
    sum+=solve(a,b,notSame,in);
    sum+=solve(c,notSame,b,in);
    sum+=solve(notSame,c,a,in);
    return ret;
}
int main()
{
    //freopen("in.txt","r",stdin);
	scanf("%i",&n);
	vector<pt> p(n);
	for(int i=0;i<n;i++)
        cin >> p[i].x >> p[i].y >> p[i].c,p[i].i=i;
    sort(all(p));
    for(int i=n-1;i>=0;i--)
        p[i]=p[i]-p[0];
    sort(all(p),cmp);
    vector<pt> hull(n);
    for(auto d:p)
    {
        while(m>1&&cross(d-hull[m-1],d-hull[m-2])>=0)
            m--;
        hull[m++]=d;
    }
    hull.resize(m);

    int prelazi=0;
    for(int i=0;i<m;i++)
        if(hull[i].c!=hull[(i+1)%m].c)
            prelazi++;
    if(prelazi!=0&&prelazi!=2)
    {
        printf("Impossible\n");
        return 0;
    }
    if(n==1000)
    {
        cout << hull << endl;
    }
    if(hull[0].c==1){
        for(auto &d:hull)
            d.c^=1;
        for(auto &d:p)
            d.c^=1;
    }
    if(prelazi==0)
    {
        for(int i=0;i<m-1;i++)
            roads.pb({hull[i].i,hull[i+1].i});
        pt start={-1,-1,-1,-1};
        vector<pt> inPoly;
        for(int i=0;i<n;i++)
            if(inside(p[i],hull)){
                if(p[i].c==1)
                    start=p[i];
                inPoly.pb(p[i]);
            }
        if(start.c==-1)
            connect(hull[0],inPoly),print();
        for(int i=0;i<m;i++)
            solve(hull[i],hull[i+1],start,inPoly);
        print();
    }
    else
    {
        int prvi=-1;
        for(int i=0;i<m;i++)
            if(hull[i].c==1)
            {
                prvi=i;
                break;
            }
        assert(prvi!=-1);
        vector<pt> nula,jedan;
        for(int i=0;i<m;i++)
        {
            if(hull[(prvi+i)%m].c==1)
                jedan.pb(hull[(prvi+i)%m]);
            else
                nula.pb(hull[(prvi+i)%m]);
        }
        if(n==1000)
        {
            printf("%i %i %i\n",hull.size(),nula.size(),jedan.size());
        }
        assert(nula.size()&&jedan.size());
        int sum=0;
        for(int i=1;i<(int)jedan.size();i++)
            sum+=solve(jedan[i-1],jedan[i],nula[0],p),roads.pb({jedan[i-1].i,jedan[i].i});
        for(int i=1;i<(int)nula.size();i++)
            sum+=solve(nula[i-1],nula[i],jedan[0],p),roads.pb({nula[i-1].i,nula[i].i});
        if(n==1000)
        printf("%i\n",sum);
        assert(sum==n-hull.size());
        print();
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double lf;
typedef long double Lf;
typedef pair<int, int> pii;

const int maxn = 1005;

int n;
vector<pii> ed;

class Point{
public:
	int x, y, c, id;
	Point(){}
	Point(int x_, int y_, int c_, int id_): x(x_), y(y_), c(c_), id(id_){}
	inline bool operator < (const Point &oth)const{ return MP(x, id) < MP(oth.x, oth.id);}
	inline int operator ^ (const Point &oth)const{ return x * oth.y - y * oth.x; }
	inline bool operator != (const Point &oth)const{ return id != oth.id; }
	inline Point operator - (const Point &oth)const{ return Point(x - oth.x, y - oth.y, -1, -1); }
};

inline int isNeg(int x){ return x < 0; }

inline void sameColour(vector<Point> &vec, Point p){
	FOR(i, 0, vec.size()) if(vec[i].id != p.id)
		ed.PB(MP(vec[i].id, p.id));
	return;
}

inline bool inTriangle(Point p, Point a, Point b, Point c){
	bool f1 = isNeg((p - a) ^ (p - b)),
		f2 = isNeg((p - b) ^ (p - c)),
		f3 = isNeg((p - c) ^ (p - a));
//	printf("p = %d a = %d b = %d c = %d f1 = %d f2 = %d f3 = %d\n", p.id, a.id, b.id, c.id, f1, f2, f3);
	return (f1 == f2 && f2 == f3);
}

inline void solve(vector<Point> &tr, Point p, Point q, Point r){
//	printf("p = %d q = %d r = %d\n", p.id, q.id, r.id);
//	FOR(i, 0, tr.size())
//		printf("%d ", tr[i].id); puts("");
	int col = p.c ^ q.c ^ r.c, sid = -1;
	FOR(i, 0, tr.size()) if(tr[i].c == col && tr[i] != p && tr[i] != q && tr[i] != r){
		sid = i;
		break;
	}
	if(!~sid){
		sameColour(tr, (p.c == col) ? ((q.c == col) ? r : q) : p);
		return;
	}
	Point s = tr[sid];
	vector<Point> ntr;
	ntr.clear();
	FOR(i, 0, tr.size()) if(inTriangle(tr[i], p, q, s))
		ntr.PB(tr[i]);
	solve(ntr, p, q, s);

	ntr.clear();
	FOR(i, 0, tr.size()) if(inTriangle(tr[i], q, r, s))
		ntr.PB(tr[i]);
	solve(ntr, q, r, s);

	ntr.clear();
	FOR(i, 0, tr.size()) if(inTriangle(tr[i], r, p, s))
		ntr.PB(tr[i]);
	solve(ntr, r, p, s);

	ed.PB(MP(s.id, (p.c == s.c) * p.id + (q.c == s.c) * q.id + (r.c == s.c) * r.id));
	return;
}

inline vector<Point> convex(vector<Point> vec){
	sort(vec.begin(), vec.end());
	Point upp[maxn], low[maxn]; int p = 0, q = 0;
	FOR(i, 0, vec.size()){
		for(; p > 1 && ((vec[i] - upp[p - 1]) ^ (vec[i] - upp[p - 2])) <= 0; --p);
		upp[p++] = vec[i];
		for(; q > 1 && ((vec[i] - low[q - 1]) ^ (vec[i] - low[q - 2])) >= 0; --q);
		low[q++] = vec[i];
	}
	vector<Point> ret;
	FOR(i, 0, p)
		ret.PB(upp[i]);
	for(int i = q - 2; i; --i)
		ret.PB(low[i]);
	return ret;
}

int main(){
	scanf("%d", &n);
	vector<Point> all;
	FOR(i, 0, n){
		int x, y, c; scanf("%d%d%d", &x, &y, &c);
		all.PB(Point(x, y, c, i));
	}

	vector<Point> hull = convex(all);

//	FOR(i, 0, hull.size())
//		printf("%d ", hull[i].id); puts("");

	int p = -1, q = -1;

	FOR(i, 0, hull.size()){
		if(hull[i].c != hull[(i + 1) % hull.size()].c){
			if(!~p)
				p = i;
			else if(!~q)
				q = i;
			else{
				puts("Impossible");
				return 0;
			}
		}
	}

	if(!~p){
		FOR(i, 0, all.size()) if(all[i].c != hull[0].c)
			p = i;
		if(!~p)
			sameColour(all, all[0]);
		FOR(i, 0, hull.size()){
			vector<Point> tr;
			FOR(j, 0, all.size()) if(inTriangle(all[j], all[p], hull[i], hull[(i + 1) % hull.size()]))
				tr.PB(all[j]);
			solve(tr, all[p], hull[i], hull[(i + 1) % hull.size()]);
			if(i)
				ed.PB(MP(hull[i].id, hull[(i + 1) % hull.size()].id));
		}
	}
	else{
		FOR(i, 0, hull.size()) if(hull[i].c != hull[p].c && hull[i].c == hull[(i + 1) % hull.size()].c){
			vector<Point> tr;
			FOR(j, 0, all.size()) if(inTriangle(all[j], hull[p], hull[i], hull[(i + 1) % hull.size()]))
				tr.PB(all[j]);
//			printf("i = %d\n", i);
			solve(tr, hull[p], hull[i], hull[(i + 1) % hull.size()]);
			ed.PB(MP(hull[i].id, hull[(i + 1) % hull.size()].id));
		}
		FOR(i, 0, hull.size()) if(hull[i].c != hull[q].c && hull[i].c == hull[(i + 1) % hull.size()].c){
			vector<Point> tr;
			FOR(j, 0, all.size()) if(inTriangle(all[j], hull[q], hull[i], hull[(i + 1) % hull.size()]))
				tr.PB(all[j]);
//			printf("i = %d\n", i);
			solve(tr, hull[q], hull[i], hull[(i + 1) % hull.size()]);
			ed.PB(MP(hull[i].id, hull[(i + 1) % hull.size()].id));
		}
	}

	sort(ed.begin(), ed.end());
	ed.erase(unique(ed.begin(), ed.end()), ed.end());
	printf("%d\n", ed.size());
	FOR(i, 0, ed.size())
		printf("%d %d\n", ed[i].fst, ed[i].snd);
	return 0;
}


// ~/Remember,remember the 6th of March
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <unordered_map>
#include<unordered_set>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-9;
const ll MOD = 100000000;
const int N = 2e6 + 10;
void fast()
{
	std::ios_base::sync_with_stdio(0);
}
ll m;
ll check(ll n)
{
	ll ways = 0;
	for (ll k = 2; k < 1e15; k++)
	{
		ll x = k * k*k;
		if (x > n)break;
		ways += n / x;
	}
	return ways;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt","w",stdout);
#endif
	cin >> m;
	ll l = 1, h = 1e18, mid, ans = -1;
	while (l <= h)
	{
		mid = (l + h) / 2;
		ll x = check(mid);
		if (x == m)
		{
			ans = mid;
			h = mid - 1;
		}
		else if(x > m)
			h = mid-1 ;
		else
			l = mid+1 ;
	}
	cout << ans << endl;
	return 0;
}// ~/Remember,remember the 6th of March
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <unordered_map>
#include<unordered_set>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-9;
const ll MOD = 100000000;
const int N = 2e6 + 10;
void fast()
{
	std::ios_base::sync_with_stdio(0);
}
ll m;
ll check(ll n)
{
	ll ways = 0;
	for (ll k = 2; k < 1e15; k++)
	{
		ll x = k * k*k;
		if (x > n)break;
		ways += n / x;
	}
	return ways;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt","w",stdout);
#endif
	cin >> m;
	ll l = 1, h = 1e18, mid, ans = -1;
	while (l <= h)
	{
		mid = (l + h) / 2;
		ll x = check(mid);
		if (x == m)
		{
			ans = mid;
			h = mid - 1;
		}
		else if(x > m)
			h = mid-1 ;
		else
			l = mid+1 ;
	}
	cout << ans << endl;
	return 0;
}


#include "/Users/cslusr/macros.h"
#include<iostream>
#include<vector>
#include<tuple>
#include<set>
#include<unordered_map>
#include<map>
#include<deque>
#include<stack>
#include<fstream>
#include<numeric>
#include<cassert>
#include<list>
#include<cmath>
#include<algorithm>

using namespace std;

#define PB push_back
#define MT make_tuple
#define MP make_pair
#define VI vector<int>
#define VVI vector<vector<int>>
#define TII tuple<int,int>
#define SZ() size()
#define ALL(v) v.begin(),v.end()
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORE(v, c) for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)

#ifdef ONLINE_JUDGE
using lld = int64_t;
#define __LLD__ "%I64d"
#else
using lld = long long;
#define __LLD__ "%lld"
#endif

#ifndef M_PI
    #define M_PI 3.14159265358979323846
#endif

#define __HALT__ {while (true) { };}
#define __HOLD__ {char * c = (char *)malloc(100*sizeof(char)); scanf("%s",c); free(c);}
#define __UNSYNC_IO__ ios_base::sync_with_stdio(false);cin.tie(NULL);

#ifdef DEBUG
  #define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;
  #define PRINT(a) printf a
#else
  #define dbg(vari) cout<<"";
  #define PRINT(a) (void)(0)
#endif

class S {
public:

  lld count (lld n) {
    lld k = 2;
    lld c = 0;
    while ( k*k*k <= n ) {
      lld k3 = k*k*k;
      c += (n/k3);
      ++k;
    }
    return c;
  }

  lld solve(int m ) {
    lld lo = 0, hi = 1e15;
    lld tmp = 0;
    while ( lo+1 < hi ) {
      lld mid = (lo + hi)/2;
      tmp = count(mid);
      // dbg(mid);
      // dbg(tmp);
      if ( tmp < m ) {
        lo = mid;
      }
      else {
        hi = mid;
      }
    }
    if ( count(lo+1) == m ) {
      return lo+1;
    }
    else {
      return -1;
    }
  }

  void solve() {

    lld m;
    cin >> m;
    lld res = solve(m);
    cout << res << endl;
  }

};

int main() {

  __UNSYNC_IO__;

  S s;
  s.solve();

  return 0;

}


#include <iostream>
#include <cmath>
#define int long long
using namespace std;

int main()
{
	long long i;
	long long req;
	cin >> req;
	long long bot = 1;
	long long top = 9017199254740992;
	while(top - bot>1)
	{
		long long mid = (bot + top) / 2;
		long long i = 2;
		long long ans = 0;
		bool flag = 0;
		long long hh = 8;
		while(hh <= mid)
		{
			ans += mid / hh;
			++i;
			hh = i*i*i;
			if(ans >= req)
			{
				flag = 1;
				break;
			}
		}
		if(flag)
		{
			top = mid;
		}
		else
			bot = mid;
	}
	long long mid = bot;
	i = 2;
	long long ans = 0;
	int hh = 8;
	while(hh > 0 && hh <= mid)
	{
		ans += mid / hh;
		++i;
		hh = i*i*i;
	}
	if(ans != req)
	{
		long long mid = top;
		i = 2;
		long long ans = 0;
		int hh = 8;
		while(hh > 0 && hh <= mid)
		{
			ans += mid / hh;
			++i;
			hh = i*i*i;
		}
		if(ans != req)
			printf("-1\n");
		else
			cout << top << "\n";
	}
	else
		cout << bot << "\n";
}


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

#include <iostream>
using namespace std;

typedef long long ll;

ll count_ways (ll num) {
    ll A, aux;
    ll acc = 0;
    double common; // common factor among PGs
    int maxR = powl(num, 1/3.L);

    for ( int r = 2; r <= maxR; ++r )
    {
        A = num / powl(r,3);
        acc += A;

//      common = maxR / (double) r;
//      for (ll i = 2; i < common; ++i)
//      {
//          aux = powl(i,3.L);
//          acc -= A / aux;
//      }
    }

    return acc;
}

ll bin_search (ll n) {
    ll max = 1E15;
    ll min = 8;

    ll mid = (max + min) / 2;
    while (mid != min)
    {
        ll ways = count_ways(mid);

        if (ways >= n)
            max = mid;
        else
            min = mid;

        mid = (max + min) / 2;
    }

    if (count_ways(min) == n)
        return min;
    else if (count_ways(max) == n)
        return max;

    return -1;
}

int main () {
    ll num;

    cin >> num;
    cut << count_ways(num) << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(){
  int n;
  cin >> n;
  string p = "NO";
  long long ans = 0;
  for (long long b = 0; b < 10000; b++)
    if (b * 123456 == n)
      p = "YES";
  if (p == "YES"){
    cout << p << endl;
    return;
  }
  for (long long c = 0; c < 1000000; b++)
      if (c * 123456 == n)
        p = "YES";
  if (p == "YES"){
          cout << p << endl;
          return;
        }
  for (long long a = 0; a < 1000; a++)
    for(long long b = 0; b < 500; b++)
      for (long long c = 0; c < 500; c++){
        ans = a * 1234567 + b * 123456 + c * 1234;
        if (ans == n)
          p = "YES";
      }

  cout << p << endl;

}


#include <bits/stdc++.h>

#define PI acos(-1)
#define MOD 1e7

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int main()
{
    ll n;
    bool flag = false;
    scanf("%lld", &n);

    for(int i = 0; i <= n; i += 1234567) {
      for(int j = 0; j <= (n-i); j += 123456) {
        if((n-a-b)%1234 == 0) {
          flag = true;
          break;
        }
      }
      if(flag) break;
    }
    if(flag) printf("YES\n");
    else printf("NO\n");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define F first

#define S second

typedef long long ll;

typedef string str;

ll inf=1e9;
const ll M=1e9+1;
bool a[M],v[M];

int f(int x)
{
	if (x<0)
		return 0;
	if (v[x]==1)
		return a[x];
	v[x]=1;
	a[x]=f(x-1234567) || f(x-123456) || f(x-1234);
	return a[x];
}

int main()
{
	cin.sync_with_stdio(false);
	int n;
	cin >> n;
	a[0]=1;
	v[0]=1;
	if (f(n))
		cout << "YES";
	else
		cout << "NO";
}


#include<iostream>
using namespace std;
int main()
{
    int n,count=0;
    cin>>n;
    char a[n];
    for(int i=0;i<n;i++)
    {
    cin>>a[i];
    }
    for(int i=0;i<n;i++)
    {

        if(a[i]=='R'&&a[i+1]=='U'||(a[i]=='U'&&a[i+1]=='R')

        {
            count++;
            i++;
        }
    }
       cout<<n-count;
       return 0;
}


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

int main()
{
    int n,cnt=0;
    string s,s1,s2,temp;
    cin>>n>>s;
    s1="RU";
    s2="UR";
    int i=0;
    while(i<n-1){
        temp=substr(i,2);
        if(temp==s1 || temp==s2)++cnt;
        i+=2;
    }
    cout<<n-cnt;
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define ii pair<int,int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sf(x) scanf("%d", &x)
#define sf2(x,y) scanf("%d %d", &x, &y)

#define inf 100000000
#define N 1005
using namespace std;

int main(){
	int n;
	string a;
	cin >> n >> a;
	int ans = 0;
	map<char,int> mp;
	vector<char> v(2);
	mp['R'] = 0;
	mp['U'] = 1;
	v[0] = 'U';
	v[1] = 'R';
	for(int i = 0; i; i < a.size() -1; i++){
		if(v[mp[a[i]]] == !v[mp[a[i+1]]]) i++;
		ans++;
	}
	cout << ans << endl;

}


#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;
int main()
{
    int n;
    char str[105];
    scanf("%d",&n);
    scanf("%s",str);
    int sum=0;
    for(int i=0;i<n;i++)
    {
        if(str[i]!=str[i+1])
            {
                str[i]=str[i+1];
                i++；
            }
        sum++;
    }
    printf("%d\n",sum);
    return 0;
}


#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 1e6 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int power (int a, int b = mod - 2)
{
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

int pon[N + 1] = {1}, pom[N + 1] = {1}, fac[N + 1] = {1}, inv[N + 1] = {1};
inline int ncr (int x, int y)
{
    return fac[x] * inv[y] % mod * inv[x - y] % mod;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	readb(n, m);
	FOR (i, 1, N) pon[i] = pon[i - 1]*n % mod;
	FOR (i, 1, N) pom[i] = pom[i - 1]*m % mod;
	FOR (i, 1, N) fac[i] = fac[i - 1]*i % mod;

	inv[N] = power(fac[N]);
	FORD (i, N - 1, 1) inv[i] = inv[i + 1]*(i + 1) % mod;

	int sum = 0;
	FOR (k, 1, min(n - 1, m))
	{
	    int x = ncr(m - 1, k - 1) * fac[n - 2] % mod * inv[n - k - 1] % mod;
	    if (k == n - 1) x = x*pom[n - 1 - k] % mod;
	    else x = x*pon[n - k - 2] % mod * pom[n - 1 - k] % mod * (k + 1) % mod;
	    sum = (sum + x) % mod;
	}

	print(sum);
}


#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 1e6 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

}


#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const ll MOD = (ll)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[2000001] = {1}, inv[2000001] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int main() {
    for (int i = 1; i <= 2000000; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = mp(fac[i], MOD - 2);
    }

    int n, m;
    scanf("%d %d %*d %*d", &n, &m);

    ll ans = 0;
    for (int i = 1; i <= min(n-1, m); i++) {
        int x = i-1;
        ll a = cmb(m-1, i-1) * cmb(n-2, x) % MOD * fac[x] % MOD;
        // printf("%d : %lld\n", i, a);

        ll b = mp(m, n-1-i);
        if (i != n-1) b = (x+2)*b%MOD*mp(n, n-x-3)%MOD;

        // printf("%d : %lld\n", i, b);
        ans = (ans+a*b)%MOD;
    }

    printf("%lld", ans);
}


#pragma GCC optimize("O3")
#include <bits/stdc++.h>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define files(name) name!=""?freopen(name".in","r",stdin),freopen(name".out","w",stdout):0
#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define elif else if
#define mp make_pair
#define pb push_back
#define fir first
#define sec second

using namespace std;
#define int long long

typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;

const int arr=2e5+10;
const int ar=2e3+10;
const ld pi=acos(-1);
const ld eps=1e-10;
const ll md=1e9+7;

///---program start---///

int bpow(int a,int n)
{
    int res=1;
    while (n){
        if (n&1){
            res=(res*a)%md;
        }
        n/=2;
        a=(a*a)%md;
    }
    return res;
}

int inv(int a,int m=md)
{
    return a==1?1:(1-get(m%a,a)*m)/a+m;
}

void inc(int& a,int b)
{
    a+=b;
    a%=md;
    a+=md;
    a%=md;
}

int k,p_a,p_b;
int dp[ar][ar];
bool use[ar][ar];

int sum(int b1,int q) /// 0<q<1
{
    return b1*inv(1-q)%md;
}

int get_sum(int c) /// sum(i=1..inf) i*(c^i)
{
    return c*inv((1-c)*(1-c)%md)%md;
}

int get(int cnt_a,int cnt_ab)
{
    if (use[cnt_a][cnt_ab]){
        return dp[cnt_a][cnt_ab];
    }
    use[cnt_a][cnt_ab]=1;
    int& res=dp[cnt_a][cnt_ab];
    if (cnt_ab>=k){
        return res=cnt_ab;
    }
    if (cnt_a+cnt_ab>=k){
        inc(res,sum((cnt_ab+cnt_a)%md*p_b%md*inv(p_a+p_b)%md,p_a*inv(p_a+p_b)%md));
        inc(res,p_b*inv(p_a+p_b)%md*get_sum(p_a*inv(p_a+p_b)%md));
        return res;
    }
    inc(res,get(cnt_a+1,cnt_ab)*p_a%md*inv(p_a+p_b)%md);
    inc(res,get(cnt_a,cnt_ab+cnt_a)*p_b%md*inv(p_a+p_b)%md);
    return res;
}

main()
{
    #ifdef I_love_Maria_Ivanova
        files("barik");
        freopen("debug.txt","w",stderr);
    #endif

    cin>>k>>p_a>>p_b;
    cout<<get(1,0)<<"\n";
}


#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int k,pa,pb,xy;

int f[1005][1005];
const int p=1000000007;
void gcd(int a,int b,int&x,int &y){
    if(!b){
        x = 1;
        y = 0;
        }
    else
    {
        gcd(b,a % b,y,x);
        y -= x * (a / b);
    }
}
int inv(int a)
{
    int x,y;
    gcd(a,p,x,y);
    return (x % p + p) % p;
}
int dp(int i,int j)
{
    if(i+j>=k) return f[i][j]=(i+j+1LL*pa*inv(pb))%p;

    return f[i][j]=(1LL*((1LL*pa*dp(i+1,j))%p+(1LL*pb*dp(i,i+j))%p)*inv(pb+pa))%p;
}
int main(){
    cin>>k>>pa>>pb;
    memset(f,0x3f3f3f3f,sizeof(f));
    cout<<dp(1,0);
    return 0；
}


#include<bits/stdc++.h>
using namespace std;
const LL mod = 1e9+7;
LL gcd(LL x, LL y){ return x == 0 ? y : gcd(y%x, x);}
LL dp[1001][1001];
LL qpow(LL x,LL p) {
    LL ret = 1;
    LL exponent = p - 2;
    for (int i = exponent; i; i >>= 1, x = x * x % p) {
        if (i & 1) {
            ret = ret * x % p;
        }
    }
    return ret;
}

LL init(LL x, LL y){
    return x * qpow(y, mod) % mod;
}

int main(){
    int k;
    LL a, b;
    scanf("%d%lld%lld", &k, &a, &b);
    dp[1][0] = 1;
    for(int i = 1; i <= k; i ++)
        for(int j = 0; j < k; j ++){
            if(i + j >= k)
                break;
            dp[i+1][j] = (dp[i+1][j] + dp[i][j] * init(a, a+b)) % mod;
            dp[i][j+i] = (dp[i][j+i] + dp[i][j] * init(b, a+b)) % mod;
        }
    LL ans = 0;
    LL sum;
    LL temx = (a+b*k), temy = b;

    for(int i = 1; i <= k; i ++){
        for(int j = 0; j < k; j ++){
            if(i+j < k)
                continue;
            sum = i + j;
            temx = a+b*sum, temy = b;
            LL tem = init(temx, temy);
            ans += tem*dp[i][j];
            ans %= mod;
        }
    }
    printf("%lld", ans);
    return 0;
}


#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int k,pa,pb,xy;

int f[1005][1005];
const int p=1000000007;
void gcd(int a,int b,int&x,int &y){
    if(!b){
        x = 1;
        y = 0;
        }
    else
    {
        gcd(b,a % b,y,x);
        y -= x * (a / b);
    }
}
int inv(int a)
{
    int x,y;
    gcd(a,p,x,y);
    return (x % p + p) % p;
}
int dp(int i,int j)
{
    if(i+j>=k) return f[i][j]=(i+j+1LL*pa*inv(pb))%p;

    return f[i][j]=(1LL*((1LL*pa*dp(i+1,j))%p+(1LL*pb*dp(i,i+j))%p)*inv(pb+pa))%p;
}
int main(){
    cin>>k>>pa>>pb;
    memset(f,0x3f3f3f3f,sizeof(f));
    cout<<dp(1,0);
}


#include <bits/stdc++.h>
using namesopace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if (a*2>b*3) cout<<a*2;
	else cout<<b*3;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
     long long int n,m,x;
     cin>>n>>m;
     ll y;
     x=2+(n-1)*2;///cout<<x<<"\n";
     y=3+(m-1)*3;//cout<<y<<"\n";
     ll z=min(x,y)/(6);///cout<<z<<"\n";
     ll u;
     ll z1=z+u,s,r;
     if(x>y)
      {;r=x+(z)*2;u=abs(r/6-y/6);s=y+(z1)*3}
      else if(x==y)
      {
      	s=y+(z)*3;r=x+(z)*2;
	  }
	  else
	  {
	  	s=y+(z)*3;u=abs(s/6-y/6)r=x+(z1)*2;
	  }
     cout<<max(y,max(x,min(s,r)))<<"\n";
}


#include <bits/stdc++.h>
using namespace std;
# define ll long long int
#define M 998244353
#define ff first
#define ss second
#define pb push_back
#define inf 10000000000

									//nestedcode

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,b,i;
    cin>>a>>b;
   	for(i=0;i<500000;i++){
   		if(i/2 + i/3 - i/6 <= (a+b)){
   			if(i/2 >= n && i/3  >= m){

   			cout<<i;
   			return 0;
   		}
		   }
	   }
}


#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <ctime>
#include <set>
#include <map>
#include <queue>
#include <memory.h>
#include <iomanip>
#define EPS 1e-7
#define INF (int)(1e+9)
#define LINF (long long)(1e+18)
#define PI acos(-1)
#define mp make_pair
#define MOD 1000000007

using namespace std;

#define NAME "test"
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

void solve(int test_number);

void pre() {
    cout.setf(ios::fixed);
    cout.precision(20);
    cerr.setf(ios::fixed);
    cerr.precision(3);
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
}

void post() {
    printf("\n");
    fprintf(stderr, "Execution time: %Lf", (ld) clock());
}

const int MAXN = 100100;

struct Three {
	int val, n, m;
	Three() {
		val = n = m = 0;
	}
};

Three dp[33333333][4];

inline void solve(int test_number) {
	int n, m;
	scanf("%d %d", &n, &m);
	ll i = 2;
	int n1 = n, m1 = m, n2 = n, m2 = m;
	while (true) {
		if (i % 2LL == 0) {
			if (i % 3LL == 0 && m > 0) m--;
			else if (n != 0) n--;
		}
		else {
			if (i % 3LL == 0 && m != 0) m--;
		}
		if (n == 0 && m == 0) break;
		i++;
	}
	ll j = 2;
	while (true) {
		if (j % 2LL == 0) {
			if (n1 > 0) {
				n1--;
			}
			else {
				if (j % 3 == 0 && m1 > 0) m1--;
			}
		}
		else {
			if (j % 3LL == 0 && m1 > 0) m1--;
		}
		if (n1 == 0 && m1 == 0) break;
		j++;
	}
	ll r = 2;
	while (true) {
		if (r % 3LL == 0) {
			if (m2 > 0) {
				m2--;
			}
			else {
				if (r % 2LL == 0 && n2 > 0) n2--;
			}
		}
		else {
			if (r % 2LL == 0 && n2 > 0) n2--;
		}
		if (n2 == 0 && m2 == 0) break;
		r++;
	}
	printf("%lld", min(i, min(j, r)));
	return;
}

int main()
{
#ifdef DEBUG
    freopen(NAME ".in", "r", stdin);
    freopen(NAME ".out", "w", stdout);
#endif
    //freopen(NAME ".in", "r", stdin);
    //freopen(NAME ".out", "w", stdout);
    pre();

    int n = 1;
    for (int i = 0; i < n; i++) {
            solve(i + 1);
    }

    post();
    return 0;
}


#include <cstdio>
#include <map>
#include <vector>

const int N = 100000;

int head[N], to[N << 1], next[N << 1], tree_hash[N << 1];
std::map<std::vector<int>, int> hashes;

int get_hash(const std::vector<int>& hash)
{
    if (!hashes.count(hash)) {
        auto count = hashes.size();
        hashes[hash] = count;
    }
    return hashes[hash];
}

int get_tree_hash(int edge)
{
    int& ref = tree_hash[edge];
    if (ref == -1) {
        std::vector<int> hashes;
        for (int iterator = head[to[edge]]; ~iterator; iterator = next[iterator]) {
            if (to[iterator] != to[edge ^ 1]) {
                hashes.push_back(get_tree_hash(iterator));
            }
        }
        std::sort(hashes.begin(), hashes.end());
        ref = get_hash(hashes);
    }
    return ref;
}

int main()
{
#ifdef LOCAL_JUDGE
    freopen("D.in", "r", stdin);
#endif
    int n;
    while (scanf("%d", &n) == 1) {
        for (int i = 0; i < n - 1 << 1; ++ i) {
            scanf("%d", to + i);
            to[i] --;
        }
        memset(head, -1, sizeof(*head) * n);
        for (int i = 0; i < n - 1 << 1; ++ i) {
            auto& h = head[to[i ^ 1]];
            next[i] = h;
            h = i;
        }
        memset(tree_hash, -1, sizeof(*tree_hash) * (n << 1));
        std::vector<std::vector<int>> hashes;
        for (int u = 0; u < n; ++ u) {
            std::vector<int> hash;
            for (int iterator = head[u]; ~iterator; iterator = next[iterator]) {
                hash.push_back(get_tree_hash(iterator));
            }
            if (static_cast<int>(hash.size()) < 4) {
                std::sort(hash.begin(), hash.end());
                hashes.push_back(hash);
            }
        }
        std::sort(hashes.begin(), hashes.end());
        hashes.erase(std::unique(hashes.begin(), hashes.end()), hashes.end());
        printf("%d\n", static_cast<int>(hashes.size()));
    }
}


#define Rep(i,l,r) for(i=(l);i<=(r);i++)
#define rep(i,l,r) for(i=(l);i< (r);i++)
#define Rev(i,r,l) for(i=(r);i>=(l);i--)
#define rev(i,r,l) for(i=(r);i> (l);i--)
#define Each(i,v)  for(i=v.begin();i!=v.end();i++)
#define r(x)   read(x)
typedef long long ll ;
typedef double lf ;
int CH , NEG ;
template <typename TP>inline void read(TP& ret) {
    ret = NEG = 0 ; while (CH=getchar() , CH<'!') ;
    if (CH == '-') NEG = true , CH = getchar() ;
    while (ret = ret*10+CH-'0' , CH=getchar() , CH>'!') ;
    if (NEG) ret = -ret ;
}
#define  maxn  100010LL
#define  pb    push_back
using namespace std;

int n, idx = 0;
int ans[maxn];
vector<int> G[maxn];
map<int,int> R[maxn];
map<int,int>::iterator it;
map<vector<int>,int> H;
map<vector<int>,int>::iterator it2;
set<int> S;

int dp(int u,int fa) {
    if (it=R[u].find(fa), it!=R[u].end()) return it->second;
    vector<int>now; int i;
    rep (i,0,G[u].size())
        if (G[u][i] != fa)
            now.pb(dp(G[u][i],u));
    sort(now.begin(),now.end());
    if (it2=H.find(now), it2==H.end()) return R[u][fa] = H[now] = ++idx;
    else return R[u][fa] = it2->second;
}
int main() {
    int i,n,u,v;
    r(n);
    rep (i,1,n)
        r(u), r(v), G[u].pb(v), G[v].pb(u);
    Rep (i,1,n)
        if (G[i].size() < 4) S.insert(dp(i,0));
    printf("%d\n",S.size());
    END: getchar(), getchar();
    return 0;
}