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

int main() {
    int A,B;
    cin >> A >> B;
    int nyuKoke = A + B;
    int nyuShibo = B;
    int result;
    if(nyuKoke >= 15 && nyuShibo >= 8) {
        result = 1;
    } else if(nyuKoke >= 10 && nyuShibo >= 3) {
        result = 2;
    } else if (nyuKoke >= 3) {
        result = 3;
    } else {
        result = 4;
    }
    cout << result << endl;
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <sstream>
#include <numeric>
#include <queue>

using namespace std;

int main()
{
    //input
    int a, b;
    cin >> a >> b;
    vector<int> e(a + b);
    long long total = 0;

    if (a > b)
    {
        //正のほうが多い
        for (int i = 0; i < a; ++i) {
            total += i + 1;
            e.at(i) = i + 1;
        }
        for (int i = 0; i < b - 1; ++i) {
            e.at(i + a) = -(i + 1);
            total -= i + 1;
        }
        e.at(a + b - 1) = -total;
    } else {
        //負のほうがおおい
        for (int i = 0; i < b; ++i) {
            total -= i + 1;
            e.at(i) = -(i + 1);
        }
        for (int i = 0; i < a - 1; ++i) {
            e.at(i + b) = i + 1;
            total += i + 1;
        }
        e.at(a + b - 1) = -total;
    }
    for (int i = 0; i < e.size(); ++i) {
        cout << e.at(i);
        if (i != e.size() - 1)
            cout << " ";
    }
    cout << endl;
    return 0;
}


/*
    author:ujwalll
*/
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define nx cout << "\n";
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
#define pp pair<ll, ll>
#define ppi pair<int, int>
typedef long long int ll;
#define pri(x) printf("%d ", x);
#define prl(x) printf("%lld ", x);
#define fi first;
#define se second;
#define pb push_back;
#define all(v) v.begin(), v.end()
#define minimum 1
#define maximum 1e5
#define random minimum + (rand() % static_cast<int>(maximum - minimum + 1))

bool isPowerOfTwo(ll x){
    return x && (!(x & (x - 1)));
}
void fastio(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
long long binpow(long long a, long long b){
    long long res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
// Pascal triangle
ll ncr(int n, int r) {
    if (n < 0 || r < 0 || r > n)
        return 0;

    ll ans = 1;
    for (int i = 1; i <= r; i++) {
        ans *= (n + 1 - i);
        ans /= i;
    }

    return ans;
}
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};
////////////////////////////////////////////////////////////////////
map<ll,set<ll>> mp;
vector<ll> adj[200005];
vector<bool> vis(200005,0);
set<ll> st;
void dfs(int s){
    st.insert(s);
    vis[s]=1;
    for(auto i:adj[s]){
        if(!vis[i])dfs(i);
    }
}
void test_case(){
    int n;
    cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i];
    rep(i,n/2){
        if(a[i]!=a[n-i-1]){
            if(!mp[a[i]].count(a[n-i-1])){
                adj[a[i]].push_back(a[n-i-1]);
                adj[a[n-i-1]].push_back(a[i]);
            }
            mp[a[i]].insert(a[n-i-1]);
            mp[a[n-i-1]].insert(a[i]);
        }
    }
    ll ans = 0;
    for(int i=1;i<=200000;i++){
        if(!adj[i].size() || vis[i])continue;
        // cout<<i<<"\n";
        ll val = 0;
        st.clear();
        dfs(i);
        ans+=st.size()-1;
    }
    cout<<ans;
}
int main(){
    fastio();
    int tc = 1;
    // cin>>tc;
    while(tc--){
        test_case();
        done:;
    }
    return 0;
}

#include <iostream>
#include <cstring>
#include <string>
#include <queue>
#include <algorithm>

using namespace std;
using ll = long long;

int l;

ll dp[201][201];

ll memo(int idx, int leng);

int main()
{
    memset(dp, -1, sizeof dp);
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> l;
    cout << memo(0, 0);
}

ll memo(int idx, int leng)
{
    if (idx == 11)
    {
        if (leng < l)
            return 1;
        else
            return 0;
    }

    ll &ret = dp[idx][leng];

    if (ret != -1)
        return ret;
    ret = 0;

    for (int i = leng + 1; i < l; ++i)
        ret += memo(idx + 1, i);

    return ret;
}


#include<bits/stdc++.h>
#define sort(a) sort(a.begin(),a.end())
#define vpi vector< pair<long long,long long> >
#define pb push_back
#define ll long long
#define fast1 ios_base::sync_with_stdio(false)
#define fast2 cin.tie(NULL)
using namespace std;

int main() {
    fast1; fast2;
    ll n; cin>>n;

    ll sz = (1<<n);

    vector< pair<ll,ll> > a;

    for(ll i=0; i<sz; i++) {
        ll x; cin>>x;
        a.pb({x,i});
    }

    for(ll i=0; i<sz; i++) {
        vector<pair<ll,ll>> temp;
        if(a.size() == 2) {
            if(a[0].first > a[1].first) {
                cout<<a[1].second+1;
            } else {
                cout<<a[0].second+1;
            }
            break;
        }
        for(ll j=0; j<a.size(); j+=2) {
            if(a[j].first > a[j+1].first) {
                temp.pb(a[j]);
            } else {
                temp.pb(a[j+1]);
            }
        }
        a = temp;
    }
}

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ve vector<ll>
#define ve_pa vector<pair<ll,ll> >
#define pb push_back
#define mod (ll)998244353
#define INF (ll)1e13+7
#define ld long double
#define pll pair<ll,ll>
#define fi first
#define se second
#define mll map<ll,ll>
#define m_ve map<ll,ve>
#define min3(x,y,z) min(x,min(y,z))
#define max3(x,y,z) max(x,max(y,z))
#define W(x) while(x--)
#define ld long double
#define all(x) x.begin(),x.end()
#define popcount(x) __builtin_popcountll(x)
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
//int dx[]={0,1,-1,0,0,1,-1,-1,1},dy[]={0,0,0,1,-1,1,-1,1,-1};
const int N=300005;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;//cin>>t;
t=1;
while(t--)
{
	ll n;cin>>n;
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		ll x;cin>>x;
		if(x>=10)
		ans+=x-10;
	}
	cout<<ans;
}

}


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

int N;

void dfs(vector<vector<int>>& graph, vector<bool>& reachable, int v) {
  //すでにチェック済みの都市はパスする
  if (reachable.at(v)) {
    return;
  }

  //都市iから都市vへは到達可能
  reachable.at(v) = true;

  for (auto vv : graph.at(v)) {
    dfs(graph, reachable, vv);
  }
}

int main() {
  int M;
  cin >> N >> M;

  vector<vector<int>> graph(N);
  rep (i, M) {
    int A, B;
    cin >> A >> B;
    graph.at(A - 1).push_back(B - 1);
  }

  //都市iから到達可能な都市を数える
  int ans = 0;
  vector<bool> reachable(N);
  rep (i, N) {
    dfs(graph, reachable, i);
    ans += count(reachable.begin(), reachable.end(), true);
    reachable.assign(N, false);
  }
  cout << ans << endl;
}

#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#pragma GCC optimize(3)
#define inlint inline int
#define inloid inline void
#define EDGE(cu) for(int ed = nodes[cu].lastConn, to = edges[ed].to; ed; ed = edges[ed].next, to = edges[ed].to)
using namespace std;

namespace _MAIN{
	int n, m;
	inlint read(){
		int nega = 1, num = 0;
		register char c = getchar();
		for(;!isdigit(c);c = getchar()) if(c == '-') nega = -1;
		for(; isdigit(c);c = getchar()) num = num * 10 + c - '0';
		return nega * num;
	}
} using namespace _MAIN;

namespace _GRAPH{
	struct node{
		int lastConn;
	} nodes[2005];
	struct edge{
		int next, to;
	} edges[2005 * 2005];
	int edCnt;
	int vis[2005], v[2005], ans;
	void dfs(int cu){
		v[cu] = 1;
		ans++;
		EDGE(cu){
			if(!v[to]){
				dfs(to);
			}
		}
		return;
	}
	inloid addEdge(int a, int b){
		edges[++edCnt].next = nodes[a].lastConn, edges[edCnt].to = b, nodes[a].lastConn = edCnt;
		return;
	}
} using namespace _GRAPH;

int main(void){
	n = read(), m = read();
	for(int i = 1;i <= m;i++){
		int a = read(), b = read();
		addEdge(a, b);
	}
	for(int i = 1;i <= n;i++){
		memset(v, 0, sizeof(v));
		dfs(i);
	}
	cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n; cin >> n;
  ll ok = 1000000, ng = 0;
  while(abs(ok-ng) > 1) {
    ll mid = (ok+ng)/2;
    ll sum = mid*(mid+1)/2;
    (sum >= n ? ok : ng) = mid;
  }
  cout << ok << endk;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
int T,n;
char s[1000001];
int read()
{
	int pos=1,num=0;
	char ch=getchar();
	while (!isdigit(ch))
	{
		if (ch=='-') pos=-1;
		ch=getchar();
	}
	while (isdigit(ch))
	{
		num=num*10+(int)(ch-'0');
		ch=getchar();
	}
	return pos*num;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		write(-x);
		return;
	}
	if (x>=10) write(x/10);
	putchar(x%10+'0');
}
void writesp(int x)
{
	write(x);
	putchar(' ');
}
void writeln(int x)
{
	write(x);
	putchar('\n');
}
int main()
{
	T=read();
	while (T--)
	{
		n=read();
		for (int i=1;i<=n;i++)
			write(0);
		for (int i=1;i<=n;i++)
			write(1);
		write(0);
		putchar('\n');
		scanf("%s",&s);
		scanf("%s",&s);
		scanf("%s",&s);
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin>>n;
  vector<int> a(n),b(n),c(n);
  for(auto& i:a) cin>>i;
  for(auto& i:b) cin>>i;
  for(auto& i:c) cin>>i;
  sort(a.begin(),a.end());
  long long ans=0;
  for(int i=0; i<n; ++i){
    int x=(int)(upper_bound(a.begin(),a.end(),b[c[i]-1])-a.begin());
    if(a[x-1]!=b[c[i]-1]) continue;
    ans+=(x-(int)(lower_bound(a.begin(),a.end(),b[c[i]-1])-a.begin()));
  }
  cout<<ans<<endl;
  return 0;
}


//K-OS WITH THE OCDE

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

#include <iostream>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;

#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007

ll check(ll x)
{
    ll c = 0;
    while(x % 5 == 0)
    {
         x /= 5;
         c++;
    }

    if(x > 1)
        return MAX;

    return c;
}

void solve()
{
     ll n;
     cin >> n;

     ll p = 1;
     ll c = 0;
     while(p < n / 3) {

         p *= 3;
         c++;

         ll r = n - p;

         if(check(r) != MAX) {
            cout << c << " " << check(r) << endl;
            return;
         }

     }

     cout << -1;
}

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

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

// #define int long long
#define pb push_back
#define vt std::vector
#define lb lower_bound
#define sz(x) (int(x.size()))
#define all(x) x.begin(), x.end()
#define mst(x, bit) memset(x, bit, sizeof(x))
#define rep(i, l, r) for (ll i = (l); i < (r); ++ i)
#define forr(i, l, r) for (ll i = (l); i >= (r); -- i)
#define dmp(x) cerr << __LINE__ << "->" << #x << " " << x << "\n"

using ll = long long;
using db = double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<typename... Args>
inline void _wpr_(Args... args) { std::cout << '\n'; }
template<typename T, typename... Args>
inline void _wpr_(T val, Args... args) { std::cout << " " << val; _wpr_(args...); }
template<typename T, typename... Args>
void wpr(T val, Args... args) { std::cout << val; _wpr_(args...); }

const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1e5 + 50;

// 对于这种不断递推的，先写出预处理式子，再用for循环处理（方便）

void solve(){
    // < 1,000 +1
    // < 1,000,000 + 2
    // < 1,000,000,000 + 3
    ll n; std::cin >> n;
    vt<ll> add(10);
    iota(all(add), 0ll);

    ll base = 1, ans = 0;
    for (int i = 0;; ++ i, base *= 1000){
        if (base * 1000 > n) { ans += (n - base + 1) * add[i]; break; }
        else ans += (1000 * base - base) * add[i];
    }

    wpr(ans);
}

signed main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    // std::cin >> t;
    while (t--) solve();
    return 0;
}


/*
           _                   _         _       __  __  _____
     /\   | |            /\   | |       | |     |  \/  |/ ____|
    /  \  | |__   ___   /  \  | |__   __| | ___ | \  / | |
   / /\ \ | '_ \ / _ \ / /\ \ | '_ \ / _` |/ _ \| |\/| | |
  / ____ \| |_) | (_) / ____ \| |_) | (_| | (_) | |  | | |____
 /_/    \_\_.__/ \___/_/    \_\_.__/ \__,_|\___/|_|  |_|\_____|

*/

#include <bits/stdc++.h>
#include <bits/extc++.h>

using namespace std;
using namespace __gnu_pbds;

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld eps = 1e-9;
const int mod = 1e9 + 7;
const int oo = 1e9 + 7;
const ll lloo = 1e18 + 7;
const int N = 1e6 + 7;

void solve();

int main()
{
	// freopen("in","r",stdin);
	// freopen("out","w",stdout);
	int t = 1;
	// scanf("%d",&t);
	while (t--) solve();
	return 0;
}

int n,d,h;
int x[N],y[N];
void solve()
{
	scanf("%d %d %d",&n,&d,&h);
	for(int i = 0 ; i < n ; i++) scanf("%d %d",x+i,y+i);
	ld ans = 1000;
	for(int i = 0 ; i < n ; i++)
	{
		ld m = h-y[i];
		m/=d-x[i];
		ld ca = m*d-h;
		bool ok = 1;
		for(int j = 0 ; j < n ; j++)
		{
			ld yy = m*x[j]-ca;
			if (abs(yy-y[j]) < eps || yy > y[j]) ok &= 1;
			else ok &= 0;
		}
		if (ok) ans = min(ans,-ca);
	}
	ans = max(ans,(ld)0);
	printf("%.9Lf\n",ans);
}

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

int main(){
    int n,D,H;
    cin>>n>>D>>H;
    double ans=0;
    rep(i,n){
        int d,h;
        cin>>d>>h;
        double now=H- double ((H-h)*D)/(D-d);
        ans=max(ans,now);

    }
    printf("%.10f\n",ans);
    return 0;
}


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

int main() {
    ll N,M,K; cin >> N >> M >> K;
    ll a; set<ll> NG;
    rep(i,K){
        cin >> a; NG.insert(a);
    }
    double dpa[N+M],dpb[N+M],suma[N+M+1],sumb[N+M+1];
    rep(i,M){
        dpa[N+i] = 0; dpb[N+i] = 0;
        suma[N+i] = 0; sumb[N+i] = 0;
    }
    suma[N+M] = 0; sumb[N+M] = 0;
    for(ll i=N-1;i>=0;i--){
        if(NG.count(i)){
            dpa[i] = 1; dpb[i] = 0;
            suma[i] = dpa[i]+suma[i+1];
            sumb[i] = dpb[i]+sumb[i+1];
        }
        else{
            if(suma[i+1]-suma[i+M+1]==M){
                cout << -1 << endl; return 0;
            }
            dpa[i] = (double)(suma[i+1]-suma[i+M+1])/M;
            dpb[i] = (double)(sumb[i+1]-sumb[i+M+1])/M +1;
            suma[i] = dpa[i]+suma[i+1];
            sumb[i] = dpb[i]+sumb[i+1];
        }
    }
    cout << setprecision(10) << dpb[0]/(1-dpa[0]) << endl;
}

#include <stdio.h>
#include <math.h>
#define MN 100000
const double eps = 1e-8;

int n,m,k;
bool b[MN+5];

struct F{
	double k,a;
	F(){
		k = a = 0;
	}
	F(double k,double a){
		this->k = k;
		this->a = a;
	}
	F operator + (const F& that)const{
		F ret;
		ret.k = this->k + that.k;
		ret.a = this->a + that.a;
		return ret;
	}
	F operator - (const F& that)const{
		F ret;
		ret.k = this->k - that.k;
		ret.a = this->a - that.a;
		return ret;
	}
	F operator * (double x)const{
		F ret = *this;
		ret.k *= x;
		ret.a *= x;
		return ret;
	}
	F operator / (double x)const{
		F ret = *this;
		ret.k /= x;
		ret.a /= x;
		return ret;
	}
	F& operator += (const F& that){
		*this = *this+that;
		return *this;
	}
	F& operator -= (const F& that){
		*this = *this-that;
		return *this;
	}
}f[MN+5];

int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1,a;i<=k;i++){
		scanf("%d",&a);
		b[a] = true;
	}
	f[n] = F(0,0);
	F t = f[n]*m;
	for(int i=n-1;i>=0;i--){
		t += f[i+1];
		if(i+m+1<=n) t -= f[i+m+1];
		else t -= f[n];
		if(b[i]){
			f[i].a = 0;
			f[i].k = 1;
		}else{
			f[i] = t/m;
			f[i].a++;
		}
	}
	f[0].k = 1-f[0].k;
	if(fabs(f[0].k)<eps){
		puts("-1");
	}else{
		printf("%.6lf\n",f[0].a/f[0].k);
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define rep(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << '\n'; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll bb, cc;
    cin, bb, cc;
    if (bb == 0) {
        print(cc / 2 * 2 + (cc % 2));
        return 0;
    }
    ll ans = 0;
    {
        ll b = bb;
        ll c = cc;
        if (b < 0) {
            c--;
            b = -b;
        }
        ll m = b - c / 2;
        if (m <= 0) {
            ans += 2 * b + 1;
            dump(ans);
        } else {
            ans += 2 * (b - m + 1);
            if ((c % 2) == 0) {
                ans--;
            }
            dump(ans);
        }
    }
    {
        ll b = bb;
        ll c = cc;
        if (bb > 0) {
            c--;
        } else {
            b = -b;
        }
        ans += c / 2 * 2;
        dump(ans);
        if (c / 2 > 0 && (c % 2) == 0) {
            ans--;
            dump(ans);
        }
    }
    print(ans);

    return 0;
}

#include<bits/stdc++.h>
//#include <atcoder/all>

#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)x.size())

using namespace std;
//using namespace atcoder;
using ld = long double;
using ll = long long;
using P = pair<ll, ll>;

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

const ll ZER = 0;
const ll MOD = 998244353;
const ll INF = 1e18;

int main(){
    ll b, c;
    cin >> b >> c;
    ll res;
    if(b > 0)res = 2 * min(c, 2 * b) - 1 + max((ll)0, c - 2 * b);
    if(b == 0)res = c;
    if(b < 0){
        b *= -1;
        res = 2 * min(c, 2 * b + 1) - 1 + max((ll)0, c - 2 * b - 1);
    }
    if(c == 1){
        res = 2 - (int)(!b);
    }
    cout << res << endl;
}


#include <bits/stdc++.h>
using namespace std;
int n,m,a[200050],dp[200050],ans=-2e9;
vector<int> e[200050];
bool vis[200050];

void dfs(int x) {
	if (vis[x]) return;
	vis[x]=1;
	for (int i:e[x]) {
		dfs(i); dp[x]=max(dp[x],dp[i]);
	}
	ans=max(ans,dp[x]-a[x]);
	dp[x]=max(dp[x],a[x]);
}

int main() {
	cin>>n>>m;
	for (int i=1; i<=n; ++i)
		scanf("%d",a+i),dp[i]=-1e9;
	while (m--) {
		int x,y; scanf("%d%d",&x,&y);
		e[x].push_back(y);
	}
	for (int i=1; i<=n; ++i)
		if (!vis[i]) dfs(i);
	cout<<ans;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

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

map<int, int> rev;
const int N = 102;
const int M = 102102;
vi vis(N), ans(M), ok(M);
vii ed(M);

void dfs(vector<vii> &gr, int u, int p) {
  vis[u] = 1;
  for (auto [v, e]: gr[u]) if (p != v) {
    if (vis[v]) {
      ok[rev[e]] = 1;
      ans[rev[e]] = ed[rev[e]].fst == v;
    }
    else {
      ans[rev[e]] = ed[rev[e]].snd == v;
      ok[rev[e]] = 1;
      dfs(gr, v, u);
    }
  }
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

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

  vi c(n+1), done(m), vis(n+1);

  vector<vii> g(n+1);
  rep(i,0,m) {
    cin >> ed[i].first >> ed[i].second;
    g[ed[i].fst].eb(ed[i].snd, i);
    g[ed[i].snd].eb(ed[i].fst, i);
  }

  rep(i,1,n+1) cin >> c[i];

  rep(i,1,n+1) {
    if (vis[i]) continue;
    queue<int> q;
    q.push(i);
    vis[i] = 1;
    vi comp;
    while (!q.empty()) {
      int u = q.front(); q.pop();
      comp.pb(u);
      for (auto [v, j]: g[u]) if (!vis[v] && c[v] == c[u]) {
        vis[v] = 1;
        q.push(v);
      }
    }

    vector<vii> gr(n+1);
    int nedges = 0;
    for (auto u: comp) {
      for (auto [v, j]: g[u]) {
        if (c[u] == c[v] && !done[j]) {
          rev[nedges] = j;
          gr[u].eb(v, nedges);
          gr[v].eb(u, nedges);
          ++nedges;
          done[j] = 1;
        }
      }
    }

    dfs(gr, i, i);
  }

  rep(i,0,m) {
    if (!ok[i]) {
      assert(c[ed[i].fst] != c[ed[i].snd]);
      ans[i] = c[ed[i].fst] > c[ed[i].snd];
    }
    if (ans[i]) cout << "->";
    else cout << "<-";
    cout << '\n';
  }

}


#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }
template<class T>
ostream &operator<<(ostream &os, const vector<T> &x){
    os << "{";
    for(size_t i = 0; i < x.size(); i++){
        if(i < x.size()-1) os << x[i] << ", ";
        else os << x[i];
    }
    os << "}";
    return os;
}

int main(void){
    int b;
    rep(k, 1000){
        int sx, sy, tx, ty;
        cin >> sx >> sy >> tx >> ty;
        int dx = tx-sx;
        int dy = ty-sy;
        char u, v;
        u = 'D', v = 'R';
        if(dx < 0) u = 'U', dx = -dx;
        if(dy < 0) v = 'L', dy = -dy;
        rep(i, dx) cout << u;
        rep(i, dy) cout << v;
        cout << endl;
        cout << flush;
        cin >> b;
    }
    return 0;
}

#include <algorithm>
#include <chrono>
#include <cmath>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;

//------------------------------------------------------------------------------
class Timer {
public:
	explicit Timer()
		: mStart(chrono::system_clock::now())
	{}
	void start() { mStart = chrono::system_clock::now(); }
	double msec() const {
		auto t = chrono::system_clock::now();
		return 1e-3 * chrono::duration_cast<std::chrono::microseconds>(t - mStart).count();
	}
private:
	chrono::system_clock::time_point mStart;
};

//------------------------------------------------------------------------------
class XorShift {
public:
	using result_type = uint32_t;
	explicit XorShift(result_type seed){ init(seed); }
	void init(result_type s){
		x = 1812433253U * (s ^ (s >> 30));
		y = 1812433253U * (x ^ (x >> 30)) + 1;
		z = 1812433253U * (y ^ (y >> 30)) + 2;
		w = 1812433253U * (z ^ (z >> 30)) + 3;
	}
	static constexpr result_type min() { return numeric_limits<result_type>::min(); }
	static constexpr result_type max() { return numeric_limits<result_type>::max(); }
	result_type operator() () {
		result_type t = x ^ (x << 11);
		x = y; y = z; z = w;
		return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
	}
private:
	result_type x;
	result_type y;
	result_type z;
	result_type w;
};

void randomPlay(){
    for(int _=0;_<1000;_++){
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        string s;
        if(x1 < x2) s.append(string(x2-x1, 'D'));
        if(x1 > x2) s.append(string(x1-x2, 'U'));
        if(y1 < y2) s.append(string(y2-y1, 'R'));
        if(y1 > y2) s.append(string(y1-y2, 'L'));
        cout << s << endl;
        int score; cin >> score;
    }
}

int main(){
    randomPlay();
}


#include <iostream>
using namespace std;

int main() {
  int x;
  cin >> x;
  cout << (100 - (x%100)) << "\n";
}

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

int main() {
  int N, revnum, t, pali;
  cin >> N;
  revnum = 0;
  if (N == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  while (N % 10 == 0) {
    N = N / 10;
  }
  pali = N;
  while (N != 0) {
    t = N % 10;
    revnum = revnum * 10 + t;
    N = N / 10;
  }
  if (pali == revnum) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

}


#include<bits/stdc++.h>
using namespace std;
#define debug printf("%d %s\n",__LINE__,__FUNCTION__)
using ll=long long;using ld=double;using pii=pair<int,int>;using vi=vector<int>;
using qi=queue<int>;using pqi=priority_queue<int>;using si=set<int>;
#define pb push_back
#define mk make_pair
#define ins insert
#define era erase
#define fi first
#define se second
#define lowbit(x) x&-x
const int INF=0x3f3f3f3f;
const ll INFLL=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
int _w,_t;FILE* _f;

const int N=3e5+5;

int n,q,a[N],sum[N];

void add(int u,int d){
    while(u<=n){
        sum[u]^=d;
        u+=lowbit(u);
    }
}

int qsum(int u){
    int tmp=0;
    while(u>0){
        tmp^=sum[u];
        u-=lowbit(u);
    }
    return tmp;
}

void solve(){
    scanf("%d%d",&n,&q);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        add(i,a[i]);
    }
    int t,x,y;
    while(q--){
        scanf("%d%d%d",&t,&x,&y);
        if(t^2){
            add(x,y);
        }
        else{
            printf("%d\n",qsum(y)^qsum(x-1));
        }
    }
}

int main(){
    #ifdef MULTI_CASES
    _w=scanf("%d",&_t);while(_t--)
    #endif
    solve();
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

//#pragma target("sse,sse2,sse3,ssse3,sse,popcnt,abm,mmx,avx,avx2,fma,tune=native")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

template <typename T>
istream& operator >> (istream& in, vector<T>& a) {
    for (auto& i : a)
        in >> i;
    return in;
}

template <typename T>
ostream& operator << (ostream& out, const vector<T>& a) {
    for (auto& i : a) {
        out << i << " ";
    }
    return out;
}

template <typename T, typename D>
istream& operator >> (istream& in, pair<T, D>& a) {
    in >> a.first >> a.second;
    return in;
}

template <typename T, typename D>
ostream& operator << (ostream& out, const pair<T, D>& a) {
    out << a.first << " " << a.second;
    return out;
}

struct LogOutput{
    template<typename T>
    LogOutput& operator<<(T x) {
#ifdef DIVAN
        cout << x;
#endif
        return *this;
    }
};

LogOutput fout;

typedef long long ll;
typedef unsigned long long ull;
typedef double dl;

#define nl '\n'
#define elif else if
#define all(_v) _v.begin(), _v.end()
#define rall(v) v.rbegin(), v.rend()
#define sz(v) (int)(v.size())
#define sqr(_v) ((_v) * (_v))
#define vpi vector<pair<int, int>>
#define eb emplace_back
#define pb push_back
#define mod(x, m) ((x) >= 0 ? ((x) % m) : (((x) % m) + m))
#define vi vector<int>
#define pi pair<int, int>
#define ti tuple<int, int, int>
#define minq(x, y) x = min((x), (y))
#define maxq(x, y) x = max((x), (y))
#define forn(i, n) for (int i = 0; i < (n); ++i)

const ll INFL = 9187201950435737471;
const ll nINFL = -9187201950435737472;
const int INF = 2139062143;
const int nINF = -2139062144;
const ull ULINF = numeric_limits<ull>::max();
const long double Pi = acos(-1);
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rnd(seed);

inline void IO() {
#ifdef DIVAN
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

const int MAXN = 1e5 + 15;

vpi adj[MAXN];
int col[MAXN];
bool used[MAXN];

void DFS(int v) {
    used[v] = 1;
    for (auto [to, c] : adj[v]) {
        if (used[to]) {continue;}
        if (col[v] == c) {
            if (c == 1) {
                col[to] = 2;
            } else {
                col[to] = 1;
            }
        } else {
            col[to] = c;
        }
        DFS(to);
    }
}

void Solve() {
    int n, m;
    cin >> n >> m;
    while (m--) {
        int a, b, c;
        cin >> a >> b >> c;
        adj[a].eb(b, c);
        adj[b].eb(a, c);
    }
    col[1] = 1;
    DFS(1);
    for (int i = 1; i <= n; ++i) {
        cout << col[i] << '\n';
    }
}

signed main() {
    IO();
    int t = 1;
//    cin >> t;
    int startTime = clock();
    while (t--) {
        Solve();
    }
    int endTime = clock();
#ifdef DIVAN
    cout << '\n' << "Time: " << (endTime - startTime + 999) / 1000;
#endif
    return 0;
}


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

int main()
{
    int N, count = 0;
    char a = '!';
    cin >> N;
    vector<string> s(N);
    set<string> z;
    for (int i = 0; i < N; i++)
    {
        cin >> s.at(i);
        z.insert(s.at(i));
    }

    for (auto value : z)
    {
        if (z.count(value) && z.count(a+value))
        {
            cout << value << endl;
            return 0;
        }

    }

    cout << "satisfiable" << endl;

    return 0;
}

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

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

int main(){
	string S;
	cin >> S;
	int s_siz = S.size();
	vector<int> num(10);
	rep(i,s_siz){
		int n = S[i] - '0';
		num[n]++;
	}
	for(int i=8; i<1000; i+=8){
		string t = to_string(i);
		int t_siz = t.size();
		rep(j,min(s_siz,3)-t_siz) t = '0' + t;
		map<char,int> mp;
		rep(j,t_siz) mp[t[j]]++;
		bool flag = true;
		for(auto itr : mp){
			int n = itr.first - '0';
			if(itr.second > num[n]){
				flag = false;
				break;
			}
		}
		if(flag){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

	return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>
#include<functional>
#include<cfenv>
#include<cmath>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll ,ll>
#define INT_MAX 2147483647
#define MOD 1000000007
#define PI 3.14159265358979323846
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

int main() {
	int n, k; cin >> n >> k;
	int nsum = 100 * n * (n + 1) / 2;
	int ksum = k * (k + 1) / 2;
	cout << nsum * k + ksum * n<<endl;

	return 0;
}

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

#define pb push_back
#define pob pop_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>
#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 = 2e5 + 15;
const ll inf = 1e18;

void solve()
{
        ll a , b;
        cin >> a >> b;
        ll ans = 0;
        for(ll i=1;i<=a;i++)
        {
                for(ll j=1;j<=b;j++)
                        ans += (i*100 + j);
        }
        cout << ans;
}

void debug(ll tt) {}

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


#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define pll pair<ll,ll>
#define ppl pair<pll,ll>
#define plp pair<ll,pll>
#define pi 3.14159265358979323846264338327950
const ll MOD=1e9 + 7;
const ll N=4e5 + 7;
using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// use rng for random number generation

ll POWER(ll base,ll expo)
{
    ll ret=1;
    while(expo)
    {
        if(expo&1)ret=ret*base%MOD;
        expo>>=1;
        base=base*base%MOD;
    }
    return ret%MOD;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll tt = 1; //cin>>tt;
    while(tt--)
    {
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        ll n; cin>>n;
        ll ans = n*(n - 1)/2;
        map<ll,ll> mp;
        for(ll i=0;i<n;i++){
            ll x; cin>>x;
            mp[x]++;
        }

        for(auto i : mp){
            ll x = i.se;
            ll rem = x*(x - 1)/2;
            ans -= rem;
        }
        cout<<ans;
    }
    return 0;
}

/*** In the name of Allah(swt), the most gracious, most merciful.***/
/*** Alhamdulillah for Everything ***/

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

typedef bool                   boo;
typedef int                    li;
typedef long                   il;
typedef unsigned long          ul;
typedef long long int          ll;
typedef unsigned long long     ull;
typedef double                 dd;
typedef string                 str;

#define vli                    vector < li >
#define vll                    vector < ll >
#define sli                    set < li >
#define sll                    set < ll >
#define pli                    pair < li , li >
#define pll                    pair < ll , ll >
#define vpi                    vector < pair < li , li > >
#define vpl                    vector < pair < ll , ll > >
#define mpl                    map < ll , ll >

#define Test                   ll t; std :: cin >> t; while(t--)
#define input(a , n)           for( int i = 0 ; i < n ; i++ ) std :: cin >> a[i];
#define lp(a , i , b)          for( ll i = a ; i < b ; i++ )
#define rlp(a , i , b)         for( ll i = a; i >= b ; i-- )
#define sz(x)                  x.size()
#define len(z)                 z.begin() , z.end()
#define ci(x)                  std :: cin >> x;
#define co(x)                  std :: cout << x nl;
#define fix(x)                 fixed << setprecision(x)
#define mem(z , l)             memset( z , l , sizeof(z) )
#define MP                     make_pair
#define pb                     push_back
#define F                      first
#define S                      second
#define nl                     << endl;
#define nll                    std :: cout << endl;
#define cy                     std :: cout << "YES" << endl;
#define cn                     std :: cout << "NO" << endl;
#define rn                     return;
#define Good_Bye               return 0;
#define gcd(a , b)             __gcd( a , b )
#define lcm(a , b)             ( a * ( b / gcd( a , b ) ) )
#define Faster                 ios_base :: sync_with_stdio( 0 ); cin.tie( 0 ); cout.tie( 0 );
int dx[] = { -1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
int dx1[] = { -1, -1, -1, 0, 0, 0, 1, 1, 1};
int dy1[] = { -1, 0, 1, -1, 0, 1, -1, 0, 1};

const double eps =             1e-9;
const int inf =                2000000000;
const ll infLL =               9000000000000000000;
const ll MOD =                 1e+7;
const double PI =              3.141592653589793238462643383279;

///_____________________________________________ L E T ' S  B E G I N ____________________________________________________________

int main()
{
	Faster
	ll x, n, sum(0);
	cin >> n;
	int ar[n + 2]; //,br[n+2];
	map<ll, ll>mp;
	lp(0, i, n)
	{
		cin >> ar[i];
		++mp[ar[i]];
	}
	lp(0, i, n)
	{
		--mp[ar[i]];
		sum += n - i - 1 - mp[ar[i]];
	}
	cout << sum nl
    Good_Bye
}
//                                                                                author : Md. Nahid Chowdhury(IIUC_CSE48th Batch)
///||||||||||||||||||||||||||||||||||||||||||||||| E N D ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define M 1000000000
#define MAX 20000000000
#define set_zero(a) memset(a,0,sizeof(a))
#define N 100005
using namespace std;
void solve(ll tc){
   string s; cin>>s;
   ll n = s.length();
   bool ok = false;
   ll j = -1;
   for(ll i = 0;i<n;i++){
      if(s[i] == '.'){
         ok = true;
         j = i;
         break;
      }
   }
   if(ok){
      for(ll i = 0;i<j;i++) cout<<s[i];
      cout<<endl;
   }
   else cout<<s<<endl;
}
int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL); cout.tie(NULL);
   ll t = 1 ;// cin>>t;
   ll tc = 0;
   while(t--){
       tc++;
       solve(tc);
   }
   return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define COUT(x) cout << (x) << endl
#define PB push_back
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define MOD 1000000007

const vector<int> DX = {1, -1, 0, 0};
const vector<int> DY = {0, 0, 1, -1};

template<typename T>
void pv(const vector<T> &vec) {
  for (auto x : vec) {
    cout << x << ' ';
  }
  cout << '\n';
}
/*
--------------------------------------------------------
*/

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

  int n;
  cin >> n;
  if (n % 2) {
    cout << "Black" << endl;
  } else {
    cout << "White" << endl;
  }
  return 0;

}


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

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
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;}
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;

	FOR(y,20) {
		FOR(x,20) cout<<(char)('A'+rand()%8);
		cout<<endl;
	}
}

int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

//wtrl,everybody hangbeat me
#include<bits/stdc++.h>
/*#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>*/
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef pair<ll,ll> pll;
/*=====================================================================*/
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define sz(a) (int)(a.size())
#define all(s) (s).begin(),(s).end()
#define m_p make_pair
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define forn(i,p,n) for(int i=p;i<=n;i++)
#define ford(i,p,n) for(int i=n;i>=p;i--)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define INF 1e9
#define PI acos(-1)
/*=====================================================================*/
string int_to_string(ll n)
{
	string s="";
	while(n)
	{
		ll now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
ll string_to_int(string s)
{
	ll n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
/*======================================================================*/
ll lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}
bool prime(int n)
{
	if(n==0||n==1)
	  return false;
	for(int i=2;i*i<=n;i++)
	  if(n%i==0)
	    return false;
	return true;
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
const int month[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};
vi v[100010];
pii dfs(int now)
{
	int ok=1,pos=0,neg=0;
	vi to;
	rep(i,v[now].size())
	{
		pii nxt=dfs(v[now][i]);
		if(nxt.second)
		{
			ok=1-ok;
			to.pb(nxt.first);
		}
		else
		{
			if(nxt.first>0)
			{
				pos+=nxt.first;
			}
			else
			{
				neg+=nxt.first;
			}
		}
	}
	sort(all(to));
	int ans=1;
	ans+=neg;
	rep(i,to.size())
	{
	  if(i%2)
	  {
	  	ans-=to[i];
	  }
	  else
	  {
	  	ans+=to[i];
	  }
	}
	if(to.size()%2)
	{
		ans-=pos;
	}
	else
	{
		ans+=pos;
	}
	return pii(ans,ok);
}
/*======================================================================*/
int main()
{
    std::ios::sync_with_stdio(false);
  /*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
  */
  /*====================================================================*/
  int n;
  cin>>n;
  rep(i,n-1)
  {
  	int p;
  	cin>>p;
  	p--;
  	v[p].pb(i+1);
  }
  cout<<(dfs(0).first+n)/2<<endl;
  return 0;
}


#include<bits/stdc++.h>
using ll = int_fast64_t;
#define REP(i,b,e) for(ll i=b; i<e; i++)

int main(){
	ll n, k;
	scanf("%ld %ld", &n, &k);
	ll ans = 0;
	REP(ab, 2, 3*n){
		ll cd = ab-k;
		if(cd<2) continue;
		ll l1 = std::max(0l, ab-n), r1 = std::min(ab, 0+n);
		ll l2 = std::max(0l, cd-n), r2 = std::min(cd, 0+n);
		ans += std::max(0l, std::min(ab-1, r1-l1+1)) * std::max(0l, std::min(cd-1, r2-l2+1));
	}
	printf("%ld\n", ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fi(i,n) for(int i=0;i<n;i++)
#define f(i, a, b) for(int i=a;i<b;i++)
#define vi vector<int>
#define pb push_back
#define MOD 998244353
#define pii pair<int, int>
#define ff first
#define ss second
#define setzero(a) memset(a,0,sizeof(a))

ll digits(ll n)
{
    return floor(log10(double(n))) + 1;
}
void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
ll modularExponentiation(ll x,ll n,ll M)
{
    ll result = 1;
    while(n>0)
    {
        if(n % 2 ==1)
        {
            result = ((result%M)*(x%M))%M;
        }
        x  = ((x%M)*(x%M))%M;
        n = n/2;
    }
    return result%M;
}
ll d, x, y;
void extendedEuclid(ll A, ll B)
{
    if(B == 0)
    {
        d = A;
        x = 1;
        y = 0;
    }
    else
    {
        extendedEuclid(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}
// DP solution for nCr
ll nCrModp(ll n, ll r)
{
    if (r > n - r)
        r = n - r;
    ll C[r + 1];
    memset(C, 0, sizeof(C));

    C[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i,r); j > 0; j--)
        {
            C[j] = (C[j] + C[j - 1]);
        }

    }
    return C[r];
}
ll modInverse(ll A, ll M)
{
    extendedEuclid(A,M);
    return (x%M+M)%M;    //x may be negative
}
// primefactors[a] = primefactors[a/primedivisor[a]] + 1
ll sumdigits(ll n)
{
    ll ans = 0;
    while(n>0)
    {
        ans += n%10;
        n = n/10;
    }
    return ans;
}
ll less_power2(ll n)
{
    ll i = 1;
    while(i*2<=n)
    {
        i = i*2;
    }
    return i;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}
int main()
{
    ll n,k;
    cin>>n>>k;
    ll arr[2*n + 1];
    arr[0] = 0;
    arr[1] = 0;
    ll i = 1;
    for(ll j = 2;j<(2 + n);j++)
    {
        arr[j] = i;
        i++;
    }
    i = n - 1;
    for(ll j = n + 2;j<=2*n;j++)
    {
        arr[j] = i;
        i--;
    }
    ll ans = 0;
    for(ll i = 2;i<=2*n;i++)
    {
        ll sol1 = k + i;
        ll freq1 = arr[i];
        if(sol1<= 2*n && sol1>=2)
        {
            ll freq2 = arr[sol1];
            ans += freq1*freq2;
        }
    }
    cout<<ans;
}


#include <bits/stdc++.h>

#define ll long long
#define ld long double
using namespace std;

const int N = 100 + 5;

int mod, k, dp[N][N], a[N];
string s;

int add(int a, int b){
    return (a + b) % mod;
}

int mul(int a, int b){
    return 1ll * a * b % mod;
}

int fp(int b, int p){
    if(p == 0) return 1;
    int ret = fp(b, p >> 1);
    ret = mul(ret, ret);
    if(p & 1) ret = mul(ret, b);
    return ret;
}

int beats(int a, int b){
    if(a == b) return a;
    if((a + 1) % 3 == b) return b;
    return a;
}

int solve(int idx, int k){
    if(k == 0) return a[idx];
    if(dp[idx][k] != -1) return dp[idx][k];

    int l = solve(idx, k - 1);
    int r = solve(add(idx, fp(2, k - 1)), k - 1);

    return dp[idx][k] = beats(l, r);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> mod >> k >> s;
    for(int i = 0; i < mod; i++){
        if(s[i] == 'P') a[i] = 1;
        else if(s[i] == 'S') a[i] = 2;
    }
    memset(dp, -1, sizeof dp);
    int ans = solve(0, k);
    if(ans == 0) cout << 'R';
    else if(ans == 1) cout << 'P';
    else cout << 'S';

    return 0;
}

    #include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007ll
#define pb push_back
#define vl vector<ll>
#define pll pair<ll,ll>
#define mp make_pair
using namespace std;
#define pi (long double)3.14159265358979323846
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 struct sch{
  ll s,e,t;
};
bool sortinrev(const struct sch &a, const struct sch &b)
{
    return (a.s < b.s);
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
ll lcm(ll a,ll b)
{
  return a*b/gcd(a,b);
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}
int main()
{
    ll n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    while(k--)
    {
        s = s+s;
        string tmp = "";
        for(int i=0;i<s.size();i+=2)
        {
            if((s[i]=='R' && s[i+1]=='P') || (s[i]=='P' && s[i+1]=='R'))
            {
                tmp += 'P';
            }
            else if((s[i]=='R' && s[i+1]=='S') || (s[i]=='S' && s[i+1]=='R'))
            {
                tmp += 'R';
            }
            else if((s[i]=='S' && s[i+1]=='P') || (s[i]=='P' && s[i+1]=='S'))
            {
                tmp += 'S';
            }
            else
            {
                tmp += s[i];
            }
        }
        s = tmp;
    }
    cout<<s[0]<<endl;
}


#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <chrono>
#include <random>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
// typedef pair<int,int> P;
// typedef pair<int,P> IP;
// typedef pair<P,P> PP;
double const PI=3.141592653589793;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

int I[]={1,0,-1,0};
int J[]={0,1,0,-1};

int N=50;
int si, sj;
int t[50][50];
int p[50][50];

int main(){
    cin>>si>>sj;
    rep(i,N) rep(j,N) cin>>t[i][j];
    rep(i,N) rep(j,N) cin>>p[i][j];

    string ans;
    vector<int> chk(N*N,1);
    int x=si, y=sj;
    while(true){
        chk[t[x][y]]=0;
        int maxi=-1;
        int id=-1;
        rep(k,4){
            int i=x+I[k];
            int j=y+J[k];
            if(0<=i && i<N && 0<=j && j<N && chk[t[i][j]] && maxi<p[i][j]){
                // cout<<p[i][j]<<endl;
                maxi=p[i][j];
                id=k;
            }
        }
        if(id==-1) break;
        // cout<<id<<endl;
        x+=I[id];
        y+=J[id];
        if(id==0) ans+='D';
        else if(id==1) ans+='R';
        else if(id==2) ans+='U';
        else if(id==3) ans+='L';
    }

    cout<<ans<<endl;

    return 0;
}


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

int main()
{
	int n;

	cin >> n;

	vector<pair<int, string> > t(n);

	for (int i = 0; i < n; i++)
	{
		cin >> t.at(i).second >> t.at(i).first;
	}

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

	cout << t.at(n - 2).second << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
using ll=long long;
using P=pair<int, int>;
int main(){
  int n;
  cin>>n;
  vector<P> pv(n);
  vector<string> sv(n);
  rep(i, n){
    pv[i].second=i;
    cin>>sv[i]>>pv[i].first;
  }
  //cout<<pv[1].second<<endl;
  sort(pv.begin(), pv.end());
  cout<<sv[pv[n-2].second]<<endl;
  return 0;
}


#include <bits/stdc++.h>
#include <algorithm>
#include <unordered_map>
#define ull unsigned long long
#define int long long
#define ll long long
#define fr(i, n) for (int i = 0; i < n; i++)
#define frf(i, j, n) for (int i = j; i <= n; i++)
#define frd(i, n) for (int i = n; i >= 0; i--)
#define mp(i, j) make_pair(i, j)
#define pb(x) push_back(x)
#define INF 1e18
#define int64_t 64
using namespace std;
typedef pair<int, int> pi;
const int MAX = 1e6 + 1;
// typedef vector<vector<ll>> matrix;
const ll PRIME = 1e9 + 7;
// typedef pair<int, pair<int, int>> ppi;
// const ll MAX = 1e6 + 1;
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
const int mod = 998244353;

int mul (int a,int b)
{
    return ( ((a%mod) * (b%mod )) % mod);
}
int add(int a,int b)
{
    return ((a % mod ) + (b % mod) % mod) ;
}
void solve()
{
 int n;
 cin>>n;
 int a,b;
 int sum=0;

 fr(i,n)
 {
     cin>>a>>b;
    a--;
    int temp1= (b*(b+1))/2;
    int temp2= (a*(a+1))/2;
    sum+=(temp1-temp2);
 }
 cout<<sum;

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

    // int k=1;
    while (t--)
    {
        // cout << "Case " << k++ << ":\n";
        solve();
    }
}

#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
ll t, n;
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> t >> n;
    ll x = (n * 100) / t;
    if ((n * 100) % t) ++x;
    cout << x + n - 1;
    return 0;
}


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

int main() {
    int a,b;
    cin>>a>>b;
    for(int x=-100;x<=100;x++){
        for(int y=-100;y<=100;y++){
            if(x+y==a and x-y==b){
                cout<<x<<" "<<y<<endl;
                break;
            }
        }
    }

}

#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	cout<<(a+b)/2<<" "<<(a-b)/2<<"\n";
	return 0;
}


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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<P,int>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = 998244353;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr int di8[] = {0, 1, 1, 1, 0, -1, -1, -1};
constexpr int dj8[] = {1, 1, 0, -1, -1, -1, 0, 1};
constexpr double EPS = 1e-9;

vector<vector<int> > g;

void chmin(int &a, int b){
    a = min(a,b);
}

ll N, K;
ll dp[3005][3005];  // i:unit, j:cnt, k:2^k

ll rec(ll i, ll j){
    if(i==0 && j==0) return 1;
    if(i==0 || j==0) return 0;
    if(dp[i][j] != -1) return dp[i][j];

    ll res = 0;
    if(i>=1 && j>=1) res += rec(i-1,j-1);
    if(i*2 <= j) res += rec(i*2, j);
    res %= MOD;
    return dp[i][j] = res;
}

int main(){
    for(int i=0;i<=3000;i++){
        for(int j=0;j<=3000;j++){
            dp[i][j] = -1;
        }
    }
    cin >> N >> K;
    cout << rec(K, N) << endl;

    return 0;
}

//_base::sync_with_stdio(false);
// cin.tie(nullptr);
// cout.tie(nullptr);
#include <valarray>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <stdio.h>
#include <string.h>
#include <unordered_set>
#include <random>
#include <unordered_map>
#define mxN 1000000007
#define mat vector<vector<int>>
#define ll long long
#define pb push_back
#define all(a) a.begin(), a.end()
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int h, w, mod = 998244353;
    cin >> h >> w;
    vector<string> v;
    for (int i = 0; i < h; ++i) {
        string s;
        cin >> s;
        v.pb(s);
    }
    ll ans = 1;
    for (int i = 0; i < w; ++i) {
        bool ald = true;
        int y = 0, x = i;
        set <int> s;
        while (x > -1 && y < h) {
            if (v[y][x] != '.') {
                ald = false;
                s.insert(v[y][x]);
            }
            --x;
            ++y;
        }
        if (s.size() > 1) {
            cout << 0 << endl;
            return 0;
        }
        if (ald) {
            ans *= 2;
        }
        ans %= mod;
    }
    for (int i = 1; i < h; ++i) {
        bool ald = true;
        int y = i, x = w - 1;
        set <int> s;
        while (x > -1 && y < h) {
            if (v[y][x] != '.') {
                ald = false;
                s.insert(v[y][x]);
            }
            --x;
            ++y;
        }
        if (s.size() > 1) {
            cout << 0 << endl;
            return 0;
        }
        if (ald) {
            ans *= 2;
        }
        ans %= mod;
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{

  int i;
  bool flag=false;
  string s;
  cin >> s;

  for(i=0;i<s.length();i++)
  {
  	if (i%2==0 && !(s[i]>='a' && s[i]<='z'))
  	{
  		flag=true;
  		break;
  	}
  	if (i%2!=0 && !(s[i]>='A' && s[i]<='Z'))
  	{
  		flag=true;
  		break;
  	}
  }

  if(flag) cout << "No" << endl;
  else cout << "Yes" << endl;

  return 0;
}

                              //ABHISHEK AGRAWAL,BIT mesra//
                      //Newbie......You have to be odd to be no. ONE :)//
//Authhor: Abhishekagrawal
//Date: 20/02/2021
//Time: 17:30:13
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define fl float
#define vll vector<ll>
#define pii pair<int,int>
#define vpll vector<pair<ll,ll>>
#define pb push_back
#define f first
#define s second
#define mll map<ll,ll>
#define mp make_pair
#define sp(n) fixed<<setprecision(n)
#define mod (ll)1000000007
#define sortv(v) sort(v.begin(),v.end())
#define INF (ll)(1e15)
#define loop(i,n) for(int i=0;i<n;i++)
#define loop1(i,n) for(int i=1;i<=n;i++)
#define rloop(n,i) for(int i=n-1;i>=0;i--)
#define sorta(a) sort(a,a+n,greater<ll>())
#define countone(n) __builtin_popcount(n)
#define numoftrailzero(n) __builtin_ctz(n)
#define maxpowoftwo(n) __builtin_clz(n)
#define leastindexwithone(n)  __builtin_ffs(n)
#define what_is(x) cerr << #x << " is " << x << endl;
#define pfv(v) cout<<v.size()<<"\n";loop(i,v.size()) cout<<v[i]<<" ";cout<<"\n";
#define pv(v) loop(i,v.size()) cout<<v[i]<<" ";
#define all(v) v.begin(),v.end()
#define mset(dp,val) memset(dp,val,sizeof(dp))
 ll test,n;ll sum,ans;
// #ifdef TESTING
// #define DEBUG fprintf(stderr, "====TESTING====\n")
// #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
// #define debug(...) fprintf(stderr, __VA_ARGS__)
// #else
// #define DEBUG
// #define VALUE(x)
// #define debug(...)
// #endif
void the_happiest_place_on_earth()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  #ifdef ENABLE_FILE_IO
    freopen("out.txt", "r", stdin);
    freopen("out1.txt", "w", stdout);
  #endif
}
// bool comp(const pair<ll,ll> &a, const pair<ll,ll> &b){
//   if(a.s+2*a.f==b.s+2*b.f) return a.f>b.f;
//   return (a.s+2*a.f>b.s+2*b.f);
// }
const int N=200040;ll a[N],b[N],c[N],par[N],Size[N],present[N],color[N];
void testcase(){
  string s;
  cin>>s;
  n=s.length();
  loop(i,n){
    if(i&1){
      if(s[i]>='a'){cout<<"No";return;}
    }
    else{
      if(s[i]<='Z'){cout<<"No";return;}
    }
  }
  cout<<"Yes";
  return;
}

int main(){
  the_happiest_place_on_earth();
  // Today's thought: Push yourself,because no one else is going to do it for you.
  // Things are not always #000000 and #FFFFFF
  // START OF PROGRAM LOGIC
  // g++ -o a BB.cpp -DENABLE_FILE_IO;./a
  // g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -o a file_name.cpp;./a
  test=1;int t=0;
  // cin>>test;
  while(test--){
    //cout<<"Case #"<<++t<<": ";
    testcase();
  }
  cerr << "Time : " << 1000 *((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
  // //END OF PROGRAM LOGIC
  return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?)
    * do smth instead of nothing and stay organized
    * WRITE STUFF DOWN
    * DON'T GET STUCK ON ONE APPROACH
*/


#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define pi 3.141592653589793
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define sz size()
#define cu cout<<
#define en endl
#define sp " "
#include<cstdio>
#include<cstring>
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll modd = (ll)1e9 + 7;
const int mod = 10000007;
/*#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                pe[j] = false;
        }
    }
}*/
void pr (int f)
{
    if(f==1)cout<<"YES\n";
    else cout<<"NO\n";
}
bool isprime(ll n)
{
    if(n<2) return 0;
    if(n==2) return 1;
    else
    {
        for(int i=2; i*i<=n; i++)
            if(n%i==0) return 0;
    }
    return 1;
}

ll countSum(ll x)
{
    ll res = 0;
    while (x != 0)
    {
        res += (x % 10);
        x /= 10;
    }
    return res;
}
const int NN = 1e6+5;
int main()
{
    fast ;
    int n;
    cin >> n;
    string s[n];
    map<string , int>mp;
    for(int i=0;i<n;i++)
    {
        cin >> s[i];
        mp[s[i]]++;
    }
    for (int i=0;i<n;i++)
    {
        string k ="!";
        string x = k+s[i];
        if(mp[x])
        {
            cout << s[i]<<endl;
            return 0;
        }
    }
    cout <<"satisfiable\n";

}

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

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

    int n;
    cin >> n;

    unordered_set<string> st;
    rep(i, n){
        string s;
        cin >> s;
        st.insert(s);
    }

    for(auto e: st){

        string other = '!' + e;
        if(st.count(other)){
            cout << e << endl;
            return 0;
        }
    }

    cout << "satisfiable" << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define endl '\n'
#define pb push_back
#define sz(c) (ll)c.size()
#define mp make_pair
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define F first
#define S second
#define M 1000000007
#define PI 3.1415926535897932384
#define pii pair<ll,ll>

const ll INF=2e18;
const ll N=1e5;
ll mod=998244353;
typedef pair<ll,ll> pi;
typedef vector<ll>   vi;
typedef vector<pair<ll,ll>> vp;
typedef vector<vector<ll>> vvi;

//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;
//}
//ll fact(ll n)
//{
//    ll ans=1;
//    for(ll i=1;i<=n;i++)
//	ans=(ans*i)%M ;
//	return ans;
//}
//
//
//
//
ll exp(ll x,ll n){

	ll res=1;
	while(n>0){
		if(n%2==1)
		res=(res*x)%M;
		x=(x*x)%M;
		n=n/2;
	}
	return res;
}
//
//
//ll nCr(ll n, ll k)
//{
//    ll res = 1;
//
//    // Since C(n, k) = C(n, n-k)
//    if(k>n-k){
//    	k=n-k;
//	}
//
//    // Calculate value of
//    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
//    for (ll i=0;i<k;i++) {
//        res *= (n - i);
//        res /= (i + 1);
//    }
//
//    return res;
//}
//vector<ll> fact(1005,0);
//void fac(){
//	fact[0]=1;
//	fact[1]=1;
//	for(int i=2;i<1005;i++){
//		fact[i] = (fact[i-1]*i)%M;
//	}
//}
//ll ncr(ll n,ll r){
//	ll num= fact[n];
//	ll den= (fact[n-r]*fact[r])%M;
//	den = exp(den,M-2);
//	return (num*den)%M;
//
//}

//vector<vector<ll>> dp(1001,vector<ll>(503,1));
//void pre(){
//	for(int i=0;i<=1000;i++){
//		for(int j=0;j<=min(i,502);j++){
//			if(j==0 or i==j){
//				dp[i][j]=1;
//				continue;
//			}
//			dp[i][j]= (dp[i-1][j]+ dp[i-1][j-1])%M;
//		}
//	}
//}
//string db(ll n)
//{
//    // array to store binary number
//    ll binaryNum[32];
//
//    // counter for binary array
//    ll i = 0;
//    while (n > 0) {
//
//        // storing remainder in binary array
//        binaryNum[i] = n % 2;
//        n = n / 2;
//        i++;
//    }
//    string s="";
//    // printing binary array in reverse order
//    for (int j = i - 1; j >= 0; j--) {
//    	s+= (binaryNum[j]+'0');
//	}
//	return s;
////        cout << binaryNum[j];
//
//}

void null(){

	ll n,s,d;
	cin>>n>>s>>d;
	bool res=false;
	for(int i=0;i<n;i++){
		ll x,y;
		cin>>x>>y;
		if(x<s and y>d){
			res=true;
		}
	}
	if(res)
	cout<<"Yes";
	else
	cout<<"No";
	cout<<endl;

}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	cout<<setprecision(9);
	cout<<fixed;
    ll t = 1;
    clock_t start, end;
    start = clock();

//    #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//    freopen("error.txt", "w", stderr);
//    #endif
//    cin>>t;
//    compute();
    while(t--){
        null();
    }

    end = clock();
    double time_taken = double(end - start) / double(CLOCKS_PER_SEC);
    //cerr<<time_taken;
}

#include <iostream>
using namespace std;
int main(){
    int T;
    cin>>T;
    while (T--){
        int n;
        cin>>n;
        string s1;
        string s2;
        string s3;
        cin>>s1>>s2>>s3;
        string res;
        for (int i=0;i<n;i++){
            res+='1';
        }
        for (int i=0;i<n;i++){
            res+='0';
        }
        res+='1';
        cout << res<<'\n';
    }
}


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

typedef long long ll;

int main(){
    ll n,ans=LONG_LONG_MAX;
    cin>>n;
    for(int b=0;(1LL<<b)<=n;b++)
        ans=min(ans,b+(n>>b)+(n&((1LL<<b)-1)));
    cout<<ans<<endl;
}

/* HAVE PATIENCE YOU CAN SOLVE EVERY QUESTION
   JUST THINK*/
   //#pragma GCC optimize("Ofast")
   //#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
//#include <unordered_set>
//#include <unordered_map>

using namespace std;
int mod = 1000000007;
const double pi = 3.141592653689793238460;
const int inf = 0x3f3f3f3f;
const int   N = 2e5 + 5;
const int pr = 31;
#define ll long long
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define MEM(x) memset(x,inf,sizeof(x))
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i< n; i++)
#define forl(i,l,u) for(int i=(int)l;i<=(int)u;++i)
#define all(v) (v).begin(), (v).end()
#define sum(a)   ( accumulate ((a).begin(), (a).end(), 0ll))
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

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

}
int f(int x, int y, string a[]) {
    int l;
    if (a[x][y] == '+')l = 1;
    else l = -1;
    return l;
}

int n;
long long dp[501][501];
vector<int > one(n);
vector<int> zero(n);
int main()
{
//#define int ll
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    ll n;
    cin >> n;
    ll ans = 1e18;
    forl(i, 0, 61) {
        ll b = (ll)pow(2, (ll)i);
        ll c = n % b;
        ll a = n / b;
        ans = min(ans, (a + (ll)i + c));
    }
    cout << ans << endl;
}


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

#define int long long
#define endl        "\n"
#define debug(arr) for(int x : arr) cout << x <<  " "; cout << endl;
#define fast        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int32_t main() {
	fast;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int x, y;
	cin >> x >> y;

	if(x == y) {
		cout << x << endl;
	}else {
		cout << 3 - (x + y) << endl;
	}

	return 0;

}

#include <iostream>
using namespace std;

int main()
{
    int x,y, rock=0, scissors=1, paper=2;
    cin>>x>>y;
    if(x==y) cout<<x;
    else{
        if(x==rock&&y==scissors || x==scissors&&y==rock) cout<<paper;
        else if(x==paper&&y==rock || x==rock&&y==paper) cout<<scissors;
        else cout<<rock;
    }
    return 0;
}


#include <set>
#include <map>
#include <stdio.h>
#include <stdlib.h>
#include <queue>
#include <string>
#include <vector>
#include <cmath>
#include <cstdio>
#include <utility>
#include <iostream>
#include <iterator>
#include <algorithm>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {

	int x; cin >> x;
	x = x % 100;
	cout << 100 - x << endl;
}

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

#define LOCAL 1;
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

template<typename T>
ostream& operator<< (ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ", ";
  }
  out << "]";
  return out;
}

template<typename F, typename S>
ostream& operator<< (ostream& out, const pair<F,S>& p) {
  out << "[" << p.first << ", " << p.second << "]";
  return out;
}

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

  ll x; cin >> x;
  cout << (100 - x%100) << endl;

  return 0;

}


#include "bits/stdc++.h"

using namespace std;

void Main() {
    int N, K;
    cin >> N >> K;
    map<int, int> m;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        m[a] += 1;
    }

    vector<int> numOfA;
    for (int i = 0; i < N; ++i) {
        if (m.count(i) == 0) {
            break;
        }
        numOfA.push_back(m[i]);
    }
    for (int i = 1; i < numOfA.size(); ++i) {
        numOfA[i] = min(numOfA[i - 1], numOfA[i]);
    }
    if (numOfA.size() == 0) {
        cout << 0 << endl;
        return;
    }
    vector<int> combination;
    for (int i = 0; i < numOfA.back(); ++i) {
        combination.push_back(numOfA.size());
    }
    for (int i = numOfA.size() - 2; i >= 0; --i) {
        int n = numOfA[i] - numOfA[i + 1];
        for (int j = 0; j < n; ++j) {
            combination.push_back(i + 1);
        }
    }

    int ans = 0;
    for (int i = 0; i < K; ++i) {
        if (i == combination.size()) {
            break;
        }
        ans += combination[i];
    }
    cout << ans << endl;
}

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

// #include <atcoder/all>
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int n;
ll a[200009], b[200009];

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

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

    ll sum = 0;
    rep(i, n) sum += a[i];

    vector<int> odd, even;
    rep(i, n)(i & 1 ? odd : even).push_back(b[i] - a[i]);

    sort(ALL(odd), greater<int>());
    sort(ALL(even), greater<int>());

    ll ans = sum;
    rep(i, n / 2) chmax(ans, sum += odd[i] + even[i]);

    cout << ans << endl;

    return 0;
}


#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<map>
#include<stack>
#include<queue>
#include<math.h>

using namespace std;

#define int long long
#define mod 1000000007

int ans = 0;

vector<int>graph[200001];
vector<int>visited(200001, -1);

void dfs(vector<int>graph[], int start, vector<int>&visited)
{
    visited[start] = 1;

    for (auto i : graph[start])
    {
        if (visited[i] == -1)
        {   ans++;
            dfs(graph, i, visited);
        }
    }

}

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

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

    int n;
    cin >> n;

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

    int i = 0;
    int j = n - 1;
    while (i < j)
    {

        graph[arr[i]].push_back(arr[j]);
        graph[arr[j]].push_back(arr[i]);

        i++;
        j--;
    }

    for (int i = 0; i < arr.size(); i++)
    {
        if (visited[arr[i]] == -1)
        {

            dfs(graph, arr[i], visited);
        }
    }
    cout << ans << endl;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define endl "\n"
#define deb(x) cout<<#x<<" "<<x<<endl;
#define sc(ar,n) for(int pen=0;pen<n;pen++){ cin>>ar[pen];}
#define pr(ar,n) for(int pen=0;pen<n;pen++){ cout<<ar[pen]<<" ";} cout<<endl;
#define fr(i,x,n) for(int i=x;i<n;i++)
#define frt(it,vb) for(auto it=vb.begin();it!=vb.end();it++)
#define mem(ar,x) memset(ar,x,sizeof(ar));
#define pb push_back
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define rt return 0;
#define ct continue;
#define MAX 1000000000000000000
#define MAX1 1000000000
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

inline int solve()
{
    int n;
    cin>>n;
    int ar[n];
    sc(ar,n);
    vector <int> vt[200010];
    fr(i,0,n/2){
        if(ar[i] != ar[n-i-1]){
            vt[ar[i]].push_back(ar[n-i-1]);
            vt[ar[n-i-1]].push_back(ar[i]);
        }
    }
    int vis[200010];
    mem(vis,0);
    int ans = 0;
    fr(i,1,200010){
        if(vis[i] == 0){
            queue <int> q;
            q.push(i);
            vis[i] = 1;
            int c = 0;
            while(!q.empty()){
                int x = q.front();
                q.pop();
                c++;
                frt(it,vt[x]){
                    if(vis[*it] == 0){
                        q.push(*it);
                        vis[*it] = 1;
                    }
                }
            }
            ans += c-1;
        }
    }
    cout << ans << endl;
    rt;
}
signed main()
{
    // fastio;
    int t;
    int test_cases=1;
    if(test_cases==0)
    cin>>t;
    else
    t=1;
    while(t--){
        solve();
    }
}


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

const ll MIN = -1e18;

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

	int n;
	ll m, ans = 1e18;

	cin >> n >> m;

	vector<ll> a(n);
	for (ll& x : a) cin >> x;

	for (int k = 1; k <= n; ++k) {
		vector<vector<ll>> dp(k, vector<ll>(k+1, MIN));
		dp[0][0] = 0;
		for (ll x : a) {
			for (int c = k; c >= 1; --c) {
				for (int r = 0; r < k; ++r) {
					if (dp[(r-x%k+k)%k][c-1] >= 0) {
						dp[r][c] = max(dp[r][c], dp[(r-x%k+k)%k][c-1] + x);
					}
				}
			}
		}
		if (dp[m%k][k] < 0) continue;
		ans = min(ans, (m - dp[m%k][k])/k);
	}

	cout << ans;

	return 0;
}

#include <iostream>
#include <vector>
#include <limits>
#include <cstring>
#include <time.h>
#include <math.h>
#include <algorithm>
#include <random>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <chrono>
#include <sstream>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii > vii;
typedef vector<vector<ll> > vvi;
typedef vector<vvi > vvvi;
typedef vector<vector<pair<ll, ll> > > vvii;
typedef ll func_ii_i(ll, ll);

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,s,e) for(ll i=(s);i<(e);++i)
#define repr(i,s,e) for(ll i=(e);i>(s);--i)
#define io do { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(10); } while (0)
#define endl '\n'
#define newl cout << '\n';

#define fill0(a) memset(a, 0, sizeof(a))
#define fill1(a) memset(a, -1, sizeof(a))

#define all(v) v.begin(), v.end()
#define bg begin()
#define ed end()
#define tr(it, v) for (auto it = v.bg; it != v.ed; it++)
#define prv(v) do { tr(it, v) { cout << *it << " "; }; cout << endl; } while (0)
#define prm(m) tr(it, m) { cout << it->first << " -> " << it->second << endl; }
#define scan(a, n) rep(_idx,0,n) cin >> a[_idx];
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define sumv(v) accumulate(all(v), 0ll)
#define ub(a, x) upper_bound(all(a), x)
#define lb(a, x) lower_bound(all(a), x)

#define tcT template<class T

ll min3(ll a, ll b, ll c) { return min(a, min(b, c)); }
ll max3(ll a, ll b, ll c) { return max(a, max(b, c)); }
ll mid3(ll a, ll b, ll c) { return a + b + c - min3(a, b, c) - max3(a, b, c); }
ll ceil1(ll x, ll y) { if(x % y) return (x + y) / y; else return x / y; }
tcT> void rmdup(vector<T> &v) { sort(all(v)); v.erase(unique(all(v)), v.ed); }
tcT> ll fst1(ll l, ll h, T f) {
	++h; // f is increasing
	while(l<h) {
		ll mi = l + ((h - l) >> 1);
		f(mi) ? h = mi : l = mi + 1;
	}
	return l;
}
tcT> ll lst1(ll l, ll h, T f) {
	--l; // f is decreasing
	while(l<h) {
		ll mi = l + ((h - l + 1) >> 1);
		f(mi) ? l = mi : h = mi - 1;
	}
	return l;
}

const ll MOD = 1e9+7;
const ll INF = 1e16;
const ll TE3 = 1005;
const ll TE5 = 300005;
const ll dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
const string YN[2] = {"NO", "YES"};

using namespace std;

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

ll g(vi &v,ll n,ll k,ll x,ll rem,ll t) {
	if(rem==0 && t==0) {
		return 0;
	}
	if(rem<=0) {
		return -INF;
	}
	if(x<0) {
		return -INF;
	}
	if(dp[x][rem][t]!=-1) {
		return dp[x][rem][t];
	}
	ll e=v[x];
	ll em=e%k;
	ll nm=(t-em+k)%k;
	ll ans=g(v,n,k,x-1,rem,t);
	ans=max(ans,e+g(v,n,k,x-1,rem-1,nm));
	return dp[x][rem][t]=ans;
}

int main()
{
	io;
	ll n,x;
	cin>>n>>x;
	vi v(n);
	scan(v,n);

	ll ans=-1;
	rep(k,1,n+1) {
		ll t=x%k;
		fill1(dp);
		ll su=g(v,n,k,n-1,k,t);
		if(su<0) {
			continue;
		}
		ll local=(x-su)/k;
		if(ans==-1) {
			ans=local;
		} else {
			ans=min(ans,local);
		}
	}
	cout<<ans<<endl;
	return 0;
}


#include <iostream>
#include <bits/stdc++.h>
#include <map>

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    char a[H][W];
    int dist[H][W];
    map<char, vector<pair<int, int>>> mp;
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            char c;
            cin >> c;
            a[i][j] = c;
            if(c != '#' && c != '.') mp[c].emplace_back(i, j);
            dist[i][j] = -1;
        }
    }
    dist[mp['S'][0].first][mp['S'][0].second] = 0;
    queue<pair<int, int>> q;
    q.emplace(mp['S'][0].first, mp['S'][0].second);
    // cout << list_d[0].size() << endl;
    vector<int> dx{-1, 0, 1, 0};
    vector<int> dy{0, 1, 0, -1};
    while(q.size()) {
        // cout << "t:" << t << ' ' << e[0] << ' ' << e[1] <<  endl;
        auto [x, y] = q.front();
        q.pop();
        for(int d=0; d<4; d++) {
            // cout << i << ' ' << j << endl;
            int x2 = x + dx[d];
            int y2 = y + dy[d];
            if(dist[x2][y2] == -1 && x2 >= 0 && x2 < H && y2 >= 0 && y2 < W && a[x2][y2] != '#') {
                // cout << x << ' ' << y << ' ' <<  endl;
                if(a[x2][y2] == 'G') {
                    cout << dist[x][y]+1 << endl;
                    return 0;
                }
                dist[x2][y2] = dist[x][y] + 1;
                q.emplace(x2, y2);
            }
        }
        for(const auto& c : mp[a[x][y]]) {
            if(dist[c.first][c.second] >= 0) continue;
            dist[c.first][c.second] = dist[x][y] + 1;
            q.emplace(c.first, c.second);
            // cout << c[0] << ' ' << c[1] << endl;
        }
    }
    cout << -1 << endl;
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr char newl = '\n';

ll dp[100][200000 + 10];

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

    int n, K;
    ll m;
    cin >> n >> K >> m;

    int lim_sum = (n - 1) / 2;
    lim_sum = lim_sum * (lim_sum + 1) / 2 * K;

    dp[0][0] = 1;
    for (int i = 1; i < n; i++) {
        int max_sum = min((i - 1) * i / 2 * K, lim_sum);
        for (int j = 0; j <= max_sum; j++) {
            if (dp[i - 1][j] == 0) continue;
            for (int k = 0; k <= K; k++) {
                if (j + k * i > lim_sum) break;
                dp[i][j + k * i] += dp[i - 1][j];
                if (dp[i][j + k * i] >= m) dp[i][j + k * i] -= m;
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        int li = i - 1;
        int ri = n - i;
        int mini = min(li, ri);
        int max_sum = mini * (mini + 1) / 2 * K;

        ll ans = 0;
        for (int j = 0; j <= max_sum; j++) {
            (ans += dp[li][j] * dp[ri][j] % m);
            if (ans >= m) ans -= m;
        }
        ans = (ans * (K + 1) + m - 1) % m;
        cout << ans << newl;
    }
    return 0;
}


//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
#define all(v) v.begin(), v.end()
using in = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const in MOD = 1000000007;
const in INF=(in)1e18+7;
const int inf=max(int(1e18)+7,int(1e9)+7);
using P=pair<int,int>;
using T=tuple<int,int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};
template <typename Typ>
bool chmin(Typ &a, const Typ& b) {if (a > b) {a = b; return true;} return false;}
template <typename Typ>
bool chmax(Typ &a, const Typ& b) {if (a < b) {a = b; return true;} return false;}
template <typename Typ>
Typ ceil(Typ x, Typ y){return (x+y-1)/y;}
#ifdef  _DEBUG
    #define debug(x) cout<<"debug:"<<x<<endl
    #define vdebug(x) cout<<"debug:";\
                      for(auto asdf:x) cout<<asdf<<" ";\
                      cout<<endl
#else
    #define debug(x)
    #define vdebug(x)
#endif

int main(){
ios::sync_with_stdio(false);cin.tie(nullptr);
//cout << fixed << setprecision(12);
    int n,m;  cin>>n>>m;
    vector<int> a(m),b(m);
        rep(i,m) cin>>a[i]>>b[i];
    int k;  cin>>k;
    vector<int> c(k),d(k);
        rep(i,k) cin>>c[i]>>d[i];
    int ans=0;
    for(int tmp = 0;tmp< (1<<k); tmp++){
        bitset<16> bt(tmp);
        vector<bool> num(n,false);
        rep(i,k){
            if(bt.test(i)) num[d[i]-1]=true;
            else num[c[i]-1]=true;
        }
        int cnt=0;
        rep(i,m){
            if(num[a[i]-1] and num[b[i]-1]) cnt ++;
        }
        chmax(ans,cnt);
    }
    cout<<ans<<"\n";

}/*
./problem.exe
*/

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

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using ordered_set = tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

const ll MOD = 1e9+7;
const ll INF = 1e18;
const ll N = 2e5+5;

#define S second
#define F first
#define vt vector
#define rep(i, st, en) for(ll i = (st); i < (en); ++i)
#define repr(i, en, st) for(ll i = (en); i >= (st); --i)

int main() {
	fastio();

	ll r, x, y;
	cin >> r >> x >> y;

	ll d2 = x*x + y*y;
	ll r2 = r*r;

	ll n = sqrtl(d2/r2);
	while (r2*n*n < d2) {
		n++;
	}

	if (r2 > d2) {
		n = 2;
	}

	cout << n << "\n";

}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<cstdlib>
#include<utility>
using namespace std;
int main()
{
    int T;
    scanf("%d",&T);
    while (T--)
    {
        long long n;
        scanf("%lld",&n);
        if (n%2==1)
        {
            printf("Odd\n");
            continue;
        }
        n/=2;
        if (n%2==1)
        {
            printf("Same\n");
            continue;
        }
        printf("Even\n");
    }
}

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <math.h>
#include <random>
#include <chrono>
#include <assert.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
template<class T> using V = vector<T> ;
template<class T> using VV = V<V<T>> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
long double pie = acos(-1) ;
ll INF = 1e18 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
ll extGCD(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x = 1 ;
        y = 0 ;
        return a ;
    }
    ll d = extGCD(b,a%b,y,x) ;
    y -= a/b*x ;
    return d ;
}
void fix_cout(){cout << fixed << setprecision(20) ;}
template<class T> void chmax(T &a,T b){if(a<b) a = b ;}
template<class T> void chmin(T &a,T b){if(a>b) a = b ;}

int main(){
    int n ; cin >> n ;
    V<ll> a(n) ;
    for(auto &i:a) cin >> i ;
    sort(all(a)) ; reverse(all(a)) ;
    ld ans = 1e15 ;
    ll sum = 0 ;
    for(int i=0;i<n;i++){
        ld sub = 0 ;
        ld x = a[i]/2.0 ;
        sub += sum-a[i]*i;
        sub /= n ;
        sub += x ;
        sum += a[i] ;
        chmin(ans,sub) ;
    }
    fix_cout() ;
    cout << ans << endl ;
}


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

#define llong long long
#define len(x) ((int)x.size())
#define rep(i,n) for (int i = -1; ++ i < n; )
#define rep1(i,n) for (int i = 0; i ++ < n; )
#ifdef testing/*{{{*/
mt19937 rng(177013);
#else
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
#endif
#define rand() (int)(rng() >> 1)
#define CONCAT_(x, y) x##y
#define CONCAT(x, y) CONCAT_(x, y)
#define SPEC(name) CONCAT(name, __LINE__)
#ifdef LOCAL_DEBUG
int __db_level = 0;
#define clog cerr << string(__db_level * 2, ' ')
struct debug_block {
    string msg;
    debug_block(const string& s): msg(s) { clog << "{ " << msg << endl; ++__db_level; }
    ~debug_block() { --__db_level; clog << "} " << msg << endl; }
};
#define DB(args...) stringstream SPEC(ss); SPEC(ss)<< args; debug_block SPEC(dbbl)(SPEC(ss).str())
#else
#define clog if (0) cerr
#define DB(...)
#endif
#define db(val) "[" #val " = " << val << "]; "
template<class U, class V> ostream& operator<<(ostream& out, const pair<U, V>& p) {
    return out << "(" << p.first << ", " << p.second << ")";
}
template<size_t i, class T> ostream& print_tuple_utils(ostream& out, const T& tup) {
    if constexpr(i == tuple_size<T>::value) return out << ")";
    else return print_tuple_utils<i + 1, T>(out << (i ? ", " : "(") << get<i>(tup), tup);
}
template<class ...U>
ostream& operator<<(ostream& out, const tuple<U...>& tup) { return print_tuple_utils<0, tuple<U...>>(out, tup); }
template<class, typename = void> struct has_const_iterator : false_type {};
template<class T> struct has_const_iterator<T, void_t<typename T::const_iterator>> : true_type {};
template<class T>
typename enable_if<has_const_iterator<T>::value && !is_same<T, string>::value, ostream&>::type
operator<<(ostream& out, const T& container) {
    auto beg = container.begin(), end = container.end();
    out << "(" << container.size() << ") {";
    if (beg != end) out << *(beg++);
    while (beg != end) out << ", " << *(beg++);
    return out << "}";
}
#define ptrtype(x) typename iterator_traits<x>::value_type
template<class u> vector<ptrtype(u)> $v(u a, u b) { return vector<ptrtype(u)>(a, b); }/*}}}*/
// ACTUAL SOLUTION START HERE ////////////////////////////////////////////////////////////////

const int max_col = 400000 + 10;
int n;
int dsu[max_col];
bool has_cycle[max_col];

int find_set(int u) {
    return dsu[u] < 0 ? u : dsu[u] = find_set(dsu[u]);
}

bool join(int u, int v) {
    u = find_set(u);
    v = find_set(v);
    if (u == v) return false;
    if (-dsu[u] < -dsu[v]) swap(u, v);
    dsu[u] += dsu[v];
    if (has_cycle[v]) has_cycle[u] = true;
    dsu[v] = u;
    return true;
}

int main(void) {
#ifdef LOCAL
    freopen("main.inp", "r", stdin);
    freopen("main.out", "w", stdout);
    freopen(".log", "w", stderr);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    memset(dsu, -1, sizeof(dsu));
    memset(has_cycle, 0, sizeof(has_cycle));

    rep(i, n) {
        int u, v; cin >> u >> v;
        if (!join(u, v)) {
            has_cycle[find_set(u)] = true;
        }
    }

    int ans = 0;
    rep(i, max_col) {
        if (dsu[i] >= 0) continue;
        if (has_cycle[i]) ans += -dsu[i];
        else ans += -dsu[i] - 1;
    }
    cout << ans;

    return 0;
}

// vim: foldmethod=marker

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cstdio>
#include <cstring>
#define min(a, b) ((a) < (b) ? (a) : (b))

static constexpr int cm = 1 << 17;
char cn[cm], *ci = cn + cm, ct;

inline char getcha() {
	if (ci - cn == cm) {
		fread(cn, 1, cm, stdin);
		ci = cn;
	}
	return *ci++;
}

inline int getint() {
	int A = 0;
	while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	return A;
}

static constexpr int mx = 400000;
int p[mx], cnt[mx], siz[mx];

inline int get(int x) { return p[x] == -1 ? x : p[x] = get(p[x]); }

int main() {
	int n = getint();
	memset(p, -1, sizeof(p));
	while (n--) {
		int a = get(getint() - 1), b = get(getint() - 1);
		if (a != b) {
			p[b] = a;
			cnt[a] += cnt[b];
		}
		cnt[a]++;
	}
	for (int i = 0; i < mx; i++) {
		siz[get(i)]++;
	}
	int ans = 0;
	for (int i = 0; i < mx; i++) {
		if (get(i) == i) {
			ans += min(cnt[i], siz[i]);
		}
	}
	printf("%d", ans);
}


/* >>>>>Shwetal<<<<< */
#include <bits/stdc++.h>
#define int long long
#define f(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define inputArray(arr) f(i, 0, arr.size()) cin >> arr[i]
#define printArray(arr) f(i, 0, arr.size()) cout << arr[i] << ' '; cout << endl
#define endl '\n'
typedef long long ll;
const int mod = 1e9+7;
using namespace std;

bool solve() {
    string s;
    cin >> s;
    int n = s.size();
    // bool flag = true;
    f(i, 0, n){
        if(i % 2 == 1 && islower(s[i])){
            return false;
        }
        if(i % 2 == 0 && isupper(s[i])){
            return false;
        }
    }
    return true;

}

int32_t main(){
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T = 1;
    // cin >> T;
    while(T--){
        // solve();
        if(solve())
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  string S;
  cin >> S;

  for (int i = 0; i < (int)S.size(); i++) {
    if ((i % 2 == 0) && (S.at(i) < 'a' || S.at(i) > 'z')) {
      cout << "No" << endl;
      return 0;
    }

    else if ((i % 2 == 1) && (S.at(i) < 'A' || S.at(i) > 'Z')) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef gp_hash_table<int, int> hashmap;
//typedef tree<pii, null_type, std::less<pii>, splay_tree_tag, tree_order_statistics_node_update> splaytree;
//typedef tree<pii, null_type, std::less<pii>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
//typedef __gnu_pbds::priority_queue<int, std::greater<int>, __gnu_pbds::binary_heap_tag> binheap;
//typedef __gnu_pbds::priority_queue<int, std::greater<int>, __gnu_pbds::pairing_heap_tag> pairingheap;

template <typename T>
inline void read(T &x)
{
    T data = 0, f = 1;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        data = (data << 3) + (data << 1) + ch - '0';
        ch = getchar();
    }
    x = f * data;
}
template <typename T, typename... Args>
inline void read(T &t, Args &...args)
{
    read(t);
    read(args...);
}
#define int ll
//mt19937 rnd(time(0));
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int maxn = 6e5 + 9;
const ll mod = 998244353;
int n, n2;

ll BIT[maxn], a[maxn], ans[maxn];
inline int lowbit(int x)
{
    return x & -x;
}
void add(int k, int x)
{
    for (; k <= n; k += lowbit(k))
        BIT[k] += x;
}

ll ask(int k)
{
    ll ret = 0;
    for (; k; k -= lowbit(k))
        ret += BIT[k];
    return ret;
}

signed main()
{
    //freopen("in.txt","r",stdin);
    //freopen("data.txt","w",stdout);
    //std::ios::sync_with_stdio(false);
    //std::cin.tie(0);
    //std::cout.tie(0);
    read(n);
    for (int i = 1; i <= n; ++i)
    {
        read(a[i]);
        a[i]++;
        a[i + n] = a[i];
    }
    n2 = n * 2;
    int cnt = 0;
    for (int i = 1, l = 1, r = 0; i <= n; ++i)
    {
        int ql = i, qr = i + n - 1;
        ans[i] = ans[i - 1];
        while (l < ql)
        {
            ans[i] -= ask(a[l] - 1);
            add(a[l], -1);
            l++;
            cnt--;
        }
        while (r < qr)
        {
            r++;
            add(a[r], 1);
            cnt++;
            //cout << r << ' ' << cnt << ' ' << ask(a[r]) << '\n';
            ans[i] += (cnt - ask(a[r]));
        }
        cout << ans[i] << '\n';
    }
    // for (int i = 1; i <= n; ++i)
    // {
    //     cout << ans[i] - ans[i + n] << '\n';
    // }
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
#define lin(x) ll x; cin>>x;
#define stin(x) string x; cin>>x;
#define yn(x)  if(x) {  cout<<"Yes"<<endl;   }    else {    cout<<"No"<<endl;   }
#define YN(x)  if(x) {  cout<<"YES"<<endl;   }    else {    cout<<"NO"<<endl;   }
#define co(x) cout<<x<<endl;
using ll=long long;
using ld=long double;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll mod=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
template <typename T> inline bool chmax(T &a, T b) {
    return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
    return ((a > b) ? (a = b, true) : (false));
}
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}

template <class T>
class SegTree {
    int n;// 葉の数
    vector<T> data;// データを格納するvector
    T def; // 初期値かつ単位元
    function<T(T, T)> operation; // 区間クエリで使う処理
    function<T(T, T)> update;// 点更新で使う処理

    T find(int a, int b) {
        T val_left = def, val_right = def;
        for (a += (n - 1), b += (n - 1); a < b; a >>= 1, b >>= 1)
        {
            if ((a & 1) == 0){
                val_left = operation(val_left, data[a]);
            }
            if ((b & 1) == 0){
                val_right = operation(data[--b],val_right);
            }
        }
        return operation(val_left, val_right);
    }
    public:
    // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
    // _update:更新関数
    SegTree(size_t _n, T _def, function<T(T, T)> _operation=[](T  a, T  b){return  a+b;},
        function<T(T, T)> _update=[](T a,T b){return b;})
        : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
    }
    void set(int i, T x) { data[i + n - 1] = x; }
    void build() {
        for (int k=n-2;k>=0;k--) data[k] = operation(data[2*k+1],data[2*k+2]);
    }
    // 場所i(0-indexed)の値をxで更新
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    // [a, b)の区間クエリを実行
    T query(int a, int b) {
        //return _query(a, b, 0, 0, n);
        return find(a,b);
    }

    // 添字でアクセス
    T operator[](int i) {
        return data[i + n - 1];
    }
};
int main() {
lin(N);
  vl A(N);
  rep(i,N) {
    cin>>A.at(i);
  }

  SegTree <ll>st(N,0);
  ll count=0;
  rep(i,N) {
    count+=st.query(A.at(i),N);
    st.change(A.at(i),1);
  }

  rep(i,N) {
    co(count);
    count+=N-1-2*A.at(i);
  }

}