#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>
//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

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

struct BIT {    // 1-indexed
    int n;
    vector<long long> bit;

    BIT(int n) : n(n), bit(n + 1, 0) {}

    void add(int i, int w){
        for(int x = i; x <= n; x += x & -x) bit[x] += w;
    }

    long long sum(int i){ // sum of [1, i]
        int ret = 0;
        for(int x = i; x > 0; x -= x &- x) ret += bit[x];
        return ret;
    }

    long long sum(int l, int r){  // sum of [l, r]
        return sum(r) - sum(l - 1);
    }
};

void solve() {
    ll h, w, m;
    cin >> h >> w >> m;
    vll x(m), y(m);
    rep(i, m) {
        cin >> x[i] >> y[i];
        --x[i], --y[i];
    }
    vector<set<ll>> sety(w), setx(h);
    rep(i, w) sety[i].insert(h);
    rep(i, h) setx[i].insert(w);
    rep(i, m) {
        sety[y[i]].insert(x[i]);
        setx[x[i]].insert(y[i]);
    }
    ll ans = 0;
    for(ll j = 0; j < *setx[0].begin(); ++j) {
        ans += *sety[j].begin();
//        cout << ans << endl;
    }
    set<pll> setob;
    rep(i, m) setob.emplace(x[i], y[i]);
    for(ll j = *setx[0].begin()+1; j < w; ++j) {
        setob.emplace(0, j);
    }
    BIT bit(w+2);
    for(ll i = 0; i < *sety[0].begin(); ++i) {
        ll r = *setx[i].begin();
        ll cntob = bit.sum(r);
//        cout << i << ' ' << cntob << ' ' << r << endl;
        ans += cntob;
        while(!setob.empty() && setob.begin()->first <= i) {
            ll j = setob.begin()->second;
            setob.erase(setob.begin());
            ll now = bit.sum(j+1, j+1);
            if(now == 0) bit.add(j+1, 1);
        }
    }
    cout << ans << endl;
    return;
}

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

#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ep emplace
#define epb emplace_back
#define scll static_cast<long long>
#define sz(x) static_cast<int>((x).size())
#define pfll(x) printf("%lld\n", x)
#define ci(x) cin >> x
#define ci2(x, y) cin >> x >> y
#define ci3(x, y, z) cin >> x >> y >> z
#define co(x) cout << x << endl
#define co2(x, y) cout << x << " " << y << endl
#define co3(x, y, z) cout << x << " " << y << " " << z << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> PQ;
typedef priority_queue<int, vector<int>, greater<int>> PQG;
typedef priority_queue<P> PQP;
typedef priority_queue<P, vector<P>, greater<P>> PQPG;

const int MAX_N = 2e5, MOD = 1e9 + 7, INF = 1e9;
int h, w, m;
int mh[MAX_N], mw[MAX_N];

const int ST_SIZE = (1 << 20) - 1;
vector<int> dat[ST_SIZE];

void init(int k, int l, int r) {
    if (r - l == 1) dat[k].push_back(mw[l]);
    else {
        int lch = k * 2 + 1, rch = k * 2 + 2;
        init(lch, l, (l + r) / 2);
        init(rch, (l + r) / 2, r);
        dat[k].resize(r - l);

        merge(dat[lch].begin(), dat[lch].end(),
              dat[rch].begin(), dat[rch].end(), dat[k].begin());
    }
}

int query(int i, int j, int x, int k, int l, int r) {
    if (j <= l || r <= i) return 0;
    else if (i <= l && r <= j) {
        return upper_bound(dat[k].begin(), dat[k].end(), x) -
               dat[k].begin();
    }
    else {
        int lc = query(i, j, x, k * 2 + 1, l, (l + r) / 2);
        int rc = query(i, j, x, k * 2 + 2, (l + r) / 2, r);
        return lc + rc;
    }
}

int main() {
    ci3(h, w, m);
    fill(mh, mh + w, h);
    fill(mw, mw + h, w);

    rep(i, m) {
        int x, y;
        ci2(x, y);
        mh[y - 1] = min(mh[y - 1], x - 1);
        mw[x - 1] = min(mw[x - 1], y - 1);
    }
    ll ans = 0;
    rep(i, mh[0]) ans += mw[i];

    init(0, 0, mh[0]);
    for (int i = 1; i < mw[0]; i++) {
        ans += query(1, min(mh[i], mh[0]), i - 1, 0, 0, mh[0]);
        ans += max(mh[i] - mh[0], 0);
    }
    co(ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int q;q=1;
    while(q--)
    {
       int a,b,x,y;cin>>a>>b>>x>>y;
       if(a>=b)
       {
           if(a==b)
           cout<<x;
           else
           {
               if(2*x>=y)
               cout<<x+(a-b-1)*y;
               else
               cout<<(a-b)*2*x-x;
           }
       }
       else
       {
               if(2*x>=y)
               cout<<x+(b-a)*y;
               else
               cout<<(b-a)*2*x+x;

       }
    }

}

#include <bits/stdc++.h>

using namespace std;

#define PI 3.14159265358979323846264338327950L

int A = 0, B = 1;
int a, b, x, y;
vector<vector<int >> dp;
queue<pair<int, int>> que;

int solver(int ab, int floor) {
	if (dp[ab][floor] > 0) {
		return dp[ab][floor];
	}

	if (floor < a) {
		return 0;
	}

	int ret;
	if (ab == A) {
		ret = min(solver(A, floor - 1) + y, min(solver(B, floor) + x, solver(B, floor) + x));
	}
	else {
		ret = min(solver(A, floor) + x, solver(B, floor) + y);
	}

	return dp[ab][floor] = ret;

}

int main(void) {

	int start = A, end = B;

	cin >> a >> b >> x >> y;

	int tmp = a;
	a = a - tmp;
	b = b - tmp;

	if (a > b) {
		int tmp = a - b;
		a = 1;
		b = tmp + 1;
		start = B;
		end = A;

	}

	vector<int> tmpvec1(b + 3, INT_MAX);
	vector<vector<int>> tmpDp(2, tmpvec1);
	dp = tmpDp;

	dp[start][a] = 0;
	dp[end][a] = x;

	pair<int, int> tmpP = make_pair(A, a);
	que.push(tmpP);

    for(int i=a;i<=b;i++){
        int floor=i;

        dp[A][floor + 1] = min(dp[A][floor + 1], dp[A][floor] + y);
        dp[B][floor] = min(dp[B][floor], dp[A][floor] + x);

        dp[B][floor + 1] = min(dp[B][floor + 1], dp[B][floor] + y);
        dp[A][floor + 1] = min(dp[A][floor + 1], dp[B][floor] + x);
    }

	cout << dp[end][b] << endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define cs const
#define fr first
#define se second
#define ls (now<<1)
#define rs (now<<1|1)
#define mid ((l+r)>>1)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define low(i) (i&(-i))
#define par pair<int,int>
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define sep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])

cs int G = 3;
cs int ff = 1e6 + 15;
cs int inf = 1e18 + 1;
cs int base = 4;
cs int M = 998244353;

void Add(int &x, int y) { x = (x + y) % M; if(x < 0) x += M; }

int ksm(int x, int y) { return (y % 2 == 1 ? x : 1) * (y ? ksm(x * x % M, y >> 1) : 1) % M; }

int fa[ff][2];
int find(int x, int typ) { return fa[x][typ] == x ? x : fa[x][typ] = find(fa[x][typ], typ); }

int qz[ff], a[53][53], n, kq, sz[ff][2];
void init()
{
	qz[0] = 1;
	rep(i, 1, 55) qz[i] = qz[i - 1] * i % M;
	cin >> n >> kq;
	rep(i, 1, n) fa[i][0] = fa[i][1] = i, sz[i][0] = sz[i][1] = 1;
	rep(i, 1, n)
		rep(j, 1, n) cin >> a[i][j];
	rep(i, 1, n)
		rep(j, i + 1, n)
		{
			int tag1 = 0, tag2 = 0;
			rep(k, 1, n)
				tag1 |= (a[i][k] + a[j][k] > kq),
				tag2 |= (a[k][i] + a[k][j] > kq);
		//	cout << i << " " << j << " " << tag1 << " " << tag2 << "\n";
			if(!tag1 && find(i, 0) != find(j, 0)) sz[find(j, 0)][0] += sz[find(i, 0)][0], fa[find(i, 0)][0] = find(j, 0);
			if(!tag2 && find(i, 1) != find(j, 1)) sz[find(j, 1)][1] += sz[find(i, 1)][1], fa[find(i, 1)][1] = find(j, 1);
		}
	int s1 = 1, s2 = 1;
	rep(i, 1, n)
		s1 = s1 * qz[sz[find(i, 0)][0]] % M, sz[find(i, 0)][0] = 1,
		s2 = s2 * qz[sz[find(i, 1)][1]] % M, sz[find(i, 1)][1] = 1;
	cout << s1 * s2 % M;
}
signed main()
{
//	freopen("triad.in", "r", stdin);
//	freopen("triad.out", "w", stdout);
	int Ts = 1;
	while(Ts--)
		init();

}
/*

*/

#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e5 + 5;

int pri[maxn], t;
bool vis[maxn];
int yue[maxn];
int last[maxn];

void pre() {
    memset(vis, 0, sizeof(vis));
    t = 0;
    yue[1] = 1;
    last[1] = 0;
    for (int i = 2; i < maxn; i++) {
        if (!vis[i]) {
            pri[t++] = i;
            yue[i] = 2;
        }
        for (int j = 0; j < t && i * pri[j] < maxn; j++) {
            vis[i * pri[j]] = true;
            if (pri[j] % i == 0) {
                yue[i * pri[j]] = yue[i] + 1;
                break;
            } else {
//                last[i * pri[j]] = 1;
                yue[i * pri[j]] = yue[i] + 1;
            }
        }
    }
}

int main() {
#ifdef LOAD
    freopen("../1.txt", "r", stdin);
//    cout<<"haha"<<endl;
#endif
    int n;
    scanf("%d", &n);
    pre();
    for (int i = 1; i <= n; i++) {
        printf("%d%c", yue[i], i == n ? '\n' : ' ');
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin>>n;
	cout<<(1<<n)-1<<endl;
	for(int i=1;i<1<<n;i++){
		for(int j=0;j<1<<n;j++){
			if(__builtin_popcount(j&i)&1) cout<<'B';
			else cout<<'A';
		}
		cout<<endl;
	}
}

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<string> now;
  now.push_back("AB");
  N--;
  int len = 2;
  while(N--) {
    vector<string> next;
    string tmp = "";
    REP(i, len) tmp += 'A';
    REP(i, len) tmp += 'B';
    next.push_back(tmp);
    REP(i, now.size() * 2) {
      string tmp = "";
      tmp += now[i/2];
      string tmp2 = now[i/2];
      if(i%2 == 1) {
        REP(j, tmp2.size()) {
          if(tmp2[j] == 'A') tmp2[j] = 'B';
          else tmp2[j] = 'A';
        }
      }
      tmp += tmp2;
      next.push_back(tmp);
    }
    now = next;
    len *= 2;
  }
  cout << now.size() << "\n";
  REP(i, now.size()) cout << now[i] << "\n";
}


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define N 20005
using namespace std;
const int inf=0x3f3f3f3f,mod=998244353;
inline int read() {
	int s=0,f=0;
	char ch=getchar();
	while(ch<48||ch>57)f=(ch=='-'),ch=getchar();
	while(ch>47&&ch<58)s=(s<<1)+(s<<3)+(ch^48),ch=getchar();
	return f?-s:s;
}
int n,m,ans,mx,fac[N],inv[N],f[20][N];
int Ksm(int a,int n,int ans=1) {
	for(; n; n>>=1,a=1ll*a*a%mod)if(n&1)ans=1ll*ans*a%mod;
	return ans;
}
int C(int n,int m) {
	if(n<m)return 0;
	return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int Mod(int x) {
	return x<mod?x:x-mod;
}
void Add(int &x,int y) {
	x=Mod(x+y);
}
signed main() {
	n=read(),m=read(),fac[0]=1;
	if(m&1)return puts("0"),0;
	for(int i=1; i<=n; ++i)fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=Ksm(fac[n],mod-2);
	for(int i=n-1; ~i; --i)inv[i]=inv[i+1]*(i+1ll)%mod;
	for(int k=0; k<=n; k+=2)f[0][k>>1]=C(n,k);
	for(int i=0; (1<<i)<m; ++i) {
		if(mx=i+1,(m>>i+1)&1) {
			for(int j=1; j<=10000; j+=2)
				if(f[i][j])for(int k=0; k<=n; k+=2)Add(f[i+1][k+j>>1],1ll*f[i][j]*C(n,k)%mod);
		} else {
			for(int j=0; j<=10000; j+=2)
				if(f[i][j])for(int k=0; k<=n; k+=2)Add(f[i+1][k+j>>1],1ll*f[i][j]*C(n,k)%mod);
		}
	}
	cout<<f[mx][0];
	return 0;
}


#include <bits/stdc++.h>
#define ri register int
#define fi first
#define se second
#define pb push_back
#define ppp pop_back
#define rez resize
using namespace std;
typedef unsigned int uit;
typedef long long ll;
typedef vector <int> poly;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
const int rlen = 1 << 20 | 5;
char buf[rlen], *ib = buf, *ob = buf;
#define gc() (((ib == ob) && (ob = (ib = buf) + fread(buf, 1, rlen, stdin))), ib == ob ? -1 : *ib++)
inline int read() {
  static int ans, f;
  static char ch;
  for (ans = 0, f = 1, ch = gc(); !isdigit(ch); f ^= ch == '-', ch = gc());
  for (; isdigit(ch); ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc());
  return f ? ans : -ans;
}
inline ll readl() {
  static ll ans;
  static int f;
  static char ch;
  for (ch = gc(), ans = 0, f = 1; !isdigit(ch); f ^= ch == '-', ch = gc());
  for (; isdigit(ch); ans = ((ans << 2) + ans << 1) + (ch ^ 48), ch = gc());
  return f ? ans : -ans;
}
inline int Read(char *s) {
  static int len;
  static char ch;
  for (ch = gc(), len = 0; !isalpha(ch); ch = gc());
  for (; isdigit(ch); s[++len] = ch, ch = gc());
  return len;
}
template <typename T> inline void ckmax(T &a, T b) {
  a = a > b ? a : b;
}
template <typename T> inline void ckmin(T &a, T b) {
  a = a < b ? a : b;
}
namespace modular {
  const int mod = 1e9 + 7;
  inline int add(int a, int b) {
    return a < mod - b ? a + b : a - mod + b;
  }
  inline int dec(int a, int b) {
    return a < b ? a - b + mod : a - b;
  }
  inline int mul(int a, int b) {
    return (ll) a * b % mod;
  }
  inline void Add(int &a, int b) {
    a = a < mod - b ? a + b : a - mod + b;
  }
  inline void Dec(int &a, int b) {
    a = a < b ? a - b + mod : a;
  }
  inline void Mul(int &a, int b) {
    a = (ll) a * b % mod;
  }
  inline int ksm(int a, int p) {
    static int ret;
    for (ret = 1; p; p >>= 1, Mul(a, a)) {
      (p & 1) && (Mul(ret, a), 1);
    }
    return ret;
  }
}  using namespace modular;
const int N = 1e5 + 5;
ll n;
inline ll calc(ll t) {
  ll x = t, y = n - t, sz = 0;
  x = t, y = n - t;
  ++sz;
  while (x >= 3 && y >= 3) {
    if (x > y) {
      ++sz;
      x -= y;
    } else  if (x < y) {
      ++sz;
      y -= x;
    }
    if (x == y) {
      break;
    }
  }
  return sz + x + y;
}
int main() {
  #ifdef ldxcaicai
  freopen("lx.in", "r", stdin);
  #endif
  double tt = (sqrt(5.0) - 1) / 2;
  n = readl();
  ll t, x, y;
  t = (ll) (tt * (double) n);
  for (ll i = max(0ll, t - 5000); i <= min(n, t + 5000); ++i) {
    if (calc(i) <= 130) {
      x = i, y = n - i;
      poly res;
      res.pb(3);
      while (x >= 3 && y >= 3) {
        if (x > y) {
          res.pb(3);
          x -= y;
        } else  if (x < y) {
          res.pb(4);
          y -= x;
        }
        if (x == y) {
          break;
        }
      }
      while (x) {
        --x;
        res.pb(1);
      }
      while (y) {
        --y;
        res.pb(2);
      }
      cout << res.size() << '\n';
      while (res.size()) {
        cout << res.back() << '\n';
        res.ppp();
      }
      return 0;
    }
  }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<int> vec;
using Graph = vector<vector<int>>;
const long long INF = 1LL<<60;
const long long MOD = 1000000007;
const int inf=1e9+7;

struct edge { ll to, cost, time; };   //辺
int V;   //頂点数
const int MAX_V = 1000000;
vector<vector<edge>> G(MAX_V);
ll d[MAX_V];

void dijkstra(int s) {
    //greater<P>でfirstが小さい順に取り出せる
    //first:最短距離,second:頂点番号
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first)continue;
        rep(i, G[v].size()) {
            edge e = G[v][i];
            ll sta=d[v];
            if(d[v]%e.time!=0){
              sta+=(e.time-d[v]%e.time);
            }
            if (d[e.to] > sta + e.cost) {
                d[e.to] = sta + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m,x,y;cin>>V>>m>>x>>y;
    x--,y--;
    rep(i,m){
      ll a,b,t,k;
      cin>>a>>b>>t>>k;
      a--;b--;
      G[a].push_back({b,t,k});
      G[b].push_back({a,t,k});
    }
    dijkstra(x);
    if(d[y]>=INF)cout<<-1<<endl;
    else cout<<d[y]<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
using ll=long long;
using P = pair<int,int>;
int main(){
    string s;
    cin >> s;
    ll c[10]={0};
    ll answer=0;
    ll one = (ll)s[0]-48;
    ll two =(ll)s[1]-48;
    ll three =(ll)s[2]-48;
    if(s.size()==1){
        if(one%8==0)answer=1;
    }else if(s.size()==2){
        if((one*10+two)%8==0)answer++;
        else if((two*10+one)%8==0)answer++;
    }
    else if(s.size()==3){
        if((one*100+two*10+three)%8==0)answer++;
        else if((one*100+three*10+two)%8==0)answer++;
        else if((two*100+one*10+three)%8==0)answer++;
        else if((two*100+three*10+one)%8==0)answer++;
        else if((three*100+one*10+two)%8==0)answer++;
        else if((three*100+two*10+one)%8==0)answer++;
    }
    else{
        for(ll i=0;i<(ll)s.size();i++){
           if(c[(ll)s[i]-48]!=3){
              c[(ll)s[i]-48]++;
          }
        }
        ll count=0;
        for(ll i=1;i<10;i++){
            count+=c[i];
        }
        ll an[count];
        ll now=0;
        for(ll i=1;i<10;i++){
            for(ll j=0;j<c[i];j++){
               an[now]=i;
              now++;
          }
        }
        for(ll a=0;a<count;a++){
         for(ll b=0;b<count;b++){
                for(ll c=0;c<count;c++){
                    if(a==b||b==c||c==a)break;
                    if((an[a]*100+an[b]*10+an[c])%8==0)answer++;
               }
         }
        }
    }
    if(answer==0)cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

// g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -o

int main(){
 string s;
 cin>>s;
 map<int,int>d;
 int n=s.length();
 for(int i=0;i<n;i++){
  d[s[i]-'0']++;
 }
 if(n==1)cout<<(s=="8"?"Yes\n":"No\n");
 else if(n==2){
  string r=s;
  reverse(r.begin(),r.end());
  for(int i=16;i<100;i+=8){
   if(stoi(s)==i || stoi(r)==i){
    cout<<"Yes\n";
    return 0;
   }
  }
  cout<<"No\n";
  return 0;
 }
 if(n>=3){
  int flag=1;
  for(int i=104;i<1000;i+=8){
   map<int,int>num;
   int N=i;
   while(N){
    num[N%10]++;
    N/=10;
   }
   for(auto x:num){
    if(d[x.first]<x.second){
     flag=0;
     break;
    }
   }
   if(flag){
    cout<<"Yes\n";
    return 0;
   }
   flag=1;
  }
  cout<<"No\n";
 }
 return 0;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long
//using mint = atcoder::modint;

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c){
    struct Edge {
        int index, to;
    };
    vector<vector<Edge>> edges(N+1);
    rep(i,0,M) {
        edges[a[i]].push_back(Edge{(int)i, (int)b[i]});
        edges[b[i]].push_back(Edge{(int)i, (int)a[i]});
    }
    vector<string> answer(M);
    vector<int> visited(N+1, false);
    auto dfs = [&](auto&& self, int current) -> void {
        visited[current] = true;
        for (const auto& [edgeIndex, next] : edges[current]) {
            if (c[current] != c[next]) continue;
            if (next == b[edgeIndex]) {
                answer[edgeIndex] = "->";
            } else {
                answer[edgeIndex] = "<-";
            }
            if (visited[next]) continue;
            self(self, next);
        }
    };
    rep(i,1,N+1) {
        if (visited[i]) continue;
        dfs(dfs, i);
    }
    rep(i,0,M) {
        if (c[a[i]] > c[b[i]]) cout << "->" << endl;
        else if (c[a[i]] < c[b[i]]) cout << "<-" << endl;
        else {
            cout << answer[i] << endl;
        }
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    std::vector<long long> c(N+1);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&c[i+1]);
    }
    solve(N, M, std::move(a), std::move(b), std::move(c));
    return 0;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    int M; cin>>M;
    vec_int a(M);
    vec_int b(M);
    rep(i,M)cin>>a.at(i)>>b.at(i);
    vec_int c(N); rep(i,N)cin>>c.at(i);
    vector<vec_int> G(N+1);
    rep(i,M){
        G.at(a.at(i)).push_back(b.at(i));
        G.at(b.at(i)).push_back(a.at(i));
    }
    map<P, int> path_map;
    rep(i, M){
        path_map[make_pair(a.at(i), b.at(i))] = i;
        path_map[make_pair(b.at(i), a.at(i))] = i;
    }
    vector<string> ans(M,"");
    rep(i,M){
        if(c.at(a.at(i)-1)>c.at(b.at(i)-1)){
            ans.at(i) = "->";
        }else if(c.at(a.at(i)-1)<c.at(b.at(i)-1)){
            ans.at(i) = "<-";
        }
    }

    rep(i,M){
        if(ans.at(i)==""){
            vec_int visited(N+1, 0);
            visited.at(a.at(i)) =1;
            stack<P> st;
            st.push(make_pair(b.at(i), a.at(i))); // node, parent
            int node_val = c.at(a.at(i)-1);
            while(!st.empty()){
                int node = st.top().first;
                int parent = st.top().second;
                st.pop();
                int ind = path_map[make_pair(parent, node)];
                if(ans.at(ind)!="")continue;
                if(a.at(ind)==parent && b.at(ind)==node){
                    ans.at(ind) = "->";
                }else{
                    ans.at(ind) = "<-";
                }
                for(auto next_node: G.at(node)){
                    if(next_node==parent)continue;
                    if(c.at(next_node-1)!=node_val)continue;
                    st.push(make_pair(next_node, node));
                }
            }
        }
    }
    rep(i,M){
        cout<<ans.at(i)<<endl;
    }

    return 0;
}


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

int main() {
	// your code goes here
	int a,b,c,d,m,n;
	cin>>a>>b>>c>>d;
	m=max(a,b);
	n=min(c,d);
	cout<<m-n<<"\n";

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
vector<ll> v;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,m,i,j,k,a,b,c,t,q,sum = 0,cnt = 0,maxn = 0,ans = 0;
	cin>>n>>a>>b>>c;
	a*=n;
	b*=n;
	if(a<=c&&c<=b)cout<<"No";
	else cout<<"Yes";
}


#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 4000000000000000000 //オーバーフローに注意
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define SIZE 200005

typedef vector<ll> V;
typedef vector<V> MATRIX;

struct Info{

	ll x,y;
};

int num_P;
int N = 3;
Info info[SIZE];
ll table[SIZE][3][3];

MATRIX calc(MATRIX left,MATRIX right){

	MATRIX ret(N,V(N));

	for(int i = 0; i < N; i++){
		for(int k = 0; k < N; k++)ret[i][k] = 0;
	}

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++){
			for(int a = 0; a < N; a++){
				ret[row][col] += left[row][a]*right[a][col];
			}
		}
	}

	return ret;

}

//MULTのT乗を計算する
MATRIX pow(MATRIX MULT,int count){

	MATRIX ret(N,V(N));

	for(int row = 0; row < N; row++){
		for(int col = 0; col < N; col++){
			if(row == col)ret[row][col] = 1;
			else{
				ret[row][col] = 0;
			}
		}
	}

	while(count > 0){
		if(count%2 == 1)ret = calc(ret,MULT);
		MULT = calc(MULT,MULT);
		count /= 2;
	}

	return ret;
}

int main(){

	scanf("%d",&num_P);

	for(int i = 1; i <= num_P; i++){

		scanf("%lld %lld",&info[i].x,&info[i].y);
	}

	MATRIX MULT(N,V(N));
	for(int i = 0; i <= 2; i++){

		MULT[i][i] = 1;
	}

	MATRIX A1(N,V(N));
	A1[0][1] = 1,A1[1][0] = -1,A1[2][2] = 1;

	MATRIX A2(N,V(N));
	A2[0][1] = -1,A2[1][0] = 1,A2[2][2] = 1;

	MATRIX AX(N,V(N));
	AX[0][0] = -1,AX[1][1] = 1,AX[2][2] = 1;

	MATRIX AY(N,V(N));
	AY[0][0] = 1,AY[1][1] = -1,AY[2][2] = 1;

	MATRIX work(N,V(N));

	for(int row = 0; row < 3; row++){
		for(int col = 0; col < 3; col++){

			table[0][row][col] = MULT[row][col];
		}
	}

	int M;
	scanf("%d",&M);

	int command;
	ll p;

	for(int i = 1; i <= M; i++){

		scanf("%d",&command);

		if(command == 1){

			MULT = calc(A1,MULT);
		}else if(command == 2){

			MULT = calc(A2,MULT);

		}else{

			scanf("%lld",&p);

			if(command == 3){

				for(int row = 0; row < 3; row++){
					for(int col = 0; col < 3; col++){

						work[row][col] = AX[row][col];
					}
				}
				work[0][2] = 2*p;

				MULT = calc(work,MULT);

			}else{

				for(int row = 0; row < 3; row++){
					for(int col = 0; col < 3; col++){

						work[row][col] = AY[row][col];
					}
				}
				work[1][2] = 2*p;

				MULT = calc(work,MULT);
			}
		}

		for(int row = 0; row < 3; row++){
			for(int col = 0; col < 3; col++){

				table[i][row][col] = MULT[row][col];
			}
		}
	}

	int Q;
	scanf("%d",&Q);

	int count,index;

	for(int loop = 0; loop < Q; loop++){

		scanf("%d %d",&count,&index);

		ll x = info[index].x;
		ll y = info[index].y;

		ll ans_x = table[count][0][0]*x + table[count][0][1]*y + table[count][0][2];
		ll ans_y = table[count][1][0]*x + table[count][1][1]*y + table[count][1][2];

		printf("%lld %lld\n",ans_x,ans_y);
	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll=int64_t;
using pll=pair<ll,ll>;

struct OP{
    pll o={0,0},ex={1,0},ey={0,1};
};
pll operator+(pll a,pll b){return{a.first+b.first,a.second+b.second};}
pll operator-(pll a,pll b){return{a.first-b.first,a.second-b.second};}
pll operator*(pll a,ll b){return {a.first*b,a.second*b};}
OP operator*(const OP& a,const OP& b){
    OP ans;
    ans.o=b.o+b.ex*a.o.first+b.ey*a.o.second;
    ans.ex=b.ex*a.ex.first+b.ey*a.ex.second;
    ans.ey=b.ex*a.ey.first+b.ey*a.ey.second;
    return ans;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll N;
    cin>>N;
    vector<pair<ll,ll>> point(N);
    for(auto& [X, Y] : point)cin>>X>>Y;
    ll M;
    cin>>M;
    vector<OP> op(M);
    for(OP& a:op){
        ll type;
        cin>>type;
        if(type==1){
            a.ex={0,-1};
            a.ey={1,0};
        }
        else if(type==2){
            a.ex={0,1};
            a.ey={-1,0};
        }else if(type==3){
            ll p;
            cin>>p;
            a.o={p*2,0};
            a.ex={-1,0};
        }else {
            ll p;
            cin>>p;
            a.o={0,p*2};
            a.ey={0,-1};
        }
    }
    op.insert(op.begin(),OP{});
    for(ll i=0;i<M;i++)op[i+1]=op[i]*op[i+1];
    ll Q;
    cin>>Q;
    for(ll i=0;i<Q;i++){
        ll A,B;
        cin>>A>>B;
        const auto [X, Y] =point[B-1];
        pll ans=op[A].o+op[A].ex*X+op[A].ey*Y;
        cout<<ans.first<<' '<<ans.second<<'\n';
    }
}


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

int main()
{
    ll n,w;
    cin>>n>>w;
    cout<<n/w<<endl;

}

/*
8888888888888888888888888888
    Md. Masud Mazumder
    University of Chittagong
    Department of CSE
8888888888888888888888888888
*/

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <sstream>
#include <iomanip>
using namespace std;

#define int int64_t
#define vi vector<int>
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define all(x) (x).begin(), (x).end()
#define vii vector< vector<int> >
#define rip(dp, n, m) vector< vector<int> > dp(n, vector<int>(m,0))
#define ff first
#define ss second
#define pii pair<int64_t, int64_t>
#define miv map<int, vector<int> >
#define mp make_pair
#define pb push_back
#define prr(x) cout << (#x) <<'	' << (x) << endl
#define pr(x) cout  << (x) << endl
#define f(i,n) for(i=0;i<n;i++)
#define pqb priority_queue<int>
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define autoitr(x,it) for(auto it = x.rbegin(); it != x.rend(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define pqs priority_queue<int,vi,greater<int> >
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x) int x; cin>>x; while(x--)
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dr8[] = {1,1,0,-1,-1,-1, 0, 1};
int dc8[] = {0,1,1, 1, 0,-1,-1,-1};
int dr4[] = {1,0,0,-1};
int dc4[] = {0,1,-1,0};
int gcd(int a, int b)
{
    if(a%b==0) return b;
    return gcd(b, a%b);
}
void inp(int &x)
{
    bool neg=false;
    register int c;
    x =0;
    c=getchar();
    if(c=='-')
    {
        neg = true;
        c=getchar();
    }
    for(;(c>47 && c<58);c=getchar())
        x = (x<<1) + (x<<3) +c -48;
    if(neg)
    x *=-1;
}
void solve();

int32_t main()
{
    FIO;
    int t=1;
    //cin >> t;
for(int i=1;i<=t;i++)
    {
        solve();
    }
}
void solve()
{
    int i, n, j, m, k, l, t;
    cin >> n >> m;
    cout << n/m;
}


#include <iostream>
#include <string>
#include<math.h>
#include<vector>
#include<algorithm>

using ll = long long;
using namespace std;
int main(void) {
	ll n, k; cin >> n >> k;
	ll ans=0;
	ll before=0;
	vector<vector<ll>> a(n,vector<ll>(2)); for (int i = 0; i < n; i++) cin >> a[i][0]>>a[i][1];
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		if (k < (a[i][0]-before)) {
			ans += k;
			k = 0;
			break;
		}
		else {
			k += (a[i][1] + before - a[i][0]);
			ans =a[i][0];
		}
		before = a[i][0];
	}
	if (k != 0)ans += k;
	cout << ans << endl;
	return 0;
}

#include<iostream>
#include<cstring>
#include<algorithm>
#define int long long

using namespace std;

int a[101];
int g1(int x)
{
	if(x==0)return 0;
	int cnt=0;
	while(x)
	{
		a[++cnt]=x%10;
		x/=10;
	}
	sort(a+1,a+1+cnt);
	int ans=0;
	for(int i=cnt;i>=1;i--)
	{
		ans*=10;
		ans+=a[i];
	}
	return ans;
}

int g2(int x)
{
	if(x==0)return 0;
	int cnt=0;
	while(x)
	{
		a[++cnt]=x%10;
		x/=10;
	}
	sort(a+1,a+1+cnt);
	int ans=0;
	for(int i=1;i<=cnt;i++)
	{
		ans*=10;
		ans+=a[i];
	}
	return ans;
}

signed main()
{
	int N,K;cin>>N>>K;
	for(int i=1;i<=K;i++)
	{
		int tmp=g1(N)-g2(N);
		N=tmp;
	}
	cout<<N;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
//const long nPrime = 1000000007;
//const long nPrime = 998244353;
int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<pair<int,int>>> vviiNum(n);
    for(int i = 0; i < m; i++){
        int x,y,z;
        cin >> x >> y >> z;
        x--, y--;
        vviiNum[x].push_back(make_pair(y,z));
    }

    vector<long> viDP((1<<n),0);
    viDP[0] = 1;
    for(int i = 1; i < (1<<n); i++){
        long nCount = 0;
        vector<long> viCount(n,0);
        for(int j = 0; j < n; j++){
            if((i|(1<<j)) != i){
                continue;
            }
            nCount++;
            for(int k = j; k < n; k++){
                viCount[k]++;
            }
        }
        bool b = true;
        for(int j = 0; j < vviiNum[nCount-1].size(); j++){
            int y = vviiNum[nCount-1][j].first;
            int z = vviiNum[nCount-1][j].second;
            if(viCount[y] > z){
                b = false;
                break;
            }
        }
        if(!b){
            continue;
        }
        for(int j = 0; j < n; j++){
            if((i|(1<<j)) != i){
                continue;
            }
            viDP[i] += viDP[i^(1<<j)];
        }
    }

    cout << viDP[(1<<n)-1] << endl;
    return 0;
}

#include<bits/stdc++.h>
#define f(i,n) for(long long int i = 0 ; i < n;  i++)
#define F first
#define S second
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define all(s) s.begin(), s.end()
#define u_s unordered_set
#define u_m unordered_map
#define ll long long int
#define pb push_back
#define pll pair<ll,ll>
#define parr(arr) for(auto x: arr)cout<<x<<" ";cout<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define testcase ll tt; cin>>tt; while(tt--)
using namespace std;
vector<vector<pll>> cond;
ll n, m;
ll dp[18][524300], dp1[18][524300];
bool check(ll idx, ll taken){
    if(cond[idx].size() == 0) return 1;
    if(dp1[idx][taken] != -1) return dp1[idx][taken];
    ll pre[n+1] = {};
    for(ll i = 1; i <= n; i++){
        pre[i] = ((taken & (1<<i)) != 0);
        pre[i] += pre[i-1];
    }
    for(auto &x: cond[idx]){
        if(pre[x.F] > x.S) return dp1[idx][taken] = 0;
    }
    return dp1[idx][taken] = 1;
}

ll helper(ll idx, ll taken){
    if(idx == n)
        return 1LL;
    if(dp[idx][taken] != -1) return dp[idx][taken];
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        if(taken & (1LL<<i)) continue;
        taken ^= (1LL<<i);
        if(check(idx, taken)) ans += helper(idx+1, taken);
        taken ^= (1LL<<i);
    }
    return dp[idx][taken] = ans;
}

void solve(){
    cin>>n>>m;
    cond.resize(n);
    while(m--){
        ll x , y , z; cin>>x>>y>>z; x--;
        cond[x].pb({y,z});
    }
    memset(dp,-1,sizeof dp);
    memset(dp1,-1,sizeof dp1);
    cout<<helper(0, 0);
}

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


#include <bits/stdc++.h>
using namespace std;
#define int long long
const int nax=1e5+100;
struct node
{
    int n,ok;
    vector<int> par;
    node(int n):n(n),par(n,-1),ok(n){}
    bool merge(int x,int y)
    {
        x=find(x);
        y=find(y);
        if(x==y)
        return 0;
        if(par[x]>par[y])
        swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        --ok;
        return 1;
    }
    int find(int v)
    {
        if(par[v]<0)
        return v;
        return par[v]=find(par[v]);
    }
    int get(int x)
    {
        return -par[find(x)];
    }
    bool same(int x,int y)
    {
        return find(x)==find(y);
    }
    vector<int> check() const{
        vector<int> res;
        res.reserve(ok);
        for(int i=0;i<par.size();i++)
        if(par[i]<0)
        res.push_back(i);
        return res;
    }
};
int32_t main()
{
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    for(int i=0;i<h;i++)
    cin>>s[i];
    node root(h+w);
    root.merge(0,h);
    root.merge(0,h+w-1);
    root.merge(h-1,w);
    root.merge(h-1,h+w-1);
    for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
    if(s[i][j]=='#')
    {
        int row=i,col=h+j;
        root.merge(row,col);
    }
    int res=0;
    for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
    {
        if(s[i][j]=='#')
        {
            if(!root.same(i,0))
            {
                root.merge(i,0);
                ++res;
            }
        }
    }
    int e=0,o=0;
    {
        for(int i=1;i<=h-2;i++)
        {
            bool f=1;
            for(int j=0;j<w;j++)
            if(s[i][j]=='#')
            {
                f=0;
                break;
            }
            if(f)
            ++e;
        }
        for(int j=1;j<=w-2;j++)
        {
            bool f=1;
            for(int i=0;i<h;i++)
            if(s[i][j]=='#')
            {
                f=0;
                break;
            }
            if(f)
            o++;
        }
    }
    res+=min(e,o);
    cout<<res;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> pii;
typedef pair<LL,pii> ppi;
typedef pair<pii,pii> ppp;
#define FOR(i, n) for(int i = 1; i<=n; i++)
#define F0R(i, n) for(int i = 0; i<n; i++)
#define mp make_pair
#define pb push_back
#define f first
#define s second

template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {cout << "["; F0R(i, v.size()) {if (i) cout << ", "; cout << v[i];} return cout << "]";}

struct fenwick{
	LL sz;
	vector<array<LL, 2>> tr;

	fenwick(LL ss){
		sz = ss;
		tr.assign(sz, {0, 0});
	}

	void upd(LL g, array<LL, 2> k){
		for(; g<sz; g+=g&-g){
			tr[g][0] += k[0];
			tr[g][1] += k[1];
		}
	}

	array<LL, 2> ge(LL g){
		array<LL, 2> res = {0, 0};
		for(; g>0; g-=g&-g){
			res[0] += tr[g][0];
			res[1] += tr[g][1];
		}

		return res;
	}
};

//var
const LL MX = 400000;
LL T, n, m, q, ans = 0, a[200005], b[200005];
fenwick tra(400005), trb(400005);
array<LL, 3> queries[200005];
vector<LL> vals;
map<LL, LL> indexx;

void solve(){
	cin >> n >> m >> q;

	FOR(i, q){
		F0R(j, 3){
			cin >> queries[i][j];
		}
		vals.pb(queries[i][2]);
	}

	vals.pb(0);

	sort(vals.begin(), vals.end());
	vector<LL> equal = vals;
	vals.clear(); LL pr = -1;
	for(auto u : equal){
		if(u != pr) vals.pb(u);
		pr = u;
	}

	F0R(i, (int)vals.size())
		indexx[vals[i]] = i+1;

	tra.upd(indexx[0], {0, n});
	trb.upd(indexx[0], {0, m});

	FOR(i, n) a[i] = indexx[0];
	FOR(i, m) b[i] = indexx[0];

	//cout << vals << '\n';

	FOR(z, q){
		LL t1, i, x;
		t1 = queries[z][0], i = queries[z][1], x = queries[z][2];

		x = indexx[x];

		if(t1 == 1){
			tra.upd(a[i], {-vals[a[i] - 1], -1});
			ans -= trb.ge(a[i])[1] * vals[a[i] - 1] + (trb.ge(MX)[0] - trb.ge(a[i])[0]);

			a[i] = x;

			tra.upd(a[i], {vals[a[i] - 1], 1});
			ans += trb.ge(a[i])[1] * vals[a[i] - 1] + (trb.ge(MX)[0] - trb.ge(a[i])[0]);
		}
		else{
			trb.upd(b[i], {-vals[b[i] - 1], -1});
			ans -= tra.ge(b[i])[1] * vals[b[i] - 1] + (tra.ge(MX)[0] - tra.ge(b[i])[0]);

			b[i] = x;

			trb.upd(b[i], {vals[b[i] - 1], 1});
			ans += tra.ge(b[i])[1] * vals[b[i] - 1] + (tra.ge(MX)[0] - tra.ge(b[i])[0]);
		}

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

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

	T = 1;
	//cin >> T;
	FOR(t, T)
		solve();

	cout.flush();
	return 0;
}


// I SELL YOU...!
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MAX = 210,INF=1e15;
vector<ll> a(MAX),b(MAX);
ll joker = 0;
ll n;
vector<vector<ll>> dp(MAX,vector<ll>(MAX,-1));
ll solve(ll l,ll r){
  if(dp[l][r]!=-1) return dp[l][r];
  ll res;
  ll size = r-l+1;
    res = 0;
    vector<ll> cnt(MAX,0);
    for(int i=0;i<n;i++){
      if(a[i]==b[i]&&a[i]==-1) continue;
      if(l<=a[i]&&a[i]<=r){
        cnt[a[i]]++;
        ll idx;
        if(b[i]==-1){
          idx = min(MAX-1,a[i]+size/2);
        }else if(b[i]-a[i]==size/2){
          idx = b[i];
        }else{
          res = INF;
          break;
        }
        cnt[idx]++;
      }else if(l<=b[i]&&b[i]<=r){
        cnt[b[i]]++;
        ll idx;
        if(a[i]==-1){
          idx = max(0ll,b[i]-size/2);
        }else if(b[i]-a[i]==size/2){
          idx = a[i];
        }else{
          res = INF;
          break;
        }
        cnt[idx]++;
      }
    }
    for(int i=0;i<MAX;i++){
      if((l>i||i>r)&&cnt[i]){
        res = INF;
        break;
      }
      if(cnt[i]>=2){
        res = INF;
        break;
      }
    }
    for(int i=l;i<l+size/2;i++){
      if((cnt[i]+cnt[i+size/2])==0){
        res++;
      }
    }
    for(int i=l+2;i<r;i++){
      res = min(res,solve(l,i-1)+solve(i,r));
    }
  return dp[l][r] = res;
}
signed main(){
  init_io();
  cin >> n;
  bool can = true;
  map<ll,ll> mp;
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
    if(a[i]==b[i]&&a[i]==-1){
      joker++;
    }
    mp[a[i]]++;
    mp[b[i]]++;
    if(a[i]!=-1&&b[i]!=-1&&a[i] >= b[i]){
      can = false;
    }
  }
  for(auto [x,y]:mp){
    if(x==-1) continue;
    if(y!=1){
      can = false;
      break;
    }
  }
  if(!can){
    cout <<"No"<<endl;
    return 0;
  }
  ll v = solve(1,n*2);
  if(v<=joker){
    cout << "Yes"<<endl;
  }else{
    cout <<"No"<<endl;
  }
}

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
namespace atcoder {}
using namespace atcoder;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2> bool chmin(T1 &l, const T2 &r);
template <class T1, class T2> bool chmax(T1 &l, const T2 &r);
#define int long long int

void solve(long long N, std::vector<long long> A, std::vector<long long> B,
           std::vector<long long> C, std::vector<long long> D,
           std::vector<long long> E) {
  int up = 2e9, low = 0;
  auto check = [&](int there) {
    int dp[3001][1 << 5][4] = {};
    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
      int mask = 0;
      if (A[i] >= there)
        mask |= 1;
      if (B[i] >= there)
        mask |= 2;
      if (C[i] >= there)
        mask |= 4;
      if (D[i] >= there)
        mask |= 8;
      if (E[i] >= there)
        mask |= 16;

      for (int j = 0; j < 1 << 5; j++) {
        for (int k = 0; k < 4; k++) {
          if (k != 3)
            dp[i + 1][j | mask][k + 1] |= dp[i][j][k];
          dp[i + 1][j][k] |= dp[i][j][k];
        }
      }
    }
    return dp[N][31][3];
  };
  while (up - low > 1) {
    int mid = (up + low) / 2;
    (check(mid) ? low : up) = mid;
  }
  cout << low << endl;
}

signed main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  std::vector<long long> C(N);
  std::vector<long long> D(N);
  std::vector<long long> E(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
    scanf("%lld", &C[i]);
    scanf("%lld", &D[i]);
    scanf("%lld", &E[i]);
  }
  solve(N, std::move(A), std::move(B), std::move(C), std::move(D),
        std::move(E));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2> bool chmin(T1 &l, const T2 &r) {
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2> bool chmax(T1 &l, const T2 &r) {
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2> void vadd(vector<T1> &v, T2 x) {
  for (auto &s : v)
    s += T2(x);
}


#include <iostream>
using namespace std;
using ll=long long;
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  ll MOD=1000000000+7;
  ll N,P;cin>>N>>P;
  ll res=P-1;
  res*=modpow(P-2,N-1,MOD);

  res=res%MOD;
  cout<<res<<endl;
}

//ll __(){
//    _(int,n);
//    _(string,s);
//    _(string,t);
//    vi a,b;
//    rep(i,n){
//        if(s[i] == '1')
//            a.pb(i);
//        if(t[i] == '1')
//            b.pb(i);
//    }
//    vi erase;
//    ll ans = 0;
//    int l = 0;
//    rep(i,sz(a)){
//        if(l < sz(b) && a[i] >= b[l]){
//            ans += a[i]-b[l];
//            ++l;
//        }
//        else
//            erase.pb(a[i]);
//    }
//    if(l < sz(b) || sz(erase)%2)
//        return -1;
//    for(int i = 0; i < sz(erase); i += 2)
//        ans += abs(erase[i]-erase[i+1]);
//    return ans;
//}
//
#include <iomanip>
#include <vector>
#include <utility>
#include <iostream>
#include <string>
#define pb push_back
#define REP_ZERO_INT(i,r) for(int i = 0; i < (r); ++i)
#define GET_REP_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define rep(...) GET_REP_MACRO(__VA_ARGS__,REP_ANY,REP_INT,REP_ZERO_INT)(__VA_ARGS__)
#define all(v) (v).begin(), (v).end()
#define sz(v) ll(v.size())
#define T1 template<typename T> static
using namespace std;
typedef long long ll;
typedef vector<int> vi;
T1 ostream& operator<<(ostream& stream, const vector<T>& t);
T1 istream& read(T, T, istream& = cin);
#define INPUT_WITHOUT_INIT(type,name) type name; cin >> name
#define GET_INPUT_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define _(...) GET_INPUT_MACRO(__VA_ARGS__,_IWI,_IWI,_IWI,_IWI,_IWI,_IWI,INPUT_WITHOUT_INIT)(__VA_ARGS__)
ll __(){
    _(int,n);
    _(string,s);
    _(string,t);
    vi a,b;
    rep(i,n){
        if(s[i] == '1')
            a.pb(i);
        if(t[i] == '1')
            b.pb(i);
    }
    vi erase;
    ll ans = 0;
    int l = 0;
    rep(i,sz(a)){
        if(l < sz(b) && a[i] >= b[l]){
            ans += a[i]-b[l];
            ++l;
        }
        else
            erase.pb(a[i]);
    }
    if(l < sz(b) || sz(erase)%2)
        return -1;
    for(int i = 0; i < sz(erase); i += 2)
        ans += abs(erase[i]-erase[i+1]);
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
        cout << __() << '\n';
}


#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define rep(i,j,k) for(int i=j;i<k;i+=1)
#define rrep(i,j,k) for(int i=n-1;i>=0;i-=1)
#define sorti(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define mm map<int,int>
#define vv vector<int>
#define tmm map<int,map<int,int>>
#define trav(a, x) for(auto& a : x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define pb push_back
#define alot(x,y) memset(x,y,sizeof(x))
#define pii pair<int,int>
#define code ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int MOD=1e9+7;
const double pi=acos(-1.0);
/*memset(array_name,value_to_be_intialized,sizeof(array_name));
 __builtin_popcount(n) count no of set bit in number n
next_permutation(s.begin(),s.end());
int binpow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1)res*=a;
        a*=a;
        b>>=1;

    }
    return res;
}
// lower_bound==> if the element is present it return its first occurence else 1st element which is greater than
// upper_bound==> it will always return iterator to element which is greater than searched element
*/
int32_t main ()
{
     code;
    int tt;
    //cin>>tt;
    tt=1;
    while(tt--){
        int n;
        cin>>n;
        mm mxa;
        int a[n+1];
        int b[n+1];
        cin>>a[0];
        mxa[0]=a[0];
        for(int i=1;i<n;i++){
            cin>>a[i];
            mxa[i]=max(mxa[i-1],a[i]);
        }
        cin>>b[0];
         for(int i=1;i<n;i++){
            cin>>b[i];
        }
        cout<<a[0]*b[0]<<'\n';
        int ans=a[0]*b[0];
        for(int i=1;i<n;i++){
             int p=mxa[i]*b[i];
             ans=max(ans,p);
             cout<<ans<<"\n";
        }

        cout<<"\n";

    }
    return 0;

}

# include <bits/stdc++.h>
#include <cmath>
#include <string>
#include <vector>
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 fs(n) fixed << setprecision(n)
#define mp(i, j) make_pair(i, j);

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 = 1e5 + 10;
const int xm = - 20 + 10;
const int sq = 320;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int mod = 1e9 + 7;//998244353;
const int base = 257;

int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
 freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
int n, ans = 0;
cin >> n;
int a[n];
for(int i = 0; i < n; i++){
    cin >> a[i];
}
for(int i = 0; i < n; i++){
    if(a[i] > 10){
        ans = ans + (a[i] - 10);
    }
}
cout << ans;
}


// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで str[0]=toupper(str[0]);
// g++ hoge.cpp -std=c++17 -I . でコンパイルできる
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
//#include <atcoder/all>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define endl '\n'
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
//using namespace atcoder;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,k,x,y,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>str;
    cout<<str[1]<<str[2]<<str[0]<<endl;

    return 0;
}

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

int main()
{
    char s[4];
    cin >> s;
    // cout << s << endl;
    char temp;
    temp = s[0];
    s[0] = s[1];
    s[1] = s[2];
    s[2] = temp;
    cout << s << endl;
}


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

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

#define FastIO()            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define read()              freopen("in.txt","r",stdin)
#define write()             freopen("out.txt","w",stdout)

typedef long long           ll;
typedef unsigned long long  ull;
typedef double              dbl;
typedef float               flt;

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

typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef vector<pii>         vpii;
typedef vector<pl>          vpl;

#define pie                 acos(-1)

#define mp                  make_pair
#define pb                  push_back
#define eb                  emplace_back
#define ff                  first
#define ss                  second

#define MAX                 300005
#define MOD                 1000000007
#define INF                 1000000100

#define for0(i, n)          for(ll i=0; i<n; i++)
#define for1(i, n)          for(ll i=1; i<=n; i++)
#define forab(i, a, b)      for(ll i=a; i<=b; i++)
#define forabx(i, a, b, x)  for(ll i=a; i<=b; i+=x)
#define forinv(i, a, b)     for(ll i=a; i>=b; i--)

#define clr0(a)             memset(a, 0, sizeof(a))
#define ceil(x, y)          (x+y-1) / (y)
#define max3(a, b, c)       max(a, max(b, c))
#define min3(a, b, c)       min(a, min(b, c))
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a * b) / __gcd(a, b))
#define sort1(a, x, y)      sort(a+x, a+y+1)
#define debug(x)            cout << "DEBUG " << x << endl;

#define Y()                 cout << "YES" << endl;
#define N()                 cout << "NO" << endl;
#define inArr(a, x, y)      forab(i, x, y) { cin >> a[i]; }
#define outArr(a, x, y)     forab(i, x, y) { cout << a[i] << " "; } cout << endl;

void solve() {
    ll n;
    cin >> n;
    char a[n+10], b[n+10];
    cin >> a;
    cin >> b;
    vl a0, b0;
    ll ca=0, cb=0;
    for0(i, n) {
        if (a[i]=='0') {
            ca ++;
            a0.pb(i);
        }
        if (b[i]=='0') {
            cb++;
            b0.pb(i);
        }
    }
    ll ans = 0;
    if (ca!=cb) {
        ans = -1;
    }
    else {
        for0(i, ca) {
            if (a0[i]!=b0[i]) {
                ans ++;
            }
        }
    }
    cout << ans << endl;
}

void testcase() {
    ll t;
    cin >> t;
    while (t--) {
        solve();
    }
}

int main () {
    FastIO()

    //testcase();
    solve();

    return 0;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//turn on extra precision
//#pragma GCC target("fpmath=387")

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef string str;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
#define fbo find_by_order
#define ook order_of_key
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define watch(x) cout << (#x) << " is : " << (x) << newl

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
vi dirx = {0,0,1,-1};
vi diry = {1,-1,0,0};
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 122) return char(x-32);
    if( 65 <= int(x) && int(x) <= 90) return x;
    return -1;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 122) return x;
    if( 65 <= int(x) && int(x) <= 90) return char(x+32);
    return -1;
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57) return int(x-'0');
    if(97 <= int(x) && int(x) <= 122) return int(x-96);
    if(65 <= int(x) && int(x) <= 90) return int(x-64);
    return -1;
}
bool isect (int l1, int r1, int l2, int r2){ return max(l1,l2) <= min(r1,r2); }
ll quickpow (ll num1, ll num2, ll MOD){
    if(num2==0)return 1%MOD;
    else if(num2==1)return num1%MOD;
    else{
        ll temp = quickpow (num1,num2>>1LL,MOD); ll res = ((temp%MOD) * (temp%MOD))%MOD;
        if(num2&1) res = ((res%MOD)*(num1%MOD))%MOD; return res;
    }
}
ll invmod (ll num, ll MOD){return quickpow (num,MOD-2,MOD);}
ll gcd (ll num1, ll num2){
    if(num1 < num2) swap(num1,num2); ll num3 = num1 % num2 ;
    while(num3 > 0){ num1 = num2; num2 = num3; num3 = num1 % num2;}
    return num2;
}
ll lcm (ll num1 , ll num2){return (ll) (num1/__gcd(num1,num2))*num2;}
// end of Template

int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

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

    int a,b,c,d; cin >> a >> b >> c >> d;
    cout << b - c << newl;

    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, ans=0; cin >> N; int A[N];
REP(i, N){ cin >> A[i]; A[i]=A[i]%200; }
int M=min(8, N), R[200]={};

vector<int> X={}, Y={};
REP(i, 1<<M){
if(i==0){ continue; }
int k=i, d=0, n=0; Y={};
while(k){
  if(k%2==1){ n=(n+A[d])%200; Y.push_back(d+1); }
  k/=2; d++;
}
if(R[n]){
  cout << "Yes\n";
  int l=R[n], g=0;
  while(l){ if(l%2==1){ X.push_back(g+1); } l/=2; g++; }
  cout << X.size();
  REP(j, X.size()){ cout << " " << X[j]; }
  cout << "\n" << Y.size();
  REP(j, Y.size()){ cout << " " << Y[j]; }
  cout << "\n";
  return 0;
}else{ R[n]=i; }
}
cout << "No\n";
}

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

using namespace std;

#define ll long long int
#define ld long double
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007

ll p(ll a , ll n){
    if(n == 0){
        return 1;
    }
    ll res = p(a*a , n / 2);
    if(n % 2){
        res *= a;
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin>>n;
    ll ans = 0;
    set<ll> s;
    for(ll i = 2; i <= 2e5; i++){
        for(ll j = 2; j <= 40; j++){
            ll c = p(i , j);
            if(c > n){
                break;
            }
            s.insert(c);
        }
    }
    ans = n - (sz(s));
    cout<<ans<<"\n";
    return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD
#define MODSUB(SUB_X,SUB_Y)  ((SUB_X-SUB_Y)+MOD)%MOD
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD
#define LCM(LCM_X,LCM_Y) (LCM_X/__gcd(LCM_X,LCM_Y))*LCM_Y
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,mx=0,ans;
    cin>>n;
    for(int i=1; i<=n; i++)
        cin>>arr[i];
    for(int i=2; i<=1000; i++)
    {
        int cnt=0;
        for(int j=1; j<=n; j++)
        {
            if(arr[j]%i==0)
                cnt++;
        }
        if(cnt>mx){
            mx=cnt;
            ans=i;
        }
}
cout<<ans<<endl;

return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >>a[i];
    int max=0;
    int ans=0;
    for(int i=2;i<1000;i++){
        int cnt =0;
        for(int j=0;j<n;j++){
            if(a[j]%i == 0) cnt++;
            if(max<cnt){
                max=cnt;
                ans=i;
            }
        }

    }
    cout << ans << endl;
}


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

#define int long long
#define forn(i,a,n) for (int i=a; i<n; i++)

int n;
int a[200005],b[200005],c[200005];
int suma,sumb;

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

	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	cin>>n;
	forn(i,0,n){
		cin>>a[i]>>b[i];
		sumb+=a[i];
		c[i]=a[i]+b[i]+a[i];
	}
	sort(c,c+n);
	reverse(c,c+n);
	int cur=0;
	int sum=sumb-suma;
	while (sum>=0){
		sum-=c[cur];
		cur++;
	}
	cout<<cur<<endl;
	return 0;
}

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

void __dbg() { cout << endl; }
template<typename Arg, typename... Args> void __dbg(Arg A, Args... B) { cout << " " << A; __dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", __dbg(__VA_ARGS__)

#define rep(i,a,b) for(int i=a;i<b;i++)
#define lprin(n) printf("%lld\n", n)
#define lpri(n) printf("%lld ", n)
#define lscn(n) scanf("%lld", &n)
#define prin(n) printf("%d\n", n)
#define pri(n) printf("%d ", n)
#define scn(n) scanf("%d", &n)
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second

const int inf  = INT_MAX;
const int ninf = INT_MIN;
const int mod  = 1e9 + 7;
const int maxN = 1e6 + 2;

int main()
{
   int n;
   scn(n);

   vector<ll> a(n), b(n);
   vi order(n); iota(order.begin(), order.end(), 0);

   rep(i, 0, n) {
      lscn(a[i]); lscn(b[i]);
   }

   ll B = 0, A = accumulate(a.begin(), a.end(), 0LL);

   sort(order.begin(), order.end(), [&](const int& i, const int& j){
      return (2 * a[i] + b[i]) > (2 * a[j] + b[j]);
   });

   rep(k, 0, n) {
      int i = order[k];

      B += a[i] + b[i];
      A -= a[i];

      if(B > A) {
         prin(k + 1);
         exit(0);
      }
   }

   assert(false);

   return 0;
}


#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
int main(){
  int N;
  cin >> N;
  vector<int> W(N);
  for (int i = 0; i < N; i++){
    cin >> W[i];
  }
  int S = 0;
  for (int i = 0; i < N; i++){
    S += W[i];
  }
  if (S % 2 == 1){
    cout << 0 << endl;
  } else {
    vector<vector<long long>> dp(1, vector<long long>(S / 2 + 1, 0));
    dp[0][0] = 1;
    for (int i = 0; i < N; i++){
      vector<vector<long long>> dp2(i + 2, vector<long long>(S / 2 + 1, 0));
      for (int j = 0; j <= i; j++){
        for (int k = 0; k <= S / 2; k++){
          if (dp[j][k] > 0){
            dp2[j][k] += dp[j][k];
            dp2[j][k] %= MOD;
            if (k + W[i] <= S / 2){
              dp2[j + 1][k + W[i]] += dp[j][k];
              dp2[j + 1][k + W[i]] %= MOD;
            }
          }
        }
      }
      swap(dp, dp2);
    }
    vector<long long> cnt(N + 1, 0);
    for (int i = 0; i <= N; i++){
      cnt[i] = dp[i][S / 2];
    }
    vector<long long> fact(N + 1, 1);
    for (int i = 1; i <= N; i++){
      fact[i] = fact[i - 1] * i % MOD;
    }
    long long ans = 0;
    for (int i = 0; i <= N; i++){
      ans += fact[i] * fact[N - i] % MOD * cnt[i] % MOD;
    }
    ans %= MOD;
    cout << ans << endl;
  }
}

#include<bits/stdc++.h>
template <typename _Tp>void read(_Tp &x){
	char ch(getchar());bool f(false);while(!isdigit(ch))f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch))x=x*10+(ch&15),ch=getchar();
	if(f)x=-x;
}
template <typename _Tp,typename... Args>void read(_Tp &t,Args &...args){read(t);read(args...);}
const int N=105,mod=998244353;
template<typename _Tp1,typename _Tp2>inline void add(_Tp1 &a,_Tp2 b){(a+=b)>=mod&&(a-=mod);}
template<typename _Tp1,typename _Tp2>inline void sub(_Tp1 &a,_Tp2 b){(a-=b)<0&&(a+=mod);}
int f[N][20005],g[N][20005];
long long fac[N];
int main(){
	fac[0]=fac[1]=1;for(int i=2;i<N;++i)fac[i]=fac[i-1]*i%mod;
	int n;read(n);
	f[0][10000]=1;int s=0;
	for(int i=1,x;i<=n;++i){
		read(x),s=std::min(10000,x+s);
		memset(g,0,sizeof(g));
		for(int j=0;j<i;++j){
			for(int k=10000-s;k<=10000+s;++k){
				if(k-x>=0)add(g[j+1][k-x],f[j][k]);
				if(k+x<=20000)add(g[j][k+x],f[j][k]);
			}
		}
		memcpy(f,g,sizeof(f));
	}
	int ans=0;
	for(int i=0;i<=n;++i)add(ans,1LL*f[i][10000]*fac[i]%mod*fac[n-i]%mod);
	printf("%d\n",ans);
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <queue>
#include <string>
#include <utility>
#include <functional>
using namespace std;
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
    int N;
    cin >> N;
    for(int i=1;i<=N;i++){
        //cout << i << ":";
        cout << (i-1)/2+1 << " " << (N+i+1)/2 << endl;
    }
}

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

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

	for (int i = 0; i < n; i++) {
		cout << (2*i)%n + 1 << " " << (2*i+1)%n + 1 << endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
const ll LL_MAX=LLONG_MAX;

struct In{
    template<typename T>
    operator T(){
        T x;
        cin >> x;
        return x;
    }
};
In in;

template <typename T,typename U>
void forin(T* x,U n){
    for (U i=0;i<n;i++) cin >> x[i];
}

template <typename T>
int div1(T x) {
    return x%1000000007;
}

template <typename T>
void out(T x){
    cout << x << endl;
}

template <typename T>
T gcd(T x,T y){
    if (y == 0) return x;
    return gcd(y,x%y);
}

template <typename T>
T lcm(T x,T y){
    return x*y/gcd(x,y);
}

int main(){
    int n=in;
    string s=in;
    int at,cg,ans=0;
    for (int i=0;i<n;i++){
        at=0;
        cg=0;
        if (s[i]=='A') at++;
        else if (s[i]=='T') at--;
        else if (s[i]=='C') cg++;
        else if (s[i]=='G') cg--;
        for (int i2=i+1;i2<n;i2++){
            if (s[i2]=='A') at++;
            else if (s[i2]=='T') at--;
            else if (s[i2]=='C') cg++;
            else if (s[i2]=='G') cg--;
            if (at==0 && cg==0) ans++;
        }
    }
    out(ans);
}

#include <bits/stdc++.h>
using namespace std;
#define mp   make_pair
#define pb   push_back
#define eb   emplace_back
#define f first
#define s second
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define int  long long
#define endl "\n"
#define yn(b) cout << &("NO\n\0YES\n"[4*b]);
#define show(a) {for(auto x:a) cout << x << " "; cout << endl;}
template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
void solve(){
	int n;
	cin >> n;
	int ans = n/100;
	if(n%100!=0) ans++;
	cout << ans << endl;
}

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


#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <set>
#include <ctime>
#include <random>
#include <chrono>
#include <cassert>
#include <tuple>
#include <numeric>
#include <utility>
using namespace std;

namespace {
  using Integer = long long; //__int128;
  template<class T, class S> istream& operator >> (istream& is, pair<T,S>& p){return is >> p.first >> p.second;}
  template<class T> istream& operator >> (istream& is, vector<T>& vec){for(T& val: vec) is >> val; return is;}
  template<class T> istream& operator ,  (istream& is, T& val){ return is >> val;}
  template<class T, class S> ostream& operator << (ostream& os, const pair<T,S>& p){return os << p.first << " " << p.second;}
  template<class T> ostream& operator << (ostream& os, const vector<T>& vec){for(size_t i=0; i<vec.size(); i++) os << vec[i] << (i==vec.size()-1?"":" "); return os;}
  template<class T> ostream& operator ,  (ostream& os, const T& val){ return os << " " << val;}

  template<class H> void print(const H& head){ cout << head; }
  template<class H, class ... T> void print(const H& head, const T& ... tail){ cout << head << " "; print(tail...); }
  template<class ... T> void println(const T& ... values){ print(values...); cout << endl; }

  template<class H> void eprint(const H& head){ cerr << head; }
  template<class H, class ... T> void eprint(const H& head, const T& ... tail){ cerr << head << " "; eprint(tail...); }
  template<class ... T> void eprintln(const T& ... values){ eprint(values...); cerr << endl; }

  class range{ Integer start_, end_, step_; public: struct range_iterator{ Integer val, step_; range_iterator(Integer v, Integer step) : val(v), step_(step) {} Integer operator * (){return val;} void operator ++ (){val += step_;} bool operator != (range_iterator& x){return step_ > 0 ? val < x.val : val > x.val;} }; range(Integer len) : start_(0), end_(len), step_(1) {} range(Integer start, Integer end) : start_(start), end_(end), step_(1) {} range(Integer start, Integer end, Integer step) : start_(start), end_(end), step_(step) {} range_iterator begin(){ return range_iterator(start_, step_); } range_iterator   end(){ return range_iterator(  end_, step_); } };

  inline string operator "" _s (const char* str, size_t size){ return move(string(str)); }
  constexpr Integer my_pow(Integer x, Integer k, Integer z=1){return k==0 ? z : k==1 ? z*x : (k&1) ? my_pow(x*x,k>>1,z*x) : my_pow(x*x,k>>1,z);}
  constexpr Integer my_pow_mod(Integer x, Integer k, Integer M, Integer z=1){return k==0 ? z%M : k==1 ? z*x%M : (k&1) ? my_pow_mod(x*x%M,k>>1,M,z*x%M) : my_pow_mod(x*x%M,k>>1,M,z);}
  constexpr unsigned long long operator "" _ten (unsigned long long value){ return my_pow(10,value); }

  inline int k_bit(Integer x, int k){return (x>>k)&1;} //0-indexed

  mt19937 mt(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count());

  template<class T> string join(const vector<T>& v, const string& sep){ stringstream ss; for(size_t i=0; i<v.size(); i++){ if(i>0) ss << sep; ss << v[i]; } return ss.str(); }

  inline string operator * (string s, int k){ string ret; while(k){ if(k&1) ret += s; s += s; k >>= 1; } return ret; }
}
constexpr long long mod = 9_ten + 7;

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

  long long r = my_pow_mod(10, n, m);
  long long x = my_pow_mod(10, n, m*m);

  println((x-r) / m);

  return 0;
}

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

const int N = 100010, M = 1 << 13;
const double eps = 1e-10;

ll n, m;
//int w[N], d[N], b[N];
//double x[N], y[N];
//char s[N];

ll powMOD(ll a, ll b, ll MOD) {
	ll res = 1;
	while (b) {
		if (b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void solve() {
	sc("%lld %lld", &n, &m);
//	ll t = m, x, y;
//	x = y = 0;
//	while(t % 2 == 0) t /= 2, x ++ ;
//	while(t % 5 == 0) t /= 5, y ++ ;
//	if(x <= n && x * 2 > n && y <= n && y * 2 > n && t == 1) {
//
//	}
//	else
	    pr("%lld\n", powMOD(10, n, m * m) / m % m);
}

int main() {
//    int T;
//    sc("%d", &T);
//    while(T --)
        solve();

    return 0;
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

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

void display_2int(vector<vector<int>> vec) {
    int N = vec.size();
    for (int i=0; i<N; i++) {
        for (int j=0; j<vec.at(i).size(); j++) {
            cout << vec.at(i).at(j);
            if (j < vec.at(i).size()-1) {
                cout << " ";
            }
        }
        cout << endl;
    }
}

void display_1string(vector<string> strlist) {
    int N = strlist.size();
    for (int i=0; i<N; i++) {
        cout << strlist.at(i) << endl;
    }
}

void display_1int(vector<int> intlist) {
    int N = intlist.size();
    if (N>0){
      for (int i=0; i<N - 1; i++) {
          cout << intlist.at(i) << " ";
      }
      cout << intlist.at(N-1) << endl;
    }else{
      cout << endl;
    }
}

void display_1ll(vector<long long> lllist) {
    long long N = lllist.size();
    if (N>0){
      for (int i=0; i<N - 1; i++) {
          cout << lllist.at(i) << " ";
      }
      cout << lllist.at(N-1) << endl;
    }else{
      cout << endl;
    }
}

void display_2string(vector<vector<string>> vec) {
    int N = vec.size();
    for (int i=0; i<N; i++) {
        for (int j=0; j<vec.at(i).size(); j++) {
            cout << vec.at(i).at(j);
            if (j < vec.at(i).size()-1) {
                cout << " ";
            }
        }
        cout << endl;
    }
}

int lstmax(vector<int> lst){
  int m = lst.at(0);
  int n = lst.size();
  for (int i=0; i<n-1; i++){
    m = max(m, lst.at(i));
  }
  return m;
}

int lstmin(vector<int> lst){
  int m = lst.at(0);
  int n = lst.size();
  for (int i=0; i<n-1; i++){
    m = min(m, lst.at(i));
  }
  return m;
}

int main(){
    string a;
    cin >> a;
    cout << a.at(1) << a.at(2) << a.at(0) << endl;

}

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
LL N, fib[100];
vector<int> ans;
int vis[100];
void print() {
    LL x = 0, y = 0;
    for (int i : ans) {
        if (i == 1) x++;
        if (i == 2) y++;
        if (i == 3) x = x + y;
        if (i == 4) y = x + y;
    }
    cerr << x << endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("cpp.in", "r", stdin);
#endif
    fib[0] = fib[1] = 1;
    for (int i = 2; i < 90; i++) fib[i] = fib[i - 1] + fib[i - 2];
    cin >> N;
    for (int i = 89; ~i; i--)
        if (N >= fib[i]) N -= fib[i], vis[i] = 1;
	int lim = 0;
	for (int i = 1; i < 90; i++) if (vis[i]) lim = i;
    for (int i = lim, j = 1; ~i; i--, j++) {
        if (vis[i]) {
            if (i & 1) ans.push_back(2);
            else ans.push_back(1);
        }
        if (j & 1) ans.push_back(4);
        else ans.push_back(3);
    }
    //print();
    printf("%lu\n", ans.size());
    for (int i : ans) printf("%d\n", i);
    return 0;
}


#include<bits/stdc++.h>
#define LL long long
#define dl double
#define P pair<int,int>
#define SZ(a) ((int)a.size())
using namespace std;

const int N = 4e5 + 10;

int n,a[N],id[N];
bool cmp(const int &x,const int &y){return a[x] < a[y];}
bool c[N];

int main(){
  // freopen("in.txt","r",stdin);
  // freopen("o.txt","w",stdout);
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cin >> n;n *= 2;
  for(int i = 1;i <= n;i++)cin >> a[i],id[i] = i;
  sort(id + 1,id + n + 1,cmp);
  for(int i = 1;i <= n / 2;i++)c[id[i]] = 0;
  for(int i = n / 2 + 1;i <= n;i++)c[id[i]] = 1;
  int cnt = 0;
  for(int i = 1;i <= n;i++){
    if(c[i] == 0){
      if(cnt < 0)cout << ')';
      else cout << '(';
      cnt++;
    }
    else {
      if(cnt > 0)cout << ')';
      else cout << '(';
      cnt--;
    }
  }
  return 0;
}
/**/

#include<iostream>
#include<algorithm>
using namespace std;
int N;
pair<int,int>A[4<<17];
bool lo[4<<17];
main()
{
	cin>>N;
	for(int i=0;i<2*N;i++)
	{
		cin>>A[i].first;
		A[i].second=i;
	}
	sort(A,A+2*N);
	for(int i=0;i<N;i++)lo[A[i].second]=true;
	string ans="";
	int now=0;
	bool up;
	for(int i=0;i<2*N;i++)
	{
		if(now==0)
		{
			up=lo[i];
			ans+='(';
			now++;
		}
		else
		{
			if(up==lo[i])
			{
				ans+='(';
				now++;
			}
			else
			{
				ans+=')';
				now--;
			}
		}
	}
	cout<<ans<<endl;
}


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

/*------------------------------------------------------------------*/

#define ll long long int
#define mp make_pair
#define pb push_back
#define MOD 998244353

bool isvowel(char c)
{
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
        return true;
        return false;
}
ll isprime(ll n)
{
    ll ans=1;
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return 0;
    }
    return 1;
}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    if(b==1)
        return a%m;
    ll temp=power(a,b/2,m);
    if(b%2==0)
        return ((temp%m)*(temp%m))%m;
    else
        return ((((temp%m)*(temp%m))%m)*a%m)%m;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

void ncrinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long ncr(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll c(ll n, ll k)
{
    ll i, j;
      ll C[n + 1][k + 1];
    for (i = 0; i <= n; i++)
    {
        for (j = 0; j <= min(i, k); j++)
        {

            if (j == 0 || j == i)
                C[i][j] = 1;

            else
                C[i][j] = (C[i - 1][j - 1]%MOD +
                          C[i - 1][j]%MOD)%MOD;
        }
    }
    return C[n][k]%MOD;
}
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {

        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;

        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;

    return x;
}
ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans = (ans%MOD * i%MOD)%MOD;
    }
    return ans;
}
/*-----------------------------------------------------------------------------*/
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);

    //freopen("1.txt","rt",stdin);
    //freopen("output.txt","wwt",stdout);

    ll t;
    t=1;
    //cin>>t;
    //ll t1=0;
    ll t1=0;
    while(t--)
    {
        ll h,w,x,y;
        cin>>h>>w>>x>>y;
        x--;
        y--;
        string s[h];
        for(ll i=0;i<h;i++)
         cin>>s[i];
        ll cnt=1;
        for(ll i=x+1;i<h;i++)
        {
            if(s[i][y]=='.')
             cnt++;
            else
             break;
        }
        for(ll i=x-1;i>=0;i--)
        {
            if(s[i][y]=='.')
             cnt++;
            else
             break;
        }
        for(ll i=y+1;i<w;i++)
        {
            if(s[x][i]=='.')
             cnt++;
            else
             break;
        }
        for(ll i=y-1;i>=0;i--)
        {
            if(s[x][i]=='.')
             cnt++;
            else
             break;
        }
        cout<<cnt<<endl;
    }
}

#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w,x,y;
    char s[110][110];
    cin >> h >> w >> y >> x;
    int count = 1;
    for(int i = 1; i <= h; i++){
        for(int j = 1; j <= w;j++){
            cin >> s[i][j];//問題文の通りに入力されてる
        }
    }
    for(int i = y;i >= 1;i--){ //同じ列でy~0まで調べる
        if( s[i][x] == '.' )count++;
        else{
            break;
        }
    }
    for(int i = y;i <= h;i++){ //同じ列をy~hまで調べる
        if(s[i][x] == '.')count++;
        else{
            break;
        }
    }
    for(int i = x;i >= 1;i--){ //同じ行をx~0まで調べる
        if(s[y][i] == '.')count++;
        else{
            break;
        }
    }
    for(int i = x;i <= w;i++){
        if(s[y][i] == '.')count++;
        else{
            break;
        }
    }
    cout << count - 4 << endl;

}


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

template<typename T>
vector<pair<T, int>> prime_factor(T num) {
  vector<pair<T, int>> ret;
  for(T i=2; i*i<=num; ++i) {
    int cnt = 0;
    while(num%i == 0) {
      num /= i;
      ++cnt;
    }
    if(cnt != 0) ret.emplace_back(i, cnt);
  }
  if(num != 1) ret.emplace_back(num, 1);
  return ret;
}

// if (srt > 0), sorted by ascending order. else if (srt < 0), sorted by descending order.
template<typename T>
vector<T> divisor(vector<pair<T, int>> &pf, int srt) {
  vector<T> ret;
  ret.emplace_back(1);
  for(auto &p : pf) {
    int sz = ret.size();
    T x; int y;
    tie(x,y) = p;
    T d = 1;
    for(int i=0; i<y; ++i) {
      d *= x;
      for(int j=0; j<sz; ++j) {
        ret.emplace_back(d * ret[j]);
      }
    }
  }
  if(srt > 0) sort(ret.begin(), ret.end());
  else if(srt < 0) sort(ret.rbegin(), ret.rend());
  return ret;
}

template<typename T>
vector<T> divisor(const T &num, int srt) {
  auto pf = prime_factor(num);
  return divisor(pf, srt);
}

void solve() {
  int n; cin >> n;
  vector<int> a(n);
  for(auto &x : a) cin >> x;

  unordered_map<int, int> cnt;
  map<int, vector<int>, greater<int>> to;
  to[1] = {};

  for(auto &x : a) {
    auto pf = prime_factor(x);
    auto div = divisor(pf, 0);
    for(auto &d : div) {
      ++cnt[d];
      if(!to.count(d)) {
        for(auto &[p, c] : pf) {
          if(d % p == 0) {
            to[d].emplace_back(d / p);
          }
        }
      }
    }
  }

  unordered_set<int> ng;
  int ans = 1;
  int MIN = *min_element(begin(a), end(a));

  for(auto &[d, vec] : to) {
    if(d < MIN && !ng.count(d)) ++ans;
    for(auto &x : vec) {
      if(cnt[x] < 2 || cnt[x] == cnt[d]) {
        ng.emplace(x);
      }
    }
  }

  cout << ans << endl;
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define N 2005
#define mod 998244353
#define LL long long

int n, a_min, i, a[N], j, ans;
vector<int> vec;
unordered_set<int> Ans;
map<int,int> A, ext;

int main (void)
{
	scanf("%d",&n);
	a_min=-1;
	for (i=1; i<=n; i++) {
		scanf("%d",&a[i]);
		if (a_min==-1) a_min=a[i];
		else a_min=min(a_min,a[i]);
		vec.clear();
		for (j=1; j*j<=a[i]; j++)
			if (a[i]%j==0) {
				vec.push_back(j);
				if (j*j!=a[i]) vec.push_back(a[i]/j);
			}
		sort(vec.begin(),vec.end());
		ext.clear();
		for (j=vec.size()-1; j>=0; j--) {
			if (ext.count(A[vec[j]])) continue;
			ext[A[vec[j]]]=1;
			Ans.insert(vec[j]);
		}
		for (j=0; j<vec.size(); j++) A[vec[j]]=((LL)A[vec[j]]*n+i)%mod;
	}
	ans=0;
	for (auto x:Ans) if (x<=a_min) ans++;
	printf("%d\n",ans);
	return 0;
}


#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(n) for( int i = 0 ; i < n ; i++ )
#define REP(n) for( int i = 1 ; i <= n ; i++ )
#define repll(n) for( ll i = 0 ; i < n ; i++ )
#define REPll(n) for( ll i = 1 ; i <= n ; i++ )
#define rep2(n) for( int j = 0 ; j < n ; j++ )
#define REP2(n) for( int j = 1 ; j <= n ; j++ )
#define repll2(n) for( ll j = 0 ; j < n ; j++ )
#define REPll2(n) for( ll j = 1 ; j <= n ; j++ )

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , w;
    cin >> n >> w;
    cout << n / w;
}

#include <stdio.h>

int main(void)
{
  int n, w, i;
  int count = 0;

  scanf("%d %d", &n, &w);
  for (i = n - w; i >= 0; i -= w)
    count++;
  printf("%d\n", count);
  return 0;
}


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

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

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

constexpr int MAX = 30;
ll dp[MAX + 1][MAX + 1];

string find(int A, int B, ll K) {
    if (A == 0) return string(B, 'b');
    if (B == 0) return string(A, 'a');
    if (K <= dp[A - 1][B]) {
        return string("a") + find(A - 1, B, K);
    } else {
        return string("b") + find(A, B - 1, K - dp[A - 1][B]);
    }
}

int main() {
    int A, B;
    ll K;
    cin >> A >> B >> K;

    dp[0][0] = 1;
    for (int i = 0; i <= A; i++) {
        for (int j = 0; j <= B; j++) {
            if (i > 0) dp[i][j] += dp[i - 1][j];
            if (j > 0) dp[i][j] += dp[i][j - 1];
        }
    }

    cout << find(A, B, K) << endl;
}

/**
*    author: Dooloper
*    created: 22.05.2021 20:55:00
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repp(i,k, n) for(int i = (int)(k); i < (int)(n); i++)
#define ALL(a)  (a).begin(),(a).end()
using ll = long long;
using P = pair<int, int>;
struct Edge{int to; ll w; Edge(int to, ll w) : to(to), w(w) {}};
using Graph = vector<vector<Edge>>;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

ll comb(int a, int b){
    ll ans = 1;
    ll key = a + b;
    rep(i,a){
        ans *= key;
        ans /= (i+1);
        key--;
    }
    return ans;
}

int main(){
    ll a,b,k; cin >> a >> b >> k;
    string ans;
    int n = a+b;
    rep(i,n){
        if(comb(a-1,b) < k){
            ans.push_back('b');
            k -= comb(a-1,b);
            b--;
            if(b == 0){
                rep(j,a) ans.push_back('a');
                break;
            }
        }
        else{
            ans.push_back('a');
            //k -= comb(a-1,b);
            a--;
            if(a == 0){
                rep(j,b) ans.push_back('b');
                break;
            }
        }
    }
    cout << ans << endl;
    //cout << comb(30,30) << endl;
}


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

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

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

#include <iomanip>
#include <cmath>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    ll x1 = 0, x2 = 0, xinf = 0;
    REP(i, 0, n) {
        ll a;
        cin, a;
        x1 += abs(a);
        x2 += a * a;
        chmax(xinf, abs(a));
    }
    print(x1);
    cout << fixed << setprecision(15) << sqrt(x2) << endl;
    print(xinf);
    return 0;
}

#include<iostream>
using namespace std;
int main(){
	int n,index;
	cin>>n;
	for(int i=1;;i++){
		if((i*(i+1))/2 >= n)
		{index=i;
		break;
		}

	}
	cout<<index<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll  long long
#define pb push_back
#define vec vector<ll>
#define pii pair<ll,ll>
#define pr_que priority_queue<pii,vector<pii>,greater<pii> >
#define itr(i,x,y) for(ll i=x;i<y;i++)
#define mod 1000000007
const long long N=200001,INF=1000000000000000000;
const double err=1e-9;
int main()
{
	IOS;
	ll n,ans=0,k=1;
	cin >> n;
	itr(i,1,6)
	{
		k*=1000;
		if(n>=k) ans+=n-k+1;
	}

	cout <<ans;
	return 0;
}


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

ll solve_sub(ll N, vector<ll>& V) {
    priority_queue<pii> q;
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        int i2 = 2*N-1-i;
        q.push(pii(V[i],i));
        q.push(pii(V[i2],i2));
        ans += q.top().first;
        q.pop();
    }
    return ans;
}

ll solve_sub_0(ll N, vector<ll>& V) {
    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        int i1 = N-1-i, i2 = N+i;
        ans += max(V[i1],V[i2]);
    }
    return ans;
}

ll solve() {
    ll N;
    cin >> N;
    vector<ll> V(2*N);
    for ( int i = 0; i < 2*N; i++ ) cin >> V[i];
    ll ans = solve_sub(N, V);
    return ans;
}

auto solve_small_1(ll N, vector<ll>& V) {
    ll ans = 0;
    vector<ll> ans_v;
    vector<ll> used(2*N);
    auto dfs = [&](auto self, int d, ll s) -> void {
        if ( d == N ) {
            ans = max(ans, s);
            return;
        }
        int h0, h1, c = 0;
        for ( int i = 0; i < 2*N; i++ ) {
            if ( used[i] == 0 ) {
                c++;
                if ( c <= N-d ) {
                    h0 = i;
                } else {
                    h1 = i;
                    break;
                }
            }
        }
        for ( int i = 0; i < 2*N; i++ ) {
            if ( used[i] > 0 ) continue;
            int i1 = i;
            int i2 = i < h1 ? h1 : h0;
            used[i1] = 1;
            used[i2] = 1;
            ans_v.push_back(i1);
            self(self, d+1, s+V[i1]);
            ans_v.pop_back();
            used[i1] = 0;
            used[i2] = 0;
        }
    };
    dfs(dfs,0,0LL);
    return ans;
}
struct Data {
    int id;
    ll N;
    vector<ll> V;
};
void test() {
    mt19937_64 mt64(0);
    uniform_int_distribution<ll> rnd_n(3, 4);
    uniform_int_distribution<ll> rnd_v(0, 9);

    int id = 0;
    vector<Data> ts;
    ts.push_back({++id,4,{3,2,8,6,7,6,1,6}});
    ts.push_back({++id,3,{1,2,3,4,5,6}});
    ts.push_back({++id,4,{1,4,5,8,7,6,3,2}});
    for ( int i = 0; i < 100; i++ ) {
        int n = rnd_n(mt64);
        vector<ll> a;
        for ( int j = 0; j < 2*n; j++ ) {
            a.push_back(rnd_v(mt64));
        }
        ts.push_back({++id,n,a});
    }

    for ( Data& t : ts ) {
        auto ans0 = solve_sub(t.N,t.V);
        auto ans1 = solve_small_1(t.N,t.V);
        if ( ans0 != ans1 ) {
            cout << t.id << " " << ans0 << " " << ans1 << "\n";
        }
    }
    cout << "end" << "\n";
}

int main() {
    // test();

    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  vector<lint> V1(N), V2(N);
  IREP(i, N) cin >> V1[i];
  REP(i, N) cin >> V2[i];
  multiset<lint> st;
  REP(i, N) {
    if(st.size() > 0 && *st.begin() < min(V1[i], V2[i])) {
      st.erase(st.begin());
      st.insert(V1[i]);
      st.insert(V2[i]);
    } else {
      st.insert(max(V1[i], V2[i]));
    }
  }
  lint ans = 0;
  for(lint x : st) ans += x;
  cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using ll = long long;
const int INF = 1001001001;
const ll LINF = 1002003004005006007ll;

void solve(){
  int si,sj;
  cin >> si >> sj;
  vector<vector<int> > t(50,vector<int>(50)),p(50,vector<int>(50));
  rep(i,50)rep(j,50)cin >> t[i][j];
  rep(i,50)rep(j,50)cin >> p[i][j];
  set<int> sumi;
  sumi.insert(t[si][sj]);

  while(1){
    if(sj+1<50&&!sumi.count(t[si][sj+1])){
      cout << 'R';
      sj++;
      sumi.insert(t[si][sj]);
      continue;
    }
    else if(si+1<50&&!sumi.count(t[si+1][sj])){
      cout << 'D';
      si++;
      sumi.insert(t[si][sj]);
      continue;
    }
     else if(si-1>=0&&!sumi.count(t[si-1][sj])){
      cout << 'U';
      si--;
      sumi.insert(t[si][sj]);
      continue;
    }
    else if(sj-1>=0&&!sumi.count(t[si][sj-1])){
      cout << 'L';
      sj--;
      sumi.insert(t[si][sj]);
      continue;
    }
    break;
  }
  cout << endl;
}

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

  solve();
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

int main(){
	int si, sj; cin >> si >> sj;
    int t[50][50];
    int p[50][50];
    for(int i = 0; i < 50; i++) {
        for(int j = 0; j < 50; j++) {
            cin >> t[i][j];
        }
    }

    for(int i = 0; i < 50; i++) {
        for(int j = 0; j < 50; j++) {
            cin >> p[i][j];
        }
    }
    int vis[50][50]; memset(vis, 0, sizeof vis);
    int dx[4] = {-1,0,1,0};
    int dy[4] = {0, -1, 0, 1};
    string dir = "ULDR";
    int curx = si;
    int cury = sj;
    vis[si][sj] = 1;
    string ans = "";
    set<int> s;
    s.insert(t[si][sj]);
    while(true) {

        vector<pair<int, int> > vec;
        for(int i = 0; i < 4; i++) {
            int x = curx + dx[i];
            int y = cury + dy[i];
            if(x < 0 or y < 0 or x >= 50 or y >= 50 ) {
                continue;
            }
            if(t[x][y] == t[curx][cury]) continue;
            if(s.count(t[x][y]) > 0) continue;
            vec.push_back(make_pair(p[x][y], i));
        }
        if(vec.size() == 0) break;

        std::random_shuffle(vec.begin(), vec.end());

        int i = vec[0].second;
        curx += dx[i];
        cury += dy[i];
        ans += dir[i];
        vis[curx][cury] = 1;
        s.insert(t[curx][cury]);

    }
    cout << ans << endl;

	return 0;
}


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

int main() {

	unsigned long long n;
  int a,b;
  cin >> n;
  bool torf=false;
  for(unsigned long long i=0;i<37;i++){
    for(unsigned long long j=0;j<25;j++){
      //for(k,i)
      unsigned long long c=1;//=pow(5,j+1);
      unsigned long long d=1;//pow(3,i+1);
      //cout << pow(5,j+1) << endl;
      rep(k,i+1)
        c*=3;
      rep(l,j+1)
        d*=5;

      //cout << d << endl;
      unsigned long long temp=c+d;
      if(temp==n){
        torf=true;
        a=i+1;
        b=j+1;
      }
    }
  }
  if(torf==false)
 	 cout << -1 << endl;
  else
    cout << a << ' ' << b << endl;
}

#include <bits/stdc++.h>
using namespace std;
int64_t I=2e18;
int main() {
	int64_t N;
	cin>>N;
	vector<int64_t> p={1};
	vector<int64_t> q={1};
	int A=0,B=0;
	while(I/3>=p[A]){
		p.push_back(p[A]*3);
		A++;
	}
	while(I/5>=q[B]){
		q.push_back(q[B]*5);
		B++;
	}
	for(int i=1;i<A;i++){
		for(int j=1;j<B;j++){
			if(p[i]+q[j]==N){
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}
	cout<<"-1"<<endl;
}


// Author: Pawan Raj
// Problem: B - Round Down
// Contest: AtCoder - AtCoder Beginner Contest 196
// URL: https://atcoder.jp/contests/abc196/tasks/abc196_b

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define int long long
#define F(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end()
#define show(A) for (auto i: A) cout << i << " "; cout << '\n';
#define show_(A, n) F(i, n) { show(A[i]) }

using namespace std;
using ld = long double;
using vi = vector < int > ;
using mi = map < int, int > ;
using pi = pair < int, int > ;

const int N = 100005;
const int MOD = 1e9 + 7;
const int inf = 1e18 + 1;
/***************************code begins here*****************************/

void solve() {
	string s;
	cin >> s;
	if(count (all(s),'.') == 0){
		cout << s << '\n';
	}
	else{
		string t;
		bool ok = 1;
		for(char x : s ){
			if(x=='.'){
				ok = 0;
				break;
			}
			if(ok){
				t.pb(x);
			}
		}
		cout << t << '\n';
	}
}

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

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

    return 0;
}

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

int main(){
  string x; cin >> x;
  string ans;
  for(char c : x) {
    if(c == '.') break;
    ans += c;
  }
  cout << ans << endl;
  return 0;
}