#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
	bool flag=1;
	int x=0;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
			flag=0;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return (flag?x:~(x-1));
}
int n,m,k,ans,a[200002],b[200002];
const int mod=998244353;
int qp(int x,int y)
{
	if(y==0)
		return 1;
	if(y==1)
		return x;
	if(x<=1)
		return x;
	int ans=qp(x,y/2);
	ans=(ans*ans)%mod;
	if(y&1)
		ans=(ans*x)%mod;
	return ans;
}
signed main()
{
	n=read();
	m=read();
	k=read();
	for(int i=1;i<=k;i++)
//		b[k-i+1]=b[k-i+2]+qp(i,m)-qp(i-1,m);
		b[k-i+1]=qp(i,m);
	if(n==1&&m==1)
	{
		cout<<k;
		return 0;
	}
	if(n==1)
	{
		cout<<qp(k,m)<<endl;
		return 0;
	}
	if(m==1)
	{
		cout<<qp(k,n)<<endl;
		return 0;
	}
	for(int i=1;i<=k;i++)
		ans=(ans+(qp(i,n)-qp(i-1,n)+mod)%mod*b[i]%mod)%mod;
	cout<<ans<<endl;
	return 0;
}

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

#define M 1005
#define LL long long
const LL mod = 1000000007;

int n;
LL f[M];
char Caa, Cab, Cba, Cbb;

inline LL qkpow (LL x, LL y){
	LL res = 1;
	while (y){
		if (y & 1)
			res = res * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
signed main (){
	scanf ("%d\n%c\n%c\n%c\n%c", &n, &Caa, &Cab, &Cba, &Cbb);
	if (n == 3 || n == 2){
		printf ("1\n");
		return 0;
	}
	f[1] = 2, f[2] = 3;
	for (int i = 3; i <= n; i ++)
		f[i] = (f[i - 1] + f[i - 2]) % mod;
	if (Cab == 'B'){
		if (Cbb == 'B')
			printf ("1\n");
		else{
			if (Cba == 'A'){
				printf ("%lld\n", qkpow (2, n - 3));
			}
			else{
				printf ("%lld\n", f[n - 3]);
			}
		}
	}
	else{
		if (Caa == 'A')
			printf ("1\n");
		else{
			if (Cba == 'B'){
				printf ("%lld\n", qkpow (2, n - 3));
			}
			else{
				printf ("%lld\n", f[n - 3]);
			}
		}
	}
	return 0;
}


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

int main() {
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int n;
    cin >> n;

    int ans = 0;

    while (n--)
    {
        int x;
        cin >> x;

        ans = __gcd(x, ans);
    }

    cout << ans << "\n";
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,m,n) for(ll i=(m);i<(n);i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back

ll gcd(ll a, ll b){
    ll bigger=max(a,b);
    ll smaller=min(a,b);

    if (bigger%smaller==0){
        return smaller;
    }
    else {
        return gcd(smaller,bigger%smaller);
    }
}

int main(){

    ll n;
    cin>>n;

    vector<ll> data(n);

    rep(i,n){
        int tmp;
        cin>>tmp;
        data.at(i)=tmp;
    }

  ll answer;

    if (n>=2){

     answer=gcd(data.at(0),data.at(1));

    for (int i=1;i<=n-2;i++){
        answer=gcd(answer,data.at(i+1));
    }

    }

    else {
        answer=data.at(0);
    }

    cout<<answer<<endl;

}


#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <deque>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cassert>
#include <iostream>
#include <stdio.h>
#include <time.h>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)

#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  if(n==12){
    cout << 1 << endl;
    return 0;
  }
  n-=12;
  long double C[300][300];

  //if(C[0][0]==0){
    for(int i = 0; i < 300; i++){
      C[i][0]=C[i][i]=1;
    }
    for(int i = 1; i < 300;i++){
      for(int j =1; j < i; j++){
        C[i][j]=(C[i-1][j-1]+C[i-1][j]);
      }
    }
  //}
  printf("%lld\n", (ll)C[11+n][n]);
  return 0;
}

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

int main(){

	long long int n, i, j;

	scanf("%lld", &n);

	long long int root = sqrt(n);

	int found = 0;
	long long int a = 1, b = 1;

	for (i = 3; i < n; i*=3)
	{
		b = 1;
		for (j = 5; j < n; j*=5)
		{
			if (i+j == n)
			{
				found = 1;
				printf("%lld %lld\n", a, b);
				break;
			}
			b++;
		}
		a++;

		if (found == 1)
		{
			break;
		}
	}

	if (found == 0)
	{
		printf("-1\n");
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e2+10;
const int M = 1e4+10;
typedef pair<int,int> pii;
#define fr(i,a,b) for(int i = a;i <= b; ++i)
#define nfr(i,a,b) for(int i = a;i >= b; --i)
#define pb push_back

vector<int> edge[N],id[N];
int c[N],ans[M];
pii p[M];
int n,m;
int dfn[N],tot;

inline void tarjan(int x,int fa){
   dfn[x] = ++tot;
   fr(i,0,(int)edge[x].size()-1){
      int y = edge[x][i];
      if(y == fa)continue ;
      if(!dfn[y])ans[abs(id[x][i])] = id[x][i] > 0 ? 1 : -1,tarjan(y,x);
      else ans[abs(id[x][i])] = id[x][i] > 0 ? -1 : 1;
   }
}

int main(){
   scanf("%d%d",&n,&m);
   fr(i,1,m){
      int x,y; scanf("%d%d",&x,&y);
      p[i] = pii(x,y);
   }
   fr(i,1,n)scanf("%d",c+i);

   fr(i,1,m){
      if(c[p[i].first] == c[p[i].second]){
         edge[p[i].first].pb(p[i].second); id[p[i].first].pb(i);
         edge[p[i].second].pb(p[i].first); id[p[i].second].pb(-i);
      } else {
         ans[i] = (c[p[i].first] < c[p[i].second]) ? -1 : 1;
      }
   }
   fr(i,1,n)if(!dfn[i])tarjan(i,0);
   fr(i,1,m){
      if(ans[i] == 1)puts("->");
      else puts("<-");
   }
   return 0;
}

#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<vector<int>>a;
vector<pair<int,int>>ds;
int b[104][104];
const int nmax=1e6;
int c[nmax+4];
int mau[105];
int cha[105];
int hang[105];
vector<pair<int,int>>kq;
void dfs(int u)
{
    mau[u]=1;
    for(int i=0; i<a[u].size(); ++i)
    {
        int v=a[u][i];
        //   cout<<v<<' ';
        if(!mau[v]&&c[u]==c[v])
        {
            b[u][v]=1;
            cha[v]=u;
            hang[v]=hang[u]+1;
            dfs(v);
        }

    }
}
int main()
{
    //ifstream cin("chuyen.inp");
    //ofstream cout("chuyen.out");
    cin>>n>>m;
    a.assign(n+1,vector<int>());
    for(int i=1; i<=m; ++i)
    {
        int x,y;
        cin>>x>>y;
        a[x].push_back(y);
        a[y].push_back(x);
        kq.push_back({x,y});
    }
    for(int i=1; i<=n; ++i)
    {
        cin>>c[i];
        ds.push_back({c[i],i});
    }

    for(int i=1; i<=n; ++i)
    {
        if(!mau[i])
            dfs(i);
    }

    for(int i=0; i<m; ++i)
    {
        int x=kq[i].first;
        int y=kq[i].second;
        if(c[x]==c[y])
        {
            if(cha[y]==x||(cha[x]!=y&&hang[x]>hang[y]))
                cout<<"->"<<'\n';
            else
                cout<<"<-"<<'\n';
            //continue;
        }
        else
        {
            if(c[x]>c[y])
                cout<<"->"<<'\n';
            else
                cout<<"<-"<<'\n';
        }
    }

}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main()
{
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll B, C;
    cin >> B >> C;

    ll ans = 0;
    bool flag = false;

    if (B) {
        if (B < 0) {
            flag = true;
        }
        B = abs(B);
        if (C >= 2 * B) {
            ans = 2 * B + C - 1;
            if (flag)
                ans++;
        } else {
            ans = C + (C > 2 ? C - 1 : 1);
        }
    } else {
        ans = (C >= 2 ? C : 1);
    }
    /*    if (C % 2) {
        ans = 1 + (C - 1) * (C + 1) / 4 + (C + 1) / 2;
    } else {
        ans = 1 + C * (C + 2) / 2;
    }
    */
    cout << ans << endl;
}

/**
 *    author:  yixxas
 *    created: 19.12.2020 19:56:03
**/
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cassert>

using namespace std;

int main(){

    int a,b;
    cin >> a>> b;
    cout << a/b;

    return 0;
}

//What we know is a drop, what we don't is an ocean.


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

int solve(int x){
    int sum = 0;
    while(x > 0){
        sum += x%10;
        x = x/10;
    }
    return sum;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    int k = solve(a);
    int c = solve(b);
    cout<<max(k,c)<<"\n";
    return 0;
}

#include <bits/stdc++.h>
#include <fstream>
#include <bitset>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF=2147483647;
// 9,223,372,036,854,775,807
const ll INFL = 9223372036854775807;

int s(string x){
    int l,m,n;
    l = x[2] - '0';
    m = x[1] - '0';
    n = x[0] - '0';
    return l+m+n;
}

int main(){

    string a,b;
    cin >> a>>b;
    int asum,bsum;
    asum = s(a);
    bsum = s(b);
    if(asum>=bsum){
        cout << asum << endl;
    }
    else{
        cout << bsum << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
#include<random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
lint gcd(lint a, lint b) { if (b == 0) return a; else return gcd(b, a % b); }
lint ceil(lint a, lint b) { return (a + b - 1) / b; }
lint digit(lint a) { return (lint)log10(a); }
const lint MOD = 998244353, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };
typedef pair<long double, lint> Pa;
typedef pair<lint, plint> tlint;
struct point {
	lint r;
	lint x, y;
};

lint N, M;
int main() {
	cin >> N >> M;
	vector<lint> arr(N);
	vector<lint> change(M);
	REP(i, N) {
		cin >> arr[i];
	}
	REP(i, M) {
		cin >> change[i];
	}
	sort(ALL(arr));
	vector<lint> sums(N + 1);
	vector<lint> revsums(N + 1);
	REP(i, N / 2) {
		sums[i + 1] = sums[i] + (arr[i * 2 + 1] - arr[i * 2]);
	}
	REP(i, N / 2) {
		revsums[i + 1] = revsums[i] + (arr[N - i * 2 - 1] - arr[N - i * 2 - 2]);
	}
	lint minv = INF;
	REP(i, M) {
		lint idx = lower_bound(ALL(arr), change[i]) - arr.begin();
		if (idx % 2 == 0) {
			chmin(minv, sums[idx / 2] + revsums[N / 2 - idx / 2] + abs(arr[idx] - change[i]));
		}
		else {
			idx--;
			chmin(minv, sums[idx / 2] + revsums[N / 2 - idx / 2] + abs(arr[idx] - change[i]));
		}
	}
	cout << minv << endk;
}

//#undef DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll llinf = (1ll<<61)-1;
#define sz(a) int(a.size())
#define all(x) begin(x), end(x)
#ifdef DEBUG
const int DEBUG_END = 26;
#define DOS cout
#include <debug.h>
#else
#define bug(args...) void()
#define cbug(a, args...)
#endif
#define ASSERT(a, o, b, args...) if (!((a)o(b))) bug(a, b, ##args), assert((a)o(b));
#define fi first
#define se second
const int inf = 1000000007, N=200005;
int TC = 1, CN, n, m, h[N], w[N];
ll ps[N];

signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); cout.precision(11), cout.setf(ios::fixed);
    //cin >> TC;// inputAll + resetAll -> solution
    auto kase = [&]()->void {
        cin >> n >> m;
        for (int i = 1; i <= n; i++) {
            cin >> h[i];
        }
        sort(h+1, h+1+n);
        for (int i = 1; i <= n; i++) {
            int o = (i&1 ? -1 : 1)*h[i];
            ps[i] = ps[i-1]+o;
        }
        ll ans = llinf;
        for (int i = 1; i <= m; i++) {
            cin >> w[i];
            int p = int(lower_bound(h+1, h+1+n, w[i])-h);
            ll cur = ps[p-1]+(p&1 ? -1 : 1)*w[i]-(ps[n]-ps[p-1]);
            //bug(cur);
#ifdef DEBUG
            cur = 0;
            vector<int> v(h+1, h+1+n);
            v.push_back(w[i]);
            sort(all(v));
            for (int j = 1; j <= n+1; j++) {
                cur += (j&1 ? -1 : 1)*v[j-1];
            }
            //bug(cur);
#endif
            ans = min(ans, cur);
        }
        cout << ans << '\n';
    };
    while (CN++!=TC) kase();
}


#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

//#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	long long n, i, j, k, s, MOD = 1000000007, ans;
	cin >> n;
	vector<long long> a(n);
	for (i = 0; i < n; i++) cin >> a[i];

	vector<long long> dp(n, 0), dp2(n, 0);
	vector<long long> dpc(n, 0), dpc2(n, 0);

	dp[0] = a[0];
	dpc[0] = 1;

	for (i = 1; i < n; i++) {
		dpc[i] = (dpc[i - 1] + dpc2[i - 1]) % MOD;
		dp[i] = (dp[i - 1] + dp2[i - 1] + a[i] * (dpc[i - 1] + dpc2[i - 1])) % MOD;

		dpc2[i] = dpc[i - 1];
		dp2[i] = (dp[i - 1] - a[i] * dpc[i - 1] + MOD * MOD) % MOD;
	}

	ans = (dp[n - 1] + dp2[n - 1]) % MOD;
	cout << ans << "\n";

	return 0;
}

// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int ll
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define ll long long
#define pi pair<int,int>
#define pii pair<pi,int>
#define vi vector<int>
#define pb push_back
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int co[51];
bool isprime(int x){
	for(int i = 2;i*i<=x;i++){
		if(x%i == 0){
			return false;
		}
	}
	return true;
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vi v(n);
	rep(i,n){
		cin>>v[i];
	}
	vi p;
	repa(i,2,51){
		if(isprime(i)){
			p.pb(i);
		}
	}
	int m = s(p);
	int ans = 1e18 + 1;
	for(int mask = 1;mask < (1<<m);mask++){
		int cur = 1;
		int flag = 0;
		rep(i,m){
			if((1<<i) & mask){
				cur *= p[i];
			}
		}
		rep(i,n){
			if(gcd(cur,v[i]) == 1){
				flag = 1;
				break;
			}
		}
		if(flag){
			continue;
		}
		else{
			ans = min(ans,cur);
		}
	}
	cout<<ans;
	// int n;
	// cin>>n;
	// vi v(n);
	// rep(i,n){
	// 	int x;
	// 	cin>>x;
	// 	v[i] = x;
	// 	if(x%2 == 0){
	// 		co[2] = 1;
	// 		while(x%2 == 0){
	// 			x /= 2;
	// 		}
	// 	}
	// 	for(int i = 3;i*i<=x;i+=2){
	// 		if(x%i == 0){
	// 			co[i] = 1;
	// 			while(x%i == 0)x/=i;
	// 		}
	// 	}
	// 	if(x > 1){
	// 		co[x] = 1;
	// 	}
	// }
	// int ans = 1 ;
	// repa(i,1,51){
	// 	if(co[i] > 0){
	// 		cout<<i<<"\n";
	// 		ans *= i;
	// 	}
	// }
	// cout<<ans;
	return 0;
}


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

using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vpll = vector<pair<ll, ll>>;
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define IOS ios::sync_with_stdio(false); cin.tie(nullptr);
const int inf = 1<<30;
const ll INF = 1ll<<60;
const ll mod = 1000000007;
//const ll mod = 998244353;
//const ll dx[4] = {1, 0, -1, 0};
//const ll dy[4] = {0, 1, 0, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

template<class T> void disp1(vector<T> &array, bool blank=1) {
    rep(i, array.size()) cout << ((i&&blank) ? " " : "") << array[i];
    cout << endl;
    //cout << " ";
}
template<class T> void disp2(vector<vector<T>> &array, bool blank=1) {
    rep(i, array.size()) disp1(array[i], blank);
}

ll rem(ll a, ll b) { return (a % b + b) % b; }      // 余りを0~b-1に丸める
// 小数の入力が文字で与えられたとき、10^n倍したものを返す
ll x10(string str_f, ll n) {
    if (str_f[0] == '-') return -x10(str_f.substr(1), n);
    ll times = 1; rep(i,n) times *= 10;     // times = 10^n
    int id = -1; rep(i,str_f.size()) if (str_f[i] == '.') id = i;
    if (id == -1) { return stoll(str_f)*times; }
    string str_int = str_f.substr(0, id), str_dec = str_f.substr(id+1);
    while (str_dec.size() < n) str_dec += '0';
    return stoll(str_int)*times + stoll(str_dec);
}
// A^N (mod)
ll modpow(ll A, ll N, ll mod) {
    ll RES = 1;
    while (N) {
        if (N & 1) RES = RES * A % mod;
        A = A * A % mod;
        N >>= 1;
    }
    return RES;
}

//using mint = modint1000000007;

ll dp[105][105][105];

int main() {
    ll n, x; cin >> n >> x;

    vll a(n); rep(i,n) cin >> a[i];
    ll ans = INF;
    for (int c = 1; c <= n; c++) {
        vvvll dp(n+1, vvll(n+2, vll(c, -INF)));
        dp[0][0][0] = 0;
        rep(i,n) {
            rep(j,n+1) {
                rep(k,c) {
                    // a[i]を使う
                    chmax(dp[i+1][j+1][(k+a[i])%c], dp[i][j][k]+a[i]);
                    // a[i]を使わない
                    chmax(dp[i+1][j][k], dp[i][j][k]);
                }
            }
        }
        // dp[n][c][x%c]
        //disp2(dp[n]);
        //cout << dp[n][c][x%c] << endl;
        if (dp[n][c][x%c] > 0) chmin(ans, (x-dp[n][c][x%c])/c);
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

#include<algorithm>
#include<iostream>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
#define neinf 0xc0c0c0c0c0c0c0c0ll
#define inf 0x3f3f3f3f3f3f3f3fll
#define uint unsigned int
#define ull unsigned ll
#define ll long long
#define reg register
#define db double
#define il inline
#define gc getchar
#define pc putchar
#define HgS 998244353
il ll rd()
{
	reg ll res=0,lab=1;
	reg char ch=gc();
	while((ch<'0'||ch>'9')&&ch!=EOF)
	{if(ch=='-')lab=-lab;ch=gc();}
	while(ch>='0'&&ch<='9')
		res=(res<<3)+(res<<1)+(ch&15),ch=gc();
	return res*lab;
}
il void prt(ll x,char t='\n')
{
	reg char ch[70];reg int tp=0;
	if(x<0)pc('-'),x=-x;
	while(x)ch[++tp]=(x%10)^48,x/=10;
	if(!tp)ch[++tp]=48;
	while(tp)pc(ch[tp--]);
	if(t)pc(t);
}
ll n,a[200005],ans,tmp;
//il ll qpow(ll n,ll e=HgS-2,ll p=HgS)
//{
//	reg ll res=1;
//	while(e)
//	{
//		if(e&1)res=res*n%p;
//		n=n*n%p;e>>=1;
//	}
//	return res;
//}
int main()
{
	n=rd();for(int i=1;i<=n;++i)a[i]=rd();
	sort(a+1,a+1+n);
	for(int i=n;i>=1;--i)
	{
		tmp=((tmp<<1)%HgS+a[i]-a[i+1]+HgS)%HgS;
		ans=(ans+a[i]*tmp)%HgS;
//		cerr<<a[i]<<' '<<tmp<<endl;
	}
	prt(ans);
	return 0;
}


#include <cstdio>
#include <algorithm>
using namespace std;
struct str{
	int t;
	char *s;
	bool operator<(const str &b)const{
		return t>b.t;
	}
};
int n;
str mon[1003];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;++i){
		mon[i].s=new char;
		scanf("%s%d",mon[i].s,&mon[i].t);
	}
	sort(mon,mon+n);
	printf("%s\n",mon[1].s);
	return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,m,n) for (int i = (m); i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; --i)
#define RREP(i,m,n) for (int i = (n)-1; i >= (m); ++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

int main() {
  int n; cin >> n;
  vector<pair<int, string>> v;
  rep(i,n) {
    int t;
    string s;
    cin >> s >> t;
    v.emplace_back(t, s);
  }

  sort(rall(v));

  cout << v[1].second << endl;
}


#include <bits/stdc++.h>
#define il inline
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN
#define MAXM
#define mod
#define inf (1ll << 30)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define repd(i, x, y) for(int i = x; i >= y; --i)
#define file(s) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
template <typename T> il bool chkmin(T &x, T y) {return x > y ? x = y, 1 : 0;}
template <typename T> il bool chkmax(T &x, T y) {return x < y ? x = y, 1 : 0;}
template <typename T> il void read(T &x) {
	char ch = getchar(); int f = 1; x = 0;
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = x*10+ch-'0', ch = getchar();
	x *= f;
}
template <typename T, typename... Args> il void read(T &x, Args &...args) {
	read(x), read(args...);
}
int n, m;
int main() {
	read(n, m);
	if(n == 1 && m == 0) return cout << 1 << ' ' << 2 << endl, 0;
	if(m < 0 || m == n || m == n - 1) return cout << -1 << endl, 0;
	int p = n - m - 2;
	rep(i, 1, p) cout << i * 2 - 1 << ' ' << i * 2 << endl;
	cout << 2 * p + 1 << ' ' << 3 * n - 1 << endl;
	rep(i, p + 2, n) cout << i * 2 << ' ' << i * 2 + 1 << endl;
	return 0;
}

#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template<typename T = int> using V = vector<T>;
template<typename T = int> using VV = vector<vector<T>>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}

int solve(int n,vector<int>L, vector<int>R){
    vector<pii>a(n);
    rep(i,n){
        a[i] = pii(L[i], R[i]);
    }
    sort(a.begin(), a.end(), [](pii x, pii y){
        return x.second < y.second;
    });
    int pre = -1;
    int ans = 0;
    for(auto x: a){
        if(pre < x.first){
            ans++;
            pre = x.second;
        }
    }
    return ans;
}
int solve2(int n, vector<int>L, vector<int>R){
    vector<pii>a(n);
    rep(i,n){
        a[i] = pii(L[i], R[i]);
    }
    sort(a.begin(), a.end(), [](pii x, pii y){
        return x.first < y.first;
    });
    int pre = -1;
    int ans = 0;
    for(auto x: a){
        if(pre < x.first){
            ans++;
            pre = x.second;
        }
    }
    return ans;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    if(m < 0){
        cout << -1 << endl;
        return 0;
    }
    vector<int>a(n), b(n);
    int t = 4;
    //[0,1], 2[3,4], 5[
    //[1,2] 3 [4,5]
    rep(i,n-1){
        a[i+1] = t++;
        b[i+1] = t++;
        t++;
    }
    a[0] = 1;
    b[0] = 3;
    rep(i,m+1)b[0] += 3;
    if(solve(n,a,b)-solve2(n,a,b)!=m){
        cout << -1 << endl;
        return 0;
    }
    rep(i,n){
        cout << a[i] << " " << b[i] << "\n";
    }
}


#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int M=2e5+10,mod=1e9+7;
LL f[M][2],g[M];
LL a[M];
int n;
int main(){
	n=read();
	F(i,1,n){
		a[i]=read();
	}
	f[0][0]=1; g[0]=1;
	F(i,1,n){
		f[i][0]=(f[i-1][1]+f[i-1][0])%mod;
		f[i][1]=f[i-1][0];
		g[i]=(f[i][1]+f[i][0])%mod;
	}
	LL tot=g[n-1];
	LL ans=g[n-1]*a[1]%mod;
//	cout<<tot<<"   tt\n";
	F(i,2,n){
		LL tmp=f[i-1][1]*(n-i-1<=0 ? 1 : g[n-i-1])%mod;
//		cout<<tmp<<"\n";
		ans=(ans+(tot-2ll*tmp%mod+mod)*a[i])%mod;
	}
	cout<<ans<<"\n";
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/

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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 1; i < n; ++i) {
        int p;
        cin >> p;
        p--;
        g[p].push_back(i);
    }

    vector<int> f(n), sz(n);
    auto dfs = [&](auto self, int u) -> void {
        int stock = 0;
        vector<int> fs;
        for (int v : g[u]) {
            self(self, v);
            sz[u] += sz[v];
            if (sz[v] % 2 == 0) {
                if (f[v] < 0) {
                    f[u] += f[v];
                } else {
                    stock += f[v];
                }
            } else {
                fs.push_back(f[v]);
            }
        }
        sort(fs.begin(), fs.end());
        for (size_t i = 0; i < fs.size(); ++i) {
            f[u] += (i % 2 == 0 ? fs[i] : -fs[i]);
        }
        f[u] += (fs.size() % 2 == 0 ? stock : -stock);
        f[u]++;
        sz[u]++;
    };

    dfs(dfs, 0);

    int ans = (n + f[0]) / 2;
    cout << ans << '\n';
}


#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define forn(i,x1,n)     for(int i=x1; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x1)      __builtin_popcountll(x1)
#define zrobits(x1)      __builtin_ctzll(x1)
#define mod             1000000007
// #define mod             998244353
#define inf             1e18
#define ps(x1,y)         fixed<<setprecision(y)<<x1
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x1)            int x1; cin>>x1; while(x1--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void zeus()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {

	zeus();

	int a;
	double b;

	cin >> a >> b;

	cout << a*(b / 100) << endl;

}

#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    vector<vector<string>> ans(9);
    ans[1] = {"AB"};
    for (int i = 2; i <= 8; ++i) {
        for (auto op : ans[i-1]) {
            ans[i].emplace_back(op+op);
            string nop = op;
            for (char &c : nop) c ^= 'A' ^ 'B';
            ans[i].emplace_back(op+nop);
        }
        ans[i].emplace_back(string(1 << i-1, 'A') + string(1 << i-1, 'B'));
    }
    int N; cin >> N;
    cout << int(ans[N].size()) << '\n';
    for (auto op : ans[N]) {
        cout << op << '\n';
    }
    return 0;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <math.h>
#include <random>
#include <chrono>
#include <assert.h>
#include <climits>

using namespace std;
#define int long long

signed main() {
  int n,k;
  cin >> n >> k;
  vector<vector<int>> a(n,vector<int>(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  int l = -1, r = 1e9+10;
  while(r - l > 1) {
    // 中央値がmidになると仮定
    int mid = (r + l) / 2;
    // 2次元累積和
    vector<vector<int>> sum(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (a[i][j] <= mid) sum[i][j] = 1;
        else sum[i][j] = 0;
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 1; j < n; j++) {
        sum[i][j] += sum[i][j-1];
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 1; j < n; j++) {
        sum[j][i] += sum[j-1][i];
      }
    }

    bool ok = false;
    for (int i = 0; i + k - 1 < n; i++) {
      for (int j = 0; j + k - 1 < n; j++) {
        int cnt = sum[i+k-1][j+k-1];
        if (i > 0) cnt -= sum[i-1][j+k-1];
        if (j > 0) cnt -= sum[i+k-1][j-1];
        if (i > 0 && j > 0) cnt += sum[i-1][j-1];
        int tot = k*k;

        if (cnt >= tot/2 + (tot%2)) ok = true;
      }
    }
    if (ok) {
      r = mid;
    } else {
      l = mid;
    }
  }
  cout << r << '\n';
}

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string(string(s)); }
string to_string(bool b) { return to_string(int(b)); }
string to_string(vector<bool>::reference b) { return to_string(int(b)); }
string to_string(char b) { return "'" + string(1, b) + "'"; }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) {
	string res = "{";
	for (const auto& x : v) res += (res == "{" ? "" : ", ") + to_string(x);
	return res + "}";
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug(T...);
}
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define db(...) 42
#endif
typedef long long ll;
typedef long double ld;
int main() {
	int n, K;
	scanf("%d%d", &n, &K);
	vector<vector<int>> E(n);
	for (int i = 1; i < n; ++i) {
		int u, v;
		scanf("%d%d", &u, &v);
		--u;
		--v;
		E[u].push_back(v);
		E[v].push_back(u);
	}
	vector<int> depth(n, -1), par(n, -1);
	depth[0] = 0;
	function<void(int)> dfs = [&](int x) {
		for (int y : E[x]) {
			if (depth[y] != -1) continue;
			depth[y] = depth[x] + 1;
			par[y] = x;
			dfs(y);
		}
	};
	dfs(0);
	vector<int> vs(n);
	iota(vs.begin(), vs.end(), 0);
	sort(vs.begin(), vs.end(), [&](int x, int y) {
		return depth[x] > depth[y];
	});
	auto check = [&](int d) {
		vector<int> used(n, -1);
		function<void(int, int, int)> flood = [&](int x, int cur, int p) {
			if (used[x] >= cur) return;
			used[x] = cur;
			if (!cur) return;
			for (int y : E[x]) {
				if (y == p) continue;
				flood(y, cur - 1, x);
			}
		};
		int need = 0;
		for (int v : vs) {
			if (used[v] != -1) continue;
			++need;
			if (need > K) return false;
			int x = v;
			for (int i = 0; i < d; ++i) {
				if (par[x] == -1) break;
				x = par[x];
			}
			flood(x, d, -1);
			assert(used[v] != -1);
		}
		return true;
	};
	int lo = 1, hi = n - 1;
	while (lo < hi) {
		int d = (lo + hi) >> 1;
		if (check(d)) hi = d;
		else lo = d + 1;
	}
	printf("%d\n", lo);
}


#include <bits/stdc++.h>

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;

template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll N, W; cin >> N >> W;
    vl imos(2*100010, 0);
    REP(i, N)
    {
        ll s, t, p; cin >> s >> t >> p;
        imos[s] += p;
        imos[t] -= p;
    }
    REP(i, 2*100010-1) imos[i+1] += imos[i];
    REP(i, 2*100010)
    {
        if(imos[i] > W)
        {
            No;
            return 0;
        }
    }
    Yes;
}

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ve vector<ll>
#define ve_pa vector<pair<ll,ll> >
#define pb push_back
#define mod 1000000007
#define INF 1e18+7
#define ld long double
#define pll pair<ll,ll>
#define fi first
#define se second
#define mll map<ll,ll>
#define m_ve map<ll,ve>
#define min3(x,y,z) min(x,min(y,z))
#define max3(x,y,z) max(x,max(y,z))
#define W(x) while(x--)
#define ld long double
#define all(x) x.begin(),x.end()
#define popcount(x) __builtin_popcountll(x)
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
class compare
{
public:
    bool operator() (pll p1,pll p2)
    {
        if(p1.fi>p2.fi)
        return 1;
        else
        return 0;
    }
};

int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n,w;cin>>n>>w;
vector<pair<pll,ll> >pos;
for(int i=0;i<n;i++)
{
	ll s,t,p;
	cin>>s>>t>>p;
	pos.pb({{s,t},p});
}
sort(all(pos));
priority_queue<pll,vector<pll>,compare >q;
for(int i=0;i<n;i++)
{
	while(q.size()&&q.top().fi<=pos[i].fi.fi)
	{
		w+=q.top().se;
		q.pop();
	}
	w-=pos[i].se;
	q.push({pos[i].fi.se,pos[i].se});
	if(w<0)
	{
		cout<<"No";
		return 0;
	}
}
cout<<"Yes";

}


//Hare Krishna
//author: Dipjoy Basak
//dip_10

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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

#define endl "\n"
#define ll long long
#define int ll
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int, int>
#define vpi vector<pair<int, int>>
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define ppc __builtin_popcountll
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define rrep(i, r, l) for (int i = r; i >= l; i--)
#define readarray(a, n) rep(i, 0, n - 1) cin >> a[i];
#define all(v) v.begin(), v.end()
#ifndef ONLINE_JUDGE
#define debug(x)       \
    cerr << #x << " "; \
    _print(x);         \
    cerr << endl;
#else
#define debug(x) ;
#endif
#define INF 1e18

// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

//*----------------------------------------DEBUG functions--------------------------*

void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(ld t) { cerr << t; }
void _print(double t) { cerr << t; }

template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p)
{
    cerr << "{";
    _print(p.ff);
    cerr << ",";
    _print(p.ss);
    cerr << "}";
}
template <class T>
void _print(vector<T> v)
{
    cerr << "[ ";
    for (T i : v)
    {
        _print(i);
        cerr << " ";
    }
    cerr << "]";
}
template <class T>
void _print(set<T> v)
{
    cerr << "[ ";
    for (T i : v)
    {
        _print(i);
        cerr << " ";
    }
    cerr << "]";
}
template <class T>
void _print(multiset<T> v)
{
    cerr << "[ ";
    for (T i : v)
    {
        _print(i);
        cerr << " ";
    }
    cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v)
{
    cerr << "[ ";
    for (auto i : v)
    {
        _print(i);
        cerr << " ";
    }
    cerr << "]";
}

//-----------------------------------------------------------------------------------------------------------------------------

const int mod = 1000000007;
const long double PI = 3.141592653589793;
const int maxn = 100005;
int x, y, z, n, k;

void solve()
{
    string s;
    cin >> s;
    string ans = "";
    int n = (int)s.size();
    rep(i, 0, n - 1)
    {
        if (s[i] == '.')
            break;
        ans += s[i];
    }
    cout << ans << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout << setprecision(15) << fixed;
    int t;
    t = 1;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

/*     Hare Krishna............Har Har Mahadev    */
//cin.ignore();getline(cin,s,'\n');
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define lab(i,a,b) for(i=a;i<=b;i++)
#define bal(i,a,b) for(i=b;i>=a;i--)
#define ff first
#define ss second
#define pb push_back
#define se(v) v.begin(), v.end()
#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tc ll t;cin>>t;while(t--)
#define fceil(a,b) ceil((ld)a/(ld)b)
#define dis(v) for(auto it:v)cout<<it<<" "
#define yep cout<<"YES\n"
#define nope cout<<"NO\n"
//bool isPrime(ll n){if(n <= 1)return false;if(n <= 3)return true;if(n%2==0||n%3==0)return false;for(ll i=5;i*i<= n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
//bool cmp(pll &a, pll &b){ if(a.ss == b.ss)return a.ff < b.ff;return a.ss < b.ss;}
const ll MOD = 1e9 + 7;
/*ll vis[2005];
vll adj[2005];
void  dfs(ll node )
{
	  vis[node]=1;
	  for(int child:adj[node])
	  {
	  	if(!vis[child])dfs(child);
	  }
}*/
//ll powerLL(ll x, ll n){ll result = 1;while (n){if (n & 1)result = result * x % MOD;n = n / 2;x = x * x % MOD;}return result;}
int main()
{
    fst
    ll n,m,i,j,k,f,x,y,z,ans;
    //tc
    {
      m=0,i=0,j=0,f=0,x=0,y=0,z=0,ans=0;
      cin>>n;
      ll an=1.08*n;
      if(an<206.0)cout<<"Yay!";
      else if(an==206.0)cout<<"so-so";
      else cout<<":(";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int fastio() { ios_base::sync_with_stdio(false); cout << fixed << setprecision(10); cin.tie(nullptr); return 0; }
int __fastio = fastio();

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
typedef long long ll;
typedef pair<ll, ll> ii;
#define fi first
#define se second
#define sz(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

int main(){
    int n;
    cin >> n;
    cout << (n-1);
}

#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
using namespace std;
const int mod = 998244353, N = 100;

ll n, fib[N];
vector<int> ans;

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

int main() {
	cin >> n;
	fib[0] = fib[1] = 1;
	for (R int i = 2; i <= 90; ++i)
		fib[i] = fib[i - 1] + fib[i - 2];
	for (R int i = 43; i; --i) {
		if (n >= fib[2 * i]) {
			n -= fib[2 * i];
			ans.push_back(1);
		}
		ans.push_back(4);
		if (n >= fib[2 * i - 1]) {
			n -= fib[2 * i - 1];
			ans.push_back(2);
		}
		ans.push_back(3);
	}
	cout << ans.size() << endl;
	for (auto &v : ans) cout << v << endl;
	return 0;
}


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

#define maxn 200005
typedef pair<long long,int> II;
II a[maxn];

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

   for(int i=1;i<=n;++i)
      scanf("%lld %d",&a[i].first,&a[i].second);

   sort(a+1,a+n+1);

  long long local=k;
   int i=1;
   while(i<=n && local>=a[i].first){
       local+=1ll*a[i].second;
       ++i;
   }
  printf("%lld",local);
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<n; i++)

string f(string n){
	vector<int> s;
	for(int i=0; i<n.size(); i++){
		s.push_back(n[i] - '0');
	}

	sort(s.begin(), s.end());

	int g1=0, g2=0;

	for(int i=0; i<n.size(); i++){
		g1 += (pow(10, n.size() - i - 1))*s[n.size()-i-1];
		g2 += (pow(10, n.size() - i - 1))*s[i];
	}

	string F = to_string(g1 - g2);
	return F;
};

int main(){
	string N;
	int K;
	cin >> N >> K;

	rep(i, K){
		N = f(N);
	}

	cout << N << endl;
}


#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;

	int n;
	string s, t;
	cin >> n >> s >> t;
	int bal = 0;
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		if(t[i] == '1') bal++, ans -= i;
		if(s[i] == '1') {
			if(bal > 0) bal--, ans += i;
			else bal++, ans -= i;
		}
	}
	if(bal) cout << -1 << endl;
	else cout << ans << endl;

}

#line 2 "/home/defineprogram/Desktop/Library/template/template.cpp"
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<ll,ll>
#define len(s) (ll)s.size()

template<class T,class U> inline bool chmin(T &a, U b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T,class U> inline bool chmax(T &a, U b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr ll inf = 3e18;
#line 3 "/home/defineprogram/Desktop/Library/structure/UnionFind.cpp"

class UnionFind{
	int N;
	vector<int>par,siz;
public:
	int find(int x){
		assert(x<N);
		return (par[x]==x?x:par[x]=find(par[x]));
	}
	void merge(int x,int y){
		assert(x<N&&y<N);
		x=find(x);y=find(y);
		if(x==y)return;
		if(siz[x]>siz[y])swap(x,y);
		par[x]=y;siz[y]+=siz[x];
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	int size(int x){
		return siz[find(x)];
	}
	UnionFind(int N):N(N),siz(N,1),par(N){
		iota(all(par),0);
	}
};

/*
@brief Union Find
@docs docs/UnionFind.md
*/
#line 3 "main.cpp"

int N;
string S,T;
vector<int>zero,one;
bool t[500005];
int main(){
    cin>>N>>S>>T;
    int now=0,now2=0;
    rep(i,N){
        now^=S[i]-'0';
        now2^=T[i]-'0';t[i]=now2;
        if(!now)zero.push_back(i);
        else one.push_back(i);
    }
    ll ans=0;int cur=0;
    int idx0=0,idx1=0;
    bool flag0=false,flag1=false;
    rep(i,N){
        chmax(cur,i);
        while(idx0<len(zero)&&zero[idx0]<cur){idx0++;flag0=false;}
        while(idx1<len(one)&&one[idx1]<cur){idx1++;flag1=false;}
        if(!t[i]){
            if(idx0==len(zero)){cout<<"-1\n";return 0;}
            if(!flag0)ans+=zero[idx0]-i;
            flag0=true;
            chmax(cur,zero[idx0]);
        }else {
            if(idx1==len(one)){cout<<"-1\n";return 0;}
            if(!flag1)ans+=one[idx1]-i;
            flag1=true;
            chmax(cur,one[idx1]);
        }
    }
    cout<<ans<<endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int li;
const ll MAXN=4.5e6+51,MOD=1e9+7;
ll n,m,sm,res;
ll invf[MAXN];
inline ll read()
{
	register ll num=0,neg=1;
	register char ch=getchar();
	while(!isdigit(ch)&&ch!='-')
	{
		ch=getchar();
	}
	if(ch=='-')
	{
		neg=-1;
		ch=getchar();
	}
	while(isdigit(ch))
	{
		num=(num<<3)+(num<<1)+(ch-'0');
		ch=getchar();
	}
	return num*neg;
}
int main()
{
	n=read(),m=read(),res=m+n,invf[1]=1;
	for(register int i=1;i<=n;i++)
	{
		sm+=read();
	}
	if(m<sm)
	{
		return puts("0"),0;
	}
	for(register int i=2,j=m+n-1;i<=n+sm;i++,j--)
	{
		invf[i]=MOD-(li)(MOD/i)*invf[MOD%i]%MOD;
		res=(li)res*j%MOD*invf[i]%MOD;
	}
	printf("%d\n",res);
}

#include <cstdio>
#include <algorithm>
#define ll long long
using namespace std;
const ll MOD=1e9+7;
ll Inv[4002005];
ll C(ll r,ll n)
{
	if(r>n) return 0;
	ll ret=1;
	for(int i=1;i<=r;i++) ret=ret*(n-i+1)%MOD*Inv[i]%MOD;
	return ret;
}
int main() {
	ll n,m,Sum1;
	Inv[0]=Inv[1]=1;
	for(int i=2;i<=4002000;i++) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	scanf("%lld %lld",&n,&m);Sum1=n;
	for(int i=1,x;i<=n;i++) scanf("%d",&x),Sum1+=x;
	printf("%lld",C(Sum1,m+n));
	return 0;
}


//Littleboy123 Template 1.8
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

//pragmas
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")t
#pragma GCC optimization ("unroll-loops")
*/

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef unsigned long long int ull;
typedef long double ld;
typedef unsigned long long ull;

const long double pi = acos(-1.0);

#define FOR(a,b,c) for(int (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(int (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(int (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(int (a)=(b);(a)>=(c);--(a))
#define TC(n) cout << "Case #" << (n) << ": "
#define DEBUG(x) cout << "DEBUG " << #x << ' ' << x << '\n';
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>

void init(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void infile(){
    freopen("geometry.in", "r", stdin);
}

void outfile(){
    freopen("output.txt", "w", stdout);
}

ll rp(ll a, ll b, ll mod){
    ll res = 0;
    while(b > 0){
        if(b & 1)
            res = (res + a) % mod;
        res %= mod;
        a = (a << 1)%mod;
        b = b >> 1;
    }
    return res;
}

ll modex(ll a, ll b, ll mod){
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    ll tmp = modex(a, b/2LL, mod);
    tmp = rp(tmp, tmp, mod);
    if(b & 1LL)
        tmp = rp(tmp, a, mod);
    return tmp;
}

ll ex(ll a, ll b){
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    ll tmp = ex(a, b/2LL);
    tmp = (tmp * tmp);
    if(b & 1LL)
        tmp = (tmp * a);
    return tmp;
}

//End of template

int main(){
    init();
    // infile();

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min({a, b, c, d}) << endl;
    return 0;
}

//#pragma GCC optimize(2)
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<map>
#include<cmath>
#include<cctype>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<sstream>
#include<ctime>
#include<cstdlib>
#define X first
#define Y second
#define L (u<<1)
#define R (u<<1|1)
#define pb push_back
#define mk make_pair
#define Mid (tr[u].l+tr[u].r>>1)
#define Len(u) (tr[u].r-tr[u].l+1)
#define random(a,b) ((a)+rand()%((b)-(a)+1))
#define db puts("---")
using namespace std;

//void rd_cre() { freopen("d://dp//data.txt","w",stdout); srand(time(NULL)); }
//void rd_ac() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//AC.txt","w",stdout); }
//void rd_wa() { freopen("d://dp//data.txt","r",stdin); freopen("d://dp//WA.txt","w",stdout); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;

const int N=1000010,mod=1e9+7,INF=0x3f3f3f3f;
const double eps=1e-6;

int n,ans=INF;

int main()
{
//	ios::sync_with_stdio(false);
//	cin.tie(0);

    n=4;
    while(n--)
    {
        int x; scanf("%d",&x);
        ans=min(ans,x);
    }
    printf("%d\n",ans);

	return 0;
}
/*

*/


//#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define re register int
#define ll long long
#define I inline int
#define V inline void
#define LL inline ll
#define FOR(i,a,b) for(re i=(a),i##i=(b);i<=i##i;++i)
#define ROF(i,a,b) for(re i=(a),i##i=(b);i>=i##i;--i)
//#define gc (_ft==_fs&&(_ft=(_fs=buf)+fread(buf,1,1<<20,stdin),_ft==_fs))?0:*_fs++
#define gc getchar()
using namespace std;
const int N=1e5+10,S=1200,mo=1e9+7;
char buf[1<<20],*_fs,*_ft;
LL read(){
	ll w=0,p=0; char ch=gc;
	while(!isdigit(ch)) w=ch=='-',ch=gc;
	while(isdigit(ch))  p=p*10+ch-'0',ch=gc;
	return w?-p:p;
}
char a[N];
int n,ans;
V ipt(){ n=read(); scanf("%s",a+1); }
V sol(){
	ans=-1;
	if(a[1]!=a[n]) return ans=1,void();
	FOR(i,2,n-1) if(a[i]!=a[1]&&a[i+1]!=a[n]) return ans=2,void();
	return ;
}
V opt(){ cout<<ans; }
int main(){
	ipt();
	sol();
	opt();
	return 0;
}

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repl(i,l,r) for(int i=l;i<r;i++)
#define rrepl(i,l,r) for(int i=r-1;i>=l;i--)
const int inf=1e9+10;
const ll INF=2e18+10;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

const ll MOD=1e9+7;

int main(){
    ll n;cin>>n;
    ll l,r;
    l=0,r=INF;
    ll ans;
    while(l+1<r){
        ll mid=(l+r)/2;
        if((n+1)*2/mid+1<mid-1){
            r=mid;
            continue;
        }
        ll sum=mid*(mid+1)/2;
        //cout<<mid<<" "<<sum<<endl;
        if(sum>n+1)r=mid;
        else l=mid;
    }
    ans=n-l+1;
    //if(ans==1)ans=1;
    //if(ans==2)ans=1;

    cout<<ans<<endl;

    return 0;
}


#include <iostream>

using namespace std;

int a, b, c;
int main(){
    cin >> a >> b >> c;

    if ( a+c <= b){
        cout << "Aoki" << endl;
    }else{
        cout << "Takahashi" << endl;
    }

    return 0;
}

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

int main() {
    char a, b, c;
    cin>> a >> b >> c;
    if (a == b && b == c) printf("Won");
    else printf("Lost");
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
const unsigned int mod = 1000000007;
using namespace std;

int main() {
    int x; cin>>x;
    if(x>=0)
        cout<<x<<endl;
    else cout<<0<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long int64;

int64 pow10(int n)
{
    int64 ret=1;
    for(int i=0;i<n;i++)ret*=10;
    return ret;
}

int main()
{
    int64 n;
    int64 ans=0;
    cin >> n;
    int64 a=0;
    for(int i=1;i<=5;i++)
    {
        if(n<pow10(i*3))
        {
            ans+=(i-1)*(n-pow10((i-1)*3)+1);
            break;
        }
        else ans+=(i-1)*(pow10(i*3)-pow10((i-1)*3));
        //cout << i << " " << ans << endl;
    }
    if(n==1e+15)ans+=5;
    cout << ans;
}


#include <bits/stdc++.h>
using namespace std;
/*
 *  JUST KEEP GOING
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define allr(v)			((v).rbegin()), ((v).rend())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define For(i,s)        for(auto i:s)
#define Forr(i,s)        for(auto &i:s)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define int ll
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <int,int>
#define vii				vector <ii>
#define vll				vector <pair<ll,ll>>
#define PI acos(-1)
#define bit(mask,i) ((mask>>i)&1)
void run() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 3e6+5,mod=1e9+7,mod2=998244353,MAXN=1e6+29;
void files(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
struct Point{
    int x,y;
};

signed main() {
    run();
    files();
    int n;
    cin >> n;
    vector<Point> v(n);
    Forr(i, v)cin >> i.x >> i.y;
    int m;
    cin >> m;
    vector<vi > sum(m + 2, vi(2)); // [0] sumX, [1] sumY
    vector<short> isSwapped(m+1);
    vector<vector<short>> sign(m + 2, vector<short>(2));
    sign[0][0] = sign[0][1] = 1;
    int sumY = 0, sumX = 0;
    for (int i = 1; i <= m; ++i) {
        int Type;
        cin >> Type;
        isSwapped[i] = isSwapped[i - 1];
        sum[i][0] = sum[i - 1][0];
        sum[i][1] = sum[i - 1][1];
        sign[i][0] = sign[i - 1][0];
        sign[i][1] = sign[i - 1][1];
        if (Type == 1) {
            isSwapped[i] ^= 1;
            sum[i][!isSwapped[i]] *= -1;
            sign[i][!isSwapped[i]] *= -1;
        } else if (Type == 2) {
            isSwapped[i] ^= 1;
            sum[i][isSwapped[i]] *= -1;
            sign[i][isSwapped[i]] *= -1;
        } else if (Type == 3) {
            int p;
            cin >> p;
            sign[i][isSwapped[i]] *= -1;
            sum[i][isSwapped[i]] = 2 * p - sum[i][isSwapped[i]];
        } else {
            int p;
            cin >> p;
            sign[i][!isSwapped[i]] *= -1;
            sum[i][!isSwapped[i]] = 2 * p - sum[i][!isSwapped[i]];
        }
    }
    int q;
    cin >> q;
    while(q--) {
        int a, b;
        cin >> a >> b;
        b--;
        auto ans = v[b];
        if (isSwapped[a]) {
            swap(ans.x, ans.y);
        }
        ans.x *= sign[a][isSwapped[a]];
        ans.y *= sign[a][!isSwapped[a]];

        ans.x += sum[a][isSwapped[a]];
        ans.y += sum[a][!isSwapped[a]];

        cout << ans.x << ' ' << ans.y << endl;
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n;
vector<pair<int,int>>A,B;
map<tuple<int,int,int>,int>s,t;
int main()
{
	scanf("%d",&n);
	A.resize(n),B.resize(n);
	for(int i=0;i<n;i++)
		scanf("%d%d",&A[i].first,&A[i].second);
	for(int i=0;i<n;i++)
		scanf("%d%d",&B[i].first,&B[i].second);
	auto add=[](auto &s,auto a1,auto a2,auto a3)
	{
		int x1=a2.first-a1.first,y1=a2.second-a1.second;
		int x2=a3.first-a1.first,y2=a3.second-a1.second;
		int cr=x1*y2-y1*x2;
		int r1=x1*x1+y1*y1,r2=x2*x2+y2*y2;
		s[{cr,r1,r2}]++;
	};
	for(auto a:A)
		for(auto b:A)
			for(auto c:A)
				add(s,a,b,c);
	for(auto a:B)
		for(auto b:B)
			for(auto c:B)
				add(t,a,b,c);
	puts(s==t?"Yes":"No");
	return 0;
}


#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int n;
int a[100100];

int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	rep(i, n)
		cin >> a[i];
	sort(a, a + n);
	double val = 0;
	rep(i, n)
		val += (double)a[i] - 0.5 * a[0];
	double ans = val;
	for(int i = 1; i < n; i++){
		val += (double)(a[i] - a[i - 1]) * i * 0.5;
		val -= (double)(a[i] - a[i - 1]) * (n - i) * 0.5;
		ans = min(ans, val);
	}
	cout << fixed << setprecision(12) << ans / n << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
    int a, b, c, minimum = 100;
    cin >> a;
    minimum = min(a, minimum);
    cin >> b;
    minimum = min(b, minimum);
    cin >> c;
    minimum = min(c, minimum);
    cout << a + b + c - minimum;
    return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}

#define trace(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int>
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size()
#define PI 3.14159265358979323846

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set;

 const int N=1e5+10;

 const int INF=1e18;

 int mod= 998244353;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};

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

int n;

void solve() {
  cin>>n;
  vector<pi> vp;

  rep(i,0,n) {
			  int x,y;
			  cin>>x>>y;
			  vp.pb({x,y});
			}

		int ct=0;
		sort(all(vp));

		rep(i,0,n) {
			  rep(j,i+1,n) {
						  int x1=vp[i].fe,y1=vp[i].se;
						  int x2=vp[j].fe,y2=vp[j].se;
						   int dx=x2-x1,dy=y2-y1;
						   if(dx!=0) {
										   double ans=(double)dy/dx;
										   if(ans>=-1 && ans<=1) ct++;
										}
						}
			}

			cout<<ct<<endl;

}

int32_t main() {
	cool;
	int t=1;
	//~ freopen("input.txt","r",stdin);
 //~ freopen("output.txt","w",stdout);

 //cin>>t;
	while(t--)
	  solve();

  return 0;
}

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

int main() {
    int n;
    cin>>n;
    int count=0;
    vector<pair<int, int>> points;
    for (int i=0; i<n; i++){
        int a, b;
        cin>>a>>b;
        points.push_back({a, b});
    }
    bool used[1005][1005];
    for (int i=0; i<1005; i++) for (int j=0; j<1005; j++) used[i][j]=false;
    for (int i=0; i<n; i++){
        for (int j=0; j<n; j++){
            if (j!=i){
                double slope = ((double)(points[j].second-points[i].second)/(double)(points[j].first-points[i].first));
                if (slope>=-1 && slope<=1 && used[i][j]==false && used[j][i]==false){
                    count++;
                    used[i][j]=true;
                    used[j][i]=true;
                }
            }
        }
    }
    cout<<count<<endl;
	return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

struct chash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

template<typename T> using pb_set = gp_hash_table<T, null_type, chash>;
template<typename T, typename U> using pb_map = gp_hash_table<T, U, chash>;
pb_map<int, int> g;

void go(int x, int y) {
    if (g.find(x) == g.end()) {
        g[x] = y;
    }
    g[x] = __gcd(g[x], y);
}

void solve() {

    int N; cin >> N;
    int A[N]; F0R(i, N) cin >> A[i];
    int lo = 2e9;
    F0R(i, N) {
        FOR(j, 1, 40000) {
            if (j * j > A[i]) break;
            if (A[i] % j == 0) {
                go(j, A[i]);
                go(A[i]/j, A[i]);
            }
        }
        ckmin(lo, A[i]);
    }

    int ans = 0;
    trav(a, g) {
        if (a.f == a.s && a.f <= lo) {
            ans++;
        }
    }
    cout << ans << nl;

}

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

    int T = 1;
//    cin >> T;
    while(T--) {
        solve();
    }

	return 0;
}

// read the question correctly (ll vs int)
// template by bqi343

#define _CRT_SECURE_NO_WARNINGS
#define FAST ios::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define FOR(i,a,b) for (int i=a;i<b;i++)
#define ROF(i,a,b) for (int i=b-1;i>=a;i--)
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) (v).begine(), (v).end()
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 100005;
const int mod = (int)1e9 + 7;

void mul(int& a, int b) {
	a = (ll)a * b % mod;
}

int pow(int a, int b) {
	if (b == 0)
		return 1;
	if (b % 2)
		return (ll)a * pow(a, b - 1)%mod;
	int ret = pow(a, b / 2);
	return (ll)ret * ret % mod;
}

int rev(int a) {
	return pow(a, mod - 2);
}

int main() {
	FAST;
	int n, m, tmp;
	cin >> n >> m;
	int sum = 0;
	FOR(i, 0, n) {
		cin >> tmp;
		sum += tmp;
	}
	int p = 1, q = 1;
	FOR(i, 1, sum + n + 1) {
		mul(p, m + n + 1 - i);
		mul(q, i);
	}
	q = rev(q);
	mul(p, q);
	cout << p;
}


#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_E"

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

//BEGIN CUT HERE
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//END CUT HERE

using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pii = pair<int, int>;
using pld = pair<ll, ld>;
using ppiii =  pair<pii, int>;
using ppiill = pair<pii, ll>;
using ppllll = pair<pll, ll>;
using pplii = pair<pli, int>;
using mii = map<int, int>;
using dll = deque<ll>;
using qll = queue<ll>;
using pqll = priority_queue<ll>;
using pqrll = priority_queue<ll, vector<ll>, greater<ll>>;
using vint = vector<int>;
using vll = vector<ll>;
using vpll = vector<pll>;
using vvll = vector<vector<ll>>;
using vvint = vector<vector<int>>;
using vvpll = vector<vector<pll>>;

//マクロ
//forループ
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) x.begin(),x.end()
#define rALL(x) x.rbegin(),x.rend()
#define SIZE(x) ll(x.size())
#define fs first
#define sc second
#define INF32 2147483647 //2.147483647x10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807x10^{18}:64bit整数のinf
//定数

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

  ll N,M;
  cin>>N>>M;

  vll A(N),B(M);
  REP(i,N) cin >> A[i];
  REP(i,M) cin >> B[i];

    vvll dp(N+1,vll(M+1,INF32));
    dp[0][0] = 0;

    REP(i,N+1){
        REP(j,M+1){
            if(i>0&&j>0){
                if(A[i-1]==B[j-1])chmin(dp[i][j],dp[i-1][j-1]);
                else chmin(dp[i][j],dp[i-1][j-1]+1);
            }
            if(i>0)chmin(dp[i][j],dp[i-1][j]+1);
            if(j>0)chmin(dp[i][j],dp[i][j-1]+1);
        }
    }

    cout << dp[N][M] << endl;

  return 0;
}

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

#define endl '\n'

const int N = 3e5 + 5;

int n, m;
int a[N];
int b[N];
int dp[1001][1001];

int memo(int i, int j) {
	if(i == -1 && j == -1) return 0;
	if(i == -1) return j+1;
	if(j == -1) return i+1;
	if(dp[i][j] != -1) return dp[i][j];
	int res = min(memo(i-1, j), memo(i, j-1)) + 1;
	if(a[i] == b[j]) res = min(res, memo(i-1, j-1));
	else res = min(res, memo(i-1, j-1) + 1);
	return dp[i][j] = res;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> n >> m;
	for(int i=0; i<n; i++) cin >> a[i];
	for(int i=0; i<m; i++) cin >> b[i];
	memset(dp, -1, sizeof dp);
	cout << memo(n-1, m-1) << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,x,n) for(i=x;i<=n;i++)
#define all(v) v.begin(),v.end()
#define p_b push_back
#define fr first
#define sc second
#define m_p make_pair
#define zero(a) memset(a,0,sizeof(a))
#define setp setprecision
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f;
const ll mod=1000000007;
const ld eps=1e-14;
ll i,j;

ll n;
set<ll> st;

int check(int x){
	int ret=0;
	for(int j=2;j<=33;j++){
		ll num=pow(i,j);
		if(num>n) break;
		//cout<<num<<' ';
		if(num<=n&&st.find(num)==st.end()&&num>0){
			ret++;
			st.insert(num);
		}
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	cin>>n;
	ll ans=n;
	for(i=2;i*i<=n;i++){
		ans-=check(i);
	}
	//ans=n-ans;
	cout<<ans<<endl;
	return 0;
}

#include <cmath>
#include <iostream>
#include <unordered_set>
using namespace std;

int main()
{
  using ll = long long;
  ll N;
  cin >> N;
  const ll r = sqrt(N);
  unordered_set<ll> n;
  for (ll i = 2; i <= r; ++i)
  {
    ll ab = i*i;
    for (; ab <= N; ab *= i)
      n.insert(ab);
  }
  cout << N - n.size() << endl;
  return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1<<30;
const ll inf_l = 1LL<<61;
const int MAX = 1e5;

// union-find
struct union_find {
    vector<int> dat;

    union_find(int size) {dat.resize(size,-1);}

    int find(int x) {
        if (dat[x] < 0) {return x;}
        return dat[x] = find(dat[x]);
    }

    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) {return false;}
        if (dat[x] > dat[y]) swap(x,y);
        dat[x] += dat[y];
        dat[y] = x;
        return true;
    }

    int size(int x) {return -dat[find(x)];}
};

int main() {
    int n, q; cin >> n >> q;
    vector<unordered_map<int,int>> ct(n);
    rep(i,n) {
        int c; cin >> c;
        ct[i][c]++;
    }
    union_find uf(n);
    rep(i,q) {
        int query, a, b; cin >> query >> a >> b;
        if (query == 1) {
            a--; b--;
            a = uf.find(a);
            b = uf.find(b);
            if (uf.unite(a, b)) {
                int r = uf.find(a);
                for (P p : ct[a + b - r]) {
                    ct[r][p.first] += p.second;
                }
            }
        } else {
            a--;
            cout << ct[uf.find(a)][b] << endl;
        }
    }
}

#include<bits/stdc++.h>
using namespace std;
const int N=200000;
int c[N];
int Root[N],Rank[N],Size[N];
map<int,int>m[N];
int find(int x){
    if(Root[x]==x)return x;
    else return Root[x]=find(Root[x]);
}
void unite(int x,int y){
    int X=find(x);
    int Y=find(y);
    if(X==Y)return;
    if(Rank[X]<Rank[Y]){
        Root[X]=Y;
        for(pair<int,int>p:m[X])m[Y][p.first]+=p.second;
        m[X].clear();
    }
    else{
        Root[Y]=X;
        for(pair<int,int>p:m[Y])m[X][p.first]+=p.second;
        m[Y].clear();
        if(Rank[X]==Rank[Y])Rank[X]++;
    }
    return;
}
int main(){
    int n,q;
    cin>>n>>q;
    for(int i=0;i<n;i++){
        cin>>c[i];
        c[i]--;
        Root[i]=i;
        Rank[i]=0;
        m[i][c[i]]++;
    }
    vector<int>ans;
    for(int i=0;i<q;i++){
        int t,x,y;
        cin>>t>>x>>y;
        x--,y--;
        if(t==1)unite(x,y);
        if(t==2)ans.push_back(m[find(x)][y]);
    }
    for(int i:ans)cout<<i<<endl;
}


#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define INF 0x3f3f3f3f
#define f first
#define s second
#define FOR(i, n) for(int i = 1; i <= n; i ++)
#define FFOR(i, a, b) for(int i = a; i <= b; i ++)
#define pii pair<int, int>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define mem(x, a) memset(x, a, sizeof(x))
#define loli ios_base::sync_with_stdio(0), cin.tie(0)
using namespace std;
const int maxn = 1e6 + 50;
int n;

bool check(int x) {
	int t = x;
	while(t) {
		if(t % 10 == 7) return 0;
		t /= 10;
	}
	t = x;
	while(t) {
		if(t % 8 == 7) return 0;
		t /= 8;
	}
	return 1;
}

signed main(){
	loli;
	cin >> n;
	int ans = 0;
	FOR(i, n) {
		ans += check(i);
	}
	cout << ans << "\n";
}

#include <bits/stdc++.h>

using namespace std;

#define ll long long

bool check(int n,int m){
    while(n){
        if(n % m == 7)return true;
        n/=m;
    }
    return false;
}

void solve(){
    int n;
    cin>>n;
    int c = 0;
    for(int i = 1;i<=n;i++){
        if(check(i,8) || check(i,10))c++;
    }
    cout<<n-c;
}

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


#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using P2 = pair<ll, P>;
vector<ll> d;
ll inf = 1e18;

ll c1(ll t, ll c, ll d) {
    return t + c + (d / (t + 1));
}

ll culc(ll t, ll c, ll d) {
    int kouho = (double)(sqrt(d)+0.00001) - 1;
    ll ans = c1(t, c, d);
    for (int i = kouho - 10; i <= kouho + 10; i++) {
        if (i <= t)continue;
        ans = min(ans, c1(i, c, d));
    }
    return ans;
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<P2>> g(n);
    rep(i, m) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        g[a].push_back(P2(b, P(c, d)));
        g[b].push_back(P2(a, P(c, d)));
    }
    d = vector<ll>(n, inf);
    priority_queue<P, vector<P>, greater<P>> que;
    d[0] = 0;
    que.push(P(0, 0));

    while (!que.empty()) {
        ll dist = que.top().first;
        int s = que.top().second;
        que.pop();
        if (d[s] < dist)continue;
        for (auto nextP : g[s]) {
            int next = nextP.first;
            int cv = nextP.second.first;
            int dv = nextP.second.second;
            ll cost = culc(d[s], cv, dv);
            if (d[next] <= cost)continue;
            d[next] = cost;
            que.push(P(d[next], next));
        }
    }

    if (d[n - 1] == inf)cout << -1 << endl;
    else cout << d[n - 1] << endl;
    return 0;

}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
	double A, B, C, D;
	cin >> A >> B >> C>> D;

	double ans = abs(A - C) / (B + D) * B;
	if (C > A)
		ans += A;
	else
		ans = A - ans;

	cout << fixed <<setprecision(15) << ans << endl;
}


#include<bits/stdc++.h>

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'

typedef long long int ll;

using namespace std;

const ll N = 2e5 + 77;
ll A[N], Pre[N];
ll n , k ;

ll f(ll x){
    return max(0LL,(x-1) - 2*(max(0LL,x-n-1)));
}

void sol(){
    cin >> n >> k ;
    ll ans = 0;

    for(ll i = k + 2; i <= 2* n ; ++i){
        ans += f(i)*f(i-k);
    }
    cout << ans << endl;
}

int32_t main(){
    fast;
    int t  = 1;
    // cin >> t;
    while(t--) sol();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define inf 2147483647
#define range(x,a,b) (a)<=x&&x<=(b)
#define mod 998244353
int main(){
	ll n,k;
	cin>>n>>k;
	ll ab=2*n,cd=ab-k;
	ll count=0;
	while(ab>=2){
		if(cd>=2&&cd<=2*n)count+=(min(ab-2,2*n-ab)+1)*(min(cd-2,2*n-cd)+1);
		ab--;
		cd=ab-k;
	}
	cout<<count;
	return 0;
}


#include <bits/stdc++.h>

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

using namespace std;

int main(){
	int n; scanf("%d",&n);
	vector<int> p(n);
	rep(i,n) scanf("%d",&p[i]), p[i]--;

	vector<int> pos(n);
	rep(i,n) pos[p[i]]=i;

	vector<int> ans;
	vector<bool> used(n-1);
	rep(x,n){
		int i=pos[x];
		while(x<i){
			if(used[i-1]){
				puts("-1");
				return 0;
			}
			used[i-1]=true;
			pos[p[i]]=i-1;
			pos[p[i-1]]=i;
			swap(p[i-1],p[i]);
			ans.emplace_back(i-1);
			i--;
		}
	}

	if(ans.size()==n-1){
		rep(i,n-1) printf("%d\n",ans[i]+1);
	}
	else{
		puts("-1");
	}

	return 0;
}

#include <bits/stdc++.h>

#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " is " << (x) <<"\n"
#define test ll t;cin>>t;while(t--)
#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9+7;
const ll MAX = 2e5+100;
const ll inf = 1e9;

ll a[MAX];
int main(){
  fastio;
  ll n;
  cin>>n;
  f(i,0,n) cin>>a[i];
  f(i,0,n) a[i]--;
  vi v;
  f(i,0,n){
    if(a[i]==i) continue;
    f(j,i+1,n){
      if(a[j]==i){
        af(k,j,i+1){
          swap(a[k-1],a[k]);
          v.pb(k);
        }
        i = j-1;
        break;
      }
    }
  }
  bool go = true;
  f(i,0,n){
    if(a[i]!=i) go = 0;
  }
  if(sz(v)!=n-1) go = false;
  if(!go){
    cout<<"-1\n";
    return 0;
  }
  for(auto it : v) cout<<it<<"\n";
  return 0;
  }


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    int n,t;
    double l,r;
    cin >> n;
    vector<pair<double, double>> v;
    for (int i=0; i<n; i++) {
        cin >> t >> l >> r;
        switch(t) {
            case 2:
            r -= 0.1;
            break;
            case 3:
            l += 0.1;
            break;
            case 4:
            r -= 0.1;
            l += 0.1;
            break;
        }
        v.push_back(make_pair(l, r));
    }

    int ans = 0;
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            pair<double, double> p1 = v.at(i);
            pair<double, double> p2 = v.at(j);
            if (p1.second < p2.first || p2.second < p1.first) continue;
            ans++;
        }
    }
    cout << ans << '\n';

    return 0;
}

#pragma region templates
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using PQR = priority_queue<T,vector<T>,greater<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
constexpr ll dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
inline void Yes() { cout << "Yes" << ENDL; }
inline void No() { cout << "No" << ENDL; }
inline void YES() { cout << "YES" << ENDL; }
inline void NO() { cout << "NO" << ENDL; }

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T>
vector<T> finddivisor(T x) {  //整数xの約数(xを含む)
  vector<T> divisor;
  for(T i = 1; (i * i) <= x; i++) {
    if(x % i == 0) {
      divisor.push_back(i);
      if(i * i != x) { divisor.push_back(x / i);}
    }
  }
  sort(divisor.begin(), divisor.end());
  return divisor;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template<typename T>
T rand(T l,T r){
  static random_device rd;
  static mt19937 g(rd());
  return uniform_int_distribution<T>(l,r)(g);
}//[]

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(auto&& x: vec) is >> x;
  return is;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}

template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}
#pragma endregion templates

signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  V<ll> l(n),r(n);
  rep(i,0,n){
    ll t,a,b;cin>>t>>a>>b;
    a*=2;
    b*=2;
    if(t==1){
      l[i]=a;
      r[i]=b;
    }else if(t==2){
      l[i]=a;
      r[i]=b-1;
    }else if(t==3){
      l[i]=a+1;
      r[i]=b;
    }else{
      l[i]=a+1;
      r[i]=b-1;
    }
  }

  ll ans=0;
  rep(i,0,n){
    rep(j,i+1,n){
      if(!(r[i]<l[j]||r[j]<l[i])){
        ++ans;
      }
    }
  }
  cout<<ans<<ENDL;
}
//(・_・)(・_・)(・_・)(・_・)
//CHECK overflow,what to output?
//any other simpler approach?


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

int main()
{
  int n;
  cin>>n;
  int m=0,i=0;
  while(m<n)
  {
    m+=i;
    i+=1;
  }
  cout<<i-1;
  return 0;
}

// Problem : B - Savings
// Contest : AtCoder - AtCoder Beginner Contest 206（Sponsored by Panasonic）
// URL : https://atcoder.jp/contests/abc206/tasks/abc206_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Delete the dynamically allocated memory

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

#define ff              first
#define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	for(ll i=0;i<=n;i++){
		if((i*(i+1))/2>=n){
			cout<<i<<"\n";
			break;
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define read(a,n) forp(i,1,n){cin>>a[i];}
#define vi vector<ll>
#define newl '\n'
#define mod 1000000007
#define no cout<<"NO"<<newl; return;
#define yes cout<<"YES"<<newl; return;
#define imp cout<<"-1"<<newl; return;

void solve(){
    ll n,k; cin>>n>>k;
    map<ll,ll> m; ll x,y;
    forp(i,1,n){
        cin>>x>>y;
        m[x]+=y;
    }
    ll ans=0,aa;
    for(auto it=m.begin(); it!=m.end(); it++){
        //cout<<it->first<<" "<<ans<<" "<<k<<newl;
        if(ans+k<(it->first)){
            cout<<ans+k<<newl; return;
        } else {
            k-=(it->first - ans);
            k+=(it->second);
            ans=(it->first);
        }
        aa=it->first;
    }
    cout<<aa+k<<newl;
}

int main() {
    clock_t start,end;
    start=clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    end=clock();
    //cout<<newl<<"Time : "<<double(end - start)/double(CLOCKS_PER_SEC)<<newl;
}

#pragma GCC optimize("Ofast")
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define mod (int)(1e9+7)
#define mod2 998244353
#define PI 3.1415926535897932384626433832795

void solve() {
    int n,q; cin>>n>>q;
    int a[n];
    for(auto &it:a)
        cin>>it;
    set<int> s;
    // int mxn=*max_element(a,a+n);

    // for(int i=1;i<=1e6;i++){
    //     s.insert(i);
    // }
    // for(int i=0;i<n;i++){
    //     s.erase(a[i]);
    // }
    // vector<int> v(all(s));
    sort(a,a+n);
    // s.clear();
    int p[n];
    p[0]=a[0]-1;
    for(int i=1;i<n;i++){
        p[i]=p[i-1];
        p[i]+=(a[i]-a[i-1]-1);
    }
    while(q--){
        int x; cin>>x;
        // if(x<=(int)v.size()){
        //     cout<<v[x-1]<<' ';//continue;
        // }
        int ind=lower_bound(p,p+n,x)-p;
        if(ind<n){
            int diff=p[ind]-x+1;
            cout<<a[ind]-diff<<'\n';
        } else {
            int diff=x-p[n-1];
            cout<<a[n-1]+diff<<'\n';
        }
    }
}

int32_t main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
typedef unsigned long long ull;
typedef long long ll;
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define nep(i,r,l) for(int i=r;i>=l;i--)
void sc(int &x){scanf("%d",&x);}
void sc(int &x,int &y){scanf("%d%d",&x,&y);}
void sc(int &x,int &y,int &z){scanf("%d%d%d",&x,&y,&z);}
void sc(ll &x){scanf("%lld",&x);}
void sc(ll &x,ll &y){scanf("%lld%lld",&x,&y);}
void sc(ll &x,ll &y,ll &z){scanf("%lld%lld%lld",&x,&y,&z);}
void sc(char *x){scanf("%s",x);}
void sc(char *x,char *y){scanf("%s%s",x,y);}
void sc(char *x,char *y,char *z){scanf("%s%s%s",x,y,z);}
void out(int x){printf("%d\n",x);}
void out(ll x){printf("%lld\n",x);}
void out(int x,int y){printf("%d %d\n",x,y);}
void out(ll x,ll y){printf("%lld %lld\n",x,y);}
void out(int x,int y,int z){printf("%d %d %d\n",x,y,z);}
void out(ll x,ll y,ll z){printf("%lld %lld %lld\n",x,y,z);}
using namespace std;
const int N=3e5+5;
int n,a[N];
ll sum[N];
int main()
{
    //freopen("1.in","r",stdin);freopen("1.out","w",stdout);
    sc(n);
    rep(i,1,n) sc(a[i]);
    sort(a+1,a+1+n);
    rep(i,1,n) sum[i]=sum[i-1]+a[i];
    ll res=1e18;
    rep(i,1,n)
    {
        ll s=sum[n]-sum[i-1];
        ll cur=1ll*a[i]*n+s*2-1ll*a[i]*(n-i+1)*2;
        res=min(res,cur);
    }
    long double ans=res;
    ans/=2*n;
    printf("%.10f\n",double(ans));
}

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long double lb = 0;
	long double rb = 2e9 + 9;
	long double p = 1.0 / (long double) n;
	auto f = [&](long double x) {
		long double E = 0.0;
		for (int i = 0; i < n; i++) {
			long double v = x + a[i] - min((long double) a[i], 2.0 * x);
			E += p * v;
		}
		return E;
	};
	for (int i = 0; i < 300; i++) {
		long double g = lb + (rb - lb) / 3.0;
		long double h = lb + 2.0 * (rb - lb) / 3.0;
		if (f(g) < f(h)) {
			rb = h;
		} else {
			lb = g;
		}
	}
	cout << setprecision(8) << fixed << f(lb) << '\n';
	return 0;
}
// B


#include <iostream>
using namespace std;

int main() {
    string s;
    int count=0;
    cin >> s;

    for(int i=0; i<=8; i++) {
        if(s[i]=='Z'&&s[i+1]=='O'&&s[i+2]=='N'&&s[i+3]=='e'){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

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

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

int main(){
  ll n;
  cin>>n;
  vector<ll>v(n+1);
  v[2]=2;
  for(ll i=3;i<=n;i++){
    ll g=gcd(i,v[i-1]);
    //cout<<"gcd of "<<i<<" "<<v[i-1]<<" "<<g<<endl;
    v[i]=(i*(v[i-1]))/g;
    //cout<<v[i]<<endl; // testing

  }

  cout<<v[n]+1<<endl;

}


#include <bits/stdc++.h>
// #include <boost/multi_array.hpp>
// #include <boost/optional.hpp>
// #include <boost/range/irange.hpp>
// #include <boost/range/algorithm.hpp>
// #include <boost/range/adaptors.hpp>
// #include <atcoder/all>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep2(i, x, n) for(int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
const int INF = 1e9;
const long long llINF = 1LL << 60;

bool is_prime(long long n) { // is n prime or not
    for(long long i = 2; i * i <= n; i++) {
        if(n % i == 0)
            return false;
    }
    return true;
}

void Main() {
    int n;
    cin >> n;
    ll p = 1;
    rep(i, n) p *= 2;
    vector<int> a(p);
    rep(i, p) cin >> a[i];
    int maxa = 0, maxb = 0, ida, idb;
    rep(i, p) {
        if(i < p / 2) {
            if(a[i] > maxa) {
                maxa = a[i];
                ida = i;
            }
        } else {
            if(a[i] > maxb) {
                maxb = a[i];
                idb = i;
            }
        }
    }
    if(maxa > maxb) cout << idb + 1 << endl;
    else cout << ida + 1 << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

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

int main() {
    long N;
    cin >> N;
    set<long> ans;

    for(long i = 1; i * i <= N; i++) {
        if(N % i == 0) {
            ans.insert(i);
            ans.insert(N / i);
        }
    }

    for(auto val:ans) cout << val << endl;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '['; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << ']'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '{' << p.first << ", " << p.second << '}'; }
template<typename T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const map<A, B> &mp) { os << '['; string sep; for (const auto &x : mp) os << sep << x, sep = ", "; return os << ']'; }
template<typename T> ostream& operator<<(ostream &os, const multiset<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<typename T> istream& operator>>(istream &in, vector<T> &v) { for (auto &i : v) in >> i; return in;}
template<typename A, typename B> istream& operator>>(istream &in, pair<A, B> &a) { in >> a.first >> a.second; return in;}

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "] =", dbg_out(__VA_ARGS__)
#define show_testcase(k) cerr << "test-case : " << k << endl;
#else
#define show_testcase(...)
#define dbg(...)
#endif

#define int long long
#define mod 1000000007
#define inf 1e18
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)(x).size()
#define sb(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all(x)); auto it = unique(all(x)); x.resize(it - x.begin())
#define sum(x) accumulate(all(x), 0LL)

const string no = "NO";
const string yes = "YES";

void solve()
{
    //cout << fixed << setprecision(10);
    int a, b; cin >> a >> b;
    dbg(100.0 / a);
    cout << (a / 100.0)*b << endl;
}

int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t = 1;
    // cin >> t;
    for (int tc = 1; tc <= t; tc++) {
        show_testcase(tc);
        solve();
    }
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
    double a, b; cin >> a >> b;
    cout << b/100*a << endl;
}


#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return x*f;
}
const double eps=1e-6;
int n,D,H;
int d[1100],h[1100];
bool check(double mid){
	double k=(H-mid)/D,b=mid;
	for(int i=1;i<=n;++i){
		if(1.0*d[i]*k+b<h[i]){
			return false;
		}
	}
	return true;
}
int main(){
	n=read(),D=read(),H=read();
	for(int i=1;i<=n;++i){
		d[i]=read(),h[i]=read();
	}
	double l=0,r=1000;
	while(r-l>eps){
		double mid=(l+r)/2;
		if(check(mid)){
			r=mid;
		}else{
			l=mid;
		}
	}
	printf("%.6f\n",l);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define N 214514
const ll mod = 100000;
const ll inf = 1000000000000000000;

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
    ll t;
    cin >> t;
    vector<ll> ans;
    while (t--) {
        ll n, s, k;
        cin >> n >> s >> k;
        ll x = __gcd(k, __gcd(n - s, n));

        if (__gcd(k / x, n / x) != 1)
            ans.push_back(-1);
        else {
            ll y = modinv(k / x, n / x);
            ans.push_back((n - s) / x * y % (n / x));
        }
    }
    for (ll x : ans) cout << x << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

struct dijkstra{
    vector<long long> min_dst;
    vector<vector<pair<long long, long long>>> G;

    dijkstra(int n){
        min_dst.resize(n);
        G.resize(n);
    }

    void append(int u, int v, long long cost){G[u].push_back(make_pair(v, cost));}

    void run(int s){
        priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> que;
        fill(min_dst.begin(), min_dst.end(), -1);
        min_dst[s] = 0;
        que.push(make_pair(0, s));

        while(!que.empty()){
            auto p = que.top(); que.pop();
            int at = p.second;
            if(min_dst[at] < p.first){continue;}
            for(int i = 0; i < G[at].size(); i++){
                int to = G[at][i].first;
                long long cost = G[at][i].second;
                if(min_dst[to] == -1 || min_dst[at] + cost < min_dst[to]){
                    min_dst[to] = min_dst[at] + cost;
                    que.push(make_pair(min_dst[to], to));
                }
            }
        }
    }

    long long get(int at){return min_dst[at];}
};

ll r, c, a[505][505], b[505][505];

ll encode(ll i, ll j){
    return i * c + j;
}

ll encode2(ll i, ll j){
    return i * c + j + r * c;
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);

    cin >> r >> c;
    zep(i, 0, r)zep(j, 0, c - 1)cin >> a[i][j];
    zep(i, 0, r - 1)zep(j, 0, c)cin >> b[i][j];

    dijkstra d(2 * r * c);

    zep(i, 0, r)zep(j, 0, c - 1){
        d.append(encode(i, j), encode(i, j + 1), a[i][j]);
        d.append(encode(i, j + 1), encode(i, j), a[i][j]);
    }

    zep(i, 0, r)zep(j, 0, c){
        d.append(encode(i, j), encode2(i, j), 1);
        d.append(encode2(i, j), encode(i, j), 0);
    }

    zep(i, 0, r - 1)zep(j, 0, c){
        d.append(encode(i, j), encode(i + 1, j), b[i][j]);
        d.append(encode2(i + 1, j), encode2(i, j), 1);
    }

    d.run(0);
    //zep(i, 0, r){zep(j, 0, c)cout << d.get(encode(i, j)) << " "; cout << endl;}
    print(d.get(encode(r - 1, c - 1)))

    return 0;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+f*(c-'0'),c=getchar();
	return x;
}
const int MAXN=100,inf=1e18;
int n;
int a[MAXN];
int b[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int ans=inf;
int gcd(int x,int y)
{
	if(y==0)return x;
	return gcd(y,x%y);
}
void dfs(int x,int sum)
{
	if(x==15)
	{
		int h=0;
		for(int i=1;i<=n;i++)
		if(sum==1||gcd(sum,a[i])==1){
			h=1;
			break;
		}
		if(h==0)ans=min(ans,sum);
		return ;
	}
	dfs(x+1,sum*b[x]);
	dfs(x+1,sum);
}
signed main()
{
	n=read();
	for(int i=1;i<=n;i++)
	a[i]=read();
	dfs(0,1);
	printf("%lld\n",ans);
 	return 0;
}