#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
vector<int>freq(10);
int len=3;
bool possible=false;
void recur(int pos,vector<int>&cnt,int num) {
    if(pos==len) {
        if(num%8==0) possible=true;
        return;
    }
    for(int i=1;i<=9;i++) {
        if(freq[i]==0 or cnt[i]==freq[i]) continue;
        cnt[i]++;
        recur(pos+1,cnt,num*10+i);
        cnt[i]--;
    }
}
int main(int argc, char const *argv[]) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    string s; cin>>s;
    int n=s.size();
    len=min(len,n);
    for(auto x:s)  freq[x-'0']++;
    vector<int>cnt(10);
    recur(0,cnt,0);
    cout<<(possible?"Yes":"No")<<endl;
}

//Hachi

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end()
#define nnn "\n"
#define spa " "
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    string s;cin>>s;
    string g=s;
    reverse(range(g));
    vector<int>t(10,0);
    rep(i,0,s.size())t[s[i]-'0']++;
    if(s.size()<3)t[0]+=3-s.size();
    rep(i,0,125){
        int f=i*8;
        string d=to_string(f);
        vector<int>r(10,0);
        if(d.size()<3)r[0]+=3-d.size();
        for(auto e:d)r[e-'0']++;
        bool flag=true;
        rep(j,0,10){
            if(r[j]>t[j])flag=false;
        }
        if(s.size()<3)if(r[0]>0&&(stoi(s)%8!=0)&&(stoi(g)%8!=0))flag=false;
        if(flag){
            cout<<"Yes"<<nnn;
            return 0;
        }
    }
    cout<<"No"<<nnn;
    return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename T>bool chmin(T& x,const T&y) {if(x>y){x=y;return true;} else return false;}
template<typename T>bool chmax(T& x,const T&y) {if(x<y){x=y;return true;} else return false;}

int main() {
    int A, B, X, Y;
    cin >> A >> B >> X >> Y;
    int ans = X + abs(A - B) * Y;
    if (A > B) {
        int temp = ((A-B) + (A-B-1)) * X;
        chmin(ans, temp);
        temp = X + abs(A - 1 - B) * Y;
        chmin(ans, temp);
    } else if (A < B) {
        int temp = ((B-A) + (B-A+1)) * X;
        chmin(ans, temp);
    }
    cout << ans << '\n';
    return 0;
    // Pとpii, 重複, 境界, ll, 0, -, 1i, for s&g, debug
}

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

using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

int main(){
	ll n,k; cin>>n>>k;
	k = abs(k);
	ll ans = 0;
	for (ll i=2; i<=(2*n-k); i++){
		ans += (n - abs(i-n-1)) * (n - abs(i+k-n-1));
	}
	cout << ans << endl;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007; // 998244353;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const ld PI = acos((ld)-1);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template <typename T> V<T> prefix_sum(const V<T>& v) {
  int n = v.size();
  V<T> ret(n + 1);
  rep(i, 0, n) ret[i + 1] = ret[i] + v[i];
  return ret;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(auto&& x: vec) is >> x;
  return is;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

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

template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}

signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  V<ll> v(4);cin>>v;
  sort(all(v));

  if(v[0]+v[1]+v[2]==v[3] || v[0]+v[3]==v[1]+v[2]){
    cout<<"Yes"<<ENDL;
  }else{
    cout<<"No"<<ENDL;
  }
}
//! ( . _ . ) !
//CHECK overflow,vector_size,what to output?

#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

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

int main(){
    ll a[4];
    rep(i,4)cin >> a[i];
    ll sm = 0;
    rep(i,4){
        sm += a[i];
    }
    if(sm%2!=0){
        cout << "No" << endl;
        return 0;
    }
    rep(bits,1<<4){
        ll tmp = 0;
        rep(i,4){
            if((bits>>i)&1){
                tmp += a[i];
            }
        }
        if(tmp==sm/2){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long i64;
typedef unsigned long long ui64;
typedef vector<i64> vi;
typedef vector<vi> vvi;
typedef pair<i64, i64> pi;

#define pb push_back
#define sz(a) i64((a).size())
#define all(c) (c).begin(), (c).end()
#define REP(s, e, i) for(i=(s); i < (e); ++i)
inline void RI(i64 &i) {scanf("%lld", &(i));}
inline void RVI(vi &v) { for(i64 i=0;i<sz(v);++i) { RI(v[i]); } }
inline void RVVI(vvi &vv) { for(i64 i=0;i<sz(vv);++i) { RVI(vv[i]); } }
#define BUF_LENGTH 1000000
inline void RS(string &s) {static char buf[BUF_LENGTH]; scanf("%s", buf); s = buf;}

int main(int argc, char *argv[]) {
  i64 S, P;
  cin >> S >> P;
  i64 N = 1;
  while(N * N <= P) {
    if(P % N == 0) {
      i64 M = P / N;
      if(N + M == S) {
        cout << "Yes" << endl;
        return 0;
      }
    }
    ++N;
  }
  cout << "No" << endl;

  return 0;
}

#include <stdio.h>

constexpr unsigned char H[16] = {0, 1, 0, 3, 1, 1, 1, 1, 0, 1, 2, 2, 3, 1, 2, 3};

int main() {
  unsigned char n, k;
  scanf("%hhd %hhd", &n, &k);
  getchar_unlocked();
  unsigned char h[101], h2[101];
  for (unsigned char i = 0; i < n; i++) h[i] = getchar_unlocked() - 80;
  for (unsigned char i = 0; i < k; i++) {
    unsigned char *cur = (i & 1) ? h2 : h, *nxt = (i & 1) ? h : h2;
    for (unsigned char j = 0; j < n; j++) {
      nxt[j] = H[(cur[(j * 2) % n] * 4) + cur[((j * 2) + 1) % n]];
    }
  }
  putchar_unlocked(((k & 1) ? (*h2) : (*h)) + 80);
}


#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define debug(output) cout<<#output<<"= "<<output<<endl
using lint = long long;
typedef pair<int,int> P;
const lint linf=1e18+7;
const lint inf=1e9+7;
const int MOD=1000000007;
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
signed main(){
  int n;cin>>n;
  string s;cin>>s;
  string x;cin>>x;
  vector<int> a(n);
  rep(i,n)a[i]=s[i]-'0';
  int m=7;
  int rev=modinv(10,7);
  reverse(s.begin(),s.end());
  reverse(x.begin(),x.end());
  reverse(a.begin(),a.end());
  vector<int> dp(m,0);
  dp[0]=1;
  rep(i,n){
    vector<int> nxt(m,0);
    if(x[i]=='T'){
      rep(j,m){
        if(dp[j]){
          nxt[(j*rev+m*2-a[i])%m]+=dp[j];
          nxt[(j*rev)%m]+=dp[j];
        }
      }
    }
    else{
      rep(j,m){
        if(dp[j]==0){
          nxt[(j*rev+m*2-a[i])%m]+=1;
          nxt[(j*rev)%m]+=1;
        }
      }
      rep(j,m){
        if(nxt[j]>0)nxt[j]=0;
        else nxt[j]=1;
      }
    }
    swap(dp,nxt);
    rep(j,m)dp[j]=min(dp[j],1);
  }
  if(dp[0]>0){
    cout<<"Takahashi"<<endl;
  }
  else{
    cout<<"Aoki"<<endl;
  }
  return 0;
}


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

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

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

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

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int mod = 1e9+7;
int sum(int a, int b){return (a+b) % mod;}
int sub(int a, int b){return (a + mod - b) % mod;}
int mul(int a, int b){return (1ll * a * b) % mod;}
int power(int a,int b){
	int res = 1;
	while(b){
		if(b&1)res = mul(res,a);
		b >>= 1;
		a = mul(a,a);
	}
	return res;
}

const int maxn = 2e5+10;
int N,enCamino[maxn],res[maxn];
vi graph[maxn];

void dfs(int u,int p,int d,int &maxi,int &p1){
	if(d > maxi){
		maxi = d;
		p1 = u;
	}
	for(auto &v : graph[u]){
		if(v == p)continue;
		dfs(v,u,d+1,maxi,p1);
	}
}
int buscaCamino(int u,int p,int fin,vi &path){
	if(u == fin){
		path.pb(u);
		return 1;
	}
	for(auto &v : graph[u]){
		if(v == p)continue;
		if(buscaCamino(v,u,fin,path)){
			path.pb(u);
			return 1;
		}
	}
	return 0;

}
void dfs2(int u,int p,int &idx){
	res[u] = idx++;
	for(auto &v : graph[u]){
		if(enCamino[v])continue;
		if(v == p)continue;
		dfs2(v,u,idx);
	}
	idx++;

}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> N;
	forn(i,0,N-1){
		int u,v; cin >> u >> v; u--; v--;
		graph[u].pb(v);
		graph[v].pb(u);
	}
	int p1 = -1,lenDiameter = -1,p2 = -1;
	dfs(0,0,0,lenDiameter,p1);
	lenDiameter = -1;
	dfs(p1,p1,0,lenDiameter,p2);
	debug(p1+1,p2+1);
	vi camino;
	buscaCamino(p1,p1,p2,camino);
	reverse(all(camino));

	for(auto &u : camino)enCamino[u] = 1;

	int idx = 1;
	for(auto &u : camino){
		res[u] = idx++;
		for(auto &v : graph[u]){
			if(enCamino[v])continue;
			dfs2(v,v,idx);
		}

	}
	debug(camino);

	forn(i,0,N)cout << res[i] << ' ';
	cout << '\n';
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/

#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define WT int T=read();while(T--)
#define NO puts("NO");
#define YES puts("YES");
using namespace std;

inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}

const int M=2e5+10;
int n,a[M],p[M],dis[M][2],f[M],vis[M],s,t,cnt;
int de[M],ff[M][25];
vector<int>e[M];

void dfs1(int u,int fa,int tt)
{
	f[u]=fa;
	for (int i=0;i<e[u].size();i++)
	{
		int to=e[u][i];if (to==fa)continue;
		dis[to][tt]=dis[u][tt]+1,dfs1(to,u,tt);
	}
}

void dfs2(int u,int fa)
{
	p[++cnt]=u;
	for (int i=0;i<e[u].size();i++)
	{
		int to=e[u][i];if (to==fa||vis[to])continue;
		dfs2(to,u);
	}
	for (int i=0;i<e[u].size();i++)
	{
		int to=e[u][i];if (to==fa||(!vis[to]))continue;
		dfs2(to,u);
	}
}

void dp()
{
	for (int j=1;j<=20;j++)
		for (int i=1;i<=n;i++)
			ff[i][j]=ff[ff[i][j-1]][j-1];
}

int LCA(int x,int y)
{
	if (de[x]<de[y])swap(x,y);
	for (int i=20;i>=0;i--)
		if (de[ff[x][i]]>=de[y])x=ff[x][i];
	if (x==y)return x;
	for (int i=20;i>=0;i--)
		if (ff[x][i]!=ff[y][i])
			x=ff[x][i],y=ff[y][i];
	return ff[x][0];
}

int gdis(int u,int v)
{
	return de[u]+de[v]-2*de[LCA(u,v)];
}

void dfs3(int u,int fa)
{
	ff[u][0]=fa;de[u]=de[fa]+1;
	for (int i=0;i<e[u].size();i++)
		if (e[u][i]!=fa)
			dfs3(e[u][i],u);
}

signed main()
{
	n=read();
	for (int i=1;i<n;i++)
	{
		int u=read(),v=read();
		e[u].pb(v),e[v].pb(u);
	}dfs1(1,0,0);
	for (int i=1;i<=n;i++)
		if (dis[i][0]>dis[s][0])s=i;
	dfs1(s,0,1);
	for (int i=1;i<=n;i++)
		if (dis[i][1]>dis[t][1])t=i;
	int l=t;while(l!=s)vis[l]=1,l=f[l];
	dfs2(s,0);dfs3(s,0);dp();a[s]=1;
	for (int i=2;i<=n;i++)
		a[p[i]]=a[p[i-1]]+gdis(p[i],p[i-1]);
	for (int i=1;i<=n;i++)
		cout<<a[i]<<' ';
	return 0;
}
/*

*/


//**He who has a why can survive almost any how***

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

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

int main(){
	ll n,ans=0;
	cin>>n;
	ll a[n+5],fr[200]={0};
	forn(i,n) cin>>a[i];

	forn(i,n){
		ll cur=a[i]%200;
		ans+=fr[cur];
		fr[cur]++;
	}
	cout<<ans;
}

#include <bits/stdc++.h>

using namespace std;

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

typedef long long ll;

void solve() {
  int n; cin >> n;
  vector<int> cnt(200);
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int v; cin >> v;
    ans += cnt[v % 200];
    cnt[v % 200]++;
  }
  cout << ans << "\n";
}

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


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

typedef long long ll;

#define F0R(i, x, y) for (int i = x; i < y; i++)
#define FOR(i, n) F0R(i, 0, n)
#define F0RD(i, x, y) for (int i = y - 1; i >= x; i--)
#define FORD(i, n) F0RD(i, 0, n)

#define F first
#define S second

namespace output {
  void pr(int x) {
    cout << x;
  }
  void pr(long x) {
    cout << x;
  }
  void pr(ll x) {
    cout << x;
  }
  void pr(unsigned x) {
    cout << x;
  }
  void pr(unsigned long x) {
    cout << x;
  }
  void pr(unsigned long long x) {
    cout << x;
  }
  void pr(float x) {
    cout << x;
  }
  void pr(double x) {
    cout << x;
  }
  void pr(long double x) {
    cout << x;
  }
  void pr(char x) {
    cout << x;
  }
  void pr(const char * x) {
    cout << x;
  }
  void pr(const string & x) {
    cout << x;
  }
  void pr(bool x) {
    pr(x ? "true" : "false");
  }

  template < class T1, class T2 > void pr(const pair < T1, T2 > & x);
  template < class T > void pr(const T & x);

  template < class T, class...Ts > void pr(const T & t,
    const Ts & ...ts) {
    pr(t);
    pr(ts...);
  }
  template < class T1, class T2 > void pr(const pair < T1, T2 > & x) {
    pr("{", x.F, ", ", x.S, "}");
  }
  template < class T > void pr(const T & x) {
    pr("{"); // const iterator needed for vector<bool>
    bool fst = 1;
    for (const auto & a: x) pr(!fst ? ", " : "", a), fst = 0;
    pr("}");
  }

  void ps() {
    pr("\n");
  } // print w/ spaces
  template < class T, class...Ts > void ps(const T & t,
    const Ts & ...ts) {
    pr(t);
    if (sizeof...(ts)) pr(" ");
    ps(ts...);
  }

  void pc() {
    cout << "]" << endl;
  } // debug w/ commas
  template < class T, class...Ts > void pc(const T & t,
    const Ts & ...ts) {
    pr(t);
    if (sizeof...(ts)) pr(", ");
    pc(ts...);
  }
  #define dbg(x...) pr("[", #x, "] = ["), pc(x);
}

#ifdef mikey
using namespace output;
#else
using namespace output;
#define dbg(x...)
#endif

const int MX = 100005;

vector<int> adj[MX];
int dp[MX], sub[MX];

void dfs(int v, int p) {
    sub[v] = 1;
    dp[v] = 1;
    vector<int> child;
    int bad = 0;
    for (int to : adj[v]) {
        if (to != p) {
            dfs(to, v);
            sub[v] += sub[to];
            if (sub[to] % 2 == 0 && dp[to] < 0) {
                dp[v] += dp[to];
            } else if (sub[to] % 2 == 1) {
                child.push_back(dp[to]);
            } else {
                bad += dp[to];
            }
        }
    }
    sort(child.begin(), child.end());
    FOR(i, child.size()) {
        if (i % 2 == 0) dp[v] += child[i];
        else dp[v] -= child[i];
    }
    if (child.size() % 2) {
        dp[v] -= bad;
    } else {
        dp[v] += bad;
    }
}

int main() {
#ifdef mikey
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    FOR(i, n - 1) {
        int p; cin >> p;
        adj[i + 1].push_back(p - 1);
        adj[p - 1].push_back(i + 1);
    }

    dfs(0, -1);
    cout << (n + dp[0]) / 2 << '\n';
}

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

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<pair<long double, int> , null_type,less<pair<long double, int> >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

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

const int inf = int(1e9);
const ll INF = ll(1e16);
const int mod = inf + 7;
const int N = 3e5 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}
template<typename T_vector> // neal
void output_vector(const T_vector &v, bool add_one = false, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = int(v.size());

    for (int i = start; i < end; i++)
        cout << v[i] + (add_one ? 1 : 0) << (i < end - 1 ? ' ' : '\n');
}

int ok[200200];
void solve(){
    int n;
    cin >> n;
    int j = 0;
    for(int i = 1; i <= n; ++i){
        int x;
        cin >> x;
        ok[x] = 1;
        while(ok[j]) j++;
        cout << j << '\n';

    }
}

int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}


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

struct S {
    ll p, a, b;

    bool operator<(const S &rhs) const {
        return a < rhs.a;
    }
};

struct T {
    ll a, b, c, d, e, f;

    T() : a(1), b(0), c(0), d(1), e(0), f(0) {
    }

    ll get_x(ll x, ll y) const {
        return a * x + b * y + e;
    }

    ll get_y(ll x, ll y) const {
        return c * x + d * y + f;
    }

    void query(ll p, ll q) {
        T t = *this;
        if (p == 1) {
            swap(a, c);
            swap(b, d);
            swap(e, f);
            c *= -1;
            d *= -1;
            f *= -1;
        } else if (p == 2) {
            a = -t.c;
            b = -t.d;
            e = -t.f;
            c = t.a;
            d = t.b;
            f = t.e;
        } else if (p == 3) {
            a *= -1;
            b *= -1;
            e *= -1;
            e += q * 2;
        } else {
            c *= -1;
            d *= -1;
            f *= -1;
            f += q * 2;
        }
    }
};

struct A {
    ll x, y;

    void action(const T &rhs) {
        ll tx = x, ty = y;
        x = rhs.get_x(tx, ty);
        y = rhs.get_y(tx, ty);
    }
};

int main(void) {
    ll n;
    cin >> n;
    Vec x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];

    ll m;
    cin >> m;
    Vec op(m), p(m);
    rep(i, m) {
        cin >> op[i];
        if (op[i] >= 3)
            cin >> p[i];
    }

    ll q;
    cin >> q;
    Vec a(q), b(q);
    rep(i, q) cin >> a[i] >> b[i];
    vector<S> s(q);
    rep(i, q) s[i] = S{i, a[i], b[i]};
    sort(all(s));

    vector<A> ans(q);
    rep(i, q) ans[i] = A{x[b[i] - 1], y[b[i] - 1]};

    ll c = 0;
    T t;
    rep(i, m + 1) {
        while (c < q && s[c].a == i) {
            ans[s[c++].p].action(t);
        }

        if (i == m)
            break;
        t.query(op[i], p[i]);
        // ce(t.a, t.b, t.c, t.d, t.e, t.f);
    }

    rep(i, q) co(ans[i].x, ans[i].y);

    return 0;
}

#include <iostream>
#include<algorithm>
using namespace std;
int a[200005];
int main() {
    int n;
    scanf("%d",&n);
    for (int i=1; i<=n; i++) {
        scanf("%d",&a[i]);
    }
    sort(a+1, a+n+1);
    long long sum=0;
    for (int i=1; i<=n-1; i++) {
        sum+=(a[i+1]-a[i])*(long long)(n-i)*(long long)i;
    }
    printf("%lld",sum);
}


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

template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
#define CLR(a) memset((a), 0 ,sizeof(a))
//constant
//--------------------------------------------
//clear memory

int main(){
    int X;
    cin>>X;
    cout<<100-X%100<<endl;
    return 0;
}

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

#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define count_setbits __builtin_popcountll
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.1415926535897932384626
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

typedef vector<int>     vi;
typedef vector<ll>      vl;

const ll mod = 1'000'000'007;
//const ll mod= 998244353;

const int N = 5e5 + 20;
vi adj[N];
int sieve[N+1];
bool vis[N];
ll fac[N];
map<ll,ll> factor;
int dx[4] = {0, 1, 0, -1};
int dy[4]={1, 0, -1, 0};

const int maxn = 1e6+10;
const ll INF = 1e18;

void solve(){
   string s;
   cin >> s;
   reverse(s.begin(), s.end());
   for(int i=0; i<(s.size()); i++){
    if(s[i]=='6') s[i]='9';
    else if(s[i]=='9') s[i]='6';
   }

   cout<<s<<endl;
}

int main() {

    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif

    fast;
    /*clr(sieve);
    sieve[1]=1;
    for(int x=2;x<=1010;x++)
    {
        if(sieve[x]) continue;
        for(int u=2*x;u<=1010;u+=x)
        {
            sieve[u]=x;
        }
    }*/
    /*
    fac[0]=1;
    fac[1]=1;
    Fo(i,2,3e5)
    {
        fac[i]=((fac[i-1]%mod)*i)%mod;
    }
    */

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


/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Too Heavy
 */

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

using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef pair<int,int> pii;

/* global variables */

pii ais[MAX_N], sws[MAX_N];
int as[MAX_N], bs[MAX_N], ps[MAX_N], qs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d", as + i);
    ais[i] = pii(as[i], i);
  }
  sort(ais, ais + n);

  for (int i = 0; i < n; i++) scanf("%d", bs + i);
  for (int i = 0; i < n; i++)
    scanf("%d", ps + i), ps[i]--, qs[ps[i]] = i;

  int cnt = 0;
  for (int i = 0; i < n; i++) {
    //for (int j = 0; j < n; j++) printf("%d ", ps[j]); putchar('\n');
    //for (int j = 0; j < n; j++) printf("%d ", qs[j]); putchar('\n');

    int j = ais[i].second, k = qs[j];
    if (j != k) {
      if (as[j] <= bs[ps[j]] || as[k] <= bs[j]) {
	cnt = -1;
	break;
      }

      sws[cnt++] = pii(j, k);
      swap(qs[j], qs[ps[j]]);
      swap(ps[j], ps[k]);
    }
  }

  printf("%d\n", cnt);
  for (int i = 0; i < cnt; i++)
    printf("%d %d\n", sws[i].first + 1, sws[i].second + 1);
  return 0;
}

#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = long long; using ull = unsigned long long; using pll = pair<ll,ll>; const ll INF = 4e18;
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<fixed<<setprecision(15)<<head;print0(tail...);}
void print() { print0("\n"); }
template<typename Head,typename... Tail>void print(Head head,Tail... tail){print0(head);if(sizeof...(Tail)>0)print0(" ");print(tail...);}
// clang-format on

struct company {
    ll X;
    ll Y;
    ll R;
    //
    ll p[4];
};
uint8_t table[10000][10000];
ll dx[4] = {0, 1, 0, -1};
ll dy[4] = {1, 0, -1, 0};
ll expand(vector<company> &comps, ll cid, ll d) {
    // 拡大不可能なとき-1を返す
    // 最大になっているとき-2を返す
    company comp = comps[cid];
    ll top = comp.p[0];
    ll bottom = comp.p[2];
    ll left = comp.p[3];
    ll right = comp.p[1];
    if (d == 0 || d == 2) {
        ll y = comp.p[d] + dy[d];
        if (y < 0 || y >= 10000) return -1;
        for (ll x = left; x <= right; x++) {
            if (table[x][y] != 255) return -1;
        }
        comps[cid].p[d] = y;
        for (ll x = left; x <= right; x++) {
            table[x][y] = cid;
        }
    }
    if (d == 1 || d == 3) {
        ll x = comp.p[d] + dx[d];
        if (x < 0 || x >= 10000) return -1;
        for (ll y = bottom; y <= top; y++) {
            if (table[x][y] != 255) return -1;
        }
        comps[cid].p[d] = x;
        for (ll y = bottom; y <= top; y++) {
            table[x][y] = cid;
        }
    }
    comp = comps[cid];
    ll size = (comp.p[0] - comp.p[2]) * (comp.p[1] - comp.p[3]);
    if (size >= comp.R) return -2;
    return 0;
}
int main() {
    // 0:top,1:right,2:bottom,3:left;
    ll n;
    cin >> n;
    vector<company> comps(n);
    vector<pll> tasks;
    for (ll i = 0; i < 10000; i++) {
        for (ll j = 0; j < 10000; j++) {
            table[i][j] = 255;
        }
    }

    for (ll i = 0; i < n; i++) {
        ll x, y, r;
        cin >> x >> y >> r;
        comps[i] = {x, y, r};
        comps[i].p[0] = y;
        comps[i].p[2] = y;
        comps[i].p[1] = x;
        comps[i].p[3] = x;
        table[x][y] = i;
        for (ll d = 0; d < 4; d++) {
            tasks.push_back({i, d});
        }
    }
    std::random_device seed_gen;
    std::mt19937 engine(seed_gen());

    while (tasks.size() > 0) {
        ll taskid = engine() % tasks.size();
        pll task = tasks[taskid];
        ll cid = task.first;
        ll d = task.second;
        ll result = expand(comps, cid, d);
        if (result < 0) {
            vector<pll> new_tasks;
            for (auto t : tasks) {
                if (result == -2 && t.first != cid) new_tasks.push_back(t);
                if (result == -1 && (t.first != cid || t.second != d)) new_tasks.push_back(t);
            }
            swap(tasks, new_tasks);
        }
    }
    for (ll i = 0; i < n; i++) {
        company comp = comps[i];
        print(comp.p[3], comp.p[2], comp.p[1] + 1, comp.p[0] + 1);
    }
}


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

struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(x!=a.x) return x<a.x;
    //if(y!=a.y)
    return y<a.y;

  };
};

int a,b,c,d,i,n,m,e,ee,k,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[2][2];
int l[1010];
int ss[1];
int dp[1];
long long x,y,z;
const long long mod=1000000007,hf=(mod+1)/2;

//string r;
char r[1];
vector<int> v[1];
P u[1];
queue<int> q;

//multiset<int> s;
stack<int> s;
//unordered_
map<long long,int> p;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//rng()
bool as(P a,P b)
{
  //if(a.x!=b.x)
  //return a.x<b.x;
  //if(a.y!=b.y) return a.y>b.y;
  return a.x>b.x;
}

int main()
{
  scanf("%d",&a);
  for(int i=0;i<2;i++)
    for(int j=0;j<2;o[i][j]-='A',j++)
      scanf("\n%c",&o[i][j]);
  if(o[0][1]==o[o[0][1]][o[0][1]])
  {
    puts("1");
    return 0;
  }
  if(o[0][1]!=o[1][0])
  {
    e=1;
    for(int t=1;t<=a-3;t++)
    {
      e*=2;
      if(e>=mod) e-=mod;
    }
    printf("%d",e);
    return 0;
  }
  l[0]=l[1]=1;
  for(int t=2;t<=a-2;t++)
  {
    l[t]=l[t-1]+l[t-2];
    if(l[t]>=mod) l[t]-=mod;
  }
  printf("%d",l[a-2]);
}

#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MAXN 200005
#define REP(temp, init_val, end_val) for (int temp = init_val; temp <= end_val; ++temp)
#define REPR(temp, init_val, end_val) for (int temp = init_val; temp >= end_val; --temp)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while (c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x;
}
inline int lowbit(int x){
    return x & (-x);
}
inline int modadd(int x, int y){
    return (x + y >= MOD ? x + y - MOD: x + y);
}
inline int sgn(int x){
    return (x < 0 ? -1: (x > 0 ? 1: 0));
}
template<typename T>
T gcd(T a, T b){
    return (!b) ? a: gcd(b, a % b);
}
int poww(int a, int b){
    int res = 1;
    while (b > 0){
        if (b & 1) res = 1ll * res * a % MOD;
        a = 1ll * a * a % MOD, b >>= 1;
    }
    return res;
}
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
const int ddx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, ddy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

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

int n, c1, c2, c3, c4;
void init(){
    n = read();
    char s[4];
    scanf("%s", s);
    c1 = s[0] - 'A';
    scanf("%s", s);
    c2 = s[0] - 'A';
    scanf("%s", s);
    c3 = s[0] - 'A';
    scanf("%s", s);
    c4 = s[0] - 'A';
}
void solve(){
    int tt = c1 * 8 + c2 * 4 + c3 * 2 + c4;
    if (tt <= 3 || tt == 5 || tt == 7 || tt == 13 || tt == 15){
        printf("1\n");
    } else if (tt == 4 || tt == 10 || tt == 11 || tt == 12){
        if (n == 2) printf("1\n");
        else printf("%d\n", poww(2, n - 3));
    } else {
        int f0 = 1, f1 = 1;
        n -= 2;
        while (n > 0){
            int f2 = modadd(f0, f1);
            f0 = f1, f1 = f2;
            --n;
        }
        printf("%d\n", f0);
    }
}
int main(){
    int T = 1;
    while (T--){
        init();
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int const size_n = 3010;
long long matrix[2 * size_n][2 * size_n];
bool vis[2 * size_n][2 * size_n];
long long MOD = 998244353LL;

long long solve (long long n, long long k) {
    if(vis[n][k]) { return matrix[n][k]; }
    if(n == 0 && k == 0) { return 1ll; }
    if(n == 0 || k == 0) { return 0; }
    if (n < k) { return 0; }
    vis[n][k] = true;
    return matrix[n][k] = (solve(n - 1, k - 1) + solve(n, 2ll * k)) % MOD;
}

int main () {

    long long n, k;
    scanf("%lld %lld", &n, &k);

    matrix[n][k] = solve(n, k);

    printf("%lld\n", matrix[n][k]);

    return 0;
}

//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#define int long long
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define a first
#define b second
#define fi first
#define sc second
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
#define si(x) int(x.size())

#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

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

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

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.fi<<","<<p.sc<<"}";
}

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

template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 998244353;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int par[2205],ran[2205];
void init(){ for(int i=0;i<2205;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
int n, m;
string str[1005];

void solve(){
	init();
	cin >> n >> m;
	rep(i, n) cin >> str[i];
	unite(0, n); unite(0, n+m-1);
	unite(n-1, n); unite(n-1, n+m-1);
	rep(i, n){
		rep(j, m){
			if(str[i][j] == '#'){
				unite(i, j + n);
			}
		}
	}
	set<int>x, y;
	rep(i, n) x.insert(find(i));
	rep(i, m) y.insert(find(n + i));

	cout << min(si(x), si(y)) - 1 << endl;
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	int t; t = 1; //cin >> t;
	while(t--) solve();
}


#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
unsigned int randInt() {
    static unsigned int tx = 113456789, ty=362436069, tz=521288629, tw=88675123;
    unsigned int tt = (tx^(tx<<11));
    tx = ty; ty = tz; tz = tw;
    return ( tw=(tw^(tw>>19))^(tt^(tt>>8)) );
}
double randDouble() {
    return double(randInt())/UINT_MAX;
}
#define timeLimit (1.9)
const int64_t CYCLES_PER_SEC=3000000000;
struct Timer {
	int64_t start;
	Timer() { reset(); }
	void reset() { start = getCycle(); }
	inline double get() { return (double)(getCycle() - start) / CYCLES_PER_SEC; }
	inline int64_t getCycle() {
		uint32_t low, high;
		__asm__ volatile ("rdtsc" : "=a" (low), "=d" (high));
		return ((int64_t)low) | ((int64_t)high << 32);
	}
} timer;
int N, M;
string S[1000];
string K[21];
string prev_K[21];
int L = 0;

int score() {
    int ret = 0;
    rep(k, M) {
        bool flag = false;
        rep(i, N) {
            rep(j, N) {
                bool ok = true;
                rep(l, S[k].length())
                    if(K[i][(j + l) % N] != S[k][l]) ok = false;
                if(ok) flag = true;
                if(flag) break;
            }
            if(flag) break;
        }
        rep(i, N) {
            rep(j, N) {
                bool ok = true;
                rep(l, S[k].length())
                    if(K[(i + l) % N][j] != S[k][l]) ok = false;
                if(ok) flag = true;
                if(flag) break;
            }
            if(flag) break;
        }
        ret += flag;
    }
    return ret;
}
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    // while(timer.get() < timeLimit) {
    //     cout << timer.get() << endl;
    // }
    rep(i, 20) rep(j, 20) {
        K[i] += '.';
        prev_K[i] += '.';
    }
    cin >> N >> M;
    rep(i, M) {
        cin >> S[i];
        L = max<int>(S[i].length() - 2, L);
    }
    int current_score = 0;
    rep(i, M) {
        int x = randInt() % N;
        int y = randInt() % N;
        int d = randInt() % 4;
        //if(S[i].length() >= L) continue;
        int cnt = 0;
        while(K[x][y] != '.' && (K[x][y] != S[i][0] || K[(x + dx[d] * 1 + N) % N][(y + dy[d] * 1 + N) % N ] != S[i][1])) {
            x = randInt() % N;
            y = randInt() % N;
            cnt++;
            if(cnt >= M * 1000) break;
        }
        if(cnt >= M * 1000) break;
        rep(j, S[i].length()) K[x][(y + j) % N] = S[i][j];
        //if(i % 10 == 0) cerr << i << " " << 1e+8 * score()/double(M) << endl;
    }
    // rep(i, M) {
    //     int x = randInt() % N;
    //     int y = randInt() % N;
    //     if(S[i].length() >= L) continue;
    //     rep(i, N) prev_K[i] = K[i];
    //     rep(j, S[i].length()) K[x][(y + j) % N] = S[i][j];
    //     int next_score = score();
    //     if(current_score < next_score) {
    //         current_score = next_score;
    //     } else {
    //         rep(i, N) K[i] = prev_K[i];
    //     }
    //     cerr << i << " " << current_score << endl;
    //     if(timer.get() > timeLimit) break;
    // }
    rep(i, N) {
        rep(j, N) cout << K[i][j];
        cout << endl;
    }
    cerr << 1e+8 * score()/double(M) << endl;

    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
using namespace std;

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    LL N, C;
    cin >> N >> C;
    vector<LL> a(N), b(N), c(N);

    set<LL> zipped;

    LL M = -1;
    REP(i, N) {
        cin >> a[i] >> b[i] >> c[i];
        b[i]++;
        zipped.insert(a[i]);
        zipped.insert(b[i]);
    }

    map<LL, int> dic;
    map<int, LL> inv;
    int n = 0;
    for(auto i : zipped) {
        dic[i] = n;
        inv[n] = i;
        n++;
    }

    vector<LL> cost(dic.size() + 1, 0);
    REP(i, N) {
        cost[dic[a[i]]] += c[i];
        cost[dic[b[i]]] -= c[i];
    }

    FOR(i, 1, dic.size() + 1) {
        cost[i] += cost[i - 1];
    }
    REP(i, dic.size() + 1) {
        cost[i] = min(cost[i], C);
    }

    LL s = 0;
    REP(i, dic.size()) {
        s += (inv[i + 1] - inv[i])*cost[i];
    }
    cout << s << endl;

    return 0;
}


#include <iostream>
#include <cstring>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
    long long int S,P;cin>>S>>P;
    for (long long int i = 1; i <= 1000000; i++)
    {
        if (i*(S-i)==P)
        {
            cout << "Yes";
            break;
        }
        if(i==1000000){
            cout << "No";
        }
    }

}

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

signed main(){
	int A, B;
	scanf("%d%d", &A, &B);
	printf("%lf\n", 100.0 * (A - B) / A);
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(void){
    long long n, ans = 0;
    cin >> n;
    for(long long i = 1; i < n; i++){
        long long d = 1, j = i;
        while(j > 0){
            d *= 10;
            j /= 10;
        }
        long long x = i + d * i;
        if(x <= n) ans++;
        else break;
    }
    cout << ans << endl;
}

//code by: Ravi Khatri
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define F first
#define S second
#define pb push_back
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define fr(i,n,s) for(int i=(int)n;i>=s;--i)
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
#define mod 1000000007
ll pow(ll x,ll n){
	ll res=1LL;
	while(n){
		if(n%2){
			res=(res*x)%mod;
		}
		x=x%mod*x%mod;
		n>>=1;
	}
	return res;
}
void solve()
{
	ll n;cin>>n;
	for(int i=0;;++i){
		if(stoll(to_string(i)+to_string(i))> n){
			cout<<i-1<<"\n";
			return;
		}
	}

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


#include <iostream>
using namespace std;

int main() {
    string S;
    cin>>S;
    cout<<S[1]<<S[2]<<S[0]<<endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i,x,n) for(int i = x;i <= n;++i)
#define forr(i,x,n) for(int i = n;i >= x;--i)
#define Angel_Dust ios::sync_with_stdio(0);cin.tie(0)

int main()
{
//    freopen("D:\\OJCodes\\TTT\\in.txt","r",stdin);
//    freopen("D:\\OJCodes\\TTT\\out.txt","w",stdout);

    Angel_Dust;
    string s;cin >> s;
    cout << s[1] << s[2] << s[0];

//    fclose(stdin);
//    fclose(stdout);
    return 0;
}


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

#define rep(i, s, t) for (int i = s; i < int(t); ++i)

#define sc	scanf
#define pr	printf
#define ff	first
#define ss	second
#define mp	make_pair
#define pb	push_back
#define eb	emplace_back
#define range(c)	c.begin(), c.end()
#define lowbit(x)	((x) & -(x))
#define pop_count	__builtin_popcount
#define pop_count_64	__builtin_popcountll
#define tail_count	__builtin_ctz
#define tail_count_64	__builtin_ctzll
#define lead_count	__builtin_clz
#define lead_count_64	__builtin_clzll

#define TEMP template<typename
#define CONST(type) constexpr type const

TEMP... Ts> struct is_con { static CONST(bool) value = false; };
TEMP... Ts> struct is_con<vector<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<list<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<deque<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<set<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<unordered_set<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<map<Ts...>> { static CONST(bool) value = true; };
TEMP... Ts> struct is_con<unordered_map<Ts...>> { static CONST(bool) value = true; };

TEMP T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2> const& p) { return os << "<" << p.ff << "," << p.ss << ">"; }
TEMP T> typename enable_if<is_con<T>::value, ostream>::type& operator<<(ostream& os, T const& c) {
	os << "{";
	bool first = true;
	for (auto const& x : c) {
		if (first) first = false;
		else os << ",";
		os << " " << x;
	}
	return os << " }";
}

TEMP T, typename... Ts> void dbg(T h, Ts... t) { cerr << " " << h; dbg<Ts...>(t...); }
template<> void dbg<int>(int x) { cerr << endl; }

#ifdef LOCAL
#define debug(...) cerr << "[ "#__VA_ARGS__" ] :", dbg(__VA_ARGS__, 0)
#else
#define debug(...) 0
#endif

TEMP T, typename U> using ordered_map = tree<T, U, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
TEMP T> using ordered_set = ordered_map<T, null_type>;

typedef long long i64;
typedef decimal::decimal128 i99;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef float f32;
typedef double f64;
typedef long double f80;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<i64> vl;

TEMP T> T& minn(T& lhs, T const& rhs) { return lhs = min(lhs, rhs); }
TEMP T> T& maxx(T& lhs, T const& rhs) { return lhs = max(lhs, rhs); }

constexpr const u32 maxn = 205U;

bool ok[maxn][maxn], ans[maxn];
u32 other[maxn], cnt[maxn];
char side[maxn];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	u32 n;
	std::cin >> n;
	u32 more = false;
	for (u32 i = 0; i != n; ++i) {
		u32 a, b;
		std::cin >> a >> b;
		if (~a) {
			other[a] = b;
			side[a] = 'a';
			++cnt[a];
		}
		if (~b) {
			other[b] = a;
			side[b] = 'b';
			++cnt[b];
		}
	}
	for (u32 i = 1; i <= n + n; ++i) {
		if (cnt[i] > 1U) {
			std::cout << "No" << std::endl;
			return 0;
		}
	}
	for (u32 i = 1; i != n + n; ++i) {
		for (u32 j = i + 1, l = 1; j <= n + n; j += 2, ++l) {
			ok[i][j] = true;
			for (u32 k = 0; k != l; ++k) {
				ok[i][j] &= side[i + k] != 'b';
			}
			for (u32 k = i + l; k <= j; ++k) {
				ok[i][j] &= side[k] != 'a';
			}
			for (u32 k = 0; k != l; ++k) {
				if (other[i + k]) {
					ok[i][j] &= ~other[i + k] ? other[i + k] == i + k + l : !other[i + k + l];
				}
				else {
					ok[i][j] &= !other[i + k + l] || !~other[i + k + l];
				}
			}
		}
	}
	ans[0] = true;
	for (u32 i = 2; i <= n + n; ++i) {
		for (u32 j = 1; j < i; j += 2) {
			ans[i] |= ans[j - 1] && ok[j][i];
		}
	}
	std::cout << (ans[n + n] ? "Yes" : "No") << std::endl;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <limits>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
template<class T> inline int  sz(T &a) { return a.size(); }
using ll = long long; using ld = long double;
using pi = pair<int,int>; using pl = pair<ll,ll>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
const int inf = numeric_limits<int>::max();
const ll infll = numeric_limits<ll>::max();
int main()
{
  int n; cin >> n;
  using pll = pair<pl,ll>;
  vector<pll> p(n);
  rep(i,n) {
    cin >> p[i].first.first >> p[i].first.second;
    p[i].second = i;
  }
  sort(p.begin(),p.end(), [](pll a, pll b){
    return a.first.first > b.first.first;
  });

  vl res;
  map<pl,ll> mp;
  ll a = p[0].second, b = p[n-1].second;
  ll c = max(abs(p[0].first.first - p[n-1].first.first), abs(p[0].first.second - p[n-1].first.second));
  if(a > b) swap(a, b);
  if(mp[{a,b}] == 0) {
    mp[{a, b}]++;
    res.push_back(c);
  }

  a = p[1].second; b = p[n-1].second;
  c = max(abs(p[1].first.first - p[n-1].first.first), abs(p[1].first.second - p[n-1].first.second));
  if(a > b) swap(a, b);
  if(mp[{a,b}] == 0) {
    mp[{a, b}]++;
    res.push_back(c);
  }

  a = p[0].second; b = p[n-2].second;
  c = max(abs(p[0].first.first - p[n-2].first.first), abs(p[0].first.second - p[n-2].first.second));
  if(a > b) swap(a, b);
  if(mp[{a,b}] == 0) {
    mp[{a, b}]++;
    res.push_back(c);
  }

  sort(p.begin(),p.end(), [](pll a, pll b){
    return a.first.second > b.first.second;
  });

  a = p[0].second; b = p[n-1].second;
  c = max(abs(p[0].first.first - p[n-1].first.first), abs(p[0].first.second - p[n-1].first.second));
  if(a > b) swap(a, b);
  if(mp[{a,b}] == 0) {
    mp[{a, b}]++;
    res.push_back(c);
  }

  a = p[1].second; b = p[n-1].second;
  c = max(abs(p[1].first.first - p[n-1].first.first), abs(p[1].first.second - p[n-1].first.second));
  if(a > b) swap(a, b);
  if(mp[{a,b}] == 0) {
    mp[{a, b}]++;
    res.push_back(c);
  }

  a = p[0].second; b = p[n-2].second;
  c = max(abs(p[0].first.first - p[n-2].first.first), abs(p[0].first.second - p[n-2].first.second));
  if(a > b) swap(a, b);
  if(mp[{a,b}] == 0) {
    mp[{a, b}]++;
    res.push_back(c);
  }

  sort(res.begin(),res.end(), [](ll a, ll b){
    return a > b;
  });
  cout << res[1] << "\n";

  return 0;
}


#pragma GCC optimize("Ofast")   //Comment optimisations for interactive problems (use endl)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  endl           "\n"
#define  pb             push_back
#define  sym(s)         s="#"+s+"#";
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  debv(a)        for(auto it: a)cout<<it<<" ";cout<<endl;
#define  deb1(a)        cout<<a<<endl;
#define  deb2(a,b)      cout<<a<<" "<<b<<endl;
#define  deb3(a,b,c)    cout<<a<<" "<<b<<" "<<c<<endl;
#define  deb4(a,b,c,d)  cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
#define  uniq(a)        a.resize(unique(a.begin(), a.end()) - a.begin());

typedef  long long             ll;
typedef  unsigned long long    ull;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   N  =  3e+5+7;

vll adj[N];ll vis[N]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int t=1;
int l;
//<<-----Implement Functions Here---->>//
ll NCR(ll n, ll r) {
if (r == 0) return 1;
        if (r > n / 2) return NCR(n, n - r);
        ll res = 1;
       for (ll k = 1; k <= r; ++k){
           res *= n - k + 1;
            res /= k;
        }
return res;
}

//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>l;
		ld ans = 1;l -= 12;
		ll n = l+12-1;ll r = l;
		cout<<NCR(n,r);

}

int main(){
    fastio;randomINIT;

    //cin>>t;
    while(t--){
        MAIN();
    }

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif
}


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

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
//#define int long long
typedef long long ll;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define done(x) {cout << x << endl;return;}
#define mini(x,y) x=min(x,y)
#define maxi(x,y) x=max(x,y)
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;
uniform_int_distribution<int> rng(1,1e5);
uniform_int_distribution<int> rng1(0,1);
uniform_int_distribution<int> rng2(1,5e4);

//DEBUG FUNCTIONS START
#define cerr cout
void __print(int x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
//#define deb(x...) cerr << "[" << #x << "] = "; _print(x)
#define deb(x...)  _print(x)
#else
#define deb(x...)
#endif
// DEBUG FUNCTIONS END

const int N = 2e5 + 5;

int powm(int a, int b){
    int res = 1;
    while (b) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

void solve(){

	int h, w, a, b, ans = 0;
	cin >> h >> w >> a >> b;

	rep(msk, 0, 1<<(h*w)){

		if(__builtin_popcount(msk) != a)
			continue;

		vpii v;
		vvi vis1(h, vi(w));

		rep(j,0,h*w){
			if(msk >> j & 1){
				v.pb({j/w, j%w});
				vis1[j/w][j%w] = 1;
			}
		}

		rep(msk1, 0, 1<<a){
			vvi vis = vis1;
			bool ok = 1;
			rep(j,0,a){
				int r = v[j].fi, c = v[j].se;

				if(msk1 >> j & 1){
					if(r < h-1){
						ok &= !vis[r+1][c];
						vis[r+1][c] = 1;
					}else
						ok = 0;
				}
				else{
					if(c < w-1){
						ok &= !vis[r][c+1];
						vis[r][c+1] = 1;
					}else
						ok = 0;
				}
				if(!ok)
					break;
			}
			ans += ok;
		}

	}

	cout << ans << endl;

}

signed main() {

    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}

int divide(int a, int b) {
    return (a % mod) * powm(b % mod, mod - 2) % mod;
}

#include <bits/stdc++.h>
using namespace std;
int h, w, a, b, ans;
bool vis[18][18];
void dfs(int x, int y, int lef){
	if (y>w) x++, y=1;
	if (x==h&&y==w){
		if (lef==0) ans++;
		return;
	}
	dfs(x, y+1, lef);
	if (lef!=0&&!vis[x][y]){
		if (!vis[x+1][y]){
			vis[x][y]=1, vis[x+1][y]=1;
			dfs(x, y+1, lef-1);
			vis[x][y]=0, vis[x+1][y]=0;
		}
		if (!vis[x][y+1]){
			vis[x][y]=1, vis[x][y+1]=1;
			dfs(x, y+1, lef-1);
			vis[x][y]=0, vis[x][y+1]=0;
		}
	}
	return;
}
int main(){
	for (int i=0; i<=17; i++)
		for (int j=0; j<=17; j++) vis[i][j]=1;
	cin >> h >> w >> a >> b;
	for (int i=1; i<=h; i++)
		for (int j=1; j<=w; j++) vis[i][j]=0;
	dfs (1, 1, a);
	cout << ans << endl;
	return 0;
}


#include<bits/stdc++.h>
#define ll long long int

using namespace std;

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

    ll ans = (n*(1.08));

    if(ans < 206){
        cout<<"Yay!"<<endl;
    }else if(ans == 206){
        cout<<"so-so"<<endl;
    }else{
        cout<<":("<<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<ll, ll>;

int main() {
  string s;
  cin >> s;
  ll ans = 0;
  rep(i, s.size() - 3) if (s.substr(i, 4) == "ZONe") ans++;
  cout << ans << endl;
  return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
int n;
vi a;
void MAIN() {
	int i,j;
	cin>>n;
	for(i=0;i<n;i++) {
		int x;cin>>x;
		a.pb(x);
	}
	make_unique(a);
	int mn=1e9;
	for(i=1;i<sz(a);i++) {
		mn=min(mn,__gcd(a[0],a[i]));
	}
	if(sz(a)==1)cout<<a[0];
	else cout<<mn;
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

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

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define ins insert

#define debug(a) cerr<<(a)<<endl
#define dbrep(a,n) rep(_i,n) cerr<<(a[_i])<<" "; cerr<<endl
#define dbrep2(a,n,m) rep(_i,n){rep(_j,m) cerr<<(a[_i][_j])<<" "; cerr<<endl;}

using namespace std;

template<class A, class B>
ostream &operator<<(ostream &os, const pair<A,B> &p){return os<<"("<<p.fi<<","<<p.se<<")";}
template<class A, class B>
istream &operator>>(istream &is, pair<A,B> &p){return is>>p.fi>>p.se;}

/* Some Libraries */

//-------------------------------------------------

const ll INF = LONG_LONG_MAX;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll B,C; cin>>B>>C;
    auto f = [&](ll x){
        bool f1 = B>0;
        bool f2 = x>0;
        if (f1^f2){
            return abs(x-B)*2+1;
        }else{
            if (x<B){
                return abs(x-B)*2;
            }else{
                return abs(x-B)*2+2;
            }
        }
    };

    pll a,b;
    {
        ll l=B-C/2,r=max(B,B+C/2-1);
        a = pll(l,r);
    }
    {
        C--;
        ll l=-B-C/2,r=-B+C/2;
        b = pll(l,r);
    }
    if (a>b) swap(a,b);
    if (a.se>=b.fi){
        ll ans = (b.se-a.fi+1);
        cout<<ans<<"\n";
    }else{
        ll ans = (a.se-a.fi+1) + (b.se-b.fi+1);
        cout<<ans<<"\n";
    }

    return 0;
}


#include <bits/stdc++.h>

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

namespace Problem {
using namespace std;

class Solver {
 public:
  LL n;
  LL l;
  vector<LL> a, b, A, B;
  Solver(LL n) : n(n), a(n + 2), b(n + 2), A(n + 1), B(n + 1){};

  void solve() {
    cin >> l;
    for (int i = 0; i < n; ++i) {
      cin >> a[i + 1];
    }
    for (int i = 0; i < n; ++i) {
      cin >> b[i + 1];
    }
    a[n + 1] = b[n + 1] = l + 1;
    for (int i = 0; i <= n; ++i) {
      A[i] = a[i + 1] - a[i] - 1;
      B[i] = b[i + 1] - b[i] - 1;
    }
    LL ans = 0;
    LL nxt = 0;
    DBG(A, B)
    for (LL i = 0; i <= n; ++i) {
      if (B[i] == 0) continue;
      LL j = nxt;
      LL tmpsum = 0;
      for (; j <= n; ++j) {
        tmpsum += A[j];
        if (tmpsum == B[i]) break;
      }
      DBG(j)
      if (j > n) {
        cout << -1 << endl;
        return;
      }
      DBG(i, j)
      int l = nxt;
      int r = j;
      while (A[l] == 0) l++;
      while (A[r] == 0) r--;
      //[nxt,j]
      if (i < l) {
        ans += r - i;
      } else if (i > r) {
        ans += i - l;
      } else {
        ans += r - l;
      }
      nxt = j + 1;
      DBG(ans)
    }
    cout << ans << endl;
  }
};

}  // namespace Problem

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

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

///****In the name of ALLAH, most Gracious, most Compassionate****//

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

typedef long long LL;
typedef pair <LL, LL> pii;

#define ALL(a) a.begin(), a.end()
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

#define DBG(a) cerr<< "line "<<__LINE__ <<" : "<< #a <<" --> "<<(a)<<endl
#define NL cout<<endl

template < class T1,class T2>
ostream &operator <<(ostream &os,const pair < T1,T2 > &p)
{
    os<<"{"<<p.first<<","<<p.second<<"}";
    return os;
}

const LL N=3e5+5;
const LL oo=1e9+7;
vector<LL > ai,bi;
int32_t main()
{
    FastIO;
    map<LL  ,LL > alo,ahi;
    map<LL  ,LL > blo,bhi;

    LL n,L;
    cin>>n>>L;
    for(LL i=1;i<=n;i++)
    {
        LL x;
        cin>>x;
        x-=i;

        if(alo.count(x))
            ahi[x] = i;
        else
            alo[x] =ahi[x] = i;
    }
    for(LL i=1;i<=n;i++)
    {
        LL x;
        cin>>x;
        x-=i;

        if(blo.count(x))
            bhi[x] = i;
        else
            blo[x] =bhi[x] = i;
    }

    alo[0]=0;
    ahi[0]=max(ahi[0],0LL);

    blo[0]=0;
    bhi[0]=max(bhi[0],0LL);

    L-=n+1-1;

    ahi[L] = n+1;
    if(!alo.count(L))
        alo[L]=n+1;

    bhi[L] = n+1;
    if(!blo.count(L))
        blo[L]=n+1;

    LL ans = 0;

//    DBG(&alo);
//    for(auto i: alo)
//        cout<<i<<" ";
//    NL;

    for(auto  it: blo)
    {
        LL x = it.first;
        LL l = blo[x];
        LL r = bhi[x];
//        DBG(it);

        if(alo.count(x) == 0)
        {
            cout<<"-1\n";
            return 0;
        }

        LL ll = alo[x];
        LL rr = ahi[x];

        ans += max( 0LL, ll-l);
        ans += max( 0LL, r-rr);

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


#include<bits/stdc++.h>
#define loop(i, n) for(int i = 0; i < n; i++)
#define pb          push_back
#define ll          long long int
#define vi          vector<int>
#define pi          pair<int, int>
#define W(t)        int t; cin >> t; while(t--)
#define FIO         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ff          first
#define ss          second
using namespace std;
vi read(int n){
    vi v(n);

    loop(i, n)
        cin >> v[i];
    return v;
}
void solve(){
    ll i, j, k, m, n, ans = 0, cnt = 0, sum = 0;

    string s;

    cin >> n >> s;
    int c1, c2;
    for(int i = 0; i < n; i++){
        c1 = 0, c2 = 0;
        for(int j = i; j < n; j++){
            if(s[j] == 'A')
                c1++;
            else if(s[j] == 'T'){
                c1--;
            }
            else if(s[j] == 'C'){
                c2++;
            }
            else if(s[j] == 'G'){
                c2--;
            }
            if(c1 == 0 && c2 == 0)
                ans++;
        }
    }

    cout << ans << "\n";

}

    //cout << ans << "\n";
int main(){
    FIO

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

    //W(t)
    solve();
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <assert.h>
#include <functional>
#include <iomanip>

using namespace std;

#define ll long long
#define endl "\n"
const ll mod = 1e9 + 7;
const int MX = 2e5 + 5;

multiset<int> adj[MX * 2];
int cnt[MX * 2];

int solve(){
	int n; cin >> n;
	for(int u, v, i = 0; i < n; i ++){
		cin >> u >> v;
		adj[u].insert(v);
		adj[v].insert(u);
		cnt[u] ++; cnt[v] ++;
	}

	set<int> li1;
	for(int i = 0; i < MX * 2; i ++)
		if(cnt[i] == 1) li1.insert(i);

	int ans = 0;
	while(!li1.empty()){
		int gt = *li1.begin();
		int pr = *adj[gt].begin();
		ans ++;

		adj[gt].clear();
		adj[pr].erase(adj[pr].find(gt));
		cnt[gt] --; cnt[pr] --;

		if(li1.count(gt)) li1.erase(li1.find(gt));
		if(li1.count(pr)) li1.erase(li1.find(pr));
		if(cnt[pr] == 1) li1.insert(pr);
	}

	for(int i = 0; i < MX * 2; i ++)
		if(cnt[i] > 1) ans ++;

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

int main(){
	cin.tie(0) -> sync_with_stdio(0);
	int tc = 1;
//	cin >> tc;
	for(;tc --;) solve();
}


#include <bits/stdc++.h>
#define int long long int
#include <time.h>
using namespace std;
int graph[22][22];
int g[22];
int ind_set[2000006];
int co[2000006];
bool vis[22];
bool good = true; ;
int n;
int coll[22];
void dfs(int no , int s , int p , int colou ){
    vis[no] = 1;
    coll[no] = colou;
    for(int j = 0;j<n;j++){
        if(j == p ){continue;}
        if(graph[no][j] ){
            if(s&(1<<j) ){
                if(vis[j] ){
                    if(coll[j]^colou ){
                        ;
                    }
                    else{
                        good = false;return ;
                    }
                }
                else{
                    dfs(j , s , no , colou^1 );
                }
            }
        }
    }
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int  m;
    cin>>n>>m;
    for(int i = 1;i<= m;i++){
        int l , r;
        cin>>l>>r;
        l--;
        r--;
        graph[l][r] = 1;
        graph[r][l] = 1;
        g[l]+= (1<<r);
        g[r]+= (1<<l );
    }
    ind_set[0] = 1;
    for(int i = 0;i<n;i++){
        ind_set[1<<i ] = 1;
    }
    for(int i = 1;i<(1<<n ) ;i++){
        if(ind_set[i] ){
            for(int j = 0;j<n;j++ ){
                if(i&(1<<j ) ){
                    ;
                }
                else{
                    if(i&g[j] ){
                        ;
                    }
                    else{
                        ind_set[i|(1<<j)] = 1;
                    }
                }
            }
        }
    }
    for(int i = 1;i<(1<<n);i++){
        good = true;
        for(int j = 0;j<n;j++){
            vis[j] = 0;
            coll[j] = 0;
        }
        int ce = 0;
        for(int j = 0;j<n;j++){
            if(i&(1<<j) ){
                if(!vis[j] ){
                    dfs(j , i , -1 , 0 );
                    ce++;
                    if(!good){break;}
                }
            }
        }
        if(good ){
            co[i] = ce;
        }
        else{
            co[i] = 0;
        }
    }
    int ans = 0;
    int ma = (1<<n)-1;
    for (int m=0; m<(1<<n); ++m){
        int z = m^ma;
        if(m == 0){
            if(ind_set[z]){
                ans++;
            }
            continue;
        }
        if(ind_set[z] ){
            if(co[m] ){
                ans+= (1<<co[m] );
            }
        }
    }
    cout<<ans;
}

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

const int maxn = 200010;
int n, K, lst[maxn], tmp[maxn];
vector<int> G[maxn];

int main() {
    scanf("%d %d", &n, &K);
    for (int i = 1, u, v; i < n; i++) {
        scanf("%d %d", &u, &v);
        G[u].push_back(v), G[v].push_back(u);
    }
    auto chk = [&](int x) {
        memset(lst, 0x3f, sizeof(lst));
        int cnt = 0;
        function<void(int, int)> dfs = [&](int v, int fa) {
            for (int u : G[v]) if (u ^ fa) {
                dfs(u, v);
                lst[v] = min(lst[v], lst[u] + 1);
            }
            int mx = -n;
            if (lst[v] > x) mx = 1;
            for (int u : G[v]) if (u ^ fa && lst[v] + tmp[u] > x) {
                mx = max(mx, tmp[u] + 1);
            }
            if (mx > x) cnt++, tmp[v] = -n, lst[v] = 0;
            else tmp[v] = mx;
        };
        dfs(1, 0);
        if (tmp[1] > 0) cnt++;
        return cnt;
    };
    int l = 1, r = n, ans;
    while (l <= r) {
        int mid = (l + r) >> 1;
        chk(mid) <= K ? r = (ans = mid) - 1 : l = mid + 1;
    }
    printf("%d\n", ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
main(){
    long long n, k; cin >> n >> k;
    for (int i = 0; i < k; i++){
        if (n % 200 == 0) n /= 200;
        else n = n*1000+200;
    }
    cout << n << endl;
}

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

#define rep(i,_l,_r) for(register signed i=(_l),_end=(_r);i<=_end;++i)
#define fep(i,_l,_r) for(register signed i=(_l),_end=(_r);i>=_end;--i)
#define erep(i,u) for(signed i=head[u],v=to[i];i;i=nxt[i],v=to[i])
#define efep(i,u) for(signed i=Head[u],v=to[i];i;i=nxt[i],v=to[i])
#define print(x,y) write(x),putchar(y)
// #define debug(...) do {cerr<<__LINE__<<" : ("#__VA_ARGS__<<") = "; Out(__VA_ARGS__); cerr<<flush;} while(0)
// template <typename T> void Out(T x) {cerr<<x<<"\n";}
// template <typename T,typename ...I> void Out(T x,I ...NEXT) {cerr<<x<<", "; Out(NEXT...);}

template <class T> inline T read(const T sample) {
    T x=0; int f=1; char s;
    while((s=getchar())>'9'||s<'0') if(s=='-') f=-1;
    while(s>='0'&&s<='9') x=(x<<1)+(x<<3)+(s^48),s=getchar();
    return x*f;
}
template <class T> inline void write(const T x) {
    if(x<0) return (void) (putchar('-'),write(-x));
    if(x>9) write(x/10);
    putchar(x%10^48);
}
template <class T> inline T Max(const T x,const T y) {if(x>y) return x; return y;}
template <class T> inline T Min(const T x,const T y) {if(x<y) return x; return y;}
template <class T> inline T fab(const T x) {return x>0?x:-x;}
template <class T> inline T gcd(const T x,const T y) {return y?gcd(y,x%y):x;}
template <class T> inline T lcm(const T x,const T y) {return x/gcd(x,y)*y;}
template <class T> inline T Swap(T &x,T &y) {x^=y^=x^=y;}

typedef long long ll;

int main() {
    ll n=read(9); int k=read(9);
    while(k--) {
        if(n%200==0) n/=200;
        else n=n*1000+200;
    }
    print(n,'\n');
    return 0;
}


#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
ll N, M;
bool checked[25];
ll ans = 1;
ll color[25];
struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<ll> Size;
    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n + 1); rank.resize(n + 1); Size.resize(n + 1);
        for (int i = 0; i <= n; ++i) par[i] = i, rank[i] = 0, Size[i] = 1;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        Size[x] += Size[y];
        return true;
    }

    ll size(int x){
        return Size[root(x)];
    }
};

vector<int> edges[25];
ll way = 0;
vector<int> v;

void dfs(int idx) {
    if(idx == v.size()) {
        way++;
        return;
    }
    set<int> st;
    st.insert(1);
    st.insert(2);
    st.insert(3);
    for(auto to : edges[v[idx]]) {
        st.erase(color[to]);
    }
    for(auto c : st) {
        color[v[idx]] = c;
        dfs(idx + 1);
        color[v[idx]] = 0;
    }
}

void dfs2(int now) {
    v.push_back(now);
    checked[now] = true;
    for(auto to : edges[now]) {
        if(checked[to]) continue;
        dfs2(to);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    UnionFind uni(N);
    for(int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uni.merge(a, b);
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    for(int i = 0; i < N; i++) {
        if(uni.root(i) != i) continue;
        v.clear();
        dfs2(i);
        way = 0;
        dfs(0);
        ans *= way;
    }
    cout << ans << endl;
    return 0;
}

    #include <bits/stdc++.h>
    #define HAR BAR LAGTA HAI APUN HI J BHAGWAAN HAI!!
    #define UTSAV  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    #define ll long long int
    #define loop(i,m,n) for(ll i=m;i<n;i++)
    #define sq(a) (a)*(a)
    #define MAX 1e9
    #define MIN -1e9
    #define mod 1000000007
    #define pb push_back
    #define all(x) (x).begin(), (x).end()
    #define debug(x) cerr<<#x<<'='<<(x)<<endl;
    #define output(x) cout << ( x ? "YES" : "NO" ) << '\n' ;
    #define mxn 100005
    using namespace std;
    ll n;
    vector<int> arr[100001];
    int vis[100001];
    vector<int> res;
    int c = 0;
    ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
    void dfs1(int node){
        res.push_back(node);
        vis[node]=1;
        for(int i : arr[node]) dfs1(i);
    }
    bool dfs(int node){
        if(vis[node]==1) return false;
        vis[node]=1;
        for(int i : arr[node]) dfs(i);
        return true;
    }

    bool isPrime(ll n){
        for(ll i=2;i*i<=n;i++){
            if(n%i==0) return false;
        }
        return true;
    }
    ll fact(ll n){
        if(n==1) return 1;
        else return n*fact(n-1);
    }
    ll comb(ll n,ll r){
        return fact(n)/(fact(n-r)*fact(r)) ;
    }
    bool invalid(ll n){
        ll n1 = n;
        while(n1>0){
            if(n1%10!=0&&n%(n1%10)!=0) return true;
            n1/=10;
        }
        return false;
    }
    ll cal(ll n){
        return (n*(n-1)*(n-2)/6);
    }
 ll findMin(ll a[],ll i,ll sum,ll sumTotal){
        if(i==0) return abs((sumTotal-sum)-sum);
        return std::min(findMin(a,i-1,sum+a[i-1],sumTotal),findMin(a,i-1,sum,sumTotal));
    }
    ll max_value(ll n,ll k){
        ll i=0;
        while((ll)std::pow(k,i)<=n) i++;
        return i-1;
    }
    int main()
    {
        UTSAV
        int t=1;
    // cin>>t;
        while(t-->0){
           ll n;
           cin>>n;
           ll a,b;
           ll ans1 = 1e9;
           ll ans2 = 1e9;
           ll ans = 1e9;
           vector<ll> a1,b1;
           for(int i=0;i<n;i++){
               cin>>a>>b;
               ans = std::min(ans,a+b);
               a1.pb(a);
               b1.pb(b);
           }
           for(int i=0;i<n;i++){
               for(int j=0;j<n;j++){
                   if(i==j) continue;
                   ans = std::min(ans,std::max(a1[i],b1[j]));
               }
           }
           cout<<ans<<endl;
        }
        return 0;
    }


/*Created By:---- Dibas Behera*/
#include<bits/stdc++.h>
using namespace std;

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)

#define goo(x)	cout<<"Case #"<<(x)<<": ";
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
ll binpowM(ll a,ll b,ll m=MD){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a;ans%=m; a=a*a;a%=m; b=b>>1;}	return ans;}
template <typename T>
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

//-------------------------------------------
bool pred(ll p,ll &k,vector<ll> &a){
 	ll x=upper_bound(all(a),p)-a.begin();
  return p-x<=k;
}
bool pred2(ll p,ll &k,vector<ll> &a){
 	ll x=upper_bound(all(a),p)-a.begin();
  return p-x>=k;
}
ll bin(ll &k,vl &a){
 ll lo=k,hi=1e18+1e6,mid;
  while(lo+1<hi){
    mid=lo+(hi-lo+1)/2;
    if(pred(mid,k,a)) lo=mid;
    else hi=mid;
  }
  hi=lo;
  lo=0;
  while(lo+1<hi){
    mid=lo+(hi-lo+1)/2;
    if(pred2(mid,k,a)) hi=mid;
    else lo=mid;
  }
  return hi;
}
 unordered_map<ll,ll> m;
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;

	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	int n,q;cin>>n>>q;
  	vl a(n);repi(i,n) cin>>a[i];
  sort(all(a));

  //else

	//int test1;cin>>test1;
  while(q--){
		ll k;cin>>k;
      	cout<<bin(k,a)<<'\n';
	 }
	 //*/
return 0;
}

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

signed main() {

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

    #ifndef ONLINE_JUDGE
        freopen("sp.txt","r",stdin);
    #endif

    int n,q;
    cin>>n>>q;
    vector<int>v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    while(q--){
        int k;
        cin>>k;
        int l=1;
        int r=2e18;
        int ans=-1;
        while(l<r){
            int mid=(l+r)>>1;
            int idx=upper_bound(v.begin(),v.end(),mid)-v.begin();
            int z=mid-idx;
            //cout<<mid<<' '<<z<<'\n';
            if(z>=k){
                ans=mid;
                r=mid;
            }
            else{
                l=mid+1;
            }
        }
        cout<<ans<<'\n';
    }
    return 0;
}


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

#define IO          ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int         long long
#define double      long double
#define vi          vector<int>
#define vvi         vector<vi>
#define pii         pair<int, int>
#define vii         vector<pii>
#define endl        '\n'
#define pb          push_back
#define all(v)      (v).begin(), (v).end()
#define rall(v)     (v).rbegin(), (v).rend()
#define mod         1000000007

int n, m, q;

void solve() {
	cin >> n >> m >> q;
	vii bag(n);
	for (auto& it : bag) {
		cin >> it.first >> it.second;
	}
	vi box(m);
	for (auto& it : box) {
		cin >> it;
	}
	sort(all(bag));
	while (q--) {
		int l, r;
		cin >> l >> r;
		l--, r--;
		vi a;
		for (int i = 0; i < m; i++) {
			if (i < l || i > r)
				a.pb(box[i]);
		}
		sort(all(a));
		priority_queue<int> pq;
		int idx = 0, ans = 0;
		for (auto& it : a) {
			while (idx < n && bag[idx].first <= it)	{
				pq.push(bag[idx].second);
				idx++;
			}
			if (pq.size()) {
				ans += pq.top();
				pq.pop();
			}
		}
		cout << ans << endl;
	}
}

signed main() {
	IO;
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
	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 pow_int(int a, int b){
    int result = 1;
    rep(i,b)result*=a;
    return result;
}

signed main(){
    int N, M, Q;cin >> N>>M>>Q;
    vec_int W(N), V(N); rep(i,N)cin>>W.at(i)>>V.at(i);
    vec_int X(M); rep(i,M)cin>>X.at(i);

    rep(q,Q){
        int L, R; cin>>L>>R;

        vec_int box;
        for(int i=0;i<L-1;i++){
            box.push_back(X.at(i));
        }
        for(int i=R;i<M;i++){
            box.push_back(X.at(i));
        }

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

        set<int> used;
        int ans = 0;
        for(auto size_limit:box){

            int temp_value = 0;
            int temp_index = -1;
            for(int i =0;i<N;i++){
                if(used.count(i))continue;
                if(W.at(i)>size_limit)continue;
                if(V.at(i)>temp_value){
                    temp_value = V.at(i);
                    temp_index = i;
                }
            }
            if(temp_index>=0){
                used.insert(temp_index);
                ans += temp_value;
            }
        }
        cout<<ans<<endl;

    }

    return 0;
}


//#define MULTICASES
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(i=(a);i<=(b);++i)
#define per(i,a,b) for(i=(a);i>=(b);--i)
#define REP(i,a,b) for(i=(a);i< (b);++i)
#define PER(i,a,b) for(i=(a);i> (b);--i)
#define ERR(...) fprintf(stderr,__VA_ARGS__)
inline void ac();
int main(){
#ifdef MULTICASES
	int t;scanf("%d",&t);while(t--)ac();
#else
	ac();
#endif
	return 0;
}
const int MAXN=200005;
int d,Ans;
vector<int>E[MAXN];
inline int dfs(const int &v=1,const int &f=0){
	int a=-1,b=0,t,u;
	vector<int>::iterator e,ee;
	for(e=E[v].begin(),ee=E[v].end();e!=ee;++e)if((u=*e)!=f){
		t=dfs(u,v);
		if(t<0){if(t<b)b=t;}
		else   {if(t>a)a=t;}
	}
	//ERR("v=%d a=%d b=%d\n",v,a,b);
	//if(a>-b){ERR("I. %d\n",a-1);}
	//else{if(b-1<-d){ERR("II. %d (Ans=%d)\n",d,Ans+1);}else{ERR("III. %d\n",b-1);}}
	if(a>-b)return a-1;
	else{if((--b)<-d){++Ans;return d;}else return b;}
}
inline void ac(){
	int n,k,i,v,u,l,r;
	scanf("%d%d",&n,&k);
	rep(i,2,n){
		scanf("%d%d",&v,&u);
		E[v].push_back(u);
		E[u].push_back(v);
	}
	i=n-1;l=1;r=n-2;
	while(l<=r){
		d=(l+r)>>1;Ans=0;
		if(dfs()<0)++Ans;
		//ERR("\nd=%d Ans=%d\n\n\n\n",d,Ans);
		if(Ans>k)l=d+1;
		else r=(i=d)-1;
	}
	printf("%d\n",i);
}
/*
0. int overflow, array bounds
1. special cases (n=1? n=0?)
2. do smth instead of nothing and stay organized
3. WRITE STUFF DOWN
4. DON'T GET STUCK ON ONE APPROACH
5. STAY CALM AND DON'T GET EXPLODED
*/

#include <iostream>
#include <cstring>

using namespace std;

const int N = 200010, M = 2 * N, INF = 0x3f3f3f3f;

int h[N], e[M], ne[M], idx, n, m, k;
int f[N], g[N], cnt;    //f[u]:u的子孙结点中，最近的特殊点距离u点的距离
                        //g[u]:u的子孙结点中，最远的没被特殊点覆盖的点距离u点的最远的距离
bool st[N];

void add(int a, int b) {
    e[idx] = b, ne[idx] = h[a], h[a] = idx ++;
}

void dfs(int u, int father, int mid) {
    f[u] = INF, g[u] = 0;
    for (int i = h[u]; i != -1; i = ne[i]) {
        int j = e[i];
        if (j == father)    continue;
        dfs(j, u, mid);
        f[u] = min(f[j] + 1, f[u]);
        g[u] = max(g[j] + 1, g[u]);
    }
    if (f[u] + g[u] <= mid) g[u] = -INF;
    else if (g[u] == mid) g[u] = -INF, f[u] = 0, cnt ++;
}

int check(int mid) {
    cnt = 0;
    dfs(1, -1, mid);
    if (g[1] >= 0)  cnt ++; //g[1] = 0说明1虽然被覆盖但是它的子节点还有没被覆盖的，且没被覆盖的点距离u的最远距离<mid
    return cnt;
}

int main() {
    memset(h, -1, sizeof h);
    cin >> n >> k;
    for (int i = 1; i < n; i ++)    {
        int a, b;
        cin >> a >> b;
        add(a, b), add(b, a);
    }
    int l = 1, r = n;
    int ans = 1e9;
    while (l < r)  {
        int mid = l + r >> 1;
        if (check(mid) <= k) r = mid;
        else l = mid + 1;
    }
    cout << l;
    return 0;

}


#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
bool punched[3][3];

//using Graph = vector<vector<int>>;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
ll gcd(ll a,ll b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
ll lcm(ll a,ll b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

//Union-Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

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

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%MOD;
    }
    return res;
}

bool ok(int v, int b) {
    while (v) {
        if (v % b == 7) return false;
        v /= b;
    }
    return true;
}

int main() {
 int t;
 cin >> t;
 ll a[t],b[t];
 rep (i,t) {
     cin >> a[i] >> b[i];
 }
 rep (i,t) {
     //ll ans =  a[i] * 2;
     ll ans = b[i] - a[i] * 2;
     if (ans < 0) {
         cout << 0 << endl;
         continue;
     }
     ll cnt = (ans+1)*(ans+2)/2;
     cout << cnt << endl;

 }
}

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

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (ll)(n); i++)
#define BIT(bit, n) for (int bit = 0; bit < (1<<(n)); ++bit)
#define INF 1000000000
//配列 vector<型> 配列名(要素数, 初期値);
//二次元配列 vector<vector<型>> 配列名(要素数縦,vector<int>(要素数横, 初期値))
//配列のサイズ(二次元縦) 配列名.size(), 二次元横 配列名[0].size()
//1秒間のforループは10^8くらい
//小数点桁数 cout << fixed << setprecision(20) <<
//bit全探索 条件判定 if(bit & (1 << n))

//最大公約数
int gcd(int a, int b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}

//最小公倍数
int lcm(int a, int b)
{
  return a * b / gcd(a, b);
}

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

  cout << (N + 99) / 100 << endl;
}


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

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int H,W,K;
const ll mo=998244353;
ll dp[202020];

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

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

	cin>>H>>W>>K;

	ll ret=0;
	if(H==1) {
		ret=modpow(K,W);
	}
	else if(W==1) {
		ret=modpow(K,H);
	}
	else {
		for(i=1;i<=K;i++) {
			dp[i]=modpow(i,H);
		}
		for(i=K;i>=1;i--) {
			(dp[i]+=mo-dp[i-1])%=mo;
			(ret+=dp[i]*modpow(K+1-i,W))%=mo;
		}
	}

	cout<<ret<<endl;

}

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

#define LOCAL0
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
double el[100005], er[100005], suml[200005], sumr[200005], sumk[200005];
int n, m, k;
map<int, int> tag;
int main()
{
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
    	freopen("out.txt", "w", stdout);
	#endif
	cin >> n >> m >> k;
	int temp;
	for(int i=1; i<=k; i++){
		cin >> temp;
		tag[temp] = 1;
	}
	for(int i=1; i<=n+m; i++){
		sumk[i] = sumk[i-1]+tag[i];
	}
	for(int i=n-1; i>=0; i--){
		if(sumk[i+m]-sumk[i]==m){
			cout << "-1";
			return 0;
		}
		if(!tag[i]){
			el[i] = (suml[i+1]-suml[i+m+1]+m)/m;
			er[i] = (sumr[i+1]-sumr[i+m+1]+sumk[i+m]-sumk[i])/m;
			suml[i] = suml[i+1]+el[i];
			sumr[i] = sumr[i+1]+er[i];
		}
		else{
			suml[i] = suml[i+1];
			sumr[i] = sumr[i+1];
		}
	}
	printf("%.5f", el[0]/(1-er[0]));
	//cout << setpresion(5)<< ;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define fillarray(array, value, begin, end) fill((array) + (begin), (array) + (end) + 1, value)
#define fillvector(v, value) fill((v).begin(), (v).end(), value)
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 600050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\n\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int n, f[N], wn[N], we[N], vis[N];
int Find(int x) { return x == f[x] ? x : f[x] = Find(f[x]); }
void Union(int x, int y)
{
    int fx = Find(x), fy = Find(y);
    if (fx != fy)
    {
        wn[fx] += wn[fy];
        we[fx] += we[fy];
        f[fy] = fx;
    }
}

inline void solve()
{
    scanf("%d", &n);
    for (int i = 1; i < N; ++i)
        f[i] = i;
    for (int i = n + 1; i < N; ++i)
        wn[i] = 1;
    for (int i = 1; i <= n; ++i)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        we[i] = 1;
        Union(i, x + n), Union(i, y + n);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        int fa = Find(i);
        if (vis[fa])
            continue;
        vis[fa] = 1;
        if (we[fa] >= wn[fa])
            ans += wn[fa];
        else
            ans += max(wn[fa] - 1, 0);
    }
    printf("%d\n", ans);
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
    {
        solve();
        // if (Test)
        //     putchar('\n');
    }
    TIME__END = clock();
    program_end();
    return 0;
}

/**
 *    author:  longvu
 *    created: 06/25/21 08:42:14
**/
#include<bits/stdc++.h>

using namespace std;

#define int long long
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()

const int INF = numeric_limits<int>::max();
const int nax = (int)(400001);
const int mod = 1e9 + 7;

vector<int> adj[nax];
int deg[nax];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
        deg[u]++; deg[v]++;
    }
    deque<int> dq;
    for (int i = 1; i < nax; ++i) {
        if (deg[i] == 1) {
            dq.push_back(i);
        }
    }
    int ans = 0;
    while (!dq.empty()) {
        int u = dq.front();
        dq.pop_front();
        if (deg[u] != 1) continue;
        ans++;
        deg[u]--;
        for (auto v : adj[u]) {
            if (--deg[v] == 1) {
                dq.push_back(v);
            }
        }
    }
    for (int i = 1; i < nax; ++i) {
        if (deg[i] >= 2) {
            ans++;
        }
    }
    cout << ans;
    return 0;
}