//#define _GLIBCXX_DEBUG
//#include "atcoder/all"
//using namespace atcoder;
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define Dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) (((n) >> (k)) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = true;
}  // namespace mydef
using namespace mydef;
#define pb push_back
//#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int a, b;

void solve() {
}

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

    cin >> a >> b;
    if (a < b)
        swap(a, b);
    Yes(a < b + 3);

    solve();
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N), B(N);
    vector<ll> type(2*N+1, 0);
    // type.at(i)の値が-1ならi階が始点であること、0なら未確定であること、1なら終点であることを表す
    vector<vector<ll>> p(2*N+1, vector<ll>(2*N+1, 0));
    // p.at(i).at(j)の値が-1ならi階からj階への移動が不可能であること、
    // 0なら可能であること、1なら確定していることを表す
    set<ll> source; // 終点が不明な始点の集合
    set<ll> target; // 始点が不明な終点の集合
    rep(i, N){
        cin >> A.at(i) >> B.at(i);
        if(A.at(i) != -1){
            if(type.at(A.at(i)) != 0){
                cout << "No" << endl;
                return 0;
            }
            type.at(A.at(i)) = -1;
        }
        if(B.at(i) != -1){
            if(type.at(B.at(i)) != 0){
                cout << "No" << endl;
                return 0;
            }
            type.at(B.at(i)) = 1;
        }
        if(A.at(i) != -1 && B.at(i) != -1 && A.at(i) >= B.at(i)){
            cout << "No" << endl;
            return 0;
        }
        if(A.at(i) != -1 && B.at(i) != -1){
            p.at(A.at(i)).at(B.at(i)) = 1;
        }
        if(A.at(i) != -1 && B.at(i) == -1){
            source.insert(A.at(i));
        }
        if(A.at(i) == -1 && B.at(i) != -1){
            target.insert(B.at(i));
        }
    }
    rep2(i, 1, 2*N+1){
        rep2(j, 1, i+1){
            p.at(i).at(j) = -1;
        }
    }
    for(auto i : source){
        for(auto j : target){
            p.at(i).at(j) = -1;
        }
    }
    rep(i, 2*N+1){
        if(type.at(i) == -1){
            rep(j, 2*N+1){
                p.at(j).at(i) = -1;
            }
        }
        if(type.at(i) == 1){
            rep(j, 2*N+1){
                p.at(i).at(j) == -1;
            }
        }
    }
    rep(i, N){
        if(A.at(i) != -1 && B.at(i) != -1){
            rep(k, 2*N+1){
                if(k == B.at(i)){
                    continue;
                }
                p.at(A.at(i)).at(k) = -1;
            }
            rep(k, 2*N+1){
                if(k == A.at(i)){
                    continue;
                }
                p.at(k).at(B.at(i)) = -1;
            }
        }
    }
    vector<bool> dp(N+1, false);
    // dp.at(i)は最後に区切ったのが2*i階であるということが可能かどうかを表す
    dp.at(0) = true;
    bool failure = false;
    rep(i, N){
        rep(j, i+1){
            if(!dp.at(j)){
                continue;
            }
            // i+1-j階分移動することは可能か
            rep(k, i+1-j){
                if(p.at(2*j+1+k).at(j+2+i+k) == -1){
                    failure = true;
                    break;
                }
            }
            if(failure){
                failure = false;
                continue;
            }
            dp.at(i+1) = true;
            break;
        }
    }
    if(dp.at(N)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    ll n,m;
    cin >> n >> m;
    vector<int> cnt(n);
    rep(i,n){
        string s;
        cin >> s;
        rep(j,m){
            if(s[j] == '1') cnt[i]++;;
        }
    }
    // rep(i,n){
    //     cout << cnt[i] << endl;
    // }
    ll total = n*(n-1)/2;
    ll a = 0;
    rep(i,n){
        // if(cnt[i]==cnt[i+1]) a++;
        // else{
        //     a++;
        //     total -= a*(a-1)/2;
        //     total -= (a-1)*(n-a);
        //     a = 0;
        // }
        cnt[i] %= 2;
    }
    sort(cnt.begin(), cnt.end());
    ll cnt1 = count(cnt.begin(), cnt.end(), 1);
    ll cnt0 = n - cnt1;
    cout << cnt1*cnt0 << endl;
    return 0;
}

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

#define pb push_back
#define mp make_pair

const int MOD = 1e9+7;
const int MAX_N=1e5+10;

int n, m;
string s[MAX_N];
int c1, c2;

void solve()
{

	for(int i=0;i<n;++i){
		int cur = 0;
		for(int j=0;j<m;++j){
			cur = 2*cur + (s[i][j]-'0');
		}
		if(__builtin_popcount(cur) & 1) c1++;
		else c2++;
	}
	cout<<1LL*c1*c2<<'\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	cin >> n >> m;
	for(int i=0;i<n;++i)cin>>s[i];
	solve();
	return 0;
}


//Never stop trying
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

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

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

#define dbg(x) cerr << " - " << #x << " : " << x << endl;
#define dbgs(x,y) cerr << " - " << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << " - " << #v << " : " << endl << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;

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

int power[4000009];

int32_t main() {
	boost; IO();

	power[0]=1;
	FOR(i,1,4000009) power[i]=(power[i-1]*2)%MOD;

	int N,M; cin>>N>>M;
	char g[N][M];
	int a[N][M],b[N][M],c[N][M],d[N][M];

	int K=0;
	FOR(i,0,N) FOR(j,0,M){
		cin>>g[i][j];
		if(g[i][j]=='.') K++;
	}

	//L
	FOR(i,0,N) FOR(j,0,M){
		if(g[i][j]=='#'){
			a[i][j]=0;
			continue;
		}
		a[i][j]=1;
		if(j) a[i][j]+=a[i][j-1];
	}

	//R
	FOR(i,0,N) ROF(j,0,M){
		if(g[i][j]=='#'){
			b[i][j]=0;
			continue;
		}
		b[i][j]=1;
		if(j+1<M) b[i][j]+=b[i][j+1];
	}

	//U
	FOR(j,0,M) FOR(i,0,N){
		if(g[i][j]=='#'){
			c[i][j]=0;
			continue;
		}
		c[i][j]=1;
		if(i) c[i][j]+=c[i-1][j];
	}
	FOR(j,0,M) ROF(i,0,N){
		if(g[i][j]=='#'){
			d[i][j]=0;
			continue;
		}
		d[i][j]=1;
		if(i+1<N) d[i][j]+=d[i+1][j];
	}

	/*FOR(i,0,N){
		FOR(j,0,M)
			cout << d[i][j] << ' ';
		cout << endl;
	}*/

	int ans=0;
	FOR(i,0,N) FOR(j,0,M)if(g[i][j]=='.'){
		int y=a[i][j]+b[i][j]+c[i][j]+d[i][j]-3;
		//cout << y << endl;
		int x=power[y]-1;
		x%=MOD;
		//cout << x << endl;
		x*=power[K-(y)];
		x%=MOD;
		ans+=x; ans%=MOD;
	}
	cout << ans << endl;

	return 0;
}

/* Careful!!!
	.Array bounds
	.Infinite loops
	.Uninitialized variables / empty containers
	.Order of input

   Some insights:
	.Binary search
	.Graph representation
	.Write brute force code
	.Change your approach
*/

#include<bits/stdc++.h>
using namespace std;
const int N = 2005;
const int mod = 1000000007;
int n,m;
char s[N][N];
int sum1[N][N];
int sum2[N][N];

int sum3[N][N];
int sum4[N][N];

inline int fastpow(int x,int p){
	int res=1;
	while(p){
		if(p&1)
			res=1ll*res*x%mod;
		x=1ll*x*x%mod;
		p>>=1;
	}
	return res;
}

int S;
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		scanf("%s",s[i]+1);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)if(s[i][j]=='.')++S;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			if(s[i][j]!='#')
				sum1[i][j]=sum1[i][j-1]+1;
		}
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			if(s[i][j]!='#')
				sum2[i][j]=sum2[i-1][j]+1;
		}
	}

	for(int i=1;i<=n;++i){
		for(int j=m;j>=1;--j){
			if(s[i][j]!='#')
				sum3[i][j]=sum3[i][j+1]+1;
		}
	}
	for(int i=n;i>=1;--i){
		for(int j=1;j<=m;++j){
			if(s[i][j]!='#')
				sum4[i][j]=sum4[i+1][j]+1;
		}
	}
	long long ans=0;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			if(s[i][j]=='#')continue;
			int p=sum1[i][j]+sum2[i][j]+sum3[i][j]+sum4[i][j]-3;p%=mod;
			ans+=(1ll*(fastpow(2,p)-1)*fastpow(2,S-p)%mod);
			ans%=mod;
		}
	}
	cout<<(ans%mod+mod)%mod<<endl;
}


#include<ctime>
#include<cstdio>
#include<cctype>
#define ll long long
using namespace std;
const ll N=2e5+7;
ll read(){
	char c;
	ll x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while(isdigit(c)){
		x=x*10+f*(c-48);
		c=getchar();
	}
	return x;
}
ll n,sum,a[N],s[N],m[N];
int main(){
	#ifndef ONLINE_JUDGE
	freopen("A.in","r",stdin);
	freopen("A.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	n=read();
	for(ll i=1;i<=n;++i){
		a[i]=read();
		s[i]=s[i-1]+a[i];
		m[i]=m[i-1];
		if(a[i]>m[i])
			m[i]=a[i];
	}
	for(ll i=1;i<=n;++i){
		sum+=s[i];
		printf("%lld\n",sum+m[i]*i);
	}
	//--------
	fprintf(stderr,"%0.3lfs",1.0*(clock()-t1)/CLOCKS_PER_SEC);
	return 0;
}

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

int main() {
int n;
cin >> n;
vector<long long>a(n);
vector<long long>b(n);
vector<long long>c(n);
vector<long long>d(n);
vector<long long>ans(n,0);
rep(i,n) cin >> a[i];
long long m = 0;
rep(i,n) {
    m = max(a[i],m);
  //  cout<<m<<endl;
    b[i] = m;
}

rep(i,n){
    if(i == 0) d[0] = a[0] ;
    else d[i] = d[i-1] + a[i];
}

rep(i,n){
    if(i == 0) c[0] = a[0] ;
    else c[i] = c[i-1] + d[i];
}

rep(i,n){
ans[i] = b[i] * (i+1) + c[i];
}

rep(i,n) cout<<ans[i]<<endl;
}


#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define INF INT_MAX / 2
#define INFL 1LL << 60
#define MOD 1000000007
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3)                                                 \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << endl
#define debug_4(x1, x2, x3, x4)                                             \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5)                                         \
    cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " \
         << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    rep(i, n) { cin >> a[i]; }

    ll ans = 0;
    rep(i, n) {
        if (a[i] <= 10) continue;
        ans += (a[i] - 10);
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int N, A, ans;
    cin >> N;
    ans = 0;
    for(int i = 0; i < N; i++){
        cin >> A;
        if(A > 10){
            ans += A - 10;
        }
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(v) std::begin(v), std::end(v)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Oct 11 23:22:41 JST 2020
 **/

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

const Int INF = 1e18;
signed main() {
    Int n, m;
    std::cin >> n >> m;
    std::vector<Int> w(n);
    REP(i, n) std::cin >> w[i];
    std::map<Int, Int> mp;
    mp[0] = 0;
    mp[INF] = INF;
    REP(i, m) {
        Int l, v;
        std::cin >> l >> v;
        dump(i, l, v, mp);
        if (v < *std::max_element(ALL(w))) {
            std::cout << -1 << std::endl;
            return 0;
        }
        while (1) {
            auto it = mp.lower_bound(v);
            if (it->second <= l) {
                mp.erase(it);
            } else {
                break;
            }
        }
        auto it = mp.upper_bound(v);
        if (it != mp.begin() && std::prev(it)->second >= l) continue;
        mp[v] = l;
    }
    dump(mp);
    Int ans = INF;
    std::sort(ALL(w));
    do {
        std::vector<Int> d(n);
        REP(i, 1, n) {
            Int sum = w[i];
            for (Int j = i - 1; j >= 0; j--) {
                sum += w[j];
                auto it = std::prev(mp.lower_bound(sum));
                chmax(d[i], d[j] + it->second);
            }
        }
        chmin(ans, d.back());
    } while (std::next_permutation(ALL(w)));
    assert(ans != INF);
    std::cout << ans << std::endl;
}

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

# define endl "\n"
# define io_boost std::ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
typedef unsigned long long int ulli;
typedef long long int lli;
typedef unsigned int ui;

string X;
ulli M;

int main(){
    io_boost;
    cin >> X >> M;
    ulli d = 0, pos;
    reverse(X.begin(), X.end());
    for(int i = 0; i < X.size(); i++){
        d = max(d, ulli(X[i] - '0'));
        if(X[i] != '0') pos = i;
    }
    d++;
    if(X.size() == 1){
        if((X[X.size() - 1] - '0') > M) cout << 0 << endl;
        else cout << 1 << endl;
        return 0;
    }

    if(X[X.size() - 1] - '0' > M){
        cout << 0 <<endl;
        return 0;
    }

    ulli lo = 0, hi = M + 1;
    while(lo < hi){
        ulli mid = (lo + hi) / 2;
        ulli d = mid;
        ulli sum = 0;
        bool ok = true;
        ulli p = 1;
        for(int i = 0; i < X.size(); i++){
            sum += p * ulli(X[i] - '0');
            if(i < X.size() - 1){
                if(p > M / d){
                    ok = false;
                    break;
                }
            }
            if(p > M){
                ok = false;
                break;
            }
            if(sum > M){
                ok = false;
                break;
            }
            p *= d;
        }
        if(ok) lo = mid + 1;
        else hi = mid;
    }
    if(lo >= d + 1) cout << lo - d << endl;
    else cout << 0 << endl;
    return 0;
}


#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
static long long INF = (1LL<<62);

LL H, W, N, M;
map<pair<LL, LL>, int> L, B; //L電球、B：ブロック
map<LL, map<LL, int>> maplh, mapbh; //最初のキー：H座標、次のキー：W座標
map<LL, map<LL, int>> maplw, mapbw; //最初のキー：W座標、次のキー：H座標
map<pair<LL, LL>, int> mapLON; //照らされているブロック

// l<=x<=rなる最大のl、最小のrを返す
// lはxから小さい方向に進んで最初にぶち当たる値。ない場合は-INF
// rはxから大きい方向に進んで最小にぶち当たる値。ない場合はINF
void neighbor(map<LL, int> *m, LL x, LL &l, LL & r){
	if(m->size() == 0) {
		l = -INF;
		r = INF;
		return;
	}
	auto itr = m->lower_bound(x); //x<=itrの値
	if(itr == m->end()){ //endの場合はすべてのmapの要素に対して<x
		l = (--(m->end()))->first;
		r = INF;
		return;
	}
	else{
		r = itr->first;
	}
	if(itr == m->begin()){ //x <= mapのすべての値
		l = -INF;
		r = m->begin()->first;
	}
	else{
		itr--;
		l = itr->first;
	}
}

//座標(h, w)のブロックが照らされているかいなか
LL isOn(LL h, LL w){
	if(L.count(make_pair(h,w)) != 0){
		return 1LL;
	}
	if(B.count(make_pair(h,w)) != 0){
		return 0LL;
	}

	auto bh = &(mapbh[h]); auto bw = &(mapbw[w]);
	auto lh = &(maplh[h]); auto lw = &(maplw[w]);
	LL bp = -1, bq = W, br = -1, bs = H;
	LL lp = -1, lq = W, lr = -1, ls = H;

	LL ret = 0;
	//まず行に着目しててらされるか？
	neighbor(bh, w, bp, bq);
	neighbor(lh, w, lp, lq);
	if(lp == -INF && lq == INF){
		//行方向にランプなし
	}
	else{
		if(lp != -INF && bp <= lp && lp <= bq){ ret = 1LL; return ret;}
		if(lq != INF  && bp <= lq && lq <= bq){ ret = 1LL; return ret;}
	}

	neighbor(bw, h, br, bs);
	neighbor(lw, h, lr, ls);
	if(lr == -INF && ls == INF){
		//列方向にランプなし
	}
	else{
		if(lr != -INF && br <= lr && lr <= bs){ ret = 1LL; return ret; }
		if(ls != INF  && br <= ls && ls <= bs){ ret = 1LL; return ret; }
	}
	return ret;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> H >> W >> N >> M;

	for(int i=0; i<N; i++){
		LL a, b; cin >> a >> b; a--; b--;
		auto p = make_pair(a, b);
		L[p] = 0;
		maplh[a][b] = 1;
		maplw[b][a] = 1;
	}
	for(int i=0; i<M; i++){
		LL c, d; cin >> c >> d; c--; d--;
		auto p = make_pair(c, d);
		B[p] = 0;
		mapbh[c][d] = 1;
		mapbw[d][c] = 1;
	}

	LL ans = 0;
	for(LL h=0; h<H; h++){
		for(LL w=0; w<W; w++){
			ans += isOn(h, w);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

# include <bits/stdc++.h>
# define ull unsigned long long
# define ll long long
# define double long double
# define pll pair<ll,ll>
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define all(x) x.begin(),x.end()
# define fill(a,b) memset(a,b,sizeof(a))
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(9) << x

using namespace std;
const ll INF = 922337203685477110;
const ll N = 20;
const ll mod  = 1e9+7;
const ll M = 22;
vector <ll> g[N];
ll vis[N];
map <pll,ll> edge;

ll dp[1<<N];
bool con[1<<N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,m; cin>>n>>m;
  for(ll i=1;i<=m;i++)
  {
     ll x,y; cin>>x>>y;
     g[x].pb(y); g[y].pb(x);
     edge[{x,y}]=1; edge[{y,x}]=1;
  }
  for(ll i=0;i<(1<<n);i++)
  {
      dp[i]=INF;
      vector <ll> v;
      for(ll j=0;j<n;j++)
      {
          if(i&(1<<j)) v.pb(j+1);
      }
      ll ok=1;
      for(ll j=0;j<v.size();j++)
      {
          for(ll k=j+1;k<v.size();k++)
          {
              if(!edge[{v[j],v[k]}])
                {
                    ok=0; break;
                }
          }
          if(!ok) break;
      }
      con[i]=ok;
  }
  for(ll i=0;i<(1<<n);i++)
  {
      if(con[i]) dp[i]=1;
      else{
        for(ll j=i;j; j=(j-1)&i)
        {
            dp[i] = min(dp[i],dp[j]+dp[i^j]);
        }
      }
  }
  cout<<dp[(1<<n)-1]<<endl;
}


#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define FI(n) FastIO::read(n)
#define FO(n) FastIO::write(n)
#define ull unsigned long long
#define mst(a,b) memset(a,b,sizeof(a))
#define foR(i,k,j) for(int i=(k);i>=(j);i--)
#define For(i,k,j) for(int i=(k);i<=(j);i++)
#define Foe(i,u) for(int i=lst[u],v=e[i].v;i;i=e[i].nxt,v=e[i].v)
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define Fin(s) freopen(s,"r",stdin)
#define Fout(s) freopen(s,"w",stdout)
#define file(s) Fin(s".in"),Fout(s".out")
#define INF ((1<<30)-1)
#define int long long
const int P=998244353; //
using namespace std;
template<typename T>inline void ckmax(T &a,T b) {(a<b)&&(a=b);}
template<typename T>inline void ckmin(T &a,T b) {(a>b)&&(a=b);}
inline int mul(int a,int b) {return 1ull*a*b%P;}
inline int add(int a,int b) {return a+b>=P?a+b-P:a+b;}
inline int sub(int a,int b) {return a-b>=0?a-b:a-b+P;}
inline void mulmod(int &a,int b) {a=mul(a, b);}
inline void addmod(int &a,int b) {((a+=b)>=P)&&(a-=P);}
inline void submod(int &a,int b) {((a-=b)<0)&&(a+=P);}
inline int ksm(int a,int b) {int ans=1; for(;b;b>>=1) {if(b&1) ans=1ll*ans*a%P;a=1ll*a*a%P;}return ans;}
inline void fprint(const int &x,char c=' ') {fprintf(stderr,"%d%c",x,c);}
inline void fprint(const pii &x,char c='\n') {fprintf(stderr,"%d %d%c",x.first,x.second,c);}
inline void fprint(const int *f,const int &n,char c='\n') {for(int i=1;i<=n;i++) fprint(f[i]); fprintf(stderr,"%c",c);}
inline void fprint(const vector<int> &f,char c='\n') {for(int i=0;i<(int)f.size();i++) fprint(f[i]); fprintf(stderr,"%c",c);}
inline int inv(int a) {return ksm(a,P-2);}
namespace FastIO {
  const int SIZE=1<<16; char buf[SIZE],obuf[SIZE],str[64]; int bi=SIZE,bn=SIZE,opt;
  int read(char *s) {
    while (bn) {for (;bi<bn&&buf[bi]<=' ';bi++);if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}
    int sn=0;while (bn) {for (;bi<bn&&buf[bi]>' ';bi++) s[sn++]=buf[bi];if (bi<bn) break; bn=fread(buf,1,SIZE,stdin),bi=0;}s[sn]=0;return sn;
  }
  bool read(int& x) {if(x)x=0;int bf=0,n=read(str); if(!n) return 0; int i=0; if (str[i]=='-') bf=1,i=1; for(x=0;i<n;i++) x=x*10+str[i]-'0'; if(bf) x=-x; return 1;}
  void write(int x) {
    if(!x) obuf[opt++]='0'; else {if(x<0) obuf[opt++]='-',x=-x;int sn=0; while(x)str[sn++]=x%10+'0',x/=10;for (int i=sn-1;i>=0;i--) obuf[opt++]=str[i];}
    if (opt>=(SIZE>>1)){fwrite(obuf,1,opt,stdout); opt=0;}
  }
  void write(char x) {obuf[opt++]=x;if (opt>=(SIZE>>1)){fwrite(obuf,1,opt,stdout); opt=0;}}
	void Fflush() {if (opt) fwrite(obuf,1,opt,stdout); opt=0;}
};
inline int read() {int x; FI(x); return x;}
const int MN=5e5+5;
int n,a[MN],b[MN],m; char s[MN];
signed main() {
	#ifndef ONLINE_JUDGE
		file("pro");
	#endif
	n=read();
	FI(s+1); For(i,1,n) a[i]=s[i]-'0';
	if(n==1) {
		cout<<((a[1]==1)?20000000000ll:10000000000ll)<<endl;
		return 0;
	}
	For(i,1,n) {
		if(a[i]==1&&a[i+1]==1&&a[i+2]==0) {
			b[++m]=2;	i=i+2;
		} else b[++m]=a[i];
	}
	int st=1,ed=0;
	For(i,1,n) {
		if(b[i]==2) {
			st=i;	break;
		}
	}
	foR(i,n,1) {
		if(b[i]==2) {
			ed=i; break;
		}
	}
	For(i,st,ed) if(b[i]!=2) {
		return printf("0\n"),0;
	}
//	cerr<<"?";
	int ss=0;
	if(b[1]==1) {
		if(b[1+1]!=0) return printf("0\n"),0;
		ss=2;
	} else if(b[1]==0) {
		if(n==2&&b[2]==1) ss=3;
		else {
			if(b[1+1]!=2) return printf("0\n"),0;
			ss=3;
		}

	} else ss=1;
	if(n>=3) {
		if(b[m]==1&&n>3) {
			if(b[m-1]==0) return printf("0\n"),0;
		}
		if(b[m]==0) {
			if(b[m-1]!=2) return printf("0\n"),0;
		}
	}

	int epos=30000000000ll-n+1;
	cout<<(epos-ss)/3+1<<endl;
	return FastIO::Fflush(),0;
}

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>
#include<set>

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

//const ll mod = 1e9 + 7;
const ll mod = 998244353;
const int inf = 123456789;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(15);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int cnt = 0;
	for(int i = 0; i < n - 2; i++){
		string t = s.substr(i , 3);
		if(t == "110"){
			cnt++;
		}
		if(t == "111"){
			cout << 0 << endl;
			return 0;
		}
		if(t == "010"){
			cout << 0 << endl;
			return 0;
		}
	}

	for(int i = 0; i < n - 1; i++){
		if(s.substr(i , 2) == "00"){
			cout << 0 << endl;
			return 0;
		}
	}

	if(s == "1"){
		cout << 20000000000 << endl;
		return 0;
	}
	if(s == "11" || s == "0" || s == "10" || s == "110"){
		cout << 10000000000 << endl;
		return 0;
	}
	if(s == "01" || s == "011" || s == "101" || s == "1011"){
		cout << 10000000000 - 1 << endl;
		return 0;
	}

	/*
	if(n >= 5 && n / 3 - 1 > cnt){
		cout << 0 << endl;
		return 0
	}
	*/

	if(s.substr(0 , 3) == "110" && s.substr(n - 3 , 3) == "110"){
		ll ans = 10000000000 - cnt + 1;
		cout << ans << endl;
		return 0;
	}

	if(s.substr(0 , 3) == "110" || s.substr(n - 3 , 3) == "110"){
		ll ans = 10000000000 - cnt;
		cout << ans << endl;
		return 0;
	}

	ll ans = 10000000000 - cnt - 1;
	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll =long long;
using vi = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using P = pair<ll , ll>;
using vp = vector<P>;
#define rep(i, n) for (long long int i = 0; i < n; i++)
#define rep2(i, s, n) for (int i = (s); i < n; i++)
#define sort(A) sort(A.begin(),A.end());
#define reverse(A) reverse(A.begin(),A.end());
#define vecint2(A, n, m) vector<vector<long long int>> A(n, vector<long long int>(m));
#define vecchar2(A, n, m) vector<vector<char>> A(n, vector<char>(m));
#define k(s) cout << fixed << setprecision(s);
#define t cout<<"OK"<<endl;
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
const long double pi=3.14159265358979323846;

int main() {
  int N,K;
  cin>>N>>K;
  vi A(300005);
  rep(i,300005) A[i]=0;
  rep(i,N){
    int a;
    cin>>a;
    A[a]++;
  }
  int nokori=K;
  ll ans=0;
  int ks=0;
  while(nokori>0){
    if(A[ks]>=nokori){
      ks++;
    }else{
      ans=ans+ks;
  //    cout<<ks<<endl;
      nokori--;
    }
  }
  cout<<ans<<endl;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> cnt(n, 0);
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        ++cnt[x];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        k = min(k, cnt[i]);
        ans += k;
    }
    cout << ans << "\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
long long aoki;
ll taka;
ll a[300001],b[300001],c[300001];
bool cp(ll k,ll l){
	return k>l;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a[i],&b[i]);
		c[i]=a[i]+b[i]+a[i];
		aoki+=a[i];
	}
	sort(c+1,c+1+n,cp);
	for(int i=1;i<=n;i++){
		 taka+=c[i];
		 if(taka>aoki){
		 	printf("%d",i);
		 	return 0;
		 }
	}
	return 0;
}

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

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

  void update(int a_, int b_, int c_, int d_) {
    a = a_;
    b = b_;
    c = c_;
    d = d_;
  }
  friend ostream &operator<<(ostream &os, const Rectangle &x) {
    return os << x.a << ' ' << x.b << ' ' << x.c << ' ' << x.d;
  }
};

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

  vector<int> x(n), y(n), r(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> r[i];
  }

  vector<Rectangle> ans(n);
  for (int i = 0; i < n; i++) {
    ans[i].update(x[i], y[i], x[i] + 1, y[i] + 1);
  }
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


/*
  Author     : MatsuTaku
  Date         : 06/26/21
  Certificate:
ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAAAgQDF9T447OEo8XSQ6O1AznN5tKC8mzvYc4Zs3+oOKfMqgLXfOwQnpfcoxKs4MAP1eICBD13PkcIezJ9IlV6nKQZKs1BQmvjSXJ+zKK8YCKvAueNPuNO0Bim43IBaNHNFWcMvcmUvHgRb6hUSO0V8I7OsjiFo20KDBj3gAznu9tir0Q==
CompetitiveProgrammingCertification:tkm.matsumoto@gmail.com
*/

#include <bits/stdc++.h>
using namespace std;
#include <x86intrin.h>
#define REP(i, l, r)      for (int i = (l), i##_less = (r); i < i##_less; i++)
#define rep(i, n)         REP(i, 0, n)
#define RREP(i, l, r)     for (int i = (r)-1, i##_least = (l); i >= i##_least; i--)
#define rrep(i, n)        RREP(i, 0, n)
#define chmax(dst, x)     dst = max(dst, (x))
#define chmin(dst, x)     dst = min(dst, (x))
using lint = long long int;
using ulint = unsigned long long int;
template<typename T>
using vvec = vector<vector<T>>;
template<typename T>
vvec<T> make_vvec(int n, int m, T v) { return vvec<T>(n, vector<T>(m, v)); }

class Solver {
 public:
  Solver();
  void solve();
};

Solver::Solver() {}

constexpr double EPS = 1e-6;
void Solver::solve() {
  int n; cin>>n;
  vector<pair<int,int>> P(n), Q(n);
  int pgx = 0, pgy = 0, qgx = 0, qgy = 0;
  rep(i, n) {
    int a,b; cin>>a>>b;
    P[i] = {a*n,b*n};
    pgx += a;
    pgy += b;
  }
  rep(i, n) {
    P[i].first -= pgx;
    P[i].second -= pgy;
  }
  rep(i, n) {
    int c,d; cin>>c>>d;
    Q[i] = {c*n,d*n};
    qgx += c;
    qgy += d;
  }
  rep(i, n) {
    Q[i].first -= qgx;
    Q[i].second -= qgy;
  }

  if (n == 1) {
    cout << "Yes" << endl;
    return;
  }

  int z = 0;
  if (abs(P[z].first) < EPS and abs(P[z].second) < EPS)
    z++;
  rep(i, n) {
    auto [a,b] = P[z];
    auto [c,d] = Q[i];
    double ang_p = atan2(b, a);
    double ang_q = atan2(d, c);
    double ang = ang_p - ang_q;
    double cos_qp = cos(ang);
    double sin_qp = sin(ang);
    bool ans = true;
    rep(j, n) {
      auto [qx,qy] = Q[j];
      double x = cos_qp * qx - sin_qp * qy;
      double y = sin_qp * qx + cos_qp * qy;
      bool ok = false;
      for (auto [px,py] : P) {
        ok |= abs(px-x) < EPS and abs(py-y) < EPS;
      }
      ans &= ok;
    }
    if (ans) {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(10);
  Solver solver;
  int t = 1;
//  cin>>t;
  while (t--) {
    solver.solve();
  }
  return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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 <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
//const int mod = 998244353;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};

LL N,K;
bool check(LL mid){
    LL acc = (mid) * (mid-1) / 2 * (mid-2) / 3;
    LL A = (mid-N-1) * (mid-N-2) / 2;
    chmax(A,0LL);
    LL B = (mid-2*N-1) * (mid-2*N-2) / 2;
    chmax(B,0LL);
    LL C = A*3 - B*3;
    acc = acc - C;

    if(acc >= K){
        return true;
    }else{
        return false;

    }
}

__int128 calc_acc(LL mid){

    __int128 acc = __int128(mid) * (mid-1) / 2 * (mid-2) / 3;
    //dump(acc)
    __int128 A = 0;
    if(mid-N-3 >= 0){
        A = __int128(mid-N) * (mid-N-1) / 2 * (mid-N-2) / 3;
    }

    __int128 B = 0;
    if(mid-2*N-3 >= 0){
        B = __int128(mid-2*N) * (mid-2*N-1) / 2 * (mid-2*N-2) / 3;
    }
    __int128 C = A*3 - B*3;
    acc = acc - C;

    //return LL(acc);
    return acc;

}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    cin >> N >> K;
    __int128 K1 = K;
    LL left = 2, right = 3*N;
    while(abs(left-right) > 1){
        LL mid = (left + right) / 2;

        __int128 acc = calc_acc(mid);
        //dump(mid)
        //dump(acc)
        if(acc >= K1){
            right = mid;
        }else{
            left = mid;
        }
    }

    //LL acc = (left) * (left-1) / 2 * (left-2) / 3;
    __int128 acc = calc_acc(left);
    LL sum = right;

    dump(left)
    dump(right)

    for(LL i = 1; i <= N; i++){
        dump(i)
        LL sj = max(1LL,sum-i-N);
        LL mj = min(N,sum-i-1);
        dump(sj)
            dump(mj)
        LL add = max(0LL,(mj-sj)+1);
        dump(add)
        if(acc + add < K){
            acc += add;
        }else{
            LL rem = K - acc;
            LL stj = max(1LL,sum-N-i);
            LL j = stj + rem-1;
            LL k = sum - i - j;

            cout << i << " "  << j << " " << k << endl;
            break;
        }
    }

    //dump(calc_acc(3*N));
}


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

template<int MAX>
struct Combination {
    vector<long long> _inv, _fac, _ifac;
    const long long MOD;
    Combination(long long mod) : _inv(MAX+1), _fac(MAX+1), _ifac(MAX+1), MOD(mod) { init(); }
    void init() { init_inv(), init_fac(); }

    void init_inv() {
        _inv[0] = 0;
        for (int i = 1; i <= MAX; i++) {
            if (i == 1) _inv[i] = 1;
            else {
                _inv[i] = (MOD - (MOD / i) * _inv[MOD % i]) % MOD;
                if (_inv[i] < 0) _inv[i] += MOD;
            }
        }
    }
    void init_fac() {
        _fac[0] = _ifac[0] = 1;
        for (int i = 1; i <= MAX; i++) {
            _fac[i] = _fac[i-1] * i % MOD;
            _ifac[i] = _ifac[i-1] * _inv[i] % MOD;
        }
    }

    long long modpow(long long n, long long r) {
        n %= MOD, r %= (MOD-1);
        if (!n) return 0;
        long long ret = 1; long long tmp = n;
        while (r != 0) {
            if (r % 2) ret *= tmp;
            tmp *= tmp; tmp %= MOD; ret %= MOD;
            r /= 2;
        }
        return ret;
    }
    long long invb(int i) { return (i <= MAX) ? _inv[i] : this->modpow(i, MOD-2); }
    long long inv(int i) const { return _inv[i]; }
    long long fac(int i) const { return _fac[i]; }
    long long ifac(int i) const { return _ifac[i]; }

    long long operator()(int n, int r) const {
        if (n < r) return 0;
        return fac(n) * ifac(r) % MOD * ifac(n-r) % MOD;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    constexpr long long mod = 1000000007;
    Combination<5000000> C(mod);
    long long Ans = 1;
    vector<int> A(N);
    int S = 0;
    for (auto &x: A) {
        cin >> x; S += x;
    }
    for (int i = 1; i <= N + S; i++) {
        Ans = Ans * C.invb(i) % mod;
        Ans = Ans * (M + N + 1 - i) % mod;
    }
    cout << Ans << "\n";
    return 0;
}

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

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

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

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

signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;

    int n = min(N, 20LL);
    vec w(200, -1);
    FOR(i, 1, bit(n)){
        int s = 0;
        REP(k, n) if((i >> k) & 1) s += A[k];
        if(w[s % 200] != -1){

            Out("Yes");
            cout << __builtin_popcountll(w[s % 200]) << " ";
            REP(k, n) if((w[s % 200] >> k) & 1) cout << k + 1 << " ";
            cout << endl;

            cout << __builtin_popcountll(i) << " ";
            REP(k, n) if((i >> k) & 1) cout << k + 1 << " ";
            cout << endl;

            return 0;

        }else w[s % 200] = i;
    }
    Out("No");

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back;
using namespace std;
using namespace std::chrono;
long long fpb(long long x, long long y) {
    return (y == 0) ? x : fpb(y, x % y);
}
long long kpk(long long x, long long y) {
    return x * (y / fpb(x, y));
}
bool cmp(long long a,long long b)
{
    return a>b;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    auto begin = high_resolution_clock::now();
    ll n;
    cin>>n;

    ll ans=0;
    for(ll i=1;i<=1000000;i++){
        string s=to_string(i);
        if (stoll(s+s)>n){
            break;
        }else{
            ans++;
        }
    }
    cout<<ans<<"\n";
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<milliseconds>(stop - begin);
    // cout<<duration.count()<<"\n";
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a;
    cin >> a;
    for (int i = 1; i < 3;i++)
    {
        char k;
        cin >> k;
        printf("%c", k);
    }
    printf("%c", a);
}


#include<iostream>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define per(i,b,a) for(int i = (b); i >= (a); i--)
#define N 110
#define T 1000
#define Inf 0x3f3f3f3f
using namespace std;

int t[N], n;
bool dp[N][2*N*T];

int main(){
    cin>>n;
    int tot = 0;
    rep(i,1,n) cin>>t[i], tot += t[i];
    dp[0][n*T] = true;
    int ans = Inf;
    rep(i,1,n) rep(j,0,2*n*T){
        if(j >= t[i]) dp[i][j] |= dp[i-1][j-t[i]];
        dp[i][j] |= dp[i-1][j+t[i]];
        if(i == n && dp[i][j]){
            ans = min(ans, (tot+abs(j-n*T))/2);
        }
    }
    cout<<ans<<endl;
    return 0;
}

#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 1000000007
#define ad(a,b) a=(a+b)%mod;
ll po(ll x,ll y){
	ll res=1;
	for(;y;y>>=1){
		if(y&1)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}
ll gcd(ll a,ll b){
	return (b?gcd(b,a%b):a);
}
#define X 200010
ll fac[X],ivf[X];
void initfac(){
	fac[0]=1;
	for(ll i=1;i<X;i++)fac[i]=fac[i-1]*i%mod;
	for(ll i=0;i<X;i++)ivf[i]=po(fac[i],mod-2);
}
ll C(ll n,ll k){
	return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	ll n;
	string t;
	cin>>n>>t;
	ll x=10000000000;
	if(t=="0")cout<<x<<endl;
	else if(t=="1")cout<<2*x<<endl;
	else if(t=="11"||t=="10")cout<<x<<endl;
	else if(t=="01")cout<<x-1<<endl;
	else{
		ll a=-1;
		rep(i,n)if(t[i]=='0'){a=i;break;}
		bool ok=(0<=a&&a<3);
		rep(i,n){
			if(i%3==a)ok&=(t[i]=='0');
			else ok&=(t[i]=='1');
		}
		if(!ok)cout<<0<<endl;
		else{
			ll cnt=0;
			rep(i,n)cnt+=(t[i]=='0');
			if(t[n-1]=='1')cnt++;
			cout<<x-cnt+1<<endl;
		}
	}
}


//sccは罠.
//Xi = 頂点iを選んだかどうか？とすると、
//E[ΣXi] = ΣE[Xi] = Σpi (頂点iが選ばれる確率)が答え
#include <iostream>
#include <string>
#include <queue>
#include <cstdio>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
string s[100];
vector<int> et[100];

signed main() {
	int i, j;

	cin >> n;
	rep(i, n) cin >> s[i];
	rep(i, n) {
		rep(j, n) {
			if (s[i][j] == '1') {
				et[j].push_back(i);
			}
		}
	}

	double ans = 0;
	rep(i, n) {
		queue<int> que;
		bool vis[100] = {false};

		que.push(i);
		vis[i] = true;
		while (!que.empty()) {
			int v = que.front(); que.pop();
			rep(j, et[v].size()) {
				int nv = et[v][j];
				if (vis[nv] == false) {
					vis[nv] = true;
					que.push(nv);
				}
			}
		}

		int cnt = 0;
		rep(j, n) if (vis[j]) cnt++;
		ans += 1.0 / cnt;
	}

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=105;
int n,e[maxn][maxn];
char s[maxn];
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%s",s);
		for(int j=0;j<n;j++)
			e[i][j]=s[j]-'0';
	}
	for(int k=0;k<n;k++)
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				e[i][j]|=e[i][k]&e[k][j];
	double ans=0;
	for(int i=0;i<n;i++)
	{
		int cnt=0;
		for(int j=0;j<n;j++)
			if(j!=i)
				cnt+=e[j][i];
		ans+=1.0/(double)(cnt+1);
	}
	printf("%.12lf\n",ans);
	return 0;
}


#include <iostream>
#include <vector>

int main() {
    int N;
    std::cin >> N;
    std::vector<int> A(N), B(N), C(N);
    for (auto& x : A) {
        std::cin >> x;
        x -= 1;
    }
    for (auto& x : B) {
        std::cin >> x;
        x -= 1;
    }
    for (auto& x : C) {
        std::cin >> x;
        x -= 1;
    }
    std::vector<int> count(N);
    for (int j = 0; j < N; ++j) {
        count[B[C[j]]] += 1;
    }
    long long ans = 0;
    for (int i = 0; i < N; ++i) {
        ans += count[A[i]];
    }
    std::cout << ans << '\n';
}

//#pragma GCC optimize(2)

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <cctype>

using namespace std;

#define sync ios::sync_with_stdio ( false ); cin.tie(0); cout.tie(0)  // cin优化
#define debug freopen("data.in","r",stdin); freopen("data.out","w",stdout)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<int, PII> PIP;
typedef pair<PII, int> PPI;

const int N = 1e5 + 10, M = 500;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

/*-----------------以下正文-----------------*/

int q[4][N];
int a[N], b[N];
int cnt1[N], cnt2[N];

int main ( void )
{
    sync;

    int n;
    cin >> n;
    for ( int i = 1; i <= 3; i++ )
    {
        for ( int j = 1; j <= n; j++ ) cin >> q[i][j];
    }

    for ( int i = 1; i <= n; i++ ) a[i] = q[1][i], b[i] = q[2][q[3][i] ];

    for ( int i = 1; i <= n; i++ ) cnt1[a[i]]++, cnt2[b[i]]++;

    ll res = 0;
    for ( int i = 1; i <= n; i++ ) res += (ll)cnt1[i] * cnt2[i];

    cout << res << endl;
    return 0;
}

/*
  遇到困难时你可能会用到的提示：

    1、能用 ll 就要用 ll。
    2、返回 ll 答案时，函数的返回类型要为 ll
    3、图论数据量大，最好用 scanf 或 sync
*/


#include<bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif

using namespace std;
//using namespace atcoder;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
    int x, y;
    cin >> x >> y;
    if(abs(x - y) < 3) cout << "Yes" << endl;
    else cout << "No" << endl;
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){
		if(c=='-') f=-1;
		c=getchar();
	}
	while(isdigit(c)){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}

signed main(){
	int x=read(),y=read();
	if(x>y){
		if(y+3>x) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	else{
		if(x+3>y) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


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

#define fi first
#define se second

int main() {
	long long int ans = 0, n;
	long long value;
	map<long long, long long> a;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> value;
		for(auto v : a) {
			ans += ((value - v.fi) * (value - v.fi) * v.se);
		}
		a[value]++;
	}
	cout << ans << endl;
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

#define speed ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0)
#define fre freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define N 2*100005
#define M 2002
#define st first
#define nd second
#define endl "\n"
#define pb push_back
#define mp make_pair
#define inf 1e9+7
#define mid (start+end)/2
#define sp " "
#define Endl endl
typedef long long int ll;

ll x,y,w,n,m,pl,pr,flag,ans,k;

ll a[N];

void solve(){
    cin>>n;
    ll mn=1000000009;
    for (int i = 0; i < n; ++i)
    {
    	cin>>a[i];
    }
    for (int i = 0; i < n; ++i)
    {
    	for (int j = i; j < n; ++j)
    	{
    		mn=min(mn,a[j]);
    		ans=max(ans,mn*(j-i+1));
    	}
    	mn=1000000009;
    }
    cout<<ans;
}

int main()
{
    speed;
    int TT=1;
    //cin>>TT;
    while(TT--)
        solve();
    return 0;
}


// *********************************************************************************
// *                        MURTAZA MUSTAFA KHUMUSI                                *
// *                        NIT-DGP,CSE - 2019-2023                                *
// *********************************************************************************

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007;
#define loop(i, a, n) for (int i = a; i < n; i++)
#define loop1(i, b, n) for (int i = b; i <= n; i++)
#define loopit(a) for (auto it = a.begin(); it != a.end(); it++)
#define ms(a, b) memset(a, b, sizeof(a))
#define pb(a) push_back(a)
#define MP make_pair
#define pi pair<int, int>
#define ff first
#define ss second
#define bloop(i, a, b) for (int i = a; i > b; i--)
#define bloop1(i, a, b) for (int i = a; i >= b; i--)
#define PQ priority_queue<int> pq;
#define vi vector<int>
#define si set<int>
#define MPQ priority_queue<pi, vector<int>, greater<pi>> mpq;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
const int maxm = 100001;

// ll m = 1e9+7;
ll m = 998244353;
vector<vi> adj;
vi h, sz, in;
vector<ll> fact;

//modular arithmentic

ll add(ll a, ll b, ll mod = m)
{
    return ((a % mod) + (b % mod)) % mod;
}
ll mul(ll a, ll b, ll mod = m)
{
    return ((a % mod) * (b % mod)) % mod;
}
ll sub(ll a, ll b, ll mod = m)
{
    return ((a % mod) - (b % mod) + mod) % mod;
}

ll modmul(ll a, ll b, ll mod = m)
{
    ll ans = 0;
    a = a % mod;
    while (b)
    {
        if (b & 1)
            ans = add(ans, a, mod);
        a = mul(a, 2, mod);
        b >>= 1;
    }
    return ans;
}

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

ll fe(ll base, ll exp, ll mod = m)
{
    ll ans = 1;
    while (exp)
    {
        if (exp & 1)
            ans = mul(ans, base, mod);
        base = mul(base, base, mod);
        exp >>= 1;
    }
    return ans;
}

ll modin(ll a, ll mod = m)
{
    return fe(a, mod - 2, mod);
}

ll nCr(ll a, ll b, ll mod = m)
{
    if (a < b)
        return 0;
    return mul(fact[a], mul(modin(fact[b], mod), modin(fact[a - b], mod)));
}

//graph theory
void dfs_h_sz(int cur, int par)
{
    h[cur] = h[par] + 1;
    sz[cur]++;
    for (const auto &v : adj[cur])
    {
        if (v == par)
            continue;
        dfs_h_sz(v, cur);
        sz[cur] += sz[v];
    }
}

void buildGraph(int n, int m)
{
    adj = vector<vi>(n + 1);
    h = vector<int>(n + 1);
    sz = vector<int>(n + 1);
    in = vector<int>(n + 1);

    loop(i, 0, m)
    {
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    dfs_h_sz(1, 0);
}
struct cmp
{
    bool operator()(const pi &a, const pi &b)
    {
        return a.ff < b.ff;
    }
};

void solve()
{
    int n;cin>>n;
    vector<ll> in(n);
    loop(i,0,n)cin>>in[i];
    ll ans = 0;
    vector<ll> suf(n);
    sort(in.begin(),in.end());
    bloop1(i,n-2,0){
        suf[i] = suf[i+1]+in[i+1];
        // cout<<suf[i]<<" ";
    }
    loop1(i,0,n-2){
        ans += suf[i] - (n-i-1)*in[i];
    }
    cout<<ans<<"\n";
}
int main()
{
    io;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    int test;
    // cin >> test;
    test = 1;
    while (test--)
    {
        solve();
    }
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int64_t> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    sort(A.begin(), A.end());

    vector<int64_t> sum(N+1);
    sum[0] = 0;
    for(int i=1;i<N+1;i++) sum[i] = sum[i-1]+A[i-1];

    int64_t ans = 0;
    for(int i=0;i<N-1;i++){
        ans += (sum[N]-sum[i])-(N-i)*A[i];
    }

    cout << ans << endl;

    return 0;
}


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

#define f first
#define s second
#define pb push_back
#define rep(i, begin, end)                                                     \
  for (__typeof(end) i = (begin) - ((begin) > (end));                          \
       i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define db(x) cout << '>' << #x << ':' << x << endl;
#define sz(x) ((int)(x).size())
#define newl cout << "\n"

#define ll long long int
#define vi vector<int>
#define vll vector<long long>
#define vvll vector<vll>
#define pll pair<long long, long long>

#define fast_io()                                                              \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL);

ll tc, n, m, k;

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

  cin>>n>>k;
  vvll dist(n, vll(n, 0));
  rep(i, 0, n) {
    rep(j, 0, n) cin>>dist[i][j];
  }

  vll vis(n, 0);

  ll ans = 0;
  function<void(int, int, int)> dfs = [&](int u, int time, int depth) {
    if(vis[u] && u == 0 && time == k && depth == n) {
      ans++;
      return;
    }

    if(vis[u]) return;
    vis[u] = 1;
    rep(v, 0, n) {
      if(v != u ) {
        if(v == 0 && depth == n-1 && vis[v]) {
          dfs(v, time + dist[u][v], depth+1);
        } else if(vis[v] == 0) {
          dfs(v, time + dist[u][v], depth+1);
        }
      }
    }
    vis[u] = 0;

  };

  dfs(0, 0, 0);

  cout<<ans;
  return 0;
}

#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

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

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

int solve() {
    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;
    if(r1 == r2 && c1 == c2) return 0;
    if(abs(r1-r2) + abs(c1-c2) <= 3) return 1;
    if(abs(r1-r2) == abs(c1-c2)) return 1;
    if(abs(r1+c1) % 2 == abs(r2+c2) % 2) return 2;
    ll dr = abs(r1-r2);
    if(abs((c1+dr) - c2) <= 3) return 2;
    if(abs((c1-dr) - c2) <= 3) return 2;
    return 3;
}

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


#include <algorithm>
#include <bitset>
#include <cmath>
#include <cctype>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <math.h>
#include <map>
#include <numeric>
#include <queue>
#include <stdio.h>
#include <string>
#include <sstream>
#include <stack>
#include <set>
#include <vector>

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

const int AAA = 1000000007;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;
typedef vector<int> vecI;

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}

int main(int argc, char* argv[]) {
	int i, j, k;
	int N, M, K;

	int H, W;
	cin >> H >> W >> N >> M;

	vecI A(N), B(N);
	vecI C(M), D(M);

	vector<vecI> ansBoard1(H, vecI(W, 0));
	vector<vecI> ansBoard2(H, vecI(W, 0));

	rep(i, 0, N) {
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}
	rep(i, 0, M) {
		cin >> C[i] >> D[i];
		C[i]--;
		D[i]--;
		ansBoard1[C[i]][D[i]] = -1;
		ansBoard2[C[i]][D[i]] = -1;
	}

	rep(i, 0, N) {
		int h = A[i], w = B[i];
		ansBoard1[h][w] = 1;
		ansBoard2[h][w] = 1;

		for (j = h + 1; j < H && ansBoard1[j][w] == 0; j++)
		{
			ansBoard1[j][w] = 1;
		}
		for (j = h - 1; j >= 0 && ansBoard1[j][w] == 0; j--)
		{
			ansBoard1[j][w] = 1;
		}
		for (j = w + 1; j < W && ansBoard2[h][j] == 0; j++)
		{
			ansBoard2[h][j] = 1;
		}
		for (j = w - 1; j >= 0 && ansBoard2[h][j] == 0; j--)
		{
			ansBoard2[h][j] = 1;
		}
	}
	int ans = 0;
	rep(i, 0, H) {
		rep(j, 0, W) {
			ans += (ansBoard1[i][j] == 1 || ansBoard2[i][j] == 1);
		}
	}

	cout << ans;

	return 0;
}

// khodaya khodet komak kon
# include <bits/stdc++.h>

/*
// ordered_set
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/

using namespace std;

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

# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define lc                                              id << 1
# define rc                                              id << 1 | 1
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}

const int xn = 5e3 + 10;
const int xm = - 20 + 10;
const int sq = 320;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int mod = 998244353;
const int base = 257;

ll n, m, k, dp[xn][xn], ps[2][xn][xn], pw[xn];
char s[xn][xn];

int main(){
	InTheNameOfGod;

	pw[0] = 1;
	for (int i = 1; i < xn; ++ i)
		pw[i] = 3LL * pw[i - 1] % mod;
	cin >> n >> m >> k;
	while (k --){
		int x, y;
		char c;
		cin >> x >> y >> c;
		s[x][y] = c;
	}
	if (s[n][m] == 'D' || s[n][m] == 'R' || s[n][m] == 'X')
		dp[n][m] = 1;
	else
		dp[n][m] = 3;
	for (int i = n; i >= 1; -- i){
		for (int j = m; j >= 1; -- j){
			ps[0][i][j] = ps[0][i][j + 1];
			ps[1][i][j] = ps[1][i + 1][j];
			if (s[i][j] != 'R' && s[i][j] != 'D' && s[i][j] != 'X')
				++ ps[0][i][j], ++ ps[1][i][j];
			if (i == n && j == m)
				continue;
			ll x = 0, y = 0;
			if (s[i][j] == 'D')
				++ x;
			else if (s[i][j] == 'R')
				++ y;
			else if (s[i][j] == 'X')
				++ x, ++ y;
			else
				x += 2, y += 2;
			dp[i][j] = (dp[i][j] + dp[i + 1][j] * x % mod * pw[ps[0][i][j + 1]]) % mod;
			dp[i][j] = (dp[i][j] + dp[i][j + 1] * y % mod * pw[ps[1][i + 1][j]]) % mod;
		}
	}
	cout << dp[1][1] << endl;

	return 0;
}


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

int main() {
  string s;
  int ans=0;
  cin >> s;
  for(int i=0;i<9;i++){
    if(s[i]=='Z' && s[i+1]=='O' && s[i+2]=='N' && s[i+3]=='e') ans++;
  }
  cout << ans << endl;
}

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#ifdef NDEBUG
  #define assert(e) if(!(e)){stod("");}
#endif
#ifdef ONLINE_JUDGE
  #define debug(x)
  #define debug2(x,y)
  #define debug3(x,y,z)
#else
  #define debug(x) std::cerr<<#x<<": "<<x<<"\n"
  #define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
  #define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"
#endif

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

void solve() {
  string s;
  scan(s);
  int cnt = 0;
  rep (i, 9) {
    if (s.substr(i, 4) == "ZONe") {
      cnt += 1;
    }
  }
  print(cnt);
}

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


                              //ABHISHEK AGRAWAL,BIT mesra//
                      //Newbie......You have to be odd to be no. ONE :)//
//Authhor: Abhishekagrawal
//Date: 27/02/2021
//Time: 17:30:41
#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);
// }
ll powe(ll a,ll b){ll res=1;while(b>0){if(b%2 ==1){res=(res*a);}a=(a*a);b/=2;} return res;}
const int N=200040;ll a[N],b[N],c[N],par[N],Size[N],present[N],color[N];
void testcase(){
  cin>>n;
  string s,s1;
  cin>>s>>s1;
  mll m;
  loop(i,5) m[(s[i]-'0')]++,m[(s1[i]-'0')]++;
  vll v;
  loop1(i,9){
    if(m[i]==n-1) v.pb(i);
    else if(m[i]!=n) v.pb(i),v.pb(i);
  }
  ld n1=9*n-8;
  ll nn1=v.size();
  n1=(n1*(n1-1));
  // n1/=2;
  ld an=0;
  // cout<<nn1<<" ";
  set<pair<ll,ll>>ss;
  loop(i,nn1){
    loop(j,nn1){
      if(i==j) continue;
      mll m1;
      loop(l1,4) m1[(s[l1]-'0')]++;
      m1[v[i]]++;
      ll curr=0;
      loop1(ll1,9){
        ll cc1=powe(10,m1[ll1])*ll1;
        curr+=cc1;
      }
      mll m2;
      loop(l1,4) m2[(s1[l1]-'0')]++;
      m2[v[j]]++;
      ll curr1=0;
      loop1(ll1,9){
        ll cc2=powe(10,m2[ll1])*ll1;
        curr1+=cc2;
      }
      // cout<<curr<<" "<<curr1<<"\n";
      if(curr>curr1){
        ss.insert({v[i],v[j]});
      }
    }
  }
  for(auto x:ss){
    // cout<<x.f<<" "<<x.s<<"\n";
    ll n111=n-m[x.f];
    ll n222=n-m[x.s];
    if(x.s==x.f) n222--;
    n111*=n222;
    an+=n111;
  }
  // cout<<n1<<" "<<an<<" ";
  // an*=10000;
  cout<<sp(12)<<an/n1;
  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;

typedef pair<int,int> pii;
typedef pair<string,int> psi;
typedef pair<int,string> pis;
typedef array<int,2> aii;
typedef array<int,3> aiii;
typedef array<int,4> aiiii;
typedef unsigned long long ull;
typedef long long int ll;
typedef array<ll,2> all;
typedef array<ll,3> alll;
typedef array<ll,4> allll;

#define pb push_back
#define ff first
#define ss second
#define MAX 100005
#define MOD 1000000007
#define INF 1e9+100
vector<aii>adj[MAX];
vector<int> dijkstra_dag_adj[MAX];
int xMove[] = { 0,1,0,-1,1,1,-1,-1, 2, 2, -2, -2, 1, 1, -1, -1 };
int yMove[] = { 1,0,-1,0,1,-1,1,-1, 1, -1, 1, -1, 2, -2, 2, -2 };

int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.txt","w",stdout);
    cin.tie(0),cout.tie(0);
    ios_base::sync_with_stdio(0);
    cout.setf(ios::fixed);
    cout.precision(10);
    int TC=1;
    int n,m,k,q;
    //cin>>TC;
    for(int t1=1; t1<=TC; t1++)
    {
        cin>>k;
        string s,t;
        cin>>s>>t;

        int a[10]= {},b[10]= {};
        vector<int> remaining(10,k);
        for(int i=0; i<4; i++)
            a[s[i]-48]++,remaining[s[i]-48]--;
        for(int i=0; i<4; i++)
            b[t[i]-48]++,remaining[t[i]-48]--;

        double ans=0;
        for(int i=1; i<=9; i++)
        {
            if(remaining[i]>0)
            {
                double prob=double(remaining[i])/(9*k-8);
                a[i]++;
                remaining[i]--;
                int scorea=0;
                for(int j=1; j<=9; j++)
                {
                    int cur=j;
                    for(int k=0; k<a[j]; k++)
                        cur*=10;
                    scorea+=cur;
                }

                for(int l=1; l<=9; l++)
                {
                    if(remaining[l]>0)
                    {
                        b[l]++;
                        int scoreb=0;
                        for(int j=1; j<=9; j++)
                        {
                            int cur=j;
                            for(int k=0; k<b[j]; k++)
                                cur*=10;
                            scoreb+=cur;
                        }
                        b[l]--;

                        if(scorea>scoreb)
                            ans+=prob*remaining[l]/(9*k-9);
                    }
                }

                a[i]--;
                remaining[i]++;
            }
        }

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


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

int n, m, dp[100][2];
vector<int> vals, cur;

int solve(int x, int car) {
  if (x == n-1) return 1;
  int &ret = dp[x][car];
  if (~ret) return ret;

  ret = 0;
  if (cur[x] + car == 0) ret = solve(x+1, 0);
  else if (cur[x] + car == 3) ret = solve(x+1, 1);
  else ret += solve(x+1, 0) + solve(x+1, 1);
  return ret;
}

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

  cin >> n >> m;
  vals.resize(n);
  cur.resize(n, 0);

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

  for (int i = n-1; i >= 0; --i) {
    int d = m / vals[i];
    cur[i] = d ? 1 : 0;
    m -= d * vals[i];

    if (i < n-1 && vals[i+1] / vals[i] == d + 1) {
      cur[i] = 2;
    }
  }

  cout << solve(0, 0) << '\n';
}

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define pi 2*acos(0.0)

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

// debug templates
#define debug(x)       cerr<< #x <<" : "<< x << endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";

const int mxN = 107;
double dp[mxN][mxN][mxN];

// expected value
double ev(int a, int b, int c){
    if(a>99 || b>99 || c>99) return 0;
    if(dp[a][b][c]>0) return dp[a][b][c];
    double s=a+b+c;
    double ans = (ev(a+1,b,c)+1)*a/s;
    ans += (ev(a,b+1,c)+1)*b/s;
    ans += (ev(a,b,c+1)+1)*c/s;
    dp[a][b][c] = ans;
    return dp[a][b][c];
}

// solve case for 2 then do 3
void solve(){
    int a,b,c; cin >> a >> b >> c;
    double ans = ev(a,b,c);
    cout << fixed << setprecision(9) << ans;
}

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

	solve();
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <ctype.h>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <deque>
#include <string>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <map>
#include <unordered_map>
#include <bitset>
#include<numeric>
using namespace std;

#define _crt_secure_no_warnings
#define _USE_MATH_DEFINES
#define FREELO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define all(v) v.begin(), v.end()
#define M_PI 3.14159265358979323846
#define INF 0x3F3F3F3F3F3F3F3F
#define MAX 1001
#define MOD
#define sz(s) s.size()
#define ALPHABET 128
#define for1(i, n) for (int i = 1; i <= (n); i++)
#define for0(i, n) for (int i = 0; i < (n); i++)
#define F first
#define S second
typedef long long ll;
typedef double lf;
typedef pair<int, int> ii;

int main(void) {
    int n; cin >> n;
    int w; cin >> w;
    cout << n / w;
}

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

typedef long long LL;
typedef pair<int, int> PII;
const int mod = 1e9 + 7;
const int inf = 2147483647;
const int N = 5e4 + 10, M = N * 2 * 17;

void solve() {
    int n, w;
    scanf("%d%d", &n, &w);
    printf("%d\n", n / w);
}

int main() {
    // freopen("in.txt", "r", stdin);
    // int t; cin >> t; while(t--)
    solve();
    return 0;
}


// Problem Link -
/* By Navneet Shukla */
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll				long long int
#define ld				long double
#define mod             1000000007
#define inf             1e18
#define endl			"\n"
#define pb 				emplace_back
#define vi              vector<ll>
#define vs				vector<string>
#define pii             pair<ll,ll>
#define ump				unordered_map
//#define mp 				map
#define pq_max          priority_queue<ll>
#define pq_min          priority_queue<ll,vi,greater<ll> >
#define ff 				first
#define ss 				second
#define mid(l,r)        (l+(r-l)/2)
#define loop(i,a,b) 	for(int i=(a);i<=(b);i++)
#define looprev(i,a,b) 	for(int i=(a);i>=(b);i--)
#define log(args...) 	{ string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define logarr(arr,a,b)	for(int z=(a);z<=(b);z++) cout<<(arr[z])<<" ";cout<<endl;
#define token(str,ch)	(std::istringstream var((str)); vs v; string t; while(getline((var), t, (ch))) {v.pb(t);} return v;)
vs tokenizer(string str,char ch) {std::istringstream var((str)); vs v; string t; while(getline((var), t, (ch))) {v.pb(t);} return v;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void file_i_o()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	#ifndef ONLINE_JUDGE
	    freopen("input.txt", "r", stdin);
	    freopen("output.txt", "w", stdout);
	#endif
}
ll modularExponentiation(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modularExponentiation((x*x)%M,n/2,M);
    else
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
bool cmp(pair<string,int>p1,pair<string,int>p2)
{
	return p1.ss>p2.ss;
}
int main(int argc, char const *argv[]) {
	file_i_o();
	int n;
	cin>>n;
	vector<pair<string,int>>v;
	while(n--)
	{
		string s;
		int t;
		cin>>s>>t;
		v.push_back(make_pair(s,t));
	}
	sort(v.begin(),v.end(),cmp);
	cout<<v[1].ff<<endl;
	return 0;
}

#include<bits/stdc++.h>
#define maxn 400005
#define INF 0x3f3f3f3f
#define count cnt
using namespace std;
typedef long long ll;
int vis[maxn], viss[maxn];
vector<int > V[maxn];
int flg = 0;
int count = 0;
void dfs(int u, int fa) {
	viss[u]= 1;
	count++;
	for(int i=0;i<V[u].size();i++) {
		int v = V[u][i];
		if(v == fa) continue;
		if(viss[v]) {
			flg = 0;
			return;
		}
		dfs(v, u);
	}

}

int main() {
	int n;
	cin >> n;
	for(int i=1;i<=n;i++) {
		int x,y;
		scanf("%d%d",&x,&y);
		vis[x] = vis[y] = 1;
		V[x].push_back(y);
		V[y].push_back(x);
	}
	int ans = 0;
	for(int i=1;i<=maxn-1;i++) {
		if(vis[i] && !viss[i]) {
			flg = 1;
			count = 0;
			dfs(i, 0);
			if(flg) ans += count-1;
			else ans += count;
		}
	}
	cout << ans << endl;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
typedef long long ll;
int main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	std::cout.tie(0);
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	std::cout << a * d - b * c << "\n";
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define debug printf("%d %s\n",__LINE__,__FUNCTION__);fflush(stdout)
using ll=long long;using i64=long long;using db=double;
using u32=unsigned int;using u64=unsigned long long;using db=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
#define ALL(a) a.begin(),a.end()
const int INF=0x3f3f3f3f;
const ll INFLL=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
template<class T>inline bool chkmin(T&a,T b){return b<a?a=b,true:false;}
template<class T>inline bool chkmax(T&a,T b){return a<b?a=b,true:false;}
int _w,_t;FILE* _f;

int a,b,c,d;

void solve(){
    scanf("%d%d%d%d",&a,&b,&c,&d);
    printf("%d\n",a*d-b*c);
}

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


#include <bits/stdc++.h>

using namespace std;

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

	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (__builtin_popcount(i) == 1) cnt++;
		cout << cnt << " ";
	}
	cout << "\n";
	return 0;
}

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr first
#define sc second
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin >> k;
    ll ans = 0;
    for( ll i = 1;i<=k;i++){
    	for(ll j = 1;j<=k;j++){
    		if(i*j > k) break;
    		ans = ans + k/(i*j);
    	}
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const uint64_t seed = std::chrono::system_clock::now().time_since_epoch().count();
mt19937_64 rnd(seed);
const int MOD = 998244353;

#ifdef VIPJML_LOCAL
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << "{";
    for (typename vector<T>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << *vi;
    }
    os << "}";
    return os;
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const vector<pair<A, B>> &v)
{
    os << "{";
    for (typename vector<pair<A, B>>::const_iterator vi = v.begin(); vi != v.end(); ++vi)
    {
        if (vi != v.begin())
            os << ", ";
        os << '(' << vi->first << " " << vi->second << ")";
    }
    os << "}";
    return os;
}

template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T)
{
    cerr << ' ' << H;
    dbg_out(T...);
}
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
using LL = long long;

void solve(int caseNum)
{
    LL N, T;
    cin >> N >> T;
    vector<LL> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    int H1 = N / 2;
    int H2 = N - H1;
    vector<LL> v1(1 << H1, 0);
    vector<LL> v2(1 << H2, 0);
    for (int i = 0; i < H1; i++)
    {
        v1[1 << i] = A[i];
    }
    for (int i = 0; i < H2; i++)
    {
        v2[1 << i] = A[i + H1];
    }
    for (int i = 0; i < (1 << H1); i++)
    {
        int p = (i - 1) & i;
        int q = i - p;
        v1[i] = v1[p] + v1[q];
    }
    sort(v1.begin(), v1.end());
    LL ans = 0;
    for (int i = 0; i < (1 << H2); i++)
    {
        int p = (i - 1) & i;
        int q = i - p;
        v2[i] = v2[p] + v2[q];
        LL r = T - v2[i];
        auto it = upper_bound(v1.begin(), v1.end(), r);
        if (it != v1.begin())
        {
            it--;
            ans = max(ans, v2[i] + *it);
        }
    }
    cout << ans << endl;
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    int T = 1;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        solve(i);
    }
    cout.flush();
    return 0;
}

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

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

#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define int long long
#define sz(v) (int)v.size()
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define f(i,l,r) for(long long i=l;i<=r;i++)
#define rf(i,r,l) for(long long i=r;i>=l;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

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

const int N = 1e2 + 5, mod = 1e9 + 7, bit = 61;

int dp[N][N], a[N], p[N];
char s[N];
int n, k;
int get(int a, int b)
{
	if (a == 1 or b == 1)
	{
		return max(a, b);
	}
	return min(a, b);
}
map<char, int> mp;

int solve(int x, int pw)
{
	if (pw == 0)
	{
		return a[x];
	}
	int &ans = dp[x][pw];
	if (ans != -1)
	{
		return ans;
	}
	ans = get(solve(x, pw - 1), solve((x + p[pw - 1]) % n, pw - 1));
	return ans;
}

signed main()
{
	fast;

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

	int t = 1;
	// cin >> t;
	f(tc, 1, t)
	{
		mp['R'] = 0;
		mp['P'] = 1;
		mp['S'] = 2;
		cin >> n >> k;
		p[0] = 1;
		f(i, 1, n)
		{
			p[i] = (p[i - 1] << 1) % n;
		}
		f(i, 0, n - 1)
		{
			cin >> s[i];
			a[i] = mp[s[i]];
		}
		memset(dp, -1, sizeof(dp));
		int res = solve(0, k);
		char ans;
		for (auto &x : mp)
		{
			if (x.ss == res)
			{
				ans = x.ff;
				break;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


/*
Author: Pratik Bedre
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    ll sqsum = 0, sum = 0;
    for (int i = 0; i < n; i++)
        sqsum += a[i] * a[i];
    for (int i = 0; i < n; i++)
        sum += a[i];
    ll ans = 2 * sqsum * n - 2 * sum * sum;
    cout << ans / 2;
}

        #include <bits/stdc++.h>
        #define rep(i,cc,n) for(int i=cc;i<=n;++i)
        #define drep(i,cc,n) for(int i=cc;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; }
        const long long INF = 1LL <<60;
        typedef long long ll;
        using namespace std;

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

            vector<int> a(n);
            map<int,ll> mp;

            rep(i,0,n-1){
                cin >> a[i];
                mp[a[i]]++;
            }

            ll sum = 0;

            rep(i,-200,200){
                rep(j,-200,200){
                    sum += (ll)mp[i] * mp[j] * (i-j) * (i-j);
                    //if(mp[i] > 0 && mp[j] > 0) cout << i << " " << j << endl;
                }
            }

            cout << sum / 2 << endl;
            return 0;
        }


#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define kickstart int t,o;cin>>o;for(t=1;t<=o;t++){cout<<"Case #"<<t<<": ";solve();}
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;

void solve()
{
    string s;
    cin >> s;
    bool hard = 1;
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0) {
            if (islower(s[i]) == false) {
                hard = 0;
            }
        }
        else {
            if (isupper(s[i]) == false) {
                hard = 0;
            }
        }
    }
    if (hard == false) cout << "No";
    else cout << "Yes";
}

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

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

int main() {
  string s;
  cin >> s;
  bool ans = true;
  for (int i=0; i < s.length(); i++) {
    if (i % 2 == 0) {
      if (islower(s.at(i))) continue;
      else ans = false; break;
    }
    else {
      if (isupper(s.at(i))) continue;
      else ans = false; break;
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


#include<bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = 1 << 29;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const int MAX_V = 500;
const ll mod9 = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T, class S> ostream &operator<<(ostream &os, const pair<T, S> &p)
{ cout << "(" << p.first << ", " << p.second << ")"; return os; }
template <class T, class S> istream& operator>>(istream& os,  pair<T, S>& p)
{ os >> p.first >> p.second; return os; }
template <class T> ostream &operator<<(ostream &os, const vector<T> &v)
{ for (auto &e : v){cout << e << " ";}cout << endl;return os; }
template<class T> ostream& operator << (ostream &os, set<T> P)
{ for(auto it : P) { os << "<" << it << "> "; } return os << endl; }
template<class T1, class T2> ostream& operator << (ostream &os, map<T1,T2> P)
{ for(auto it : P) { os << "<" << it.first << "->" << it.second << "> "; } return os << endl; }

ll n, X;
ll A[60];
map<pll, ll> mp;

ll f(int x, int i){
    if(mp[{x, i}] > 0) return mp[{x,i}];
    if(i == n - 1) return (x >= 0);
    ll a = A[i], b = A[i+1];
    // assert( x % a == 0);
    if( x % b == 0){
        mp[{x, i}] = f(x, i+1);
        return mp[{x, i}];
    }
    ll y = x - x % b;
    mp[{x, i}] = f(y, i+1) + f(y + b, i + 1);
    return mp[{x, i}];
}

void solve() {
    cin>>n>>X;
    rep(i,n) cin>>A[i];
    cout<<f(X, 0)<<endl;
}

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

    ll t=1;

    // cin>>t;

    rep(i,t){
        solve();
    }

    return 0;
}

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#include <chrono>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=a;i<b;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,a) rrepi(i,a,0)
#define rrepi(i,a,b) for(ll i=a-1;i>=b;--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll MOD3 = 1e6;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<int,int> pi;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
typedef complex<double> Point;
typedef string::const_iterator State;
const ll MAX = 105;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};

//1-indexed
class BIT{
    private:
        vector<ll> bit;
        ll size;
    public:
        BIT(ll n){
            bit.resize(n+1);
            size = n;
        }
        ll sum(ll i){
            ll res = 0;
            while(i > 0){
                res += bit[i];
                i -= i&-i;
            }
            return res;
        }
        void add(ll i,ll x){
            while(i <= size){
                bit[i] += x;
                i += i&-i;
            }
        }
};

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    cins(all(a));
    BIT v1(n),v2(n);
    vector<ll> cnt1(n,0),cnt2(n,0),s1(n),s2(n);
    ll s = 0;
    rep(i,n){
        s1[i] = v1.sum(a[i]+1);
        s += v1.sum(a[i]+1);
        cnt1[i] = i*(i+1)/2-s;
        v1.add(a[i]+1,1);
    }
    s = 0;
    rep(i,n){
        s2[i] = i-v2.sum(a[n-i-1]+1);
        s += v2.sum(a[n-i-1]+1);
        cnt2[i] = s;
        v2.add(a[n-i-1]+1,1);
    }
    ll k = cnt2[n-1];
    //array_output(all(cnt1));
    //array_output(all(cnt2));
    //array_output(all(s1));
    //array_output(all(s2));
    rep(i,n){
        PRINT(k);
        if (i < n-1){
            k -= n-i-1-s2[n-i-1];
            k -= s1[i];
            k += s2[n-i-1];
            k += i-s1[i];
        }
    }
}


#include<bits/stdc++.h>
using namespace std;
namespace IO
{
	const int buffer_size=1e5+5;
	char buf[buffer_size],*S,*T;
	bool flag_EOF;
	inline char read_char()
	{
	    if(S==T)
			T=(S=buf)+fread(buf,1,buffer_size,stdin);
	    return S!=T?*(S++):EOF;
	}
	inline int read_int()
	{
	    int flag=1;
	    char c=read_char();
	    while(c<'0'||c>'9')
	    {
	        if(c==EOF)
	        {
	            flag_EOF=true;
	            return 0;
	        }
	        flag=(c=='-'?-1:1);
	        c=read_char();
	    }
	    int x=0;
	    while(c>='0'&&c<='9')
	    {
	        x=x*10+(c^48);
	        c=read_char();
	    }
	    return x*flag;
	}
	char st[13];
	int _top;
	inline void Write(int x)
	{
		if(!x)
		{
			putchar('0');
			return;
		}
		if(x<0)
		{
			putchar('-');
			x=-x;
		}
		while(x)
		{
			st[++_top]=x%10+'0';
			x/=10;
		}
		while(_top>0)
			putchar(st[_top--]);
	}
}
const int max_n=2e5+5;
char str[15];
struct node
{
	string s;
	bool flag;
}p[max_n];
bool cmp(node x,node y)
{
	return x.s!=y.s?x.s<y.s:x.flag<y.flag;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%s",str+1);
		int len=strlen(str+1);
		if(str[1]=='!')
		{
			p[i].flag=true;
			for(int j=2;j<=len;++j)
				p[i].s+=str[j];
		}
		else
		{
			for(int j=1;j<=len;++j)
				p[i].s+=str[j];
		}
	}
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<n;++i)
	{
		if(p[i].s==p[i+1].s&&p[i].flag!=p[i+1].flag)
		{
			cout<<p[i].s<<endl;
			return 0;
		}
	}
	puts("satisfiable");
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int INF = (1<<30)-1;
const ll LINF = (1LL<<60)-1;

#define rep(i, n) for (int i = 0; i < n; i++)
#define sz(a) (int)(a.size())

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

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

//コーナーケースに気をつけろ！
int main() {
    int n;  cin >> n;
    vector<ll> a(n+1);
    a[1] = 1;
    for (ll x = 2; x <= n; x++) {
        ll mx = 0;
        for (ll z = 1; z * z <= x; z++) {
            if (x % z == 0) {
                chmax(mx, a[z]);
                chmax(mx, a[x/z]);
            }
        }
        a[x] = mx+1;
    }
    rep(i, n)
        cout << a[i+1] << " ";
    cout << endl;
    return 0;
}

//小数点精度
//cout << fixed << std::setprecision(15) << y << endl;