// 問題の URL を書いておく
//

#include <bits/stdc++.h>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = long long;

int main(int, const char**)
{
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    int ans = 0;
    rep(i, 1000)
    {
        auto t = i + 1;
        bool valid = true;
        rep(j, N)
        {
            if(!(A[j] <= t && t <= B[j]))
            {
                valid = false;
                break;
            }
        }
        if(valid) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n; cin >> n;
  int a = 0, b = 1000000;
  for (int i = 0; i < n; i++) {
    int a1; cin >> a1;
    a = max(a1, a);
  }
  for (int i = 0; i < n; i++) {
    int b1; cin >> b1;
    b = min(b1, b);
  }
  if (b < a) cout << 0;
  else cout << b - a + 1;
}


#include <bits/stdc++.h>

using namespace std;

#define flush cout.flush

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pl = pair<ll, ll>;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;
const ll mod2 = 998244353;
const ld eps = 1e-9;
const ld PI = acos(-1);

ld C = (ld) 9 / (ld) 20;
vector<ld> a;

ld f(ld x) {
    ld s = 0.0;
    for (auto &t : a) {
        s += x + t - min(t, 2.0 * x);
    }
    s /= a.size();
    return s;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    a.resize(n);
    for (ld &i :a)cin >> i;
    ld l = 0.0, r = 1e14 + 200;
    while (r - l > eps) {
        ld m1 = l + C * (r - l);
        ld m2 = r - C * (r - l);
        if (f(m2) > f(m1)) {
            r = m2;
        } else l = m1;
    }
    cout << fixed << setprecision(20);
    cout << f(l) << "\n";
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define DONTSYNC ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL) //dont use stdio with iostream functions //input and output are out of order now!
#define TEST unsigned long long T; cin>>T; while(T--)  //loop over each testcase
#define endl "\n"
#define fori(a,start,end) for(int a=start;a<end;a++)
#define forl(a,start,end) for(long long a=start;a<end;a++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef long long     ll;
typedef long double   ld;
typedef pair<int,int> pii;
typedef pair<ll,ll>   pll;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vii;
typedef vector<pll>   vll;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
const double PI = acos(-1);
ld calculate_prof(ld x,vector<ld> &arr,vector<ld> &pref){
    int n=arr.size()-1; ld prof=0;
    int r=lower_bound(all(arr),2*x)-arr.begin();
    prof=(n+1-r)*2*x + pref[r-1] - x*n;
    return prof;
}
void solve(){
    /* code */
    int n; cin>>n;
    vector<ld> arr(n+1),pref(n+1); pref[0]=0; arr[0]=0;
    ld tot=0;
    fori(i,1,n+1){
        cin>>arr[i];
        tot+=arr[i];
    }sort(all(arr));
    fori(i,1,n+1) pref[i]=arr[i]+pref[i-1];
    ld prof=0,x=0;
    fori(i,1,n+1){
        ld cur_prof;
        cur_prof=calculate_prof(arr[i]/2,arr,pref);
        if(cur_prof>prof) prof=cur_prof,x=arr[i]/2;
        // cur_prof=calculate_prof(arr[i],arr,pref);
        // if(cur_prof>prof) prof=cur_prof,x=arr[i];
    }
    cout<<fixed<<setprecision(6)<<(tot-prof)/n<<endl;
}

int main()
{
    DONTSYNC;
    // TEST
    solve();
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define allr(x)           (x).rbegin(),(x).rend()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define vi                vector<int>
#define vii               vector<pii>
#define mi                map<int,int>
#define mii               map<pii,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define el                '\n'

void solve()
{
    int n;
    cin>>n;
    vii v1,v2;
    rep(i,0,n){
      int x,y;
      cin>>x>>y;
      v1.pb({x,i});
      v2.pb({y,i});
    }
    sort(all(v1));
    sort(all(v2));

     int ans1=v1[n-1].fr-v1[0].fr;
     int ans2=v2[n-1].fr-v2[0].fr;
     int a,b;

     if(ans1>ans2){
      int ans=0;
         a=v1[n-1].sc;
         b=v1[0].sc;

         ans=max(ans,v1[n-1].fr-v1[1].fr);
         ans=max(ans,v1[n-2].fr-v1[0].fr);

         if((v2[n-1].sc==a&&v2[0].sc==b)||(v2[0].sc==a&&v2[n-1].sc==b)){
              ans=max(ans,v2[n-1].fr-v2[1].fr);
              ans=max(ans,v2[n-2].fr-v2[0].fr);
         }
         else{
          ans=max(ans,v2[n-1].fr-v2[0].fr);
         }
         cout<<ans<<el;
     }
     else if(ans2>ans1){
      vii vx=v1;
      v1=v2;
      v2=vx;
       int ans=0;
         a=v1[n-1].sc;
         b=v1[0].sc;

         ans=max(ans,v1[n-1].fr-v1[1].fr);
         ans=max(ans,v1[n-2].fr-v1[0].fr);

         if((v2[n-1].sc==a&&v2[0].sc==b)||(v2[0].sc==a&&v2[n-1].sc==b)){
              ans=max(ans,v2[n-1].fr-v2[1].fr);
              ans=max(ans,v2[n-2].fr-v2[0].fr);
         }
         else{
          ans=max(ans,v2[n-1].fr-v2[0].fr);
         }
         cout<<ans<<el;

     }
     else{
       int ans=0;
         a=v1[n-1].sc;
         b=v1[0].sc;

          if((v2[n-1].sc==a&&v2[0].sc==b)||(v2[0].sc==a&&v2[n-1].sc==b)){
              ans=max(ans,v1[n-1].fr-v1[1].fr);
              ans=max(ans,v1[n-2].fr-v1[0].fr);
               ans=max(ans,v2[n-1].fr-v2[1].fr);
              ans=max(ans,v2[n-2].fr-v2[0].fr);
              cout<<ans<<el;
         }
         else{
            cout<<ans1<<el;
         }

     }
}

signed main()
{

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

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

   while(t--) solve();
   return 0;
}

#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define INF63 1061109567
#define INF127 9187201950435737471
#define UINF 18446744073709551615
#define F first
#define S second
#define ll long long
#define N 100010
using namespace std;
ll n,m,mask[N],sz=0;
string s[N];
int main(){
	ll i,j;
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		cin>>s[i];
		for(j=0;j<m;j++)
		{
			if(s[i][j]=='1')
			{
				mask[i]|=(1<<j);
			}
		}
	}
	for(i=1;i<n;i++)
	{
		if(__builtin_popcount(mask[0]^mask[i])%2==1)
		{
			sz++;
		}
	}
	cout<<sz+sz*(n-1-sz)<<endl;
	return 0;
}


#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 fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define sz(c) (ll)(c).size()
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#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 vec(...) vector<__VA_ARGS__>
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
//eodefine
using namespace std;

const ll max_n = 903002;
struct dsuni {
    ll n;
    vector<ll> par, siz , color;

    dsuni(ll m) {
		init(m);
    }

    void init(ll m) {
    	n=m;
		par.resize(n,0); siz.resize(n,0); color.resize(n,0);
		rep(i,n) {
			par[i] = i; siz[i] = 1;
		}
    }

 	ll parent(ll x) {
	  return par[x] == x ? x : parent(par[x]);
	}

    ll getsize(ll x) {
    	return siz[parent(x)];
    }

    void mkuni(ll x , ll y , ll type = 0) {
		ll a = parent(x) , b = parent(y);
		if(a == b) return;
		if(siz[a] > siz[b]) {
		// rm(b);
			siz[a] += siz[b];
			par[b] = a;
			return;
		}
		// rm(a);
		siz[b] += siz[a];
		par[a] = b;
	}

 	bool isuni(ll x, ll y) {
		ll a = parent(x) , b = parent(y);
		return a == b;
	}
};
ll a[max_n];
int main(){
fcin;
	ll n;
	cin>>n;

	rep(i,n){
		cin>>a[i];
	}

	dsuni dsu(max_n);

	rep(i,n){
		dsu.mkuni(a[i],a[n-i-1]);
	}

	ll ans=0;

	rep(i,max_n){
		if(i==dsu.parent(i)){
			ans += max((ll)0,dsu.siz[i]-1);
		}
	}

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

//#define _DEBUG
#pragma GCC optimize("O2")
#include "bits/stdc++.h"
//#include <atcoder/all>
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,a5,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#define debug_6(x1,x2,x3,x4,x5,x6) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<", "#x6<<": "<<x6<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_6,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define prind(argument) cout<<std::fixed<<setprecision(13)<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define puba(a) emplace_back(a)
#define pubamp(a,b) emplace_back(mp(a,b))
typedef long long ll;
typedef long double ld;
using namespace std;
//using namespace atcoder;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
vint adj[1001][26];
bool connect[1001][1001]={};
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int N,M;
	int A[1001],B[1001];
	char C[1001];
	bool alre[1001][1001]={};
	scan(N>>M);
	rep(i,M){
		scan(A[i]>>B[i]>>C[i]);
		A[i]--; B[i]--;
		adj[A[i]][C[i]-'a'].puba(B[i]);
		adj[B[i]][C[i]-'a'].puba(A[i]);
		connect[A[i]][B[i]]=1;
		connect[B[i]][A[i]]=1;
	}
	if(connect[0][N-1]){
		prin(1);
		return 0;
	}
	vpint record;
	record.pubamp(0,N-1);
	alre[0][N-1]=alre[N-1][0]=1;
	int ans=INF;
	bool owari=0;
	for(int cnt=1;!record.empty();cnt++){
		vpint before=record;
		record.clear();
		for(const auto& pp:before){
			int u1=pp.first,u2=pp.second;
			debug(cnt,u1+1,u2+1);
			rep(k,26){
				for(const auto& v1:adj[u1][k]){
					for(const auto& v2:adj[u2][k]){
						if(alre[v1][v2]==0){
							alre[v1][v2]=1;
							alre[v2][v1]=1;
							if(v1==v2){
								chmin(ans,cnt*2);
								owari=1;
							}
							else if(connect[v1][v2]){
								chmin(ans,cnt*2+1);
								owari=1;
							}
							else record.pubamp(v1,v2);
						}
					}
				}
			}
		}
		if(owari){
			prin(ans);
			return 0;
		}
	}
	prin(-1);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
int main(){
  int n,x;
  cin >> n >> x;
  string s;
  cin >> s;
  rep(i,n){
    if(s.at(i) == 'o') x += 1;
    if(s.at(i) == 'x'){
      if(x != 0) x -= 1;
      else continue;
    }
  }
  cout << x << endl;
  return 0;
}

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

int main()
{
    int N, X;
    string S;
    cin >> N >> X >> S;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'o')
            X++;
        else
        {
            if (X > 0)
                X--;
        }
    }
    cout << X;
}


/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

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

#define mod 1000000007
#define pb push_back
#define ll long long int
#define ull unsigned ll
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse
#define itr iterator
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>

/*
const ll infinity = 9e18;

bool compare(ll a,ll b) {return a > b;}
bool compare1(ppl a,ppl b) {return a.ff > b.ff;}
bool compare2(ppl a,ppl b) {return a.ss < b.ss;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}

ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md = mod) {ll product = 1; while(b){if(b&1){product = (product*a)%md;}a = (a*a)%md;b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

    ll n,m;
    cin>>n>>m;

    vl a(n),b(m);

    forn(i,0,n)
    {
        cin>>a[i];
    }

    forn(i,0,m)
    {
        cin>>b[i];
    }

    sort(all(a));
    sort(all(b));

    ll mid = a[(n/2)];

    ll total = 0;

    vl c(n,0),d(n,0);

    for(int i = 1; i < n; i += 2)
    {
        c[i] = total + (a[i]-a[i-1]);
        if(i+1 < n) c[i+1] = c[i];
        total = c[i];
    }

    total = 0;

    for(int i = n-2; i >= 0; i -= 2)
    {
        d[i] = total + (a[i+1]-a[i]);
        if(i-1 >= 0) d[i-1] = d[i];
        total = d[i];
    }

    // p1d(c)
    // p1d(d)

    ll mini = inf;

    forn(i,0,m)
    {
        ll idx = upper_bound(all(a),b[i]) - a.begin();
        // test1(idx)

        ll x = idx-1 >= 0 ? c[idx-1] : 0;
        ll y = idx < n ? d[idx] : 0;

        if((idx&1))
        {
            // x = idx-1 >= 0 ? c[idx-1] : 0;
            // y = idx < n ? d[idx] : 0;
            // test1(a[idx-1])
            mini = min(mini,x + abs(b[i]-a[idx-1]) + y);
        }
        else
        {
            // test1(a[idx-1])
            mini = min(mini,x + abs(a[idx]-b[i]) + y);
        }

        // test3(x,y,x + abs(a[idx]-b[i]) + y)
    }

    cout<<mini;

    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 998244353
#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 stl stack<int64_t>
#define qul 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
#define pq priority_queue
#define pql priority_queue<int64_t>
#define pu push
#define pop pop()
#define top top()
#define pqr priority_queue<ll,vector<ll>,greater<ll>>
#define co cout
#define ci cin
#define wh while
#define size size()
#define front front()

int main() {
 ll a,b,m;
  m=0;
  cin>>a>>b;
  if(a>=b){
    fo(i,a){cout<<i+1<<" ";
           m+=i+1;}
    fo(i,b-1){cout<<-(i+1)<<" ";
             m+=-(i+1);}
    cout<<-m<<en;
  }
  else{
    fo(i,b){cout<<-(i+1)<<" ";
           m+=-(i+1);}
    fo(i,a-1){cout<<i+1<<" ";
             m+=i+1;}
    cout<<-m<<en;
  }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		int L,R;
		scanf("%d%d",&L,&R);
		if(R>=2*L)
			printf("%lld\n",(R-2*L+1ll)*(R-2*L+2)>>1);
		else
			puts("0");
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//#define mp make_pair
#define pb push_back
#define fp first
#define sp second
typedef long long int ll;
typedef pair<ll,ll> pp;

#define check(x, i) ((x>>i)&1LL)
#define set(x,i) (x|(1LL<<i))
#define unset(x,i) (x&~(1LL<<i))
#define INF LONG_MAX
#define MAX_N 20
#define MAX 200005
#define mod 1000000007
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i--)
#define len(i,s) for(i=0;s[i];i++)
#define T() ll t;cin>>t;while(t--)
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
ll gcd (ll a, ll b){return (a?gcd(b%a,a):b);}
ll pow1(ll a,ll b,ll MOD){ll ans=1;while(b!=0){if(b&1)ans=(ans*a)%MOD;a=(a*a)%MOD;b=b/2;}return ans;}
ll modInverse(ll a,ll p){return pow1(a,p-2,p);}
void ash(){
	boost
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

ll _mergeSort(ll arr[], ll temp[],
                 ll left, ll right);
ll merge(ll arr[], ll temp[], ll left,
                   ll mid, ll right);

/* This function sorts the
   input array and returns the
number of inversions in the array */
ll mergeSort(ll arr[], ll array_size)
{
    ll temp[array_size];
    return _mergeSort(arr, temp, 0, array_size - 1);
}

/* An auxiliary recursive function
  that sorts the input array and
returns the number of inversions in the array. */
ll _mergeSort(ll arr[], ll temp[],
                 ll left, ll right)
{
    ll mid, inv_count = 0;
    if (right > left) {
        /* Divide the array into two parts and
        call _mergeSortAndCountInv()
        for each of the parts */
        mid = (right + left) / 2;

        /* Inversion count will be sum of
        inversions in left-part, right-part
        and number of inversions in merging */
        inv_count += _mergeSort(arr, temp,
                                left, mid);
        inv_count += _mergeSort(arr, temp,
                             mid + 1, right);

        /*Merge the two parts*/
        inv_count += merge(arr, temp, left,
                           mid + 1, right);
    }
    return inv_count;
}

/* This funt merges two sorted arrays
and returns inversion count in the arrays.*/
ll merge(ll arr[], ll temp[], ll left,
          ll mid, ll right)
{
    ll i, j, k;
    ll inv_count = 0;

    i = left; /* i is index for left subarray*/
    j = mid; /* j is index for right subarray*/
    k = left; /* k is index for resultant merged subarray*/
    while ((i <= mid - 1) && (j <= right)) {
        if (arr[i] <= arr[j]) {
            temp[k++] = arr[i++];
        }
        else {
            temp[k++] = arr[j++];

            /* this is tricky -- see above
            explanation/diagram for merge()*/
            inv_count = inv_count + (mid - i);
        }
    }

    /* Copy the remaining elements of left subarray
(if there are any) to temp*/
    while (i <= mid - 1)
        temp[k++] = arr[i++];

    /* Copy the remaining elements of right subarray
(if there are any) to temp*/
    while (j <= right)
        temp[k++] = arr[j++];

    /*Copy back the merged elements to original array*/
    for (i = left; i <= right; i++)
        arr[i] = temp[i];

    return inv_count;
}
int main()
{
ash();
ll n;
cin>>n;
ll arr[n];
ll a1[n];
ll i;
REP(i,n)
{
cin>>arr[i];
a1[i]=arr[i];
}
    ll ans = mergeSort(arr, n);
    cout<<ans<<"\n";
   for(i=0;i<n-1;i++)
   {
   	ll sub=a1[i];
   	ll add=n-1-a1[i];
     ans=ans-sub+add;
    // cout<<sub<<" "<<add<<" ";
     cout<<ans<<"\n";
   }

}


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

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

const int p=1e9+7;

inline int ksm(int a,int b)
{
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%p)
		if(b&1) ans=1ll*ans*a%p;
	return ans;
}

int main()
{
	int n=read(),m=read();
	int sum=0;
	for(int i=1;i<=n;i++) sum+=read();
	int ans=1;
	sum+=n;
	n+=m;
	if(sum>n)
	{
		puts("0");
		return 0;
	}
	int t1=1,t2=1;
	for(int i=1;i<=sum;i++)
		t1=1ll*t1*(n-i+1)%p,t2=1ll*t2*i%p;
	printf("%d\n",1ll*t1*ksm(t2,p-2)%p);
	return 0;
}

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

const int 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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint C(ll x, ll y) {
    mint a = 1, b = 1;
    if (x < y) return 0;
    for (int i = 1; i <= y; i++)
        a = a * (x - i + 1);
    for (int i = 1; i <= y; i++)
        b = b * i;
    return a * b.inv();
}

int main(){
  ll n, m; cin >> n >> m;
  int s = 0;
  for(int i = 0; i < n; i++){
    ll a; cin >> a;
    s += a;
  }
  mint ans;
  ans = C(m+n, s+n); //二項係数a_C_bを計算する
  cout << ans << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;

signed main(){

    int N; cin >> N;
    string S, T; cin >> S >> T;
    vec s, t;
    int n1 = 0;
    REP(i, N){
        if(S[i] == '1') n1++;
        else s.pb(n1);
    }
    n1 = 0;
    REP(i, N){
        if(T[i] == '1') n1++;
        else t.pb(n1);
    }
    int ans;
    if(SZ(s) != SZ(t)) ans = -1;
    else{
        ans = 0;
        REP(i, SZ(s)) if(s[i] != t[i]) ans++;
    }
    Out(ans);

    return 0;
}

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

int main(){

  int n, x;
  cin >> n >> x;
  string str;
  cin >> str;

  for (int i=0; i<n; i++){
  	if (str[i]=='o'){
    	x++;
    }
    else if (str[i]=='x'){
    	x--;
    }
    x = max(x, 0);
  }

  cout << x << endl;
  return 0;
}


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

typedef long long ll;

typedef pair <int, int> pii;
typedef pair <ll,ll> pll;

typedef vector <int> vint;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef vector <string> vs;
typedef priority_queue <int> pqi;

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

#define pb push_back
#define mkp make_pair
#define vbb vector <bool>
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const int mod = 1000000007;
const long long inf = 1e18;
const char nl = '\n';

vector <vint> tree, util;
int tim = 0;
vint xin, xout, depth;

void dfs(int i){
    xin[i] = tim++;
    util[depth[i]].pb(xin[i]);
    for(int x : tree[i]){
        depth[x] = depth[i] + 1;
        dfs(x);
    }
    xout[i] = tim++;
}

void solve_it(){
    int n; cin>>n;
    vector <vint> temp(n + 1);
    FOR(i, 2, n + 1){
        int p; cin>>p;
        temp[p].pb(i);
    }
    util = vector <vint> (n + 1);
    tree = temp;
    xin = xout = depth = vint (n + 1);
    dfs(1);
    int q; cin>>q;
    while(q--){
        int u, d; cin>>u>>d;
        vint v = util[d];
        cout<<lb(all(v), xout[u]) - lb(all(v), xin[u])<<nl;
    }
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve_it();
    return 0;
}

// Problem: E - Count Descendants
// Contest: AtCoder - AISing Programming Contest 2021（AtCoder Beginner Contest 202）
// URL: https://atcoder.jp/contests/abc202/tasks/abc202_e
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Author: abhidot

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define w(x)  int x; cin>>x; while(x--)
using namespace std;
const long long N=200005, INF=2000000000000000000;

/*------------- Modular exponentiation -------------*/
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

/*------------- Sieve --------------*/
vector <int> prime;
bool is_composite[N];

void sieve (int n) {
	fill (is_composite, false);
	for (int i = 2; i < n; ++i) {
		if (!is_composite[i]) prime.push_back (i);
		for (int j = 0; j < prime.size () && i * prime[j] < n; ++j) {
			is_composite[i * prime[j]] = true;
			if (i % prime[j] == 0) break;
		}
	}
}

/*------------ Utitlity function ---------------*/
void print(bool n){
    if(n){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
}

vector<int> g[N], d[N];
int tin[N], tout[N], tim=0;

void dfs(int u, int depth=0){
	tin[u] = ++tim;
	d[depth].pb(tin[u]);
	for(auto v: g[u]){
		dfs(v, depth+1);
	}
	tout[u] = ++tim;
}

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    for(int i=2;i<=n;i++){
    	int p;
    	cin>>p;
    	g[p].pb(i);
    }

    dfs(1);

    w(T){
    	int u, k;
    	cin>>u>>k;
    	int l = tin[u], r = tout[u];
    	int ans = lower_bound(all(d[k]), r) - lower_bound(all(d[k]), l);
    	cout<<ans<<"\n";
    }
}

// Written by abhidot


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 10;
int a[maxn];
int main()
{
	int n, m, pos;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i) { scanf("%d", &pos); a[pos] ^= 1;}
	for(int i = 1; i <= m; ++i) { scanf("%d", &pos); a[pos] ^= 1;}
	for(int i = 1; i < maxn; ++i) if(a[i]) printf("%d ", i);
	return 0;
}

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

//#define FILE
#define int long long
#define debug(x) cout << #x << " = " << x << endl
#define file(FILENAME) freopen(FILENAME".in", "r", stdin), freopen(FILENAME".out", "w", stdout)
#define LINE() cout << "LINE = " << __LINE__ << endl
#define LL long long
#define ull unsigned long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fst first
#define scd second
#define inv(x) qpow((x),mod - 2)
#define lowbit(x) ((x) & (-(x)))
#define vec vector

const int MAXN = 60;
const int INF = 2e9;
const double PI = acos(-1);
const double eps = 1e-6;
//const int mod = 1e9 + 7;
//const int mod = 998244353;
//const int G = 3;
//const int base = 131;

int n, m, x;
int a[MAXN], cnt[MAXN], prod[MAXN];
int dp[MAXN][2][2];

template<typename T> inline bool read(T &a) {
	a = 0; char c = getchar(); int f = 1;
	while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
	while(c >= '0' && c <= '9') {a = a * 10 + (c ^ 48); c = getchar();}
	a *= f;
	return 1;
}

template<typename A, typename ...B>
inline bool read(A &x, B &...y) {return read(x) && read(y...);}

signed main () {
#ifdef FILE
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	read(n); read(x);
	int tmpx = x;
	for(int i = 1; i <= n; ++i) {
		read(a[i]);
		if(i != 1) prod[i - 1] = a[i] / a[i - 1];
	}
	prod[n] = INF;
	for(int i = n; i >= 1; --i) {
		cnt[i] = tmpx / a[i];
		tmpx %= a[i];
	}
	dp[0][0][0] = 1;
	for(int i = 1; i <= n; ++i) {//dp[i][j][k] 第i位放/不放 进位/不进位
		if(prod[i] == cnt[i] + 1) {
			dp[i][0][1] += dp[i - 1][0][1] + dp[i - 1][1][1];
			dp[i][1][1] += dp[i - 1][1][0] + dp[i - 1][0][0];
			dp[i][0][0] += dp[i - 1][0][0] + dp[i - 1][1][0];
		} else {
			dp[i][0][0] += dp[i - 1][1][0] + dp[i - 1][0][0];
			dp[i][0][0] += dp[i - 1][1][1] + dp[i - 1][0][1];
			if(cnt[i]) dp[i][1][1] += dp[i - 1][0][0] + dp[i - 1][1][0];
			dp[i][1][1] += dp[i - 1][0][1] + dp[i - 1][1][1];
		}
	}
	cout << dp[n][0][0] << endl;
	return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

template<typename temp>using ordered_set = tree<temp, null_type, less_equal<temp>, rb_tree_tag,tree_order_statistics_node_update>;
//order_of_key(k)  : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).//*(ost.find_by_order(k))

#define PI acos(-1)

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

const int M=1e5+5;
const int N=2e5+5;
const int mod=1e9+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c;
    cin >> a >> b;
    if(a == b)cout << a;
    else cout << 3-a-b;
    return 0;
}

/*
	Created on 19-12-20 15:05

	@author: roastedcoder
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int MOD = 1e9 + 7;
const int INF = INT_MAX;
const int MAX = 4e6 + 5;
const int N = 1e5 + 5;
//const int MAXX = 1e14;

#define ll long long
#define int ll
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pb push_back
#define mp make_pair
#define roastedcoder ios_base::sync_with_stdio(false); cin.tie(NULL);
int    dx[] = {-1,  0,  1,  0, -1, -1,  1,  1};
int    dy[] = { 0,  1,  0, -1, -1,  1,  1, -1};
char  dir[] = {'U','R','D','L'};
int power(int a, int b);
int powmod(int a, int b, int mod);
//__________________________________________________________________

//int main(){
int32_t main() {
	roastedcoder
	int n, w; cin>>n>>w;
	cout<<n/w<<endl;
}

//__________________________________________________________________
/*
Sample Input:

Sample Output:

*/

// Template Functions
int power(int a, int b) {
	int res = 1;
	while(b>0) {
		if(b%2) res *= a;
		b /= 2, a *= a; } return res;
}
int powmod(int a, int b, int mod) {
	int res = 1;
	while(b>0) {
		if(b%2) res = (res%mod * a%mod)%mod;
		b /= 2;
		a = (a%mod * a%mod)%mod;
	}
	return res%mod;
}


#include <bits/stdc++.h>
#define MAXN 80
#define MAXM 1048576

using namespace std;

int P[20] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71};

map <int,long long> mp[MAXN];

int main()
{
	long long A,B;
	cin>>A>>B;
	mp[0][0] = 1;
	for(long long i = A;i <= B;i++)
	{
		int sta = 0;
		for(int j=0;j<20;j++)
			if(i % P[j] == 0)
				sta += (1<<j);

		for(auto x:mp[i-A])
		{
			mp[i-A+1][x.first] += x.second;
			if((x.first & sta) == 0)
			{
				mp[i-A+1][x.first | sta] += x.second;
			}
		}
	}
	long long Ans = 0;
	for(auto x : mp[B-A+1])
		Ans += x.second;
	cout<<Ans;
	return 0;
}

//Challenge: Accepted
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#define ll long long
#define maxn 100005
#define pii pair<int, int>
#define ff first
#define ss second
using namespace std;
ll modpow(ll pow, ll mod) {
	ll ret = 1, mult = 10;
	while (pow) {
		if (pow & 1) ret = (ret * mult) % mod;
		mult = (mult * mult) % mod;
		pow >>= 1;
	}
	return ret;
}
int main() {
	ll n, m;
	cin >> n >> m;
	cout << modpow(n, m * m) / m << endl;
}


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

const string YES = "Yes";
const string NO = "No";

using ll = long long;

int main(){
    int N;cin >> N;
    vector<pair<int, int>> v1, v2;
    for(int i = 0;i < N;i++){
        int A, B;cin >> A >> B;
        v1.push_back(make_pair(A, B));
    }
    for(int j = 0;j < N;j++){
        int A, B;cin >> A >> B;
        v2.push_back(make_pair(A, B));
    }
    sort(v1.begin(), v1.end());
    static const double pi = 3.141592653589793;
    for(long double theta = 0;theta < 360;theta += 0.01){
        vector<pair<long double, long double>> p;
        for(int i = 0;i < N;i++){
            p.push_back(make_pair(cos(pi * theta / 180) * v2[i].first + -sin(pi * theta / 180) * v2[i].second, sin(pi * theta / 180) * v2[i].first + cos(pi * theta / 180) * v2[i].second));
        }
        sort(p.begin(), p.end());

        vector<long double> X_diff, Y_diff;
        for(int i = 0;i < N;i++){
            X_diff.push_back(p[i].first - v1[i].first);
            Y_diff.push_back(p[i].second - v1[i].second);
        }
        if(*max_element(X_diff.begin(), X_diff.end()) - *min_element(X_diff.begin(), X_diff.end()) <= 0.01 && *max_element(Y_diff.begin(), Y_diff.end()) - *min_element(Y_diff.begin(), Y_diff.end()) <= 0.01){
            cout<<YES<<endl;
            return 0;
        }
    }
    cout<<NO<<endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T1, class T2> inline bool chmax(T1 &a, const T2 &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T1, class T2> inline bool chmin(T1 &a, const T2 &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);cerr<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T> void verr(const set<T> &st) { repa(a, st) cerr << a << " "; cerr << endl; }
template <class S, class T> void verr(const map<S, T> &mp) { repa(a, mp) cerr << "{" << a.first << ", " << a.second << "} "; cerr << endl; }
template <class S, class T, class N> void verr(const vector<pair<S,T>>& a, const N& n) { rep(i, n) cerr << "{" << a[i].first << ", " << a[i].second << "} "; cerr << endl; }
template <class T, class N> void verr(const vector<T>& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << endl; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << endl; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-6;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    ll N;
    cin >> N;
    vc<complex<ld>> S(N), T(N);
    rep(i, N) {
        ld a, b;
        cin >> a >> b;
        S[i] = {a, b};
    }
    rep(i, N) {
        ld a, b;
        cin >> a >> b;
        T[i] = {a, b};
    }

    complex<ld> sc(0, 0), tc(0, 0);
    rep(i, N) sc += S[i], tc += T[i];
    sc /= N, tc /= N;

    rep(i, N){
        S[i] -= sc;
        T[i] -= tc;
    }
    rep(i, N) rep(k, 2){
        vc<complex<ld>> ss(N), tt(N);
        rep(si, N) ss[si] = S[si] * polar(1.0L, -arg(S[k]));
        rep(ti, N) tt[ti] = T[ti] * polar(1.0L, -arg(T[i]));

        bool ok = true;
        rep(si, N) {
            bool isok = false;
            rep(ti, N){
                if (abs(ss[si] - tt[ti]) < EPS) isok = true;
            }
            if(!isok){
                ok = false;
                break;
            }
        }
        if(ok){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}


#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cout << #x << " " << x << endl;
#define debl(x) std::cout << #x << " " << x << " ";
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}

void solve(){
    ll n;
    cin >> n;
    ll ans = n + 1;
    ll l = 1, r = 5e9;
    while( l + 1 < r){
        ll md = (l + r) / 2;
        ll sum = md * (md + 1)/ 2;
        if(sum == ans){
            l = md;
            cout << ans - l << endl;
            return;
        }else if ( sum > ans){
            r = md - 1;
        }else{
            l = md;
        }
    }
    if ( ans >= r * ( r + 1) / 2){
        cout << ans - r << endl;
    }else{
        cout << ans - l << endl;
    }
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}

#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include <utility>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,l,n) for(ll i=(l);i<(n);i++)
#define per(i,n) for(ll i=(n);i>0;i--)
#define pf(n) printf("%d\n",n)
#define pf_(a) printf("%d  ",a);
#define all(v) begin(v),end(v)
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);
const ll mod = 1000000007;

struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n) {
		rep(i, n) par[i] = i;
	}
	int root(int x) {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		par[rx] = ry;
	}
	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main() {
	ll n;
	cin >> n;
	ll a = n + 1;
	ll i = 1;
	ll cnt = 0;
	while (a >= i) {
		a -= i;
		i++;
		cnt++;
	}
	cout << n - cnt +1 << endl;

	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=2e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
//inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
inline char gc(){return getchar();}
inline int read(){
	int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;if(nc<0)return nc;
	x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48);return x*ny;
}
int n;char s[MAXN];
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	for(int t=read();t--;){
		n=read(),scanf("%s%s%s",s+1,s+1,s+1);
		Rep(i,1,n)cout<<'0';Rep(i,1,n)cout<<'1';cout<<'0';puts("");
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        string a,b,c;
        cin>>a>>b>>c;
        for(int i=0;i<n;i++)
        cout<<"0";
        for(int i=0;i<n;i++)
        cout<<"1";
        cout<<"0\n";
    }
}


// Murabito-B 21/04/12
#include <bits/stdc++.h>
using namespace std;
using ll    = long long;
const int N = 100005;
int n, c[N], cnt[N];
bool good[N];
vector<int> to[N];
void dfs(int u, int fa) {
    if (cnt[c[u]] == 0) good[u] = true;
    cnt[c[u]]++;
    for (int i = 0, v; i < to[u].size(); i++)
        if ((v = to[u][i]) != fa) dfs(v, u);
    cnt[c[u]]--;
}
void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> c[i];
    for (int i = 1, u, v; i < n; ++i) cin >> u >> v, to[u].push_back(v), to[v].push_back(u);
    dfs(1, 0);
    for (int i = 1; i <= n; ++i)
        if (good[i]) cout << i << "\n";
}
int main() {
    ios_base::sync_with_stdio(false), cin.tie(0);
    solve();
    return 0;
}

#include <algorithm>
#include <array>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>

using namespace std;

#define enviar {ios_base::sync_with_stdio(false);}
#define aiuda {cin.tie(NULL); cout.tie(NULL);}

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) ;F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)
#define exacto(v) cout << setprecision(v) << fixed;

#define ll long long
#define lld long double
#define eb emplace_back
#define em emplace
#define ef emplace_front
#define f first
#define s second
#define big greater<ll>()
#define bpc(x) __builtin_popcount(x)
#define bpc2(x) __builtin_clz(x)
#define DIE(args...) {print(args); return;}

#define ar(v)  array<int,v>
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x).size()
#define meminf(v) memset(v,  0x3f , sizeof(v))
#define mem(v,x) memset(v , x , sizeof v);
#define ai(a, n) for (int ele = 0; ele < n; ele++) cin >> a[ele];
#define ao(a, n) {for (int ele = 0; ele < (n); ele++) { if (ele) cout << " "; cout << a[ele]; } cout << '\n';}
#define readgraph(list, edges) for (int i = 0; i < edges; i++) {int n1, n2; cin >> n1 >> n2; n1--; n2--; list[n1].eb(n2); list[n2].eb(n1);}

template <typename T>
struct combinator {
    T t_;
    combinator(T&& t) : t_(std::forward<T>(t)) {}

    template <typename... Args>
    auto operator () (Args&&... args) const
    {
        return t_(*this, std::forward<Args>(args)...);
    }
};

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

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

string to_string(char c) { return string(1, c);}

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

string to_string(string s) { return s; }

template<class T> string to_string(T v) { bool f=1; string res; EACH(x, v) { if(!f) res+=' '; f=0; res+=to_string(x); } return res; }

template<class A> void write(A x) { cout << to_string(x); }

void print() { write("\n"); }

template<class H, class... T> void print(const H& h, const T&... t) {  write(h); if(sizeof...(t)) write(' '); print(t...); }

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef priority_queue<int, std::vector<int>, std::greater<int>> priomin;

const ll mod = 998244353;
const ll maxsize =3e5 + 10;
const ll inf = 0x3f3f3f3f3f3f3f3f ;
// size, caracter

ll c[maxsize];

bool sieve[100];
vll primes(100);

ll m;
void solve()
{
	ll n  ; cin >> n;
	string s, t;
	cin >> s >> t;

	set <ll> st;

	reverse(all(t));
	reverse(all(s));
	st.em(0);
	//  2 3 4 6 8
	//        1
	//        2
	//        3
	FOR(i , n)
	{
		set<ll> nst;
		if (t[i] == 'A')
		{
			FOR(j , 7)
			{
				ll a = (j*10 + (s[i] - '0') )% 7;
				ll b = (j*10) % 7 ;
				if ( st.count(a) && st.count(b))
				{
					nst.em(j);
				}
			}
		}
		else
		{
			FOR(j , 7)
			{
				ll a = (j*10 + (s[i] - '0') )% 7;
				ll b = (j*10) % 7 ;
				if ( st.count(a) || st.count(b))
				{
					nst.em(j);
				}
			}

		}
		st = nst;
	}

	//for(ll i : st)
	//{
		//print(i);
	//}
	if (st.count(0)) print("Takahashi");
	else print("Aoki");

}

int main(){

	enviar aiuda

	int tc = 1;
	//cin >> tc;

    while(tc--)  solve();

	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>

using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()

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

int main(){

    ll N;
    cin>>N;
    ll N1=0,N2=0,N3=0;
    v a(2*N);
    ll ev;
    vector<char> c(2*N);
    rep(i,0,2*N){
        cin>>a[i]>>c[i];
        if(c[i] == 'R')N1++;
        if(c[i] == 'G')N2++;
        if(c[i] == 'B')N3++;
    }
    if(N1 %2 == 0 && N2 %2 == 0 && N3 %2 == 0){
        cout<<0;
        return 0;
    }
    ll r=1,g=2,b=3;
    if(N1%2 == 0)ev = 1;
    if(N2%2 == 0){g=1;r=2;swap(N1,N2);}
    if(N3%2 == 0){r=3;b=1;swap(N1,N3);}

    vector<pair<ll,ll>> Arg;
    vector<pair<ll,ll>> Arb;
    vector<pair<ll,ll>> Agb;

    rep(i,0,2*N){
        pair<ll,ll> tmp;
        tmp.first = a[i];
        ll d;
        if(c[i] == 'R')d=r;
        if(c[i] == 'G')d=g;
        if(c[i] == 'B')d=b;
        tmp.second = d;
        if(d==1){Arg.push_back(tmp);Arb.push_back(tmp);}
        if(d==3){Arb.push_back(tmp);Agb.push_back(tmp);}
        if(d==2){Arg.push_back(tmp);Agb.push_back(tmp);}
    }
    ll rg = 1,gb=2,br=3;
    sort(all(Arg));
    sort(all(Arb));
    sort(all(Agb));
    vector<pair<ll,ll>> drg;
    vector<pair<ll,ll>> dgb;
    vector<pair<ll,ll>> drb;
    ll Nr;
    Nr = 0;
    rep(i,0,Arg.size()){
        if(i==0 && Arg[i].second == 1)Nr++;
        if(Arg[i+1].second == 1)Nr++;
        if(Arg[i].second == Arg[i+1].second)continue;
        drg.emplace_back(abs(Arg[i].first-Arg[i+1].first),Nr);
    }
    Nr = 0;
    rep(i,0,Arb.size()){
        if(i==0 && Arb[i].second == 1)Nr++;
        if(Arb[i+1].second == 1)Nr++;
        if(Arb[i].second == Arb[i+1].second)continue;
        drb.emplace_back(abs(Arb[i].first-Arb[i+1].first),Nr);
    }
    rep(i,0,Agb.size()){
        if(Agb[i].second == Agb[i+1].second)continue;
        dgb.emplace_back(abs(Agb[i].first-Agb[i+1].first),Nr);
    }

    sort(all(drg));
    sort(all(dgb));
    sort(all(drb));
    ll rr;
    if(drg[0].second == drb[0].second){
        if(drg[0].second == drb[1].second && drg[1].second == drb[0].second){
            rr = min(drg[0].first + drb[2].first,drg[2].first + drb[0].first);
        }
        else if(drg[0].second == drb[1].second){
            rr = min(drg[0].first + drb[2].first,drg[1].first + drb[0].first);
        }
        else if(drg[1].second == drb[0].second){
            rr = min(drg[1].first + drb[0].first,drg[0].first + drb[2].first);
        }
        else{
            rr = min(drg[0].first + drb[1].first,drg[1].first + drb[0].first);
        }
    }
    else{
        rr = drg[0].first + drb[0].first;
    }
    rr = min(rr,dgb[0].first);

    cout<<rr;
    return 0;
}

//Generated at 2020-10-03 20:08:03 UTC+8
//Created by Alphagocc
#include<bits/stdc++.h>
#ifdef USE_PBDS
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#endif
using namespace std;
#define FI __inline__ __attribute__((always_inline))
#define TN typename
#define TP template
#define TS *this
class IO{static const int bufSize=1<<18;char inBuf[bufSize],outBuf[bufSize];char*ip1=inBuf,*ip2=inBuf;int ok=1,op1=-1,op2=bufSize-1;
TP <TN T>FI void __RI(T&x){int ch=gc(),neg=1;x=0;for(;!(ch==EOF||isdigit(ch)||ch=='-');ch=gc());if(ch==EOF){ok=0;return;}if(ch=='-')neg=-1,ch=gc();for(;isdigit(ch);ch=gc())x=x*10+(ch-48)*neg;}
TP <TN T>FI void __RC(T&x){unsigned char ch;while(isspace(ch=gc()));if(ch==EOF){ok=0;return;}x=ch;}FI void __RS(string&x){char ch;x.clear();for(ch=gc();isspace(ch);ch=gc());if(ch==EOF){ok=0;return;}for(;!isspace(ch);ch=gc())x.push_back(ch);}
public:
FI int gc(){return ip1==ip2 &&(ip2 =(ip1=inBuf)+fread(inBuf,1,bufSize,stdin),ip1==ip2)?EOF:*ip1++;}
FI IO&R(char&x){__RC(x);return TS;}FI IO& R(unsigned char&x){__RC(x);return TS;}FI IO&R(string&x){__RS(x);return TS;}TP<TN T1,TN T2>FI IO&R(pair<T1,T2>&x){R(x.first),R(x.second);return TS;}TP<TN T>FI IO&R(vector<T>&x){for(auto &i:x)R(i);return TS;}
TP <TN T,TN...Args>FI IO&RA(T*a,int n){for(int i=0;i<n;++i)R(a[i]);return TS;}TP<TN T,TN...Args>FI IO&R(T&x,Args&...args){R(x),R(args...);return TS;}
TP <TN T,TN...Args>FI IO&RA(T*a,int n,Args...args){for(int i=0;i<n;++i)RA(a[i],args...);return TS;}TP<TN T>FI IO&R(T&x){static_assert(is_integral<T>::value,"Unsupported types");if(is_integral<T>::value)__RI(x);return TS;}
private:
char space=' ';TP<TN T>FI void __WI(T x){static char buf[64];static int len=-1;if(x>=0){do{buf[++len]=x%10+48,x/=10;}while(x);}else{pc('-');do{buf[++len]=-(x%10)+48,x/=10;}while(x);}while(len>=0){pc(buf[len]),--len;}}
public:
FI void pc(const char&x){if(op1==op2)flush();outBuf[++op1]=x;}
FI void flush(){fwrite(outBuf,1,op1+1,stdout),op1=-1;}FI IO&W(const char&x){pc(x);return TS;}FI IO&W(const char*x){while(*x!='\0')pc(*(x++));return TS;}FI IO&W(const string&x){W(x.c_str());return TS;}
TP<TN T>FI IO& W(const vector<T>&x){for(auto&i:x)WS(i);WL();return TS;}FI IO&WL(){W('\n');return TS;}TP<TN T1,TN T2>FI IO& W(const pair<T1,T2>&x){WS(x.first),W(x.second);return TS;}
TP<TN T>FI IO& WL(const T&x){W(x),W('\n');return TS;}FI IO&WS(){W(' ');return TS;}TP<TN T>FI IO& WS(const T&x){W(x),W(space);return TS;}
TP<TN T>FI IO& WA(T* a,int n){for(int i=0;i<n;i++)WS(a[i]);WL();return TS;}TP<TN T,TN...Args>FI IO& W(const T&x,const Args&...args){W(x),W(space),W(args...);return TS;}
TP<TN...Args>FI IO& WL(const Args&...args){W(args...),W('\n');return TS;}TP<TN T,TN...Args>FI IO& WA(T* a,int n,Args...args){for(int i=0;i<n;i++)WA(a[i],args...);return TS;}
TP<TN T>FI IO& W(const T&x){static_assert(is_integral<T>::value,"Unsupported types");if(is_integral<T>::value)__WI(x);return TS;}
TP<TN T>FI IO&operator>>(T&x){R(x);return TS;}TP<TN T>FI IO&operator<<(const T&x){W(x);return TS;}bool good(){return ok;}IO(){}~IO(){flush();}}io;
#undef TN
#undef TP
#undef FI
#undef TS
#define REP(i,x,y)for(int i=x;i<y;i++)
#define ALL(x)x.begin(),x.end()
const int32_t INF=0x3f3f3f3f;
const int64_t INFL=0x3f3f3f3f3f3f3f3fLL;

int main()
{
    int n;
    io >> n;
    vector<char> s(n);
    io >> s;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a, t, g, c;
        a = t = g = c = 0;
        for (int j = i; j < n; j++) {
            switch (s[j]) {
            case 'A': a++; break;
            case 'T': t++; break;
            case 'G': g++; break;
            case 'C': c++; break;
            default: break;
            }
            // io.WL(a, t, g, c);
            if (a == t && g == c) ans++;
        }
    }
    io.WL(ans);
    return 0;
}


#include <bits/stdc++.h>
//#include <atcoder/modint>
//#include <atcoder/math>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPP(i, n) for(int i = 1; i <= n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c = a % i_7;
    if(c >= 0) return c;
    return c + i_7;
}
long long po(long a, long b){
    if(b == 0) return 1;

    long long z = po(a , b / 2);
    z = mod(z * z);
    if(b % 2 != 0) z = mod(a * z);
    return z;
}

bool prime_(int n){
    if(n == 1){
        return false;
    }else if(n == 2){
        return true;
    }else{
        for(int i = 2; i <= std::sqrt(n); i++) if(n % i == 0) return false;
        return true;
    }
}

long long gcd_(long long a, long long b){
    if(a < b) std::swap(a,b);
    if(a % b == 0) return b;
    else return gcd_(b, a % b);
}

long long lcm_(long long x, long long y){
    return (x / gcd_(x,y)) * y;
}

using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//using mint = modint998244353;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

// Binary Indexed Tree (Fenwick Tree)
template<typename T> // T: type of cost
struct BIT {
    int n;
    std::vector<T> d;
    BIT(int n=0):n(n),d(n+1) {}
    //配列のインデックスiの要素d[i]に対して、xを加算する。
    void add(int i, T x=1) {
        for (i++; i <= n; i += i&-i) {
            d[i] += x;
        }
    }
    //配列においてインデックスがi以下の要素d[j]たちの和を計算して返す。
    T sum(int i) {
        if(i < 0) return 0;
        T x = 0;
        for (i++; i; i -= i&-i) {
            x += d[i];
        }
        return x;
    }
};

int main(){
    //using namespace std;

    int n;
    cin>>n;
    vector<long long> a(n);
    REP(i, n) cin>>a[i];

    BIT<long long> bt(n);
    vector<long long> ans(n, 0);
    REP(i, n){
        ans[0] += bt.sum(n - 1) - bt.sum(a[i]);
        bt.add(a[i]);
    }
    for(int k = 1; k < n; k++){
        bt.add(a[k - 1], -1);
        ans[k] = ans[k - 1];
        ans[k] -= bt.sum(a[k - 1] - 1);
        ans[k] += bt.sum(n - 1) - bt.sum(a[k - 1]);
        bt.add(a[k - 1]);
    }
    REP(i, n) cout << ans[i] << endl;
    return 0;
}

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cassert>
#include <map>
#include <numeric>
#include <cstring>
#include <set>
#include <ctime>
#include <queue>
#include <cmath>
#include <iomanip>
#include <iterator>

using namespace std;

clock_t timeStart, timeFinish;

void timeBegin() {
    timeStart = clock();
}

void timeEnd() {
    timeFinish = clock();
}

void timeDuration() {
    timeEnd();
    double time_taken = double(timeFinish - timeStart) / double(CLOCKS_PER_SEC);
    cout << "Time taken by program is : " << fixed << time_taken << setprecision(5);
    cout << " sec " << endl;
}

class InputReader {
public:
    InputReader() {
        input_file = stdin;
        cursor = 0;
        fread(buffer, SIZE, 1, input_file);
    }
    InputReader(const char *file_name) {
        input_file = fopen(file_name, "r");
        cursor = 0;
        fread(buffer, SIZE, 1, input_file);
    }
    inline InputReader &operator >>(int &n) {
        while((buffer[cursor] < '0' || buffer[cursor] > '9') && buffer[cursor] != '-') {
            advance();
        }
        int sign = 1;
        if (buffer[cursor] == '-') {
            sign = -1;
            advance();
        }
        n = 0;
        while('0' <= buffer[cursor] && buffer[cursor] <= '9') {
            n = n * 10 + buffer[cursor] - '0';
            advance();
        }
        n *= sign;
        return *this;
    }
private:
    FILE *input_file;
    static const int SIZE = 1 << 17;
    int cursor;
    char buffer[SIZE];
    inline void advance() {
        ++ cursor;
        if(cursor == SIZE) {
            cursor = 0;
            fread(buffer, SIZE, 1, input_file);
        }
    }
};

int main() {
    timeBegin();
    //ifstream cin("input.in");
    //ofstream cout("abbreviation.out");
    int n, m, parity[2];
    parity[0] = parity[1] = 0;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        int ones = 0;
        for (int j = 0; j < m; j++) {
            if (s[j] == '1') {
                ones ^= 1;
            }
        }
        parity[ones]++;
    }
    cout << 1LL * parity[0] * parity[1] << "\n";
    //timeDuration();
    return 0;
}


/*
Author-> Codie_1(Akash)
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(n) for(int i=0;i<n;i++)
#define repi(n) for(int i=0;i<n;i++)
#define repj(n) for(int j=0;j<n;j++)
#define repp(n) for(int i=0;i<=n;i++)
#define repab(a,b) for(int i=a;i<b;i++)
#define w(t) int t; cin>>t; while(t--)
#define endl '\n'
#define pi pair<int, int> p
#define pis pair<int, string> p
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vi vector<int> v
#define vl vector<long long> v;
typedef long long ll;

int main()
{
	int n,k,m;
	cin>>n>>k>>m;
	int l=n-1;
	int avg=0;
	while(l--)
	{
		int x;
		cin>>x;
		avg+=x;
	}
	// cout<<avg/(n-1)<<endl;
	int g=(n*m)-avg;
	if(g<=0)
		cout<<0;
	else if(g<=k)
		cout<<g;
	else
		cout<<-1;
	return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <list>
#include <cassert>
#include <numeric>
#include <cstdint>
#include <queue>
#include <deque>

using ll = long long;
using ld = long double;
using namespace std;
using Graph = vector<vector<int>>;

// typedef pair<int,int> P;
#define teisu 1000000007
#define MAX_WIDTH 60
#define MAX_HEIGHT 60
#define INF 1e9

// int N;
// string S;
// map<int,int> cnt;
// map<char,vector<int>> keep_index;
// ll X,Y,A,B;
// ll ans = 0;
// ll dfs(ll strength,ll keikenti){
//     if(strength >= Y) return 0;

//     ans = max(ans,keikenti);
//     cout << strength << endl;
//     // cout << ans << endl;

//     dfs(strength*A,keikenti+1);

//     dfs(strength+B,keikenti+1);

//     return 0;
// }

double N,D,H,d[110],h[110];
int main(){
    cin >> N >> D >> H;
    for(int i=0;i<N;i++){
        cin >> d[i] >> h[i];
    }

    double ans = 0.000000;
    for(int i=0;i<N;i++){

        double calc = h[i] - (((H-h[i])*d[i])/(D-d[i]));
        ans = max(ans,calc);
    }
    // cout << ans << endl;
    ans = min(1000.0000,ans);
    printf("%.15lf\n",ans);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
int n,q;
const ll inf=1e18;
ll a[maxn],delta[maxn],sum[maxn],k;
int main()
{

    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        delta[i-1]=a[i]-a[i-1]-1;
    }
    delta[n]=inf;
    sum[0]=delta[0];
    for(int i=1;i<=n;i++) sum[i]=sum[i-1]+delta[i];
    for(int i=1;i<=q;i++)
    {
        scanf("%lld",&k);
        if(a[1]>k){ printf("%lld\n",k); continue;}
        int pos=lower_bound(sum,sum+n+1,k)-sum;
        printf("%lld\n",a[pos]+k-sum[pos-1]);
    }
    return 0;
}

#include "bits/stdc++.h"
using namespace std;
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>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define pb push_back
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; }
//const int INF = 1123456789;
//const int mod = 1e9+7;
//const int mod=998244353;
int main(){
    int n,q; cin>>n>>q;
    vll a(n); rep(i,n) cin>>a[i];
    sor(a);
    vll v=a;
    rep(i,n) v[i]+=i;
    /*rep(i,q){
        ll k; cin>>k;
        auto itr=upper_bound(v.begin(),v.end(),k);
        if(itr==v.begin()) {cout<<k<<endl; continue;}
        itr--;
        cout<<*itr+k+a[itr-v.begin()]-1;
    }*/
    vector<pair<ll,int>> k(q);
    rep(i,q) {
        ll K; cin>>K;
        k[i]={K,i};
    }
    vll ans(q);
    sor(k);
    int m=0;
    rep(i,q){
        ll an=k[i].first+m;
        while(true){
            if(m<n&&a[m]<=an) {m++;an++;}
            else break;
        }

        ans[k[i].second]=an;
    }
    rep(i,q) cout<<ans[i]<<endl;
}


#include <iostream>
using namespace std;
int main(int argc, char** argv) {
	int n,a[1005],b[1005];
	cin>>n;
	int mmin1=1e5+1,mmin2=1e5+1;
	int _mmin1,_mmin2;
	for(int i=1;i<=n;i++)
	{   cin>>a[i]>>b[i];
	    if(a[i]<mmin1)
	    {   mmin1=a[i];_mmin1=i;
		}
		if(b[i]<mmin2)
		{   mmin2=b[i];_mmin2=i;
		}
	}
	if(_mmin1==_mmin2)
	{   int x=mmin1+mmin2;
	    int ___mmin2=1e5+1;
	    for(int i=1;i<=n;i++)
	    {   if(b[i]<___mmin2&&i!=_mmin2)
	       {   ___mmin2=b[i];
		   }
		}
	    int y=max(mmin1,___mmin2);
	    int ___mmin1=1e5+1;
	    for(int i=1;i<=n;i++)
	    {   if(a[i]<___mmin1&&i!=_mmin1)
	       {   ___mmin1=a[i];
		   }
		}
		int z=max(___mmin1,mmin2);
		cout<<min(min(x,y),z);
	}
	else
	cout<<max(mmin1,mmin2);
	return 0;
}

#pragma region header
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define int ll
#define each(i, a) for (auto &&i : (a))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vd = vector<ld>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using P = pair<int, int>;
using vp = vector<P>;
using int128 = __int128_t;//cin coutはできない
template <class T>
using greater_queue = priority_queue<T, vector<T>, greater<T>>;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a / gcd(a, b) * b;};
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template <class T>
void CVEC(const T &v) {
	int c = v.size() - 1;
	for (int i = 0; i < c; i++) cout << v[i] << ' ';
	if (c > -1) cout << v[c];
	cout << '\n';
}

#pragma endregion header

int XMAX = 10000;
int YMAX = 10000;

struct Rectangle{
	int a, b, c, d;
};

struct Point{
	int id, x, y, r;
};

void COUT(Rectangle	x){
	cout << x.a << " " << x.b << " " << x.c << " " << x.d << endl;
}

set<P> occupied;

signed main(){
    int n; cin >> n;
	vector<Point> Ps;
	map<int, Rectangle> ans;
	rep(i,n){
		int x, y, r; cin >> x >> y >> r;
		Ps.push_back({i, x, y, r});
	}
	sort(ALL(Ps), [](Point a, Point b){return a.r > b.r;});
	/*
	rep(i,n){
		int a = Ps[i].x;//x
		int b = Ps[i].y;//y
		int r = Ps[i].r;
		cout << a << " " << b << " " << r << endl;
	}
	*/
	int x = Ps[0].x;//x
	int y = Ps[0].y;//y
	int id = Ps[0].id;
	int r = Ps[0].r;
	int hen = (int)sqrt(r);
	//cout << hen << endl;
	ans[id] = {x, y, min(x + hen, XMAX), min(YMAX, y + hen)};
	rep(i,n){
		if(i == id) continue;
		ans[i] = {i, 0, i+1, 1};
	}
	rep(i,n){
		COUT(ans[i]);
	}
}


/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 1010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, m, a[MAXN], b[MAXN], dp[MAXN][MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m;
    FOR(i,1,n) cin >> a[i];
    FOR(i,1,m) cin >> b[i];
    dp[n+1][m+1] = 0;
    FOR(i,1,n) dp[i][m+1] = n-i+1;
    FOR(j,1,m) dp[n+1][j] = m-j+1;
    FORE(i,n,1)
        FORE(j,m,1) {
            dp[i][j] = dp[i+1][j+1] + (a[i] != b[j]);
            dp[i][j] = min(dp[i][j], dp[i+1][j] + 1);
            dp[i][j] = min(dp[i][j], dp[i][j+1] + 1);
        }
    int res = n + m;
    FOR(i,1,n)
        FOR(j,1,m) res = min(res, dp[i][j] + i-1 + j-1);
    cout << res;
    return 0;
}

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

#define ll long long
#define ld long double
#define ull unsigned long long
#define pi 3.141592653589793238
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define For(i,a,n) for(ll i=a;i<=n;i++)
const ll inf = 100000000000000000;
const ll mod = 1000000007;
const ll N=2e5+1;

typedef pair<int, int>     pii;
typedef pair<ll , ll>      pll;
typedef vector<int>        vi;
typedef vector<ll>         vl;
typedef vector<ull>        vll;
typedef vector<pii>        vpii;
typedef vector<pll>        vpl;
typedef vector<vi>         vvi;
typedef vector<vl>         vvl;

bool ispalin(string s){ ll len=s.length(); rep(i , 0 , len){ if(s[i] != s[len-i-1]) {return false;}} return true;}

ll add(ll a , ll b , ll m){ ll res = (a%m+b%m)%m; if(res<0)   {res+=m;} return res;}

ll mul(ll a , ll b , ll m){ ll res = (a%m*b%m)%m; if(res<0) {res+=m;} return res;}

ll power(ll a , ll b , ll m){ ll res = 1; while (b > 0) { if (b & 1) {res = mul(res,a,m);} a = mul(a , a , m); b >>= 1;} return res%m; }

ll binpow(ll a , ll b) { ll res = 1; while (b > 0) {  if (b & 1)  {res = (res*a);} a = (a*a); b >>= 1; } return res; }

ll binpow(ll a , ll b , ll m) { ll res = 1; while (b > 0) {  if (b & 1)  {res = (res*a)%m;} a = (a*a)%m; b >>= 1; } return res%m; }

bool isprime(ll n){ if (n <= 1) {return false;} if (n <= 3) {return true;} if (n%2 == 0 || n%3 == 0) {return false;} for (ll i=5; i*i<=n; i=i+6){ if (n%i == 0 || n%(i+2) == 0) {return false;}} return true; }

/// bool isprime(ll n){ int x=rand(); ll int y;  y=pow((x-1),n)-pow(x,n)+1; if(y%n==0) {return true;} else {return false;} }
///  for 1 to n prime numbers .....see down code
/// bool isprime[n+1]; for(i=0;i<=n;i++) {isprime[i]=true;} isprime[0]=false; isprime[1]=false; for(i=0;i<=n;i++) { if(isprime[i] == true) { count++; for(j=i*i;j<=n;j+=i) {isprime[j]=false;} } }

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

ll CEIL(ll a, ll b) { return (a/b+(a%b!=0));}

ll inv (ll a , ll m){ return power(a,m-2,m);}

ll C(ll n, ll r) {
    if(n<r)     return 0;
    if(n==r)    return 1;
    if(r > n-r)   r = n-r; // because C(n, r) == C(n, n - r)
    ll ans = 1;
    for(ll i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }
    return ans;
}

bool isPowerOfTwo(int x){  return x && (!(x & (x - 1)));}
bool isPerfectSq(ll x){ if (x >= 0) { ll sr = sqrt(x); return (sr * sr == x); } return false; }
ll fact(ll n , ll m){ ll f = 1;  for(ll i=1;i<=n;i++)  f = (f * i)%m;  return f%m;}

/* combinatorics .. */
// for getting max power of K that divides n!
ll fact_pow (ll n, ll k) { ll res = 0; while (n) { n /= k; res += n;} return res; }

void solve()
{
    ll x , y;
    cin>>x>>y;
    if(x == y)  cout<<x;
    else
    {
        if(x == 0 && y == 1 || y == 0 && x == 1)    cout<<"2";
        else if(x == 0 && y == 2 || x == 2 && y == 0)    cout<<"1";
        else    cout<<"0";
    }
}

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

    solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
using ll = long long;
//<< fixed << setprecision(n) 小数第n位まで表示

int main() {
    int N;
    cin >> N;
    cout << N - 1 << endl;
    return 0;
}

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

#define LL long long

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

    string s, t = ""; cin >> s; bool ok = 1;

    deque<char> q;
    for(char c : s) {
        if(c == 'R') ok = 1 - ok;
        else {
            if(ok) {
                if(q.size() && q.back() == c) {
                    q.pop_back();
                    continue;
                }
                q.push_back(c);
            }
            else {
                if(q.size() && q.front() == c) {
                    q.pop_front();
                    continue;
                }
                q.push_front(c);
            }
        }
    }

    for(char c : q) t += c;
    if(!ok) reverse(t.begin(), t.end());
    cout << t << '\n';
}


/*  TAHMID RAHMAN
    DAMIAN FOREVER
     MATH LOVER
    NEVER GIVE UP
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
#define ar array
#define lb lower_bound
#define ub upper_bound
const int mxN=2e5;
const int MOD=1e9+7;
template<typename ForwardIterator, typename T>
ForwardIterator first_less_than (ForwardIterator first, ForwardIterator last, T value)
{auto it = std::lower_bound (first, last, value);
return (it == first ? last : --it);}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}
#define debugxx(v) {for(auto x:v){cout<<x.fi<<" "<<x.se<<endl;}cout<<endl;}
#define debugx(v){for(auto y:v) {cout<<y<<" ";}cout<<endl;}
//Don't hesitate to ask me if you don't understand my code.......Happy coding,Tahmid...;
bool prime[15000000];
vector<ll>prime_list;
void seive_prime(ll n)
{
    ll i,j;
    for(i=0; i<=n; i++)
        prime[i]=true;
    for(i=2; i*i<=n; i++)
    {
        if(prime[i]==true)
        {
            for(j=i*i; j<=n; j+=i)
                prime[j]=false;
        }
    }
    prime[1]=0;
    prime[0]=0;

}

void gen_prime(ll n)
{
    seive_prime(n);
    for(ll i=0; i<=n; i++)
        if(prime[i])
            prime_list.pb(i);
}

set<ll> prime_fac(ll n)
{
    set<ll>factors;

    for(ll i=0;prime_list[i]*prime_list[i]<=n&&i<prime_list.size();i++)
    {
        if(n%prime_list[i]==0)
        {
            while(n%prime_list[i]==0)
            {
                n/=prime_list[i];
                factors.in(prime_list[i]);
            }
        }
    }

    if(n>1)
        factors.in(n);

   return factors;
}

int main()
{
    fastio;
    ll t;
    gen_prime(1010);
    t=1;
    //cin>>t;
    while(t--)
    {
        ll n,i;
        cin>>n;
        vector<ll>v(n);

        for(i=0;i<n;i++)
            cin>>v[i];
        map<ll,ll>m;
        for(i=0;i<n;i++)
        {
            set<ll>fact=prime_fac(v[i]);
            for(auto x:fact)
            {
                m[x]++;
            }
            fact.clear();
        }
        ll maxs=-1,ans=-1;
        for(auto x:m)
        {
            if(x.se>maxs){
                ans=x.fi;
                maxs=x.se;
            }
        }

        cout<<ans<<endl;

    }
}

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>
// #include <atcoder/all>

using namespace std;
// using namespace atcoder;
using ll = long long;
using ull = unsigned long long;

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

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    ll mx = 0, ans = 0;
    for(ll k = 2; k <= 1000; k++){
        ll cnt = 0;
        REP(i, n){
            if(a[i] % k == 0) cnt++;
        }
        if(mx < cnt){
            mx = cnt;
            ans = k;
        }
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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; }

const int INF = 1001001001;

int main()
{
    int n, m;
    cin >> n >> m;
    vb masu(n);
    rep(i, m) {
        int a;
        cin >> a;
        --a;
        masu[a] = true;
    }

    int x = INF;
    int t = 0;
    vi v;
    rep(i, n) {
        if(masu[i] == false) t++;
        else if(t > 0) {
            x = min(x, t);
            v.push_back(t);
            t = 0;
        }
    }
    v.push_back(t);

    int ans = 0;
    for(int i : v) {
        //cout << i << endl;
        if(i%x==0) ans += (i/x);
        else ans += (i/x)+1;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
    int64_t n, m, k = 0, ans = 0;
    cin >> n >> m;
    vector<int64_t> a(m);
    map<int64_t, int> s;
    for (auto i = 0; i < m; i++) cin >> a[i], a[i];
    sort(a.begin(), a.end());
    if (m == n) {
        cout << 0 << endl;
        return 0;
    }
    if (m == 0) {
        cout << 1 << endl;
        return 0;
    }
    for (auto i = 0; i < m - 1; i++)
        s[a[i + 1] - a[i] - 1]++;
    if (a.front() != 1) s[a.front() - 1]++;
    if (a.back() != n) s[n - a.back()]++;
    for (auto& elm : s) {
        if (elm.first == 0) continue;
        if (k == 0) k = elm.first, ans += elm.second;
        else
            ans += (elm.first / k +
                    ((elm.first % k) ? 1 : 0)) *
                   elm.second;
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1e9 + 7;
const int N = 3e5 + 10;
int32_t main() {
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   cout << setprecision(12)  << fixed ;
   vector<int>v(n);
   for (int i = 0;i < n;i++){
      cin >> v[i];
   }
   int m = 0;
   long double a = 0;
   int rr = 0;
   for(auto s : v){
      m += abs(s);
      a += s*s;
      rr = max(rr,abs(s));
   }
   a = sqrt(a);
   cout << m << "\n" << a << "\n" << rr;

   return 0;
}


 /*                    (
                     (  ) (
                      )    )
         |||||||     (  ( (
        ( O   O )        )
 ____oOO___(_)___OOo____(
(_______________________)
           JOINT           ░█─░█ ░█▀▀▀ ▀█▀ ░█▀▀▀█ ░█▀▀▀ ░█▄─░█ ░█▀▀█ ░█▀▀▀ ░█▀▀█ ░█▀▀█ █ ░█▀▀▀█ 　 ░█▀▀█ ░█▀▀▀█ ░█▀▀▄ ░█▀▀▀
                           ░█▀▀█ ░█▀▀▀ ░█─ ─▀▀▀▄▄ ░█▀▀▀ ░█░█░█ ░█▀▀▄ ░█▀▀▀ ░█▄▄▀ ░█─▄▄ ─ ─▀▀▀▄▄ 　 ░█─── ░█──░█ ░█─░█ ░█▀▀▀
                           ░█─░█ ░█▄▄▄ ▄█▄ ░█▄▄▄█ ░█▄▄▄ ░█──▀█ ░█▄▄█ ░█▄▄▄ ░█─░█ ░█▄▄█ ─ ░█▄▄▄█ 　 ░█▄▄█ ░█▄▄▄█ ░█▄▄▀ ░█▄▄▄*/

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

 // Ordered Set
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loop1(i,a,b) for(int i=a;i<=b;i++)
#define rloop(i,a,b) for(int i=a;i>b;i--)
#define rloop1(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define ff first
#define ss second
#define ncr(n,r) fact[n]*modInv(fact[r])*modInv(fact[n-r])

#define MOD 1000000007
#define modInv(a) binExp(a,mod-2)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test int t;cin>>t;while(t--)
//#define a^b=a+b-2*(a&b)

//POWER FUNCTION FOR LARGE NO.
//ll M=1000000007LL,fact[100010];

ll power(ll a, ll b, ll mod){
	ll x = 1LL, y = a;
	while (b > 0LL){
		if (b%2LL){
			x = (x*y);
			if(x>mod) x%=mod;
		}
		y = (y*y);
		if(y>mod) y%=mod;
		b /= 2LL;
	}
	return x;
}
/*
EULER'S FUNCTION FOR TAKING COMBINATION OF LARGE NO.
ll mod_inv(ll n, ll mod){
	return power(n, mod-2LL, mod);
}

ll nCr(ll n, ll k, ll mod){
	return (fact[n]* ((mod_inv(fact[k],mod)*mod_inv(fact[n-k],mod))%mod) )%mod;
}
 fact[0]=1LL;
    for(ll i=1LL;i<=100005LL;i++)
    {
        fact[i]=(fact[i-1]*i)%M;

    }*/

//pass by value increases the time complexity if you continuosly pass array or string in function it will give time complexity
//___________________(⌐⊙_⊙)__________<CHAL GURU HOJA SHURU >__________(⊙_⊙⌐)______________________________________________

signed main()
{
   int arr[4],s=0,f=0,s1=0;

   loop(i,0,4){cin>>arr[i];s+=arr[i];}
   loop(i,1,pow(2,4)-1){
       //cout<<i<<" ";
       s1=0;
     loop(j,0,4){
     if((1<<j)&i)s1+=arr[j];
     }
     if(s1==s-s1)f=1;
   }
   if(f)cout<<"Yes";
   else cout<<"No";

}

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

int main() {

	ios_base::sync_with_stdio(0);cin.tie(0);

	int num; cin>>num;

	int ans=0;

	priority_queue <int> pq;

	for (int i=0; i<num; i++) {
		int temp; cin>>temp;
		pq.push(temp);

	}

	for (int i=num; i!=0; i--) {
		if (pq.top()!=i) {
			cout<<"No";
			break;
		}

		else {
			pq.pop();
			ans+=1;
		}
	}

		if (ans==num) cout<<"Yes";

}


#include<iostream>

using namespace std;

int main(){
    int a,n=0;
    cin >> a;
    if(a%100!=0){
        n=1;
    }
    cout << a/100 + n << endl;
    return(0);
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;
#define MOD 1000000007
#define PI 3.1415926535897932
#define INF 1e18
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repe(i, j, n) for (ll i = j; i < n; i++)
#define repi(i, n) for (ll i = 0; i <= n; i++)
#define repie(i, j, n) for (ll i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<ll, ll>
#define fi first
#define se second
using Graph = vector<vector<ll>>;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

ll dp[2000][2000];
ll nCr(ll n, ll r)
{
       if(n==r) return dp[n][r] = 1;
       if(r==0) return dp[n][r] = 1;
       if(r==1) return dp[n][r] = n%MOD;
       if(dp[n][r]) return dp[n][r]%MOD;
       return dp[n][r] = nCr(n-1,r)%MOD + nCr(n-1,r-1)%MOD;
}

ll H(ll n, ll r) {
    return nCr(n+r-1, r)%MOD;
}

int prime[10000000];
bool is_prime[100000000 + 1];

int sieve(int n) {
    int pcnt = 0;
    for(int i = 0; i <= n; i++) {
        is_prime[i] = true;
    }

    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i <= n; i++) {
        if(is_prime[i]) {
            prime[pcnt++] = i;
            for(int j = 2*i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }

    return pcnt;
}

struct UnionFind {
	//自身が親であれば、その集合に属する頂点数に-1を掛けたもの
	//そうでなければ親のid
	vector<ll> r;
	UnionFind(ll N) {
		r = vector<ll>(N, -1);
	}
	ll root(ll x) {
		if (r[x] < 0) return x;
		return r[x] = root(r[x]);
	}
	bool unite(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (r[x] > r[y]) swap(x, y);
		r[x] += r[y];
		r[y] = x;
		return true;
	}
	ll size(ll x) {
		return -r[root(x)];
	}

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

void solve1() {
    ll n; cin >> n;
    n --;
    cout << n / 100 + 1 << endl;
}

int main()
{
    solve1();
}


#pragma GCC optimize("O3")
#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;
using P = pair<int, ll>;
using T = tuple<ll, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

vector<ll> dijkstra(int s, vector<vector<pair<int, ll>>> &G){
    int n = G.size();
    vector<ll> dist(n, INF);
    dist[s] = 0;
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> que;
    que.emplace(0, s);

    while(que.size()){
        ll ccost; int cv; tie(ccost, cv) = que.top(); que.pop();
        if(dist[cv] < ccost) continue;

        for(auto nxt : G[cv]){
            int nv; ll ncost; tie(nv, ncost) = nxt;
            if(ccost + ncost < dist[nv]){
                dist[nv] = ccost + ncost;
                que.emplace(dist[nv], nv);
            }
        }
    }

    return dist;
}

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

    int r, c; cin>>r>>c;
    vector<vector<int>> a(r, vector<int>(c - 1));
    for(int i=0; i<r; i++){
        for(int j=0; j<c-1; j++) cin>>a[i][j];
    }
    vector<vector<int>> b(r - 1, vector<int>(c));
    for(int i=0; i<r-1; i++){
        for(int j=0; j<c; j++) cin>>b[i][j];
    }

    int sz = 2 * r * c;
    vector<vector<P>> G(sz);
    for(int i=0; i<r; i++){
        for(int j=0; j<c; j++){
            if(j + 1 < c) G[i * c + j].emplace_back(i * c + j + 1, a[i][j]);
            if(0 <= j - 1) G[i * c + j].emplace_back(i * c + j - 1, a[i][j - 1]);
            if(i + 1 < r) G[i * c + j].emplace_back((i + 1) * c + j, b[i][j]);

            // (r, c) -> (r - i, c) の移動で i + 1 のコストがかかることを以下で実現
            // 2 階に上がるのにコストが 1 かかる
            G[i * c + j].emplace_back(r * c + i * c + j, 1);
            // 1 階に下がるのにはコストがかからない
            G[r * c + i * c + j].emplace_back(i * c + j, 0);
            // 2 階で 1 つ下のマスに行くのにコストが 1 かかる
            if(0 <= i - 1) G[r * c + i * c + j].emplace_back(r * c + (i - 1) * c + j, 1);
        }
    }

    auto dist = dijkstra(0, G);

    cout << dist[r * c - 1] << endl;

    return 0;
}

#include <bits/stdc++.h>

#include <random>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3,unroll-loops")
using ll = long long;
using ull = unsigned long long;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) for (int(i) = 0; (i) < int(n); (i)++)
#define repi(i, a, b) for (int(i) = (a); (i) < int(b); (i)++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
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;
}
constexpr int dy[4] = {-1, 0, 1, 0};
constexpr int dx[4] = {0, -1, 0, 1};
constexpr ll MOD = 1'000'000'007LL; /*998'244'353LL;*/

template <typename T>
struct Dijkstra {
    vector<vector<pair<int, short>>> e;
    vector<T> cost;
    Dijkstra(int V) : e(V) {}
    void add(int u, int v, T weight) {
        e[u].push_back({v, weight});
        e[v].push_back({u, weight});
    }
    void add_directed(int from, int to, T weight) {
        e[from].push_back({to, weight});
    }
    vector<T>& calculate(int s, T def) {
        cost.resize(e.size(), def);
        priority_queue<pair<T, int>> pq;
        cost[s] = 0;
        pq.push({0, s});
        while (!pq.empty()) {
            int n = pq.top().second;
            if (-pq.top().first != cost[n]) {
                pq.pop();
                continue;
            }
            pq.pop();
            for (int i = 0; i < e[n].size(); i++) {
                if (cost[e[n][i].first] > cost[n] + e[n][i].second) {
                    cost[e[n][i].first] = cost[n] + e[n][i].second;
                    pq.push({-cost[e[n][i].first], e[n][i].first});
                }
            }
        }
        return cost;
    }
};

int R, C;
Dijkstra<int> G(0);

signed main() {
    cin >> R >> C;
    G = Dijkstra<int>(2 * R * C);
    rep(i, R) {
        rep(j, C - 1) {
            int a;
            cin >> a;
            G.add(i * C + j, i * C + j + 1, a);
        }
    }
    rep(i, R - 1) {
        rep(j, C) {
            int a;
            cin >> a;
            G.add_directed(i * C + j, (i + 1) * C + j, a);
        }
    }
    rep(i, R) {
        rep(j, C) {
            G.add_directed(i * C + j, R * C + i * C + j, 1);
            G.add_directed(R * C + i * C + j, i * C + j, 0);
            if (i - 1 >= 0)
                G.add_directed(R * C + i * C + j, R * C + (i - 1) * C + j, 1);
        }
    }
    cout << G.calculate(0, 2e9)[R * C - 1] << endl;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rrep(i,n) for(int i = (n-1);i>=0;--i)
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int INF=1<<30;
//const ll INF=1LL<<60;

int dpa[102];
int dpb[102];

int main() {

    int a,b,x,y;
    cin >> a >> b >> x >> y;

    dpa[1] = 0;
    dpb[1] = 0;
    repi(i,1,100) {
        dpa[i+1] = min(dpa[i]+y,dpb[i]+x);
        dpb[i+1] = min(dpa[i+1]+x,dpb[i]+y);
    }

    int ans = 0;
    if(a>b)   ans+=dpa[a]-dpb[b];
    if(b>a)   ans+=dpb[b]-dpa[a]+x;
    if(a == b)  ans+= x;

    cout<<ans<<endl;

 return 0;
}

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

int main() {
  int H,W,N,M;
  cin >> H >> W >> N >> M;

  vector<vector<int>> data(H, vector<int>(W,0));
  vector<int>x(N);
  vector<int>y(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
    cin >> y.at(i);
  }
  vector<int>X(M);
  vector<int>Y(M);
  for (int i = 0; i < M; i++) {
    cin >> X.at(i);
    cin >> Y.at(i);
  }

  for (int i = 0; i < M; i++) {
    data.at(X.at(i)-1).at(Y.at(i)-1) = -1;
  }
  for (int i = 0; i < N; i++) {
    data.at(x.at(i)-1).at(y.at(i)-1) = 1;
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data.at(i).at(j) == 0){
        for (int k = i+1; k < H; k++) {
          if (data.at(k).at(j) == -1){
            break;
          }
          else if (data.at(k).at(j) == 1){
            data.at(i).at(j) = 10;
            break;
          }
        }
        for (int k = i-1; k >= 0; k--) {
          if (data.at(k).at(j) == -1){
            break;
          }
          else if (data.at(k).at(j) == 1){
            data.at(i).at(j) = 10;
            break;
          }
        }
        for (int k = j+1; k < W; k++) {
          if (data.at(i).at(k) == -1){
            break;
          }
          else if (data.at(i).at(k) == 1){
            data.at(i).at(j) = 10;
            break;
          }
        }
        for (int k = j-1; k >= 0; k--) {
          if (data.at(i).at(k) == -1){
            break;
          }
          else if (data.at(i).at(k) == 1){
            data.at(i).at(j) = 10;
            break;
          }
        }
      }
    }
  }

  int count = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (data.at(i).at(j) > 0) {
        count++;
      }
    }
  }
  cout << count << endl;

}


#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iterator>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define MOD 1000000007;
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // int T,p;
    // cin>>T;
    // for(p=1;p<=T;p++)
    // {
            ll N,M,X,Y;
            cin>>N>>M>>X>>Y;
            ll a,b,c,i,j,k;
            ll A[M][4];
            vector <vector <ll> > vect(N+1);
            ll dp[N+1];

            memset(dp,-1,sizeof(dp));

            queue <ll> q;

            for(i=0;i<M;i++)
            {
                    cin>>A[i][0]>>A[i][1]>>A[i][2]>>A[i][3];
                    vect[A[i][0]].pb(i);
                    vect[A[i][1]].pb(i);
            }

            q.push(X);
            dp[X]=0;
            bool x[N+1];
            memset(x,false,sizeof(x));
            x[X]=true;
            while(q.size()!=0)
            {
                a=q.front();
                q.pop();
                if(dp[a]==-1)
                b=1e15;
                else
                b=dp[a];
                for(i=0;i<vect[a].size();i++)
                {
                    if(A[vect[a][i]][0]==a)
                    c=A[vect[a][i]][1];
                    else
                    c=A[vect[a][i]][0];
                    // cout<<a<<" "<<c<<" cesq\n";
                    if(x[c]==false)
                    {
                        q.push(c);
                        // cout<<c<<" chek2112\n";
                        x[c]=true;
                    }
                    if(dp[c]==-1)
                    {
                        continue;
                    }
                    else
                    {
                        if(dp[c]%A[vect[a][i]][3]==0)
                        b=min(dp[c]+A[vect[a][i]][2],b);
                        else
                        {
                            b=min(b,A[vect[a][i]][2]+dp[c]+A[vect[a][i]][3]-dp[c]%A[vect[a][i]][3]);
                        }
                    }
                }
                // cout<<b<<" check12\n";
                dp[a]=b;

                for(i=0;i<vect[a].size();i++)
                {
                    if(A[vect[a][i]][0]==a)
                    c=A[vect[a][i]][1];
                    else
                    c=A[vect[a][i]][0];

                    if(dp[a]%A[vect[a][i]][3]==0)
                    b=dp[a]+A[vect[a][i]][2];
                    else
                    {
                         b=A[vect[a][i]][2]+dp[a]+A[vect[a][i]][3]-dp[a]%A[vect[a][i]][3];
                    }
                    // cout<<b<<" "<<a<<" \n";
                    if(dp[c]==-1)
                    {
                        dp[c]=b;
                    }
                    else
                    {
                        dp[c]=min(dp[c],b);
                    }
                }
            }
            cout<<dp[Y];
            return 0;
}

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

#define pb push_back
#define S second
#define F first
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vll vector<long long int>
#define pll pair<long long int,long long int>
/* unordered_map<int,int>mp; mp.reserve(1024); mp.max_load_factor(0.25); */
#define mod 1000000007
#define mod2 998244353
#define ll long long int
#define ld long double
#define pi 3.141592653589793238
#define Endl endl
#define endl "\n"
const int N = 1e5 + 5;
const ll inf = 1e18;
vector<vll> a[N];
void solve()
{
        ll n , m , x , y;
        cin >> n >> m >> x >> y;
        if(m == 0)
        {
                cout << -1;
                return;
        }
        for(ll i=1;i<=m;i++)
        {
                ll u , v , t , k;
                cin >> u >> v >> t >> k;
                a[u].pb({v,t,k});
                a[v].pb({u,t,k});
        }
        priority_queue<pll,vector<pll>,greater<pll>> pq;
        vector<ll> vis(n+1,1e18);
        pq.push({x,0});
        vis[x] = 0;
        ll ans = 1e18;
        while(!pq.empty())
        {
                pll p = pq.top();
                pq.pop();
                ll u = p.F;
                ll time = p.S;
                if(u == y)
                        ans = min(ans,time);
                for(auto v:a[u])
                {
                        ll tt = 0;
                        if(time%v[2] == 0)
                                tt = time + v[1];
                        else
                                tt = (time/v[2] + 1)*v[2] + v[1];
                        if(vis[v[0]] > tt)
                        {
                                pq.push({v[0],tt});
                                vis[v[0]] = tt;
                        }
                }
        }
        if(ans == 1e18)
                cout << -1;
        else
                cout << ans;
}

void debug(ll tt) {}

signed main()
{
        FAST;
        int t = 1;
        // cin >> t;
        while(t--)
        {
                solve();
        }
}


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

typedef long long ll;
typedef unsigned long long ull;

#define mp make_pair
#define fr first
#define sc second
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	ll cnt[2]={};
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		int t=0;
		for(char c: s)t+=c-'0';
		cnt[t&1]++;
	}
	cout<<cnt[0]*cnt[1]<<endl;
}

#include <bits/stdc++.h>

using namespace std;

#define int long long

const int N = 1e5 + 50;
string s[N];

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

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < n; i++)
        cin >> s[i];

    set<int> zeroes, ones;
    set<int> nzeroes, nones;

    for (int i = 0; i < n; i++) {
        if (s[i][0] == '1')
            ones.insert(i);
        else
            zeroes.insert(i);
    }

    for (int j = 1; j < m; j++) {
        for (auto x: zeroes) {
            if (s[x][j] == '0')
                nzeroes.insert(x);
            else
                nones.insert(x);
        }
        for (auto x: ones) {
            if (s[x][j] == '1')
                nzeroes.insert(x);
            else
                nones.insert(x);
        }
        zeroes = nzeroes;
        ones = nones;
        nzeroes.clear();
        nones.clear();
    }

    cout << (int) ones.size() * (int) zeroes.size();

}


#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<iomanip>
#include<regex>
using namespace std;
#define int long long
const int mod=1e9+7;
signed main(){
	int n,a[100000],fib[100001];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	fib[0]=fib[1]=1;
	for(int i=2;i<=n;i++)
		fib[i]=(fib[i-1]+fib[i-2])%mod;
	int ans=0;
	for(int i=0;i<n;i++)
		ans=(ans+(2*fib[i]*fib[n-i]-fib[n]+mod)%mod*a[i])%mod;
	cout<<ans<<endl;
}

#include <bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include<vector>
#include<math.h>
using namespace std;
int gcd(int a, int b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
  int main()
  {
      int t,n,i,j,k,l,a,b,c,flag,d;
      int arr[100001];
      char s[100001];
      vector<int> v;
     scanf("%d",&n);
     for(i=0;i<n;i++)
     scanf("%d",&arr[i]);
     int result = arr[0];
    for (int i = 1; i < n; i++)
    {
        result = gcd(arr[i], result);

    }
    printf("%d",result) ;

  }