#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifdef APURBA
#define HERE cout<<"here - "<<__LINE__<<"\n";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout<<endl;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cout << *it << " = " << a << " ";
    err(++it, args...);
}
#else
#define HERE
#define debug(args...)
#endif
const int N = 400000 +5;
const ll mod = 1e9 + 7;
typedef pair<int,int> pii;

int mp[N];
vector<int>adj[N];
bool vis[N];

void dfs(int s, int &cnt, int &cnt2)
{
    cnt+= adj[s].size();
    cnt2++;
    vis[s]=1;
    for(int i:adj[s])
    {
        if(!vis[i])
            dfs(i,cnt,cnt2);
    }
}

void TEST_CASES(int cas)
{
    int n;
    cin>>n;
    int now = 1;
    for(int i=0;i<n;i++)
    {
        int x,y;
        cin>>x>>y;
        int u,v;
        if(mp[x]==0)
        {
            mp[x]= now;
            now++;
        }
        if(mp[y]==0)
        {
            mp[y] = now;
            now++;
        }
        adj[mp[x]].push_back(mp[y]);
        adj[mp[y]].push_back(mp[x]);
    }
    int ans = 0;
    for(int i=1;i<now;i++)
    {
        if(vis[i]==0)
        {
            int cnt =0, cnt2 = 0;
            dfs(i,cnt , cnt2);
            assert(cnt%2==0);
            cnt/=2;
            if(cnt==cnt2-1)
            {
                ans+= cnt2-1;
            }
            else{
                ans+= cnt2;
            }
        }
    }
    cout<<ans<<"\n";

}

/*

*/

int32_t main()
{
#ifndef APURBA
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    //freopen("input.txt","r",stdin);
    //freopen("out1.txt","w",stdout);
    int t=1,cas=0;
    //cin>>t;
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}

#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 ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 200006;

ll po(ll x, ll n){
    ll ans=1;
    while(n>0){ if(n&1) ans=(ans*x)%mod; x=(x*x)%mod; n/=2;}
    return ans;
}

int fen[MAXN];

void upd(int pos){
    while(pos<MAXN){
        fen[pos]++;
        pos|=(pos+1);
    }
}

ll qr(int pos){
    ll ret = 0;
    while(pos>=0){
        ret+=fen[pos];
        pos&=(pos+1);
        pos--;
    }
    return ret;
}

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

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

        int n;
        cin>>n;

        ll a[n], b[n];
        rep(i,n) cin>>a[i];
        rep(i,n) cin>>b[i];

        rep(i,n){
            a[i]+=i;
            b[i]+=i;
        }

        map<ll, vector<int> > m;

        rev(i,n-1){
            m[a[i]].pb(i);
        }

        int f=0;
        int nap=0;
        rep(i,n){
            if(m.find(b[i])==m.end()){
                f=1;
                break;
            }

            a[m[b[i]].back()]=nap++;
            m[b[i]].pop_back();

            if(m[b[i]].empty()) m.erase(b[i]);
        }

        if(f){
            cout<<-1<<el;
            return 0;
        }

        ll ans = 0;
        rep(i,n){
            ans += qr(MAXN)-qr(a[i]);
            upd(a[i]);
        }

        cout<<ans<<el;

    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

    ll N;
    string S;
    cin >> N;
    vector<ll> A(N),B(N),C(N);
    REP(i,N){
        cin >> A.at(i);
    }
    REP(i, N)
    {
        cin >> B.at(i);
    }
    REP(i, N)
    {
        cin >> C.at(i);
    }

    vector<ll> vecB(100000+1,0);

    REP(i,N){
        vecB.at(B.at(C.at(i)-1))++;
    }
    //debug(vecB);
    ll ans = 0;

    REP(i,N){
        if(vecB.at(A.at(i))>0){
            ans += vecB.at(A.at(i));
        }
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>

const long long INF = 1e9;
const long long MOD = 1e9 + 7;
//const long long MOD = 998244353;
const long long LINF = 1e18;
using namespace std;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define COUT(x) cout<<(x)<<endl
#define SCOUT(x) cout<<(x)<<" "
#define VECCOUT(x) for(auto&youso_: (x) )cout<<right<<setw(10)<<youso_<<" ";cout<<endl
#define ENDL cout<<endl
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) long long __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define mp make_pair
#define PQ priority_queue<long long>
#define PQG priority_queue<long long,V,greater<long long>>

typedef long long ll;
typedef vector<long long> vl;
typedef vector<long long> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef pair<long long, long long> pll;

#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
template<class T>
void mod(T &x) {
    x %= MOD;
    x += MOD;
    x %= MOD;
}

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

struct COMB{
    vl fact, fact_inv, inv;
    void init_nCk(long long SIZE) {
        fact.resize(SIZE + 5);
        fact_inv.resize(SIZE + 5);
        inv.resize(SIZE + 5);
        fact.at(0) = fact.at(1) = fact_inv.at(0) = fact_inv.at(1) = inv.at(1) = 1;
        for(long long i = 2; i < SIZE + 5; i++) {
            fact.at(i) = fact.at(i - 1)*i%MOD;
            inv.at(i) = MOD - inv.at(MOD%i)*(MOD/i)%MOD;
            fact_inv.at(i) = fact_inv.at(i - 1)*inv.at(i)%MOD;
        }
    }
    long long nCk (long long n, long long k) {
        assert(!(n < k));
        assert(!(n < 0 || k < 0));
        return fact.at(n)*(fact_inv.at(k)*fact_inv.at(n - k)%MOD)%MOD;
    }
};
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if(b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a/b*x;
    return d;
}

void Main() {
    LCIN(N);
    vl x(N), y(N);
    for(int i = 0; i < N; i++) {
        cin >> x.at(i) >> y.at(i);
    }
    ll ans = 0;
    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            int X = x.at(i) - x.at(j);
            int Y = y.at(i) - y.at(j);
            if(abs(X) >= abs(Y)) ans++;
        }
    }

    cout << ans << endl;

}

int main() {
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


//Bismillahir-Rahmanir-Rahim
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int llu;
#define f1(i,n) for(i=1;i<=n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define Max 100009
#define pb push_back
#define mp make_pair
#define cy "YES\n"
#define cn "NO\n"
using namespace std;
int main()
{
        ll n,i,j,m,s=0,mx,mn;
       cin>>n;
       ll in1,in2,mx1=0,mx2=0;
       n=pow(2,n);
       ll a[n+1];
       f1(i,n) cin>>a[i];
       for(i=1;i<=n/2;i++)
       {
           if(a[i]>mx1)
           {
               mx1=a[i];
               in1=i;
           }
       }
       for(i=n/2+1;i<=n;i++)
       {
           if(a[i]>mx2)
           {
               mx2=a[i];
               in2=i;
           }
       }
       if(mx1>mx2)
        cout<<in2<<endl;
       else cout<<in1<<endl;
}

#include <bits/stdc++.h>

using namespace std;

#define eps 1e-9
#define INF 2000000000              // 2e9
#define LLINF 2000000000000000000ll // 2e18 (llmax:9e18)
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define drep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)

#define popcount __builtin_popcount
#define next __next
#define prev __prev

#ifndef LOCAL
#define dmp(...) ;
#else
#define dmp(...)                                                               \
  cerr << "[ " << #__VA_ARGS__ << " ] : " << dump_str(__VA_ARGS__) << endl
#endif

// ---------------- Utility ------------------

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;

template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

// ----------------- Input -------------------

template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  return is >> p.first >> p.second;
}

template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}

// ----------------- Output ------------------

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << p.first << ',' << p.second;
}

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

template <class T>
ostream &operator<<(ostream &os, const deque<T> &d) {
  for (const T &e : d) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &s) {
  os << "{ ";
  for (const T &e : s) os << e << " ";
  return os << "}";
}

template <class T, class U>
ostream &operator<<(ostream &os, const map<T, U> &m) {
  os << "{ ";
  for (const auto &[key, val] : m) os << "( " << key << " -> " << val << " ) ";
  return os << "}";
}

template <class TupleTy, size_t... I>
void dump_tuple(ostream &os, const TupleTy t, std::index_sequence<I...>) {
  (..., (os << (I == 0 ? "" : ",") << std::get<I>(t)));
}

template <class... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t) {
  os << "(";
  dump_tuple(os, t, std::make_index_sequence<sizeof...(Args)>());
  return os << ")";
}

void dump_str_rec(ostringstream &) {}

template <class Head, class... Tail>
void dump_str_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << ", " << head;
  dump_str_rec(oss, forward<Tail>(tail)...);
}

template <class T, class... U>
string dump_str(T &&arg, U &&... args) {
  ostringstream oss;
  oss << arg;
  dump_str_rec(oss, forward<U>(args)...);
  return oss.str();
}

// --------------- Fast I/O ------------------

void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

// ------------ End of template --------------

#define endl "\n"
using ll = long long;
using pii = pair<int, int>;

void solve() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == '.') break;
    cout << s[i];
  }
  cout << endl;
  return;
}

int main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


// Problem: F - Close Group
// Contest: AtCoder - AtCoder Beginner Contest 187
// URL: https://atcoder.jp/contests/abc187/tasks/abc187_f
// Memory Limit: 1024 MB
// Time Limit: 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define F(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end()

using ld = long double;
using vi = vector <int>;
using mi = map <int, int>;
using pii = pair <int, int>;

const int N = 600005;
const int MOD = 1e9 + 7;

#define show(arr) { for (auto x: arr) cout << x << " "; cout << '\n'; }
#define show_(arr, n) F(i, n) show(arr[i])
int adj[20][20];
int dp[N];
int dist[N];
void solve() {
	int n,m, ans = 0; cin>>n>>m;
   	F(i, m){
   		int x,y;
   		cin>>x>>y; x--; y--;
   		adj[x][y]=1;
   		adj[y][x]=1;
   	}
	int a = 0;
	for(int i=0;i<n;i++) a += (1ll<<i);

	F(i,(1ll<<n)){
		dp[i]=0;
	}
	dp[0]=1;
	F(i,(1ll<<n)){
		dist[i] = 1e9;
		for(int j=0;j<n;j++){
			if(dp[i^(1ll<<j)]){
				bool ok=1;
				int x=(i^(1ll<<j));
				for(int k=0;k<n;k++){
					if(k==j) continue;
					if(((1ll<<k) & x )&&(adj[k][j]==0)){ ok=0; break;}
				}
				if(ok){
					dp[i]=1;
					break;
				}
			}
		}
	}
	dist[0]=0;
	for(int i=0;i+1<(1<<n);i++)
	{
		int j=0;
		while(i>>j&1)j++;
		int t=~i&(1<<n)-1;
		t^=1<<j;
		for(int k=t;;k=k-1&t)
		{
			if(dp[k|1<<j])
			{
				dist[i|k|1<<j]=min(dist[i|k|1<<j],dist[i]+1);
			}
			if(k==0)break;
		}
	}
	cout<<dist[(1<<n)-1]<<endl;
}
int32_t main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);

   int32_t t=1;
   // cin >> t;
   while (t--) solve();

   return 0;
}

//abc187_f.cpp
//Sat Jan  9 16:04:40 2021

#include <bits/stdc++.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,m;
	cin >> n >> m;

	vector<int> e(n,0);
	rep(i,m){
		int a,b;
		cin >> a >> b;
		a--;b--;
		e[a] += 1<<b;
		e[b] += 1<<a;
	}

	vector<int> dp(1<<n,99999);
	dp[0] = 0;
	rep(i,1<<n){
		if (i==0)continue;
		rep(j,n){
			if(1<<j&i){
				int target = i-(1<<j);
				if (dp[target]<=1 && (e[j]&target)==target){
					dp[i] = 1;
				}
				break;
			}
		}
	}

	rep(i,1<<n){
		for (int j=i;j>0;j=((j-1)&i)){
			int k = i-j;
			dp[i] = min(dp[i],dp[j]+dp[k]);
		}
	}

	cout << dp[(1<<n)-1] << endl;
}


#include<bits/stdc++.h>
using namespace std;
int n,dsu[110],cnt;
int find(int x){return dsu[x]==x?x:dsu[x]=find(dsu[x]);}
void merge(int x,int y){dsu[find(x)]=find(y);}
pair<double,pair<int,int> >e[20100];
pair<int,int>p[110];
int main(){
	scanf("%d",&n);
	for(int i=0;i<=n+1;i++)dsu[i]=i;
	for(int i=1;i<=n;i++)scanf("%d%d",&p[i].first,&p[i].second),e[++cnt]=make_pair(100-p[i].second,make_pair(0,i)),e[++cnt]=make_pair(p[i].second+100,make_pair(i,n+1));
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)e[++cnt]=make_pair(sqrt((p[i].first-p[j].first)*(p[i].first-p[j].first)+(p[i].second-p[j].second)*(p[i].second-p[j].second)),make_pair(i,j));
	sort(e+1,e+cnt+1);
	for(int i=1;i<=cnt;i++){merge(e[i].second.first,e[i].second.second);if(find(0)==find(n+1)){printf("%lf\n",e[i].first/2);return 0;}}
	return 0;
}


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

int main() {
 int N;
 cin >> N;
 vector<int> T(N);
 int sum = 0;
 for (int i = 0; i < N; i++) {
   cin >> T.at(i);
   sum = sum + T.at(i);
 }
 sum /= 2;
 vector<bool> ans(sum + 1, false);
 ans.at(0) = true;
 int pmax = 0;
 for (int i = 0; i < N; i++) {
   for (int j = min(pmax, sum); j >= 0; j--) {
     if (T.at(i) + j <= sum && ans.at(j) == true) {
       ans.at(j + T.at(i)) = true;
     }
   }
   pmax += T.at(i);
  }
  for (int i = sum; i >= 0; i--) {
    if (ans.at(i) == true) {
      cout << pmax - i << endl;
      return 0;
    }
  }
}

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

template<typename T> void read(T &x) {
	x = 0; int f = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') f = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + (ch - 48);
		ch = getchar();
	}
	x *= f;
}

typedef long long LL;

int n;
LL ans = 1;

LL gcd(LL a, LL b) {
	return (b == 0) ? a : gcd(b, a % b);
}

LL lcm(LL a, LL b) {
	return a * b / gcd(a, b);
}

int main() {
	read(n);
	for (LL i = 2; i <= n; i++) {
		ans = lcm(ans, i);
	}
	cout << ans + 1 << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define MOD 1000000007
#define mod9 1000000009
#define fast                       \
    ios_base ::sync_with_stdio(0); \
    cin.tie(NULL);                 \
    cout.tie(NULL);
#define mp make_pair
#define pb push_back
#define ct    \
    ll t;     \
    cin >> t; \
    while (t--)
#define bi begin()
#define ei end()
#define fi first
#define se second
#define foe(i, a, b) for (ll i = a; i < b; i++)
#define rfoe(i, a, b) for (ll i = a; i >= 0; i--)
#define sz(s) (ll) s.size()
#define mem(a, s) memset(a, s, sizeof(a))
#define all(v) v.bi, v.ei
#define MAX 8000000000000000064LL
#define MIN -8000000000000000064LL

typedef pair<ll, ll> pii;

ll add(ll a, ll b) { return (a % MOD + b % MOD + ((MAX) / MOD) * MOD) % MOD; }
ll sub(ll a, ll b) { return (a % MOD - b % MOD + ((MAX) / MOD) * MOD) % MOD; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD) + ((MAX) / MOD) * MOD) % MOD; }
long long binpow(long long a, long long b)
{
    long long res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); }
// ll fact[1000007 ]={0};
// ll expo(ll x, ll y) {ll res=1;x=x%MOD;while(y>0){if(y&1)res=(1ll*res*x)%MOD;
// y=y>>1;x=(1ll*x*x)%MOD;} return res;}
// void facto() {fact[0]=1;fact[1]=1;for(ll i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%MOD;}
// ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(expo(fact[r],MOD-2)))%MOD; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res;}
// ll npr(ll n,ll r) {facto(); ll res=1; res=fact[n]; res=(res*(expo(fact[n-r],MOD-2)))%MOD; return res; }
int const N = 1e3 + 9;
ll const INF = 2e9 + 5;
ll dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
ll dy[8] = {1, -1, 0, 0, -1, 1, -1, 1};
char dr[4] = {'R', 'L', 'D', 'U'};
ll n, c, ans = INF, a[25];
void go(ll x, ll xr)
{
    if (x == n)
    {
        ans = min(ans, xr);
        return;
    }

    ll orr = 0;
    foe(i, x, n)
    {
        orr |= a[i];
        go(i + 1, xr ^ orr);
    }
}
void solve()
{
    cin >> n;
    ll dp[32];
    mem(dp, 0);
    foe(i, 0, n)
    {
        cin >> a[i];
    }
    go(0, 0);
    cout << ans << "\n";
}
int main()
{
    fast
    // facto();
    // Sieve();
    // ct
    {
        solve();
    }
}

#include <bits/stdc++.h>

#define rep( i, a, b ) for( i = a; i < b; i ++ )

using namespace std;

struct sc {
    int t;
    int am;

    public:
    bool operator>( const sc &r ) const {
        return t == r.t ? am > r.am : t > r.t;
    }
};

int main() {
    int le, li, u, am, f, t, i;
    priority_queue< sc, vector< sc >, greater< sc > > scq;
    cin >> le >> li;
    rep( i, 0, le ) {
        cin >> f >> t >> am;
        scq.push( { f, am } );
        scq.push( { t, -am } );
    }
    while( ! scq.empty() ) {
        li -= scq.top().am;
        if( li < 0 ) {
            cout << "No" << endl;
            return 0;
        }
        scq.pop();
    }
    cout << "Yes" << endl;
    return 0;
}


#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

int main(){
  ll n,m;
  cin >> n >> m;
  if(n==1 && m==0){
    cout << 1 << " " << 2 << endl;
    return 0;
  }else if(m<0 || n-2<m){
    cout << -1 << endl;
    return 0;
  }
  for (ll i = 0; i < n-1; i++){
    cout << 3*i+3 << " " << 3*i+1+3 << endl;
  }
  cout << 3*(n-m-2)-1+3 << " " << 3*n << endl;

  return 0;
}

// KNOW NOTHING!
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fall(a) a.begin(),a.end()
#define sz(x) (int)x.size()
#define szs(x) (int)x.length()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef queue<int> qin;
typedef deque<ll> dqll;
typedef deque<int> dqint;
typedef priority_queue<ll> pqll;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
ll mpwr(ll b,ll p){ll res=1;while(p){if(p&1) {res=(res*b)%MOD; p--;}else{b=(b*b)%MOD; p>>=1;}}return res;}
int msb (int n) {return 31-__builtin_clz(n);}
ll msbl (ll n) {return 63-__builtin_clzll(n);}
int lsb (int n) {return __builtin_ctz(n);}
ll  lsbl (ll n) {return __builtin_ctzll(n);}
int setbit (int n) {return __builtin_popcount(n);}
ll setbitl (ll n) {return __builtin_popcountll(n);}
int main()
{
/*
freopen ("input.txt","r","stdin");
freopen ("output.txt","w","stdout");
*/
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
int n; cin>>n;
vector <pair<int,string>> v (n);
F (i,0,n,1) {
	cin>>v[i].ss>>v[i].fs;
}
sort (fall (v)); reverse (fall (v));
cout<<v[1].ss;
}
/* What we know is a drop , but what we don't know is an ocean !*/


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define rep(i,a,b)    for(int i=a;i<b;i++)
#define repn(i,a,b)   for(int i=a;i>=b;i--)
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
const int N = 100001;

int fexp(int a, int b,int m){int ans = 1;while(b){if(b&1)ans=(ans*a)%m; b/=2;a=(a*a)%m;}return ans;}
int inverse(int a, int p){return fexp(a, p-2,p);}

// int fac[2000001];

// int nCrModPFermat(int n, int r,int p) {
//     if (r==0) return 1;
//     return (((fac[n]*((((inverse(fac[r],p)%p)*inverse(fac[n-r],p))%p))))%p);
// }

void solve(){
    int n;cin>>n;int mx=0;
    vi a(n);rep(i,0,n){cin>>a[i];mx=max(mx,abs(a[i]));}
    int man=0;
    rep(i,0,n)man+=abs(a[i]);
    double eucl=0.0;
    rep(i,0,n)eucl+=(a[i]*a[i]);
    eucl=sqrt(eucl);
    cout<<man<<endl;
    cout<<fixed<<setprecision(10)<<eucl;
    cout<<endl<<mx;

}

signed main(){
        IOS;

        int t=1;
        // cin>>t;
        // fac[0] = 1;
        // for (int i=1 ; i<=100001; i++) fac[i] = fac[i-1]*i%mod;
        rep(i,0,t){
            // cout<<"Case #"<<i+1<<": ";
            solve();
            cout<<"\n";
        }
    //    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<long long> a;
	long long mx=0;
	for (int i=0; i<n; i++) {
		long long x;
		cin >> x;
		a.push_back(x);
		mx=max(mx,abs(x));
	}
	long long sum=0;
	for (int i=0; i<n; i++) {
		sum+=abs(a[i]);
	}
	cout << sum << endl;
	sum=0;
	for (int i=0; i<n; i++) {
		sum+=pow(abs(a[i]),2);
	}
	printf("%.14f\n", sqrt(sum));
	cout << mx << endl;
}


#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll T;

mint tri( ll x ) {
  if( x < 0 )
    return 0;

  return mint(x)*(x+1)/2;
}

int main() {
  std::cin >> T;

  rep( t, T ) {
    ll N, A, B;
    std::cin >> N >> A >> B;

    mint f = tri(N-A-B+1);

    mint X = mint(N-A+1)*(N-B+1)*f;
    mint Y = f*f;

    mint ans = X*4-Y*4;

    std::cout << ans.x << endl;
  }

  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define nl cout<<endl

#define pii pair<ll,ll>
#define vi  vector<ll>
#define vii vector<pii>
#define mi  map<ll,ll>
#define all(a)  (a).begin(),(a).end()

#define pb push_back
#define ff first
#define ss second
#define hell 1000000007

#define test4(x,y,z,a) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<"		a is "<<a<<endl;
#define test3(x,y,z) cout<<"x is "<<x<<"		y is "<<y<<"		z is "<<z<<endl;
#define test2(x,y) cout<<"x is "<<x<<"		y is "<<y<<endl;
#define test1(x) cout<<"x is "<<x<<endl;
#define N 300009

ll power(ll a,ll b,ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll n;cin>>n;
	ll a[n+2],b[n+2];
	ll ans= hell;
	rep(i,1,n+1) {
		cin >> a[i]  >> b[i];
	}
	rep(i,1,n+1) {
		rep(j,1,n+1) {
			if( i == j)
				ans = min(ans, a[i]+b[j]);
			else
				ans = min(ans, max(a[i],b[j]));
		}
	}
	cout << ans << endl;
}


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

ll fun(string s,ll mid,ll m )
{
    ll val=0,z=1;

    for(ll i=s.size()-1; i>=0; i--)
    {
        ll t=s[i]-'0';

        if(t>(m/z))
        {
            val=m+1;
            break;
        }
        val+=t*z;
        if(val>m)
        {
            val=m+1;
            break;
        }
        if(z> (m/mid) &&i>0 )
        {
            val=m+1;
            break;
        }
        if( z>(m/mid) &&i==0 )
        {

            break;
        }
        z=z*mid;
        //  cout<<"z="<<z<<endl;
    }
    return val;
}

int main()
{

    ll m;
    string s;
    cin>>s;
    cin>>m;

    if(s.size()==1)
    {
        int t=s[0]-'0';
      //  t++;
        if(t<=m)
            cout<<1<<endl;
        else
            cout<<0<<endl;
        return 0;
    }

    ll mx=0;
    for(int i=0; i<s.size(); i++)
    {
        ll x=s[i]-'0';
        mx=max(mx,x);
    }
    ll lw=mx+1;
    ll w=mx+1;
    ll ub=m;
    ll k=0;
    while(lw<=ub)
    {
        ll mid=lw+(ub-lw)/2;
        ll v=fun(s,mid,m);

       // cout<<"v="<<v<<" mid="<<mid<<endl;
        if(v<=m)
        {
            lw=mid+1;
            k=mid;
        }
        else if(v>m)
        {
            ub=mid-1;
        }
//cout<<lw<<" "<<ub<<endl;
    }
    ll e=0;
    ll f=k-mx;
    cout<<max(e,f)<<endl;

    return 0;
}

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

#define space putchar(' ')
#define enter putchar('\n')
#define MAXN

using namespace std;

typedef long long int64;

int read() {
	int f = 1,res = 0;
	char ch = getchar();
	while(ch < '0' || ch > '9') {
		if(ch == '-') f *= -1;
		ch = getchar();
	}
	while('0' <= ch && ch <= '9') {
		res = res*10+ch-'0';
		ch = getchar();
	}
	return res*f;
}

void out(int i) {
	if(i < 0) {
		putchar('-');
		i = -i;
	}
	if(i > 9) out(i/10);
	putchar(i%10+'0');
	return;
}

int main() {
	string s;
	string t = "atcoder";
	int T = read();
	while(T--) {
		cin>>s;
		if(s > t) {
			puts("0");
			continue;
		}
		bool f = true;
		int k = 0;
		for(int i = 0; i < s.size(); i++) {
			if(s[i] != 'a') {
				f = false;
				k = i;
				break;
			}
		}
		if(f) {
			puts("-1");
			continue;
		}
		for(int i = 0; i < k; i++) {
			swap(s[k-i],s[k-i-1]);
			if(s > t) {
				out(i+1);enter;
				break;
			}
		}
	}

	return 0;
}


/**
*	created: 02.11.2020 19:03:47
**/
#ifdef _LOCAL_
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/math/tools/minima.hpp>
// #include <boost/range/irange.hpp>
using namespace std;
using namespace std::chrono;
#define int long long
#define name(x) #x
#define dump(x) cout << name(x) << " = " << x << endl;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rrep(i,n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define For(i,x) for (auto &i : x)
#define len(x) ll(x.size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) ll(__builtin_popcountll(bit))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a * b / __gcd(a,b)
// using boost::math::tools::brent_find_minima;
// using boost::irange;
using ll = long long;
using P = pair<int,int>;
// using bint = boost::multiprecision::cpp_int;
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 0x7fffffffffffffffll;
const int MOD1 = 1000000007;
const int MOD2 = 998244353;
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T> bool chmin(T &a, T b) {if (b < a) {a = b; return 1;} return 0;}
template<typename T> T bpow(T a, int n) {T r(1); while(n) {if (n & 1) r *= a; a *= a; n >>= 1;} return r;}
template<typename T> auto comp(vector<T> a) {sort(all(a)); a.erase(unique(all(a)),a.end()); return a;}
template<typename T,typename U> ostream &operator<<(ostream &os, const pair<T,U> &p) {os << p.first << " " << p.second; return os;}
template<typename T,typename U> ostream &operator<<(ostream &os, const map<T,U> &mp) {For(p,mp) {os << "[" << p << "]\n";} return os;}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) {rep(i,len(v)) {if(i) os << " "; os << v[i];} return os;}
template<typename T> ostream &operator<<(ostream &os, const set<T> &st) {int c(0); For(x,st) {if (c) os << " "; os << x; c++;} return os;}

// UnionFind（Disjoint-Set Data Structure）
struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n,-1) {}
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x,y);
        par[x] += par[y]; par[y] = x;
        return true;
    }
    bool issame(int x, int y) {return root(x) == root(y);}
    int size(int x) {return -par[root(x)];}
};

void solve() {
    int n; cin >> n;
    vector<P> v(n);
    rep(i,n) {
        int a, b; cin >> a >> b;
        v[i] = P(a, b);
    }
    int s = n, t = n+1;
    vector<pair<double,P>> edge;
    rep(i,n) {
        int a = v[i].first, b = v[i].second;
        double d1 = b + 100, d2 = 100 - b;
        edge.emplace_back(d1,P(s,i));
        edge.emplace_back(d2,P(t,i));
    }
    rep(i,n) rep(j,i) {
        edge.emplace_back(hypotl(v[i].first-v[j].first,v[i].second-v[j].second),P(i,j));
    }
    sort(all(edge));
    UnionFind uf(n+2);
    int ans = 100;
    For(x, edge) {
        auto p = x.second;
        uf.merge(p.first, p.second);
        if (uf.issame(s, t)) {
            cout << x.first / 2 << endl;
            return;
        }
    }
    return;
}

signed main() {
    auto start = system_clock::now();
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    auto end = system_clock::now();
#ifdef _LOCAL_
    cout << endl << fixed << setprecision(3);
    cout << double(duration_cast<microseconds>(end-start).count())/1000;
    cout << " ms" << endl;
#endif
    return 0;
}

#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
//#define MOD 998244353LL
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>; // intの2次元の型に vvi という別名をつける
const ll llMAX=9223372036854775807LL;
const ll llMIN=-9223372036854775808LL;

void myprint1D(vi &data)
{
  REP(i,data.size())
    cout<<data[i]<<" ";
  cout<<endl;
}

//配列を[y][x]で表示
void myprint2D_T(vvi &data)
{
  REP(i,data.size())
    myprint1D(data[i]);
}

//配列を[x][y]で表示
void myprint2D(vvi &data)
{
  ll l1=data.size();
  ll l2=data[0].size();
  REP(j,l2){
    REP(i,l1)
      cout<<data[i][j]<<" ";
    cout<<endl;
  }
}

//print(a,b...)って使い方
void print1(ll a){cout<<a<<endl;}
void print2(ll a,ll b){cout<<a<<" "<<b<<endl;}
void print3(ll a,ll b,ll c){cout<<a<<" "<<b<<" "<<c<<endl;}
void print4(ll a,ll b,ll c,ll d){cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;}
void print5(ll a,ll b,ll c,ll d,ll e){cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl;}
//moddivとnCkとgarner
//c剰余下でaをbで割った値
ll moddiv(ll a,ll b,ll c){
	ll x0=c,x1=b,x2,n0=0LL,n1=1LL,n2,t=a%b,m,ans;
	if (t==0LL) return a/b;
		for(int i=0;i<900;i++){
      m=x0/x1;
      x2=x0-x1*m;
      n2=(n0-m*n1)%c;
      if (x2==1LL){
        ans=(n2+c)%c;
        break;
      }
      x0=x1;x1=x2;
      n0=n1;n1=n2;
    }
	return (a+((t*ans)%c)*b-t)/b;
}
//剰余の割ざん

//aのn乗 mod c
ll expmod(ll a,ll n,ll c){
  ll ans=1LL,aa=a,beki=n;
  for(int i=0;i<64;i++){
    if (beki%2==1LL) ans=ans*aa%c;
    aa=aa*aa%c;
    beki/=2LL;
    if (beki==0LL)break;
  }
  return ans;
}

//nCk
vi mulmod(500001);//0!,1!,2!,3!,4!,,,,
void first_nCk(){
  mulmod[0]=1LL;
  for(ll i=1;i<500001;i++){
    mulmod[i]=mulmod[i-1]*i%MOD;
  }
}
ll nCk(ll nn,ll kk){
  return moddiv(mulmod[nn],mulmod[kk]*mulmod[nn-kk]%MOD,MOD);
}

ll modinv(ll a,ll b){
  return moddiv(1,a,b);
}

ll garner(__int128_t a,__int128_t b,__int128_t ar,__int128_t br){
  __int128_t tmp=(br-ar)%b*modinv(a,b)%b;
  if (tmp<0)tmp+=b;
  return ar+tmp*a;
}

ll n;
string saa,sab,sba,sbb;

ll fib(ll nn){
  nn-=3;
  ll a0=1;
  ll a1=1;
  ll ret=1;
  for(ll nnn=0;nnn<nn;nnn++){
    a0=a1;
    a1=ret;
    ret=(a1+a0)%MOD;
  }
  return ret;
}

int main(){
  ll ans=0;
  cin >> n;

  cin>>saa>>sab>>sba>>sbb;
  if (sab=="A"){
    if (saa=="A"){
      cout<<1<<endl;
      return 0;
    }else{
      if (sba=="A"){
        ans=fib(n);
        cout<<ans<<endl;
        return 0;
      }else{
        if (n<=3){cout<<1<<endl;return 0;}
        ans=expmod(2,n-3,MOD);
        cout<<ans<<endl;return 0;
      }
    }
  }else{
    if (sbb=="B"){
      cout<<1<<endl;
      return 0;
    }else{
      if (sba=="B"){
        ans=fib(n);
        cout<<ans<<endl;
        return 0;
      }else{
        if (n<=3){cout<<1<<endl;return 0;}
        ans=expmod(2,n-3,MOD);
        cout<<ans<<endl;return 0;
      }
    }

  }

  //cout<<ans<<endl;
  return 0;
}
/*

*/


#include <bits/stdc++.h>

using namespace std;
vector<vector<long long>> graf;
vector<long long> val, trz;
vector<bool> odw;
long long curVal, curTrz;

void dfs(long long x){
	odw[x] = true;
	curVal+=val[x];
	curTrz+=trz[x];
	for(auto it:graf[x]){
		if(!odw[it]) dfs(it);
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
	long long n, m; cin>>n>>m;
	odw.resize(n);
	graf.resize(n);

	for(long long i = 0; i < n; i++){
		long long a; cin>>a; val.push_back(a);
	}
	for(long long i = 0; i < n; i++){
		long long a; cin>>a; trz.push_back(a);
	}
	for(long long i = 0; i < m; i++){
		long long a, b; cin>>a>>b;
		a--; b--;
		graf[a].push_back(b);
		graf[b].push_back(a);
	}
	for(long long i = 0; i < n;i++){
		if(!odw[i]){
			curVal=0;
			curTrz=0;
			dfs(i);
			if(curVal!=curTrz) {cout<<"No"; return 0;}
		}
	}
	cout<<"Yes";

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+9;
const int MAX=1e2+9;
const double ep=1e-10;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const double inf=1e20;
const double pi=acos(-1);
#define debug1 puts("?");
#define debug(x) cout<<"##"<<(x)<<endl;
#define mk make_pair
#define PII pair<int,int>
#define PDI pair<double,int>
#define PIII pair<int,PII >
#define PIII1 pair<PII,int>
#define PIIII pair<PII,PII >
#define PIL pair<int,ll>
#define PLI pair<ll,int>
#define PLIII pair<PLI,PII >
#define PLL pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define sd(x) scanf("%d",&(x))
#define slld(x) scanf("%lld",&(x))
#define sdd(x,y) scanf("%d%d",&(x),&(y))
#define sc(s) scanf("%s",(s))
#define pd(x) printf("%d\n",(x))
#define plld(x) printf("%lld\n",(x))
#define pdk(x) printf("%d ",(x))
#define plldk(x) printf("%lld ",(x))
#define pdd(x,y) printf("%d %d\n",(x),(y))
#define PR(x) printf("Case %d: ",(x))

/*
*/
int n,m,pre[maxn];
int Find(int x)
{
	return pre[x]==x?x:pre[x]=Find(pre[x]);
}
void mix(int x,int y)
{
	int fx=Find(x),fy=Find(y);
	pre[fx]=fy;
}
ll a[maxn],b[maxn],sum1[maxn],sum2[maxn];
bool vis[maxn];
void solve()
{
	sdd(n,m);
	rep(i,1,n)pre[i]=i;
	rep(i,1,n)slld(a[i]);
	rep(i,1,n)slld(b[i]);
	rep(i,1,m)
	{
		int u,v;
		sdd(u,v);
		mix(u,v);
	}
	rep(i,1,n)
	{
		int fx=Find(i);
		vis[fx]=1;
		sum1[fx]+=a[i];
		sum2[fx]+=b[i];
	}
	rep(i,1,n)
	{
		if(vis[i]&&sum1[i]!=sum2[i])
		{
			puts("No");return;
		}
	}
	puts("Yes");
}
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int T=1;
//    sd(T);
    while(T--)solve();
}


#include <iostream>
#include <vector>
#include <cmath>
#include<algorithm>
using namespace std;
#define endl '\n'
#define vi vector <ll>
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main()
{   fast;

  ll t;
  cin>>t;
  ll x= 1.08 * t;
   if( x< 206)
   cout<<"Yay!";
 else if(x == 206)
   cout<<"so-so";
 else
  cout<<":(";

}

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define forn(n) for(int i=0;i<n;i++)
#define pb push_back
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
void solve(){
    int n;cin>>n;set<int>s;
    for(int i=2;i<=pow(n,0.5)+5;i++){
        for(int j=2;j<24/log(i);j++){
            if(binpow(i,j)<=n){s.insert(binpow(i,j));cerr<<i<<" "<<j<<endl;}
        }
    }
    cout<<n-(int)s.size()<<endl;
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
    solve();
    return 0;
}


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

ll ll_pow(ll a, ll b) {
  if (b == 0) {
    return 1;
  }
  return a * ll_pow(a, b - 1);
}

int main() {
  ll S, P;
  cin >> S >> P;
  vector<pair<ll, ll>> v;

  for (ll i = 1; i <= sqrt(P); ++i) {
    if (P % i == 0) {
      pair<ll, ll> p = make_pair(i, P / i);
      v.push_back(p);
    }
  }

  for (auto i : v) {
    if (i.first + i.second == S) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, j, k) for(int i = j; i < k; i++)
#define print(x) cout << x
#define newline cout << endl
#define space cout << ' '
#define INF 1000000007
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

int main(){
    ll s,p;
    cin >> s >> p;
    rep(i,1000001){
        if(i*(s-i)==p){
            print("Yes");
            return 0;
        }
        if(i>=s||i>=p) break;
    }
    print("No");
    return 0;
}


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

#define ll long long

ll converter(ll number)
{
    ll num1,  num2, res;
    string num = to_string(number);

    sort(num.begin(), num.end(), greater<char>());
  	num1 = stoll(num);

  	sort(num.begin(), num.end());
    num2 = stoll(num);

  	res = num1-num2;

  	return res;
}

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

  	ll num,res;
  	int k;
  	cin >> num >> k;
  	res = num;
  	for(int i=0; i<k; i++){
  	    res = converter(res);
  	}

  	cout << res << "\n";

  	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define fo(a,b) for(int64_t a=0;a<b;a++)
#define sor(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define ll int64_t
#define mod 1000000007
#define vl vector<int64_t>
#define vc vector<char>
#define vs vector<string>
#define np(vec) next_permutation(vec.begin(),vec.end())==true
#define en endl
#define vvl vector<vector<int64_t>>
#define sti stack<int64_t>
#define qui que<int64_t>
#define ms(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
ll fun(ll x){
  ll r,s,t;
  s=0;
  t=0;
  if(x==0){return 0;}
  fo(i,11){
    ll k=i;
    if(pow(10,k-1)<=x&&x<pow(10,k)){r=k;
                                   break;}
  }
  vl vec(r);
  vl v2(r);
  fo(i,r){
    vec.at(i)=x%10;
    x=x/10;
  }
  sor(vec);
  fo(i,r){
    v2.at(i)=vec.at(i);
  }
  rev(v2);
  fo(i,r){
    s+=vec.at(i);
    s=s*10;
  }
  s=s/10;
  fo(i,r){
    t+=v2.at(i);
    t=t*10;
  }
  t=t/10;
  return abs(t-s);
}

int main(){
 ll n,k;
  cin>>n>>k;
  fo(i,k){
    n=fun(n);
  }
  cout<<n<<endl;
}


#include "bits/stdc++.h"

#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define ll long long
#define mod 1000000007
//#define mod 998244353
#define so(v) sort(v.begin(), v.end())
#define fi first
#define se second

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
//__builtin_popcount
//vector<vector<int>>
//     dir = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};

int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int mI(int a, int m)
{
    return power(a, m - 2, m);
}

#define double long double

int n,m;
vec v1(1001), v2(1001);
int dp[1001][1001];
int fun(int i,int j){
    //debug(i, j);
    if(i==n){
        return m-j;
    }
    if(j==m){
        return n - i;
    }

    if(dp[i][j]!=-1)
        return dp[i][j];
    int g = 0;
    if(v1[i]!=v2[j])
        g = 1;
    return dp[i][j]=min({fun(i + 1, j + 1) + g, fun(i, j + 1)+1,fun(i+1,j)+1});
}

void solve(){
    //int n, m;

    cin >> n>>m;
    fo(i,n) {
        cin >> v1[i];
    }
    fo(i,m){
        cin >> v2[i];
    }
    // if(n>m){
    //     swap(n, m);
    //     swap(v1, v2);
    // }
    memset(dp, -1, sizeof(dp));
    // int val = fun(0, 0);
    // //val = min({val, n, m});
    // val = max(m,n) - val;
    cout << fun(0,0) << "\n";

}

int32_t main()
{

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

#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
int m=1e9+7;
int main()
{
	int n,m,temp1,temp2;
	cin>>n>>m;
	int a[n];
	int b[m];
	int c[m+1];
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<m;i++){cin>>b[i];c[i]=i;}
	c[m]=m;
	for(int i=1;i<=n;i++)
	{
		c[0]=i;
		temp2=i-1;
		for(int j=1;j<=m;j++)
		{
			temp1=c[j];
			if(a[i-1]==b[j-1])c[j]=temp2;
			else
			{
				c[j]=min(1+temp2,min(c[j]+1,c[j-1]+1));
			}
			temp2=temp1;
		}
	}
	cout<<c[m];
	return 0;
}


#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define reps(i,n) for(ll i=1;i<=(n);++i)
#define repr(i,n) for(int i=2;i*i<=(n);++i)
#define ll long long
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb push_back
#define pob pop_back()
#define Mod (ll)(1e9+7)
#define mod (ll)(998244353)
#define setp(x) setprecision((ll)(n))
#define INF (ll)(1000000000000000000)
using namespace std;
using vi=vector<int>;
using vc=vector<char>;
using vl=vector<long long>;
using vvi=vector<vi>;
using vvl=vector<vl>;
using vvc=vector<vc>;
using vpl=vector<pair<ll,ll>>;
using vs=vector<string>;
using pii=pair<int, int>;
using pll=pair<ll,ll>;

int main(){
  ll n; cin>>n;
  vi p(n);
  rep(i,n) cin>>p[i];
  sort(all(p));
  ll sum=1,res=0;
  rep(i,n-1){
   if(p[i]==p[i+1]) sum++;
   else {
    res+=sum*(sum-1)/2;
    sum=1;
   }
  }
  res+=sum*(sum-1)/2;
  sum=1;
  cout<<n*(n-1)/2-res<<endl;
  return 0;
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<sstream>
#include<cctype>
#include<cmath>
#include<iomanip>
#include<map>
#include<stack>
#include<set>
#include<functional>
#define in(x) x=read()
#define qr read()
#define int ll
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
namespace fastIO
{
    #define BUF_SIZE 100000
    bool IOerror=0;
    inline char nc()
	{
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline ll read()
	{
        bool sign=0; char ch=nc();ll x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return 0;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
        return x;
    }
    #undef BUF_SIZE
};
using namespace fastIO;
int n,k,num=0;
vector<int>e[1000010];
int dfs(int x,int pre,int lim)
{
	int now=0,minn=1e16,son=0;
	for(auto i:e[x])
	{
		if(i==pre)continue;
		int nxt=dfs(i,x,lim);
		son++;
		now=max(now,nxt+1);
		minn=min(minn,nxt+1);
	}
	// cout<<x<<":"<<now<<","<<minn<<","<<son<<"\n";
	if(son!=1&&now+minn<=2*lim+1)now=minn;
	if(x!=1&&e[x].size()==1)return lim+1;
	if(now==2*lim+1||(x==1&&now>lim))num++,now=0;
	return now;
}
bool check(int x)
{
	num=0;
	// cout<<x<<":"<<"\n-------------------\n";
	dfs(1,1,x);
	// cout<<"num="<<num<<"\n"<<"--------------------\n";
	return num<=k;
}
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=qr,k=qr;
	for(int i=1;i<n;i++)
	{
		int x=qr,y=qr;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	int l=1,r=n,ans;
	while(l<=r)
	{
		int mid=(l+r)/2;
		if(check(mid))ans=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<ans;
	return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;
int main(int argc, char** argv) {
	double a,b,c,d;
	cin >> a >> b >> c >> d;
	printf("%.10lf",(c-a)/(b+d)*b+a);
	return 0;
}

/*Jai Shree Ram*/
// Never Give Up
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;

#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 umii            unordered_map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define F(i,s,e,j)        for(int i=s;i<=e;i+=j)
#define mt19937                 rng(chrono::steady_clock::now().tjhe_since_epoch().count());
//shuffle(arr,arr+n,rng)
 void c_p_c()
{
    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
}
int dp[16][1<<8][9][17];
int total_ways(int idx,int j,int mask1,int mask2,int n,int a,int b)
{
	if(idx==-1)
			return  mask1==0?1:0;

	if(j==0 && dp[idx][mask1][a][b]!=-1)
      return dp[idx][mask1][a][b];
	if(j==n)
	return total_ways(idx-1,0,mask2,0,n,a,b);
	if(mask1&(1<<j))
		return total_ways(idx,j+1,mask1,mask2,n,a,b);
	int ans = 0;
    if(j<n-1 && (mask1&(1<<(j+1)))==0 && a>0)
    	ans += total_ways(idx,j+2,mask1,mask2,n,a-1,b);
     if(idx>=1 && a>0)
       ans += total_ways(idx,j+1,mask1,mask2|(1<<j),n,a-1,b);
    if(b>0)
       ans += total_ways(idx,j+1,mask1,mask2,n,a,b-1);
    return dp[idx][mask1][a][b] = ans;
}
int32_t main()
{   c_p_c();
    int n,m,a,b;
    cin>>n>>m>>a>>b;
    memset(dp,-1,sizeof(dp));
    cout<<total_ways(m-1,0,0,0,n,a,b)<<endl;
}


#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <functional>
#include <numeric>
#include <iomanip>
#include <stdio.h>
//eolibraries
#define lnf 3999999999999999999
#define inf 999999999
#define PI 3.14159265359
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (ll)(c).size()
#define mkp(a,b) make_pair(a,b)
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define rsz(a,n) a.resize(n)
#define pii pair <ll,ll>
#define rep(i,n) for(ll i = 0 ; i < n ; i++)
#define drep(i,n) for(ll i = n-1 ; i >= 0 ; i--)
#define crep(i,x,n) for(ll i = x ; i < n ; i++)
#define vi vector <ll>
#define v(s) vector<s>
#define rsz(a,n) a.resize(n)
#define rszv(a,n,v) a.resize(n,v)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
//eodefine

const ll max_n = 100000;

using namespace std;
ll k,n,m;
vi a;

bool ok(ll x) {
	ll lo = 0 , hi = 0;
	rep(i,k) {
		ll p2 = (a[i]*m + x) / n;
		ll p1 = (a[i]*m - x + n - 1) / n;
		p1 = max((ll)0,p1);
		hi+=p2;
		lo+=p1;
	}
	return lo <= m and m <= hi;
}

int main(){
fcin;
	cin >> k >> n >> m;

	a.resize(k,0);

	rep(i,k)cin>>a[i];

	ll l = 0 , r = 1e15 , c = 0;

	while(l <= r) {
		ll mid = (l+r)/2;

		if(ok(mid)) {
			c = mid;
			r = mid - 1;
		}else {
			l = mid + 1;
		}
	}

	v(vi) candy;

	ll x = c;
	rep(i,k) {
		ll p2 = (a[i]*m + x) / n;
		ll p1 = (a[i]*m - x + n - 1) / n;
		candy.pb({p1,p2});
	}

	ll s = 0;

	for(auto p : candy) s += p[0];

	ll need = m - s;

	rep(i,k) {
		ll em = candy[i][0];
		candy[i][0] = min(candy[i][1] , candy[i][0] + need);
		need -= candy[i][0] - em;
	}

	rep(i,k) cout << candy[i][0] << " ";
/*
*/

    return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//optimal subsequences-2 technocup round-3 2020
using namespace std;
using namespace __gnu_pbds;
const int N=2e5+10;
//#define d double
#define F first
#define S second
#define ll long long int
#define FastIO ios_base::sync_with_stdio(false),cin.tie(0)
#define fix std::fixed<<setprecision(6)
const int M=1e9+7;
//const int M=998244353;
#define f(n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define vi vector<int>
#define pb push_back
//#define si set<int>
#define cl(n,m) (ceil(double(n)/double(m)))
#define T() int t; cin>>t; while(t--)
#define pi pair<ll,ll>
//int MOD=998244353;
//const int MOD=1e9+7;
#define endl "\n"
const double PI = 3.141592653589793238460;
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

//ll d1=304933,d2=4395853;

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

//bitset<N>bs;
//bitset<512>bb[512];
//vector<vector<int>>arr;
//#ifndef ONLINE_JUDGE
//freopen("input.txt", "r" , stdin);
//freopen("output.txt", "w", stdout);
//#endif

ll MOD;

ll power(ll a,ll b)
{
    ll res=1;
    if(a==1)return 1;
    for(;b>0;b>>=1)
    {
        if(b&1)res=(res*a);
        if(res>MOD)res%=MOD;
        a=(a*a);
        if(a>MOD)a=a%MOD;
    }
    return res;
}

bool isPrime[3000000+1];
vector<ll>prime;

vector<int>divisor;

void seive2(int limit)
{
    divisor=vector<int>(limit+1,0);

    for(int i=2;i<=limit;i++)
    {
        if(divisor[i]==0)
        {
            divisor[i]=i;
            if(i*1ll*i<=limit)
            for(int j=i*i;j<=limit;j+=i)divisor[j]=i;
        }
    }
}

void seive(int limit)
{
    isPrime[0]=isPrime[1]=1;

    for(int i=2;i*i<=limit;i++)
    {
        if(!isPrime[i])
        for(int j=i*i;j<=limit;j+=i)
        {
            isPrime[j]=1;
        }
    }
    for(int i=2;i<=limit;i++)if(!isPrime[i])prime.pb(i);
}

#define pii pair<ll,pi>
ll pt[200010],sz[200010],wt[200010];

int finds(int x)
{
    while(pt[x]!=x)
    {
        pt[x]=pt[pt[x]];
        x=pt[x];
    }
    return pt[x];
}

bool unions(int x,int y)
{
    int px=finds(x),py=finds(y);

    if(px==py)return 0;

    if(sz[px]>sz[py])swap(px,py);

    pt[px]=py;
    sz[py]+=sz[px];
    wt[py]+=wt[px];

    return 1;
}

ll bit[200100];

ll query(ll bit[],int x)
{
    ll ans=0;
    for(int i=x;i>0;i-=(i&(-i))){
        ans+=bit[i];
    }
    return ans;
}

void update(ll bit[],int x,ll val)
{
    for(int i=x;i>0;i-=(i&(-i)))
        bit[i]+=val;
}

void update2(ll bit[],int x,ll val)
{
    for(int i=x;i<=600005;i+=(i&(-i)))
        bit[i]+=val;
}

ll query2(ll sum[],int x)
{
    ll ans=0;
    for(int i=x;i<=200005;i+=(i&(-i)))
        ans+=sum[i];
    return ans;
}

void dfs(int s,vector<int>&v,vector<int>&P,int visited[])
{
    visited[s]=1;
    v.pb(s);

    int x=P[s];

    if(!visited[x])
    {
        dfs(x,v,P,visited);
    }
}

void solve()
{
    ll k,n,m;
    cin>>k>>n>>m;

    ll a[k+1];
    f(k)cin>>a[i+1];

    vector<ll>v;

    ll sum=0;

    f(k)
    {
        ll x=(a[i+1]*m+n-1)/n;
        v.pb(x);
        sum+=x;
    }

    set<pi>s;

    f(k)
    {
        ll b=v[i]-1;
        ll d=b*n-a[i+1]*m;
        s.insert({abs(d),i});
    }

    ll d=sum-m;

    while(d)
    {
        auto it=*s.begin();
        s.erase(it);

        int id=it.S;
        v[id]--;
        d--;
    }

    for(int x:v)cout<<x<<' ';

}

int main()
{
    //FastIO;

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

	for(int i=1;i<=t;i++)
    {
       // cout<<"Case #"<<i<<": ";
        solve();
        //if(i!=t)cout<<endl;
    }
	return 0;
}


#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
#define GETVEC(v) for(auto& m : v) cin >> m;
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int r1, c1, r2, c2; cin >> r1 >> c1 >> r2 >> c2;
	int ans = -1;
	if (r1 == r2 && c1 == c2)
	{
		ans = 0;
	}
	else if (abs(r1 - r2) + abs(c1 - c2) <= 3 || abs(r1 - r2) == abs(c1 - c2))
	{
		ans = 1;
	}
	else if ((r1 + c1) % 2 == (r2 + c2) % 2)
	{
		ans = 2;
	}
	else
	{
		ans = 3;
		for (int r = r1 - 2; r <= r1 + 2; ++r)
		{
			for (int c = c1 - 2; c <= c1 + 2; ++c)
			{
				if (abs(r - r2) + abs(c - c2) <= 3
					|| abs(r - r2) == abs(c - c2))
				{
					ans = 2;
				}
			}
		}
	}

	cout << ans << endl;
}

#include <bits/stdc++.h>

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  void solve() {
    LL x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 == x2 && y1 == y2) {
      cout << 0 << endl;
    } else if (x1 + y1 == x2 + y2 || x1 - y1 == x2 - y2 || abs(x1 - x2) + abs(y1 - y2) <= 3) {
      cout << 1 << endl;
    } else if (abs(x1 + y1 - x2 - y2) <= 3 || abs(x1 - y1 - x2 + y2) <= 3 || abs(x1 - x2) + abs(y1 - y2) <= 6 || (x1 + y1) % 2 == (x2 + y2) % 2) {
      cout << 2 << endl;
    } else {
      cout << 3 << endl;
    }
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);

  Problem::Solver sol;
  sol.solve();
  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

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

using namespace std;

typedef unsigned long long ull;

int main()
{
  ull x,y;
  cin>>x>>y;

  if(x==y){
    cout<<x;
  }else{
    switch(x+y){
      case 1:
        cout<<2;
        break;
      case 2:
        cout<<1;
        break;
      case 3:
        cout<<0;
        break;
    }
  }

  return 0;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
#define rrep1(i, n) for (int i = n; i >= 1; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define eb emplace_back
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
typedef long long int ll;
typedef pair<int, int> P;
// typedef modint1000000007 mint;

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 (b < a) {
        a = b;
        return true;
    }
    return false;
}

void speedUpIO() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
}
/*--------------------------------------------------*/

void solve() {
    int n, m;
    cin >> n >> m;
    V<int> a(n);
    rep(i, n) cin >> a[i];
    V<int> cnt(n + 1);
    rep(i, m) cnt[a[i]]++;
    int ans = n;
    rep(i, n) {
        if (cnt[i] == 0) {
            ans = i;
            break;
        }
    }
    for (int i = 1; i <= n - m; i++) {
        int l = i - 1;
        int r = i + m - 1;
        // if (cnt[a[l]] == 0) chmin(ans, a[l]);
        cnt[a[l]]--;
        cnt[a[r]]++;
        if (cnt[a[l]] == 0) chmin(ans, a[l]);
    }
    rep(i, n) {
        if (cnt[i] == 0) {
            chmin(ans, i);
            break;
        }
    }
    cout << ans << "\n";
}

int main() {
    speedUpIO();
    solve();
    return 0;
}


#include<cstdio>
using namespace std;
long double f=1.08;
int n,m;
int main(){
	scanf("%d",&n);
	m=n*f;
	if(m<206)printf("Yay!");
	else if(m==206)printf("so-so");
	else printf(":(");
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
long long n,cnt,sum,ans;
bool u[100005];
int main()
{
	cin>>n;
	ans=n;
	cnt=2;
	while(cnt*cnt<=n)
	{
		if(u[cnt]==1)
		{
			cnt++;
			continue;
		}
		sum=cnt*cnt;
		while(sum<=n)
		{
			if(sum<=100000)u[sum]=1;
			ans--;
			sum*=cnt;
		}
		cnt++;
	}
	cout<<ans;
    return 0;
}


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

#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
//const ll MOD = 998244353;

void solve() {
    ll l, r;   cin >> l >> r;
    ll ma = r, mi = l + l;
    if(ma < mi){
        print(0);
        return;
    }
    print((ma - mi + 1) * (ma - mi + 2) / 2);
    return;
}

int main(){
    int t;  cin >> t;
    while(t--) solve();
    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define irreps(i, m, n) for (int i = ((int)(n)-1); i > (int)(m); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) (int)(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;
using ld = long double;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll LINF = 1e18;

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

  int n; cin>>n;

  vpll v(n);
  rep(i,n){
    ll x,c; cin>>x>>c;
    v[i]={c,x};
  }
  vsort(v);
  set<ll> s;
  map<ll,ll> ma,mi;
  for(auto e: v){
    ll c,x; tie(c,x)=e;
    if(!s.count(c)) ma[c]=x;
    else chmax(ma[c],x);
    if(!s.count(c)) mi[c]=x;
    else chmin(mi[c],x);
    s.insert(c);
  }

  vc<ll> x;
  for(auto e: s) x.push_back(e);

  int m=s.size();
  vc<vc<ll>> dp(m+1,vc<ll>(2));

  rep(i,m){
    ll L=LINF, R=LINF;
    ll now=x[i];
    if(i==0){
      R=abs(mi[now])+abs(ma[now]-mi[now]); // 左行ってから右
      L=abs(ma[now])+abs(ma[now]-mi[now]);
      dp[i+1][1]=R;
      dp[i+1][0]=L;
    }else{
      ll pre=x[i-1];
      R=dp[i][1]+abs(ma[now]-mi[now])+abs(ma[pre]-mi[now]);
      chmin(R,dp[i][0]+abs(ma[now]-mi[now])+abs(mi[pre]-mi[now]));
      L=dp[i][1]+abs(ma[now]-mi[now])+abs(ma[pre]-ma[now]);
      chmin(L,dp[i][0]+abs(ma[now]-mi[now])+abs(mi[pre]-ma[now]));
      dp[i+1][1]=R;
      dp[i+1][0]=L;
    }
  }

  // cout<<mi[x[m-1]]<<' '<<ma[x[m-1]]<<endl;

  ll ans=LINF;
  chmin(ans, dp[m][0]+abs(mi[x[m-1]]));
  chmin(ans, dp[m][1]+abs(ma[x[m-1]]));
  cout<<ans<<endl;
}


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

typedef long long LL;

const int N=3000,mod=998244353;

int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}

int n,m;

void into(){
  scanf("%d%d",&n,&m);
}

int dp[N+9][N*2+9];

void Get_dp(){
  dp[0][0]=1;
  for (int i=1;i<=n;++i)
	for (int j=n;j>=1;--j) dp[i][j]=add(dp[i-1][j-1],dp[i][j<<1]);
}

void work(){
  Get_dp();
}

void outo(){
  printf("%d\n",dp[n][m]);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

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

int main (){

  #ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1","r",stdin);
  #endif

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int a, b;
  cin >> a >> b;
  int t = 1;
  if (a < b) {
  	swap(a, b);
  	t = -1;
  }
	for (int i = 1; i <= a; ++i) {
		cout << i * t << " ";
	}
	t = ~t ? -1 : 1;
	for (int i = 1; i < b; ++i) {
		cout << i * t << " ";
	}
	cout << (a - b + 1) * (a + b) / 2 * t;

  return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

struct node{
  int f,s;
  node(int ff=1,int ss=0){f=ff,s=ss;}
  node& operator+=(node a) {
    if((f+s)%2){f+=a.f; s+=a.s;}
    else{f+=a.s; s+=a.f;}
    return *this;
  }
};

const int operator<(const node& n1,const node& n2){
  int p1=(n1.f+n1.s)%2,p2=(n2.f+n2.s)%2;
  if(p1==p2){
    return n1.f-n1.s<n2.f-n2.s;
  }
  if(p1==0) return n1.f-n1.s<0;
  return n2.f-n2.s>=0;
}

void dfs(vector<vector<int>>& adj, vector<node>& game,int a=0){
  if(adj[a].size()==0) return;

  for(int v:adj[a]){
    dfs(adj,game,v);
  }
  sort(adj[a].begin(),adj[a].end(),
       [&](int i,int j){return game[i]<game[j];});
  for(int v:adj[a]){
    game[a]+=game[v];
  }
}

int main(){
  int n; cin >>n;
  vector<vector<int>> adj(n);
  rep(i,n-1){
    int p; cin >>p; p--;
    adj[p].push_back(i+1);
  }
  vector<node> game(n);
  dfs(adj,game);
  print(game[0].f);
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cctype>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <ctime>
#define _for(i,a,b) for(int i=(a);i<(b);++i)
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
inline int read_int(){
	int t=0;bool sign=false;char c=getchar();
	while(!isdigit(c)){sign|=c=='-';c=getchar();}
	while(isdigit(c)){t=(t<<1)+(t<<3)+(c&15);c=getchar();}
	return sign?-t:t;
}
inline LL read_LL(){
	LL t=0;bool sign=false;char c=getchar();
	while(!isdigit(c)){sign|=c=='-';c=getchar();}
	while(isdigit(c)){t=(t<<1)+(t<<3)+(c&15);c=getchar();}
	return sign?-t:t;
}
inline char get_char(){
	char c=getchar();
	while(c==' '||c=='\n'||c=='\r')c=getchar();
	return c;
}
inline void write(LL x){
	char c[21],len=0;
	if(!x)return putchar('0'),void();
	if(x<0)x=-x,putchar('-');
	while(x)c[++len]=x%10,x/=10;
	while(len)putchar(c[len--]+48);
}
inline void space(LL x){write(x),putchar(' ');}
inline void enter(LL x){write(x),putchar('\n');}
const int MAXN=1e5+5;
int sz[MAXN],dp[MAXN];
struct Edge{
	int to,next;
}edge[MAXN];
int head[MAXN],edge_cnt;
void Insert(int u,int v){
	edge[++edge_cnt]=Edge{v,head[u]};
	head[u]=edge_cnt;
}
struct Node{
	int d1,d2;
	bool operator < (const Node &b)const{
		return (d1-d2)>(b.d1-b.d2);
	}
};
void dfs(int u){
	sz[u]=1;
	int d1=0,d2=0;
	vector<Node> temp;
	for(int i=head[u];i;i=edge[i].next){
		int v=edge[i].to;
		dfs(v);
		sz[u]+=sz[v];
		if(sz[v]%2==0){
			if(dp[v]*2>=sz[v])
			dp[u]+=dp[v];
			else
			d1+=sz[v]-dp[v],d2+=dp[v];
		}
		else
		temp.push_back(Node{dp[v],sz[v]-dp[v]});
	}
	sort(temp.begin(),temp.end());
	for(int i=0;i<temp.size();i++){
		if(i%2==0)
		dp[u]+=temp[i].d1;
		else
		dp[u]+=temp[i].d2;
	}
	if(temp.size()%2==0)
	dp[u]+=d2;
	else
	dp[u]+=d1;
}
int main()
{
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	int n=read_int();
	_rep(i,2,n)
	Insert(read_int(),i);
	dfs(1);
	enter(n-dp[1]);
	return 0;
}


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

int main()
{
    long long n;

    cin >> n;

    long long left = 0;
    long long right = 2e9;

    while (right - left > 1)
    {
        long long x = (left + right) / 2;
        if ((x * (x + 1)) / 2 <= n + 1)
        {
            left = x;
        }
        else
        {
            right = x;
        }
    }

    cout << n + 1 - left << endl;
}

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

string X;
ll M;

bool solve(ll mid) {
   ll res = 0;
   ll multiply = 1;
   for(ll i = X.length() - 1; i >= 0; i--) {
       ll x = (X.at(i) - '0');
       if(multiply > (1e18 / x)) {
           return false;
       }
       if(res > 1e18 - x * multiply) {
           return false;
       }
       res += x * multiply;
       if(i != 0) {
           if(multiply > 1e18 / mid) {
               return false;
           }
           multiply *= mid;
       }
   }
   return (res <= M);
}

int main() {
    cin >> X;
    cin >> M;
    if(X.length() == 1) {
        ll num = X.at(0) - '0';
        if(num <= M) {
           cout << 1 << endl;
           return 0;
        }
        cout << 0 << endl;
        return 0;
    }
    ll d = 0;
    for(const char &c : X) {
        d = max(d, (ll)(c - '0'));
    }
    ll ok = d;
    ll ng = (long double)(1e18) + 1;
    while(abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if(solve(mid)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok - d << endl;
    return 0;
}


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

ll r, x, y;

int main()
{
    cin >> r >> x >> y;
    double d = sqrt(x * x + y * y);
    double num = d / r;
    double temp = d - ((ll)num * r);
    // cout << d << " " << num << " " << temp << endl;
    if (temp == 0)
        cout << (ll)num << endl;
    else
    {
        if ((ll)num == 0)
            cout << 2 << endl;
        else
            cout << (ll)num + 1 << endl;
    }
}

#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <stack>
#include <queue>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	int n;
	string s,t;
	cin >> n >> s >> t;

	ll ans = 0;
	queue<int> q;
	if(s[0]!=t[0]){
		q.push(0);
	}
	FOR(i,1,n){
		if(s[i]=='1' && !q.empty()){
			int x = q.front();
			q.pop();
			ans += i-x;
			s[i]='0';
		}

		if(s[i]!=t[i]){
			q.push(i);
		}
	}

	if(q.empty()){
		cout << ans << endl;
	}else{
		cout << "-1\n";
	}

	return 0;
}


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

vector<int> BFS(int n, vector<vector<int>>& paths, int& N) {
    // BFSで宝石nから各宝石までの距離を求める
    vector<int> dist(N, INT_MAX); dist[n] = 0;
    set<int> visited; visited.insert(n);
    deque<int> que; que.push_back(n);
    while(!que.empty()) {
        int now = que.front();
        que.pop_front();

        for (int nx: paths[now]) {
            if (visited.count(nx)) continue;
            visited.insert(nx);
            dist[nx] = min(dist[nx], dist[now]+1);
            que.push_back(nx);
        }
    }
    return dist;
}

void solve2(){
    int N, M; cin >> N >> M;
    vector<vector<int>> paths(N);
    for (int i=0; i<M; i++) {
        int A, B; cin >> A >> B; A--; B--;
        paths[A].push_back(B);
        paths[B].push_back(A);
    }

    int K; cin >> K;
    vector<int> Cs(K);
    for (int i=0; i<K; i++) {
        int C; cin >> C; C--;
        Cs[i] = C;
    }

    vector<vector<int>> dists;
    for (int i=0; i<K; i++) {
        dists.emplace_back(BFS(Cs[i], paths, N));  // 始点cからの最短距離を求める
    }

    // for (int i=0; i<K; i++) {
    //     cout << "FROM:" << Cs[i] << endl;
    //     for (int j=0; j<K; j++) {
    //         cout << Cs[j] << ":" << dists[i][Cs[j]] << endl;
    //     }
    // }

    // bitDP[S][i] := 既に訪れた重要宝石集合Sにおいて、現在の重要宝石がiのときの、最短距離
    vector<vector<int>> dp(1<<K, vector<int>(K, INT_MAX));
    for (int i=0; i<K; i++) {
        dp[0][i] = 0;
    }
    for (int i=0; i<K; i++) {
        for (int j=0; j<K; j++) {
            dp[(1<<i)|(1<<j)][j] = dists[i][Cs[j]];
        }
    }
    for (int S=1; S<(1<<K); S++) {
        for (int i=0; i<K; i++) {  // 現在の宝石i
            if (~S>>i&1) continue;  // iはまだ訪れていない
            for (int j=0; j<K; j++) {  // 次に行く宝石j
                if (S>>j&1) continue;  // jは既に訪れている
                int new_cost = dp[S][i]+dists[i][Cs[j]];
                if (new_cost<0) new_cost = INT_MAX;  // オーバーフロー対策
                dp[S|1<<j][j] = min(dp[S|1<<j][j], new_cost);
            }
        }
    }

    // 答え
    int ans = INT_MAX;
    for (int i=0; i<K; i++) {
        ans = min(ans, dp[pow(2,K)-1][i]);
    }
    if (ans == INT_MAX) {
        cout << -1 << endl;
    }
    else {
        cout << ans+1 << endl;
    }
}

int main(int argc, char const *argv[]){
    solve2();
    return 0;
}

// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

int main() {
    int N, M; cin >> N >> M;
    vector<ll> A(N);
    for(auto &e : A) cin >> e;

    using Edge = int;
    using Graph = vector< vector< Edge > >;
    Graph G(N);
    vector<int> deg(N);
    for(int i=0; i<M; i++) {
        int u, v; scanf("%d%d", &u, &v);
        u--; v--;
        G[v].emplace_back(u);
        deg[u]++;
    }

    vector<ll> dp(N, -LONGINF);
    queue< pair<ll, ll> > que;
    for(int i=0; i<N; i++) {
        if(deg[i] == 0) {
            que.emplace(i, dp[i]);
        }
    }
    while(que.size()) {
        ll cur, cost; tie(cur, cost) = que.front(); que.pop();
        for(auto to : G[cur]) {
            chmax(dp[to], max(dp[cur], A[cur]));
            if(--deg[to] == 0) {
                que.emplace(to, dp[to]);
            }
        }
    }
    ll ans = -LONGINF;
    for(int i=0; i<N; i++) {
        chmax(ans, dp[i] - A[i]);
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

int start[100005], finish[100005];

int main()
{
 	//freopen("input.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
 	ios_base::sync_with_stdio(0); cin.tie(0);
 	int n, len;
 	cin >> n >> len;
 	for (int i = 1; i <= n; i++) cin >> start[i];
 	for (int i = 1; i <= n; i++) cin >> finish[i];
 	start[n + 1] = len + 1, finish[n + 1] = len + 1, start[0] = 0, finish[0] = 0;

	queue <int> qu;
	ll ans = 0;
	for (int i = 0; i <= n + 1; i++)
	{
	 	if (start[i] > finish[i] && !qu.empty()) cout << "-1\n", exit(0);
	 	if (!qu.empty() && start[i] - finish[qu.front()] == i - qu.front()) ans += (ll) qu.size();
	 	while (!qu.empty() && start[i] - finish[qu.front()] == i - qu.front()) qu.pop();
	 	if (start[i] == finish[i] && !qu.empty()) cout << "-1\n", exit(0);
	 	if (i == n + 1) break;
		if (start[i] < finish[i]) qu.push(i);
	}
	for (int i = n + 1; i >= 0; i--)
	{
	 	if (start[i] < finish[i] && !qu.empty()) cout << "-1\n", exit(0);
	 	if (!qu.empty() && finish[qu.front()] - start[i] == qu.front() - i) ans += (ll) qu.size();
	 	while (!qu.empty() && finish[qu.front()] - start[i] == qu.front() - i) qu.pop();
	 	if (start[i] == finish[i] && !qu.empty()) cout << "-1\n", exit(0);
	 	if (i == 0) break;
        if (start[i] > finish[i]) qu.push(i);
	}
	cout << ans << '\n';
 	return 0;
}

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

bool yes;
LL X[100011], Y[100011];
LL solve(int len) {
    if (len <= 1) return 0;
//    rprintf("%lld", X, X+len);
//    rprintf("%lld", Y, Y+len);

    LL ret = len - 1;
    int left = 0;
    for (int i=1; i<len; ) {
	int j = i;
	while (j < len && Y[i] == Y[j]) j++;
	while (X[left] <= Y[i]) left++;

	if (left && X[left-1] == Y[i]) {
	    ret += i - left;
	} else {
	    yes = false;
	    return 0;
	}

	i = j;
    }

    return ret;
}

int N;
LL L;
LL A[100011];
LL B[100011];

void MAIN() {
    scanf("%d%lld", &N, &L);
    A[0] = B[0] = 0;
    REP (i, N) scanf("%lld", A+i+1);
    REP (i, N) scanf("%lld", B+i+1);
    N += 2;
    A[N-1] = B[N-1] = L+1;

    REP (i, N) {
	A[i] -= i;
	B[i] -= i;
    }

    yes = true;
    LL ans = 0;
    for (int i=0; i<N && yes; ) {
	int j = i + 1;
	while (B[j] < A[j]) j++;

	int len = j - i;
	REP (a, len) {
	    X[a] = A[i+a] - A[i];
	    Y[a] = B[i+a] - B[i];
	}
	ans += solve(len);

	int k = j;
	while (A[k] < B[k]) k++;
	if (B[k] < A[k]) {
	    yes = false;
	    break;
	}

	len = k - j + 1;
	REP (a, len) {
	    X[a] = A[k] - A[k-a];
	    Y[a] = B[k] - B[k-a];
	}
	ans += solve(len);

	i = k;
    }

    if (yes) {
	printf("%lld\n", ans);
    } else {
	puts("-1");
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}


// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define PA pair<int, int>
typedef long long ll;
#define rep(i, z, n) for(int i = z; i < n; i++)
//const ll INF = 1e9;
const ll INF = 1000000007;
//const ll MOD = 9223372036854775807;
//const ll MOD2 = 998244353;
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; }
using namespace std;

/*
long long powmod(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1){
            ret *= x;  // n の最下位bitが 1 ならば x^(2^i) をかける
            ret %= MOD;
        }
        x *= x;
        x %= MOD;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

ll nikou(ll A, ll B){
    //B Combination A
    ll x = 1, y = 1;
    rep(i, 0, A){
        x *= (B - i);
        y *= (i + 1);
        x %= MOD;
        y %= MOD;
    }
    y = powmod(y, MOD - 2);
    return x * y % MOD;
}

ll comb(int n, int r) {
    vector<vector<long long>> v(n + 1,vector<long long>(n + 1, 0));
    for (int i = 0; i < v.size(); i++) {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int j = 1; j < v.size(); j++) {
        for (int k = 1; k < j; k++) {
            v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
        }
    }
  return v[n][r];
}
*/

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M);

    if(M == 0){
        cout << 1 << endl;
        return 0;
    }

    rep(i, 0, M){
        cin >> A[i];
    }
    sort(all(A));
    int vac = A[0] - 1;
    if(vac == 0) vac = INF;
    rep(i, 0, M - 1){
        if(A[i + 1] - A[i] == 1) continue;
        vac = min(vac, A[i + 1] - A[i] - 1);
    }
    if(A[M - 1] != N){
        vac = min(vac, N - A[M - 1]);
    }

    //cout << vac << endl;

    if(vac == INF){
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;

    if(A[0] != 1){
        ll x = A[0] - 1;
        ans += ((x + vac - 1) / vac);
    }
    //cout << ans << endl;
    rep(i, 0, M - 1){
        if(A[i + 1] - A[i] == 1) continue;
        else{
            ll y = A[i + 1] - A[i] - 1;
            ans += ((y + vac - 1) / vac);
        }
    }
    //cout << ans << endl;
    if(A[M - 1] != N){
        ll z = N - A[M - 1];
        ans += ((z + vac - 1)/ vac);
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri();

	int res = 2000000000;
	for (int i = 0; i < 1 << (n - 1); i++) {
		int xored = 0;
		int ored = 0;
		for (int j = 0; j <= n; j++) {
			if (j < n) ored |= a[j];
			if (j == n || (i >> j & 1)) xored ^= ored, ored = 0;
		}
		res = std::min(res, xored);
	}

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


#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<string.h>
using namespace std;
long long int a[300001];
long long int b[300001];
long long int amax[200001];
string func0(string s);
string func1(string s);
string func2(string s);
int main() {

	int n;
	cin >> n;
	int bi[9] = { 1,2,4,8,16,32,64,128,256 };
	cout << bi[n] - 1 << endl;

	string ab[256], abold[256];

	int i, j;
	ab[0] = "AB";

	for (i = 2; i <= n; i++) {
		for (j = 0; j < 256; j++) {
			abold[j] = ab[j];
		}
		ab[0] = func0(abold[0]);
		for (j = 0; j < bi[i - 1] - 1; j++) {
			ab[j+1] = func1(abold[j]);
		}
		for (j = 0; j < bi[i - 1]-1; j++) {
			ab[j + bi[i - 1]] = func2(abold[j]);
		}
	}

	for (i = 0; i < bi[n]-1; i++) {
		cout << ab[i] << endl;
	}
	return 0;

}

string func0(string s) {
	return s + s;
}
string func1(string s) {
	int i;
	string t = "";
	for (i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			t = t + "AA";
		}
		else if(s[i] == 'B') {
			t = t + "BB";
		}
	}
	return t;
}
string func2(string s) {

	int i;
	string t = "";
	for (i = 0; i < s.size(); i++) {
		if (s[i] == 'A') {
			t = t + "AB";
		}
		else if (s[i] == 'B') {
			t = t + "BA";
		}
	}
	return t;

}

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (const T &i : v) os << i << ' ';
    return os;
}
void co() { cout << '\n'; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << '\n'; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
template <class T>
vector<T> Vec(int64_t a, int64_t x = 0) {
    return vector<T>(a, x);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1000000001;
constexpr ll LINF = 1000000000000000001;
constexpr ll MOD = 1000000007;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void) {
    ll n;
    cin >> n;
    auto a = Vec<ll>(n);
    rep(i, n) cin >> a[i];
    rep(i, n - 1) a[i + 1] += a[i];

    ll ans = 0, p = 0, max = 0;
    rep(i, n) {
        chmax(ans, p + max);
        p += a[i];
        chmax(ans, p);
        chmax(max, a[i]);
    }
    co(ans);

    return 0;
}


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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N)
        cin >> A[i];
    ll DP[N+1][2];
    ll numm[N+1]={0},nump[N+1]={0};
    memset(DP,0,sizeof(DP));
    DP[1][0] = A[0];
    nump[1] = 1;
    numm[1] = 0;
    for(int i=2;i<=N;i++){
        nump[i] = nump[i-1] + numm[i-1];
        numm[i] = nump[i-1];
        nump[i] %= MOD;
        numm[i] %= MOD;
        DP[i][0] = nump[i]*A[i-1];
        DP[i][0] %=MOD;
        DP[i][0] += DP[i-1][0] + DP[i-1][1];
        DP[i][0] %=MOD;
        DP[i][1] = DP[i-1][0] - numm[i]*A[i-1];
        if(i != N){
            while(DP[i][1] < 0)
                DP[i][1] += (ll)MOD*(ll)MOD;
        }
        DP[i][1] %=MOD;
    }

    ll ans = DP[N][0] + DP[N][1];
    while(ans < 0)
        ans += (ll)MOD * (ll)(MOD);
    ans %= MOD;
    cout << ans << endl;
}

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

#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define ff first
#define ss second
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define nn "\n"
#define sci(x) scanf("%d", &x)
#define LL_INF (1LL << 62)
#define INF (1 << 30)
#define SetBit(x, k) (x |= (1LL << k))
#define ClearBit(x, k) (x &= ~(1LL << k))
#define CheckBit(x, k) (x & (1LL << k))
#define mod 998244353
#define N 200005

int n;
ll z;
int x[105];
int dp[105][105][105];

int solve(int pos, int cnt, int rem, int k){
    if(cnt==k){
        if(rem==0) return 0;
        return -INF;
    }
    if(pos>=n) return -INF;

    if(dp[pos][cnt][rem]!=-1) return dp[pos][cnt][rem];

    int res = -INF;
  res = max(res, x[pos]+solve(pos+1, cnt+1, (k+(rem-x[pos])%k)%k, k));
    res = max(res, solve(pos+1, cnt, rem, k));

    return dp[pos][cnt][rem] = res;
}

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

    cin >> n >> z;
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }

    ll res = LL_INF;
    for(int i = 1; i <= n; i++){
        memset(dp, -1, sizeof dp);
        ll r = solve(0, 0, z%i, i);
        if(r>=0 && (z-r)%i==0) res = min(res, (z-r)/i);
    }

    cout << res << nn;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr long long INF = 1000000000 + 100;
constexpr long long LINF = 1000000000000000000 + 100;
#define all(x) (x).begin(),(x).end()
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using V = vector<T>;

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

int main(){
    int H, W, X, Y; cin >> H >> W >> X >> Y; X--, Y--;
    V<string> grid(H); rep(i, H)cin >> grid[i];

    int res = 1;
    rep(k, 4){
        int x = X, y = Y;
        while(1){
            x += dx[k], y += dy[k];
            if(x<0 or y<0 or x>=H or y>=W)break;
            if(grid[x][y]=='#')break;
            res++;
        }
    }
    cout << res << ln;
}

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

// find_by_order(k) returns the iterator to the kth largest element (start from 0)
// order_of_key(k) returns the number of elements in the set which are strictly less than the value k

using namespace std;
using namespace __gnu_pbds;

#define ff              first
#define ss              second
#define all(v)          v.begin(), v.end()
#define int             long long
#define pb              push_back
#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(x)      __builtin_popcountll(x)
#define rightmostbit(x) __builtin_ffsll(x)
#define mod             1000000007
#define inf             1e18
#define pi              3.141592653589793238
#define mk(a,n)         int n;cin>>n;vi a(n);for(int i=0;i<n;i++) cin>>a[i]
#define endl            "\n"
#define w(x)            int x; cin>>x; while(x--)

#define deb(...) cerr << "[" << #__VA_ARGS__ << "]: "; cerr << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]) { return N; } template<typename T> int SIZE(const T &t) { return t.size(); } string to_string(const string s, int x1 = 0, int x2 = 1e9) { return '"' + ((x1 < s.size()) ? s.substr(x1, x2 - x1 + 1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c) { return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1 = 0, int x2 = 1e9) { string t = ""; for (int __iii__ = min(x1, SIZE(b)),  __jjj__ = min(x2, SIZE(b) - 1); __iii__ <= __jjj__; ++__iii__) { t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1 = 0, int x2 = 1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if (l_v_l_v_l == 0) res += "\n"; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2 - x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if (e != l) { if (rnk > 1) { res += "\n"; t_a_b_s = l_v_l_v_l; }; } else { t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if (l_v_l_v_l == 0) res += "\n"; return res; } void dbgm() {;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T) { cerr << to_string(H) << " | "; dbgm(T...); }
#define debm(...) cerr << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cerr << endl

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void g_b()
{
	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);
	freopen("error.txt", "w", stderr);
#endif
}

const int N = 2e5 + 6;

int32_t main()
{

	g_b();
	int h, w, x, y; cin >> h >> w >> x >> y;
	char a[h + 1][w + 1];
	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++)
			cin >> a[i][j];
	int ans = 0;
	ans += (a[x][y] == '.');
	for (int j = y + 1; j <= w; j++) {
		if (a[x][j] == '.') ans++;
		else break;
	}
	for (int j = y - 1; j >= 1; j--)
	{
		if (a[x][j] == '.') ans++;
		else break;
	}
	for (int i = x + 1; i <= h; i++) {
		if (a[i][y] == '.') ans++;
		else break;
	}
	for (int i = x - 1; i >= 1; i--)
	{
		if (a[i][y] == '.') ans++;
		else break;
	}
	cout << ans;
	return 0;

}