#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define itn int
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

void solve() {
	int n = nxt();
	vector<int> a(n), b(n);
	generate(all(a), nxt);
	generate(all(b), nxt);
	long long sum = accumulate(all(b), 0ll);
	vector<int> ar[2];
	for (int i = 0; i < n; ++i) {
		ar[i % 2].push_back(a[i] - b[i]);
	}
	sort(all(ar[0]));
	sort(all(ar[1]));
	reverse(all(ar[0]));
	reverse(all(ar[1]));

	long long ans = sum;
	for (int i = 0; i < n / 2; ++i) {
		sum += ar[0][i] + ar[1][i];
		ans = max(ans, sum);
	}
	cout << ans << "\n";
}

int main() {
	int t = 1; // nxt();
	while (t--) {
		solve();
	}

	return 0;
}

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

int main() {
	long long n,m,i,j,ans,cur,res,mod=1000000007;
	cin >> n;
	vector<long long> a(n);
	vector<vector<long long>> dp(n,vector<long long>(2,0));
	for(i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a.begin(),a.end());
	cur=a[n/2];
	for(i=0; i<n; i++){
		a[i]*=2;
	}
	ans=0;
	for(i=0; i<n; i++){
		ans+=abs(a[i]-2*cur)+a[i];
	}
	//cout << cur << endl;
	//cout << ans << endl;
	double ans2=ans/(4.0*n);
	cout << setprecision(10);
	cout << ans2 << endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long n,p,ans,bs;
long long MOD=1000000007;
int main()
{
	cin>>n>>p;
	if(p==2)
	{
		if(n==1)cout<<"1";
		else cout<<"0";
	}
	else if(p==3)cout<<"2";
	else
	{
		ans=(p-1)%MOD;
		bs=(p-2)%MOD;
		n--;
		while(n)
		{
			if(n&1==1)ans=(ans*bs)%MOD;
			bs=(bs*bs)%MOD;
			n>>=1;
		}
		cout<<ans%MOD;
	}
    return 0;
}

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

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
//using namespace __gnu_pbds;

//template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());//uniform_int_distribution<int> (l, r)

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 1e5 + 123;
const int M = 1e6 + 123;
const double pi = 3.14159265359;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

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

void solve(){
    int n, p;
    cin >> n >> p;
    cout << 1ll*(p-1)*binpow(p-2, n-1) % MOD;

}

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++){
        //cout << "Case #" << i << ": ";
        solve();
    }
    #ifdef KAZAKH
      //  cout << endl << 1.0 * clock() / CLOCKS_PER_SEC << endl;
    #endif
    return 0;
}


#include<bits/stdc++.h>
#define mod 1000000007
#define INF 10000000000000001
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define vc vector
#define vll vector<long long>
#define pll pair<long long,long long>
#define pb push_back
#define all(v) v.begin(),v.end()
#define T ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define MAX 200005
#define sz(x) (ll)x.size()
#define ins insert
#define mp make_pair
#define int  long long
typedef  long long ll;
typedef long double ld;
using namespace std;

signed main()
{
  ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
  //T
  {
  	ll n;
  	cin>>n;
  	vector <ll>vec(1<<n),v;
	  	vector<ll> temp;
  	rep(i,0,(1<<n))
  	{
  		cin>>vec[i];
  		v.pb(i);

    }
	  //vector<ll> v;
	  ll le=sz(vec);
	  rep(i,1,n)
	  {
	  	//cout<<i<<endl;
	  	temp.clear();
//	  	for(int j=0;j<sz(v);j++) cout<<vec[v[j]]<<" ";
//	  	cout<<endl;
	  	for(int j=0;j<le;j+=2)
	  	{
	  		if(vec[v[j]]>vec[v[j+1]]) temp.pb(v[j]);
	  		else temp.pb(v[j+1]);
        }
        v=temp;
        le=sz(temp);
	  }
	  if(vec[v[0]]>vec[v[1]]) cout<<v[1]+1<<endl;
	  else cout<<v[0]+1<<endl;
  }

}

/*   Har Har Mahadev  */

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef priority_queue<ll> pqll;
int INF = 1000000005;
#define lab(i,a,b) for(i=a;i<=b;i++)
#define bal(i,a,b) for(i=b;i>=a;i--)
#define yep cout<<"Yes\n"
#define nope cout<<"No\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define bp pop_back
#define fp pop_front
#define se(v) v.begin(), v.end()
#define fst ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define tc int t;cin>>t;while(t--)
#define fceil(a,b) ceil((ld)a/(ld)b)
#define dis(v) for(auto it:v)cout<<it<<" "
bool isPrime(ll n){if(n <= 1)return false;if(n <= 3)return true;if(n%2==0||n%3==0)return false;for(ll i=5;i*i<= n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
bool cmp(pll &a, pll &b){ if(a.ss == b.ss)return a.ff < b.ff;return a.ss < b.ss;}
int main()
{
    fst

      double v,t,s,d;
      cin>>v>>t>>s>>d;
      d=d/v;
      if(d>=t && d<=s)nope;
      else yep;

    return 0;
}


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

#define _GLIBCXX_DEBUG
// 2の27乗＝１億３千万
#define rep(i, n, N) for (int i = n; i < (int)(N); i++)
#define ascending(array) sort(array.begin(), array.end())
#define descending(array) sort(array.rbegin(), array.rend())
#define log(name, message) cout << name << " = " << message << endl
#define out(content) cout << content << endl
#define max(array) *max_element(array.begin(), array.end())
#define min(array) *min_element(array.begin(), array.end())
#define roundUp(a, b) (a + (b - 1)) / b
#define element(array) \
  for (auto&& el : array) log("el", el)

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

  deque<char> deq;
  bool rev = false;
  for (auto&& el : S) {
    if (el == 'R') {
      rev = !rev;
    } else {
      if (rev) {
        deq.push_front(el);
      } else {
        deq.push_back(el);
      }
    }
  }
  if (rev) reverse(deq.begin(), deq.end());

  string T;
  if (deq.size()) {
    for (auto&& el : deq) {
      if (T.size() && T.back() == el)
        T.pop_back();
      else
        T.push_back(el);
    }
    out(T);
  } else {
    out("");
  }
}

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

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;

template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define tm (tl+tr)/2
#define child 2*v
#define ceils(s,n) (s+n-1)/n
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

const int MOD = 1e9 + 7, INF = INT_MAX, N = 3e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
ll seg[4*N];
ll a[N],n,query;
void build(ll v,ll tl,ll tr){
    if(tl==tr){
        seg[v]=a[tl];
    }
    else{
        build(child,tl,tm);
        build(child+1,tm+1,tr);
        seg[v]=(seg[child]^seg[child+1]);
    }
}
void update(ll v,ll tl,ll tr,ll pos,ll val){
    if(tl==tr){
        seg[v]=val^a[tl];
    }
    else{
        if(pos<=tm){
            update(child,tl,tm,pos,val);
        }
        else{
            update(child+1,tm+1,tr,pos,val);
        }
        seg[v]=(seg[child]^seg[child+1]);
    }
}
ll rquery(ll v,ll tl,ll tr,ll ql,ll qr){
    if(ql>qr){
        return 0;
    }
    if(ql==tl and qr == tr){
        return seg[v];
    }
    return (rquery(child,tl,tm,ql,min(qr,tm))^rquery(child+1,tm+1,tr,max(ql,tm+1),qr));
}

int main() {
    fast();
    cin >> n >> query;
    f(i,1,n+1){
        cin >> a[i];
    }
    build(1,1,n);
    ll index,val,ql,qr;
    f(i,0,query){
        ll type;
        cin >> type;
        if(type==1){
            cin >> index >> val;
            update(1,1,n,index,val);
            a[index] = a[index] ^ val;
        }
        else{
            cin >> ql >> qr;
            cout<<rquery(1,1,n,ql,qr)<<edl;
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using i64 = long long;
#define REP(i, n) for (int i = 0, REP_N_ = int(n); i < REP_N_; ++i)
#define ALL(x) std::begin(x), std::end(x)

template <class T>
inline bool chmax(T &a, T b) {
  return a < b and ((a = std::move(b)), true);
}
template <class T>
inline bool chmin(T &a, T b) {
  return a > b and ((a = std::move(b)), true);
}

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

using namespace std;

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

  int n, m;
  cin >> n >> m;
  vector<int> w(n);
  cin >> w;
  map<int, int> vlmax;
  int lmax = 0;
  int vmin = 1e9;
  REP(i, m) {
    int l, v;
    cin >> l >> v;
    chmax(lmax, l);
    chmin(vmin, v);

    auto it = vlmax.lower_bound(v);
    if (it != vlmax.begin() and prev(it)->second >= l) {
      continue;
    }
    while (it != vlmax.end() and it->second <= l) {
      it = vlmax.erase(it);
    }
    chmax(vlmax[v], l);
  }
  if (vmin < *max_element(ALL(w))) {
    cout << -1 << endl;
    exit(0);
  }

  auto get_len = [&](int w) -> int {
    auto it = vlmax.lower_bound(w);
    if (it == vlmax.begin()) return 0LL;
    --it;
    return it->second;
  };

  vector<int> camels(n);
  REP(i, n) { camels[i] = i; }

  int ans = (n - 1) * lmax;
  do {
    vector<int> pos(n);
    for (int i = 1; i < n; ++i) {
      int w_sub = w[camels[i]];
      for (int j = i - 1; j >= 0; --j) {
        w_sub += w[camels[j]];
        int len = get_len(w_sub);
        chmax(pos[i], pos[j] + len);
      }
    }
    chmin(ans, pos[n - 1]);
  } while (next_permutation(ALL(camels)));

  cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
#define repc(i,f,n) for(char i=(f); (i) <= (n); i++)
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define P pair<int, int>
#define Pl pair<ll, ll>
#define dvec vector<vector<ll>>
#define OUT(x) cout << x << endl; return 0;
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmaxe(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 ll MOD = 1000000007ll;
const ll INF = 1e+18;
const int iINF = 1e9;
const double EPS = 1e-8;

int main()
{
  int N; cin >> N;
  string S; cin >> S;
  string cmp = "";
  int num = S.size();

  rep(i, 0, num){
    cmp.push_back(S[i]);
    int sz = cmp.size();
    if(sz >= 3 && cmp.substr(sz - 3) == "fox") rep(k, 0, 3) cmp.pop_back();
  }

  cout << cmp.size() << endl;
}


#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (long long i = (s); i < (long long)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Pll = pair<ll, ll>;

int main() {
    int n;
    cin >> n;
    vector<int> a;
    a.resize(n);
    for(auto & x: a) cin >> x;

    int res = 0;

    rep(l, n){
        int minim = a[l];
        rep2(r, l, n){
            minim = min(minim, a[r]);
            res = max(res, minim * (int)(r-l+1LL));
        }
    }

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

#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define all(x) (x.begin(),x.end())
#define rep(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define endl "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define sz(a) (int)a.size()
#define Q(x) for(int i=0;i<x;i++)
#define show(x) for(auto i:x)cout<<i<<" ";cout<<endl;
// ctrl + shift + q -- stop execution
const ll mod = 1e9 + 7;
using namespace std;

void solve() {

}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	/*int t;
	cin >> t;
	while (t--) {
		solve();
	}*/
	/*int n, ans = -1;
	double x;
	cin >> n >> x;
	double tot = 0;
	bool flag = false;
	rep(i, 0, n) {
		double a, b;
		cin >> a >> b;
		tot = tot + (a * (b / 100));
		if (tot > x && flag == false) {
			ans = i + 1;
			flag = true;
		}
	}
	deb(tot);
	cout << ans << endl;*/

	int n;
	cin >> n;
	vi a(n);
	rep(i, 0, n)cin >> a[i];

	ll ans = n * (*min_element(a.begin(), a.end()));
	//deb(ans);
	for (int i = 0; i < n; i++) {
		int area = 1;
		for (int j = i + 1; j < n; j++) {
			if (a[j] >= a[i])area++;
			else break;
		}
		for (int k = i - 1; k >= 0; k--) {
			if (a[k] >= a[i])area++;
			else break;
		}
		ll tempans = area * a[i];
		ans = max(ans, tempans);
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;

int main(int argc, char *argv[])
{
	int n;
	cin >> n;

	vector<char> p(n + 1, 1); p[0] = p[1] = 0;
	for (long long i = 2; i * i < n + 1; i += 1 + (i & 1))
		if (p[i]) for (long long j = i * i; j < n + 1; j += i) p[j] = 0;

	vector<int> ans(n);
	ans[0] = 1;
	map<int, set<int>> s;
	for (int i = 1; i < n; i++) {
		if (p[i + 1]) {
			ans[i] = 2;
			for (int j = (i + 1) * 2; j <= n; j += i + 1) s[j].insert(2);
		}
	}

	for (int i = 0; i < n; i++) {
		if (ans[i]) continue;
		int c = 3;
		for ( ; s[i + 1].count(c) ; c++) {}
		ans[i] = c;
		for (int j = (i + 1) * 2; j <= n; j += i + 1) s[j].insert(c);
		s.erase(i + 1);
	}

	for (int i = 0; i < n; i++) cout << (i ? " " : "") << ans[i];
	cout << endl;

	return 0;
}

#include <iostream>

int main()
{
    unsigned long long N;
    std::cin >> N;
    unsigned long long ans = 0;
    unsigned long long t = 1;
    for (auto i = 0ull; i < 5; ++i)
    {
        t *= 1000;
        if (N >= t)
        {
            ans += N;
            ans -= (t - 1);
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
template<typename T>void ckmn(T&a,T b){a=min(a,b);}
template<typename T>void ckmx(T&a,T b){a=max(a,b);}
void rd(int&x){scanf("%i",&x);}
void rd(ll&x){scanf("%lld",&x);}
void rd(char*x){scanf("%s",x);}
void rd(ldb&x){scanf("%lf",&x);}
void rd(string&x){scanf("%s",&x);}
template<typename T1,typename T2>void rd(pair<T1,T2>&x){rd(x.first);rd(x.second);}
template<typename T>void rd(vector<T>&x){for(T&i:x)rd(i);}
template<typename T,typename...A>void rd(T&x,A&...args){rd(x);rd(args...);}
template<typename T>void rd(){T x;rd(x);return x;}
int ri(){int x;rd(x);return x;}
template<typename T>vector<T> rv(int n){vector<T> x(n);rd(x);return x;}
template<typename T>void ra(T a[],int n,int st=1){for(int i=0;i<n;++i)rd(a[st+i]);}
template<typename T1,typename T2>void ra(T1 a[],T2 b[],int n,int st=1){for(int i=0;i<n;++i)rd(a[st+i]),rd(b[st+i]);}
template<typename T1,typename T2,typename T3>void ra(T1 a[],T2 b[],T3 c[],int n,int st=1){for(int i=0;i<n;++i)rd(a[st+i]),rd(b[st+i]),rd(c[st+i]);}
void re(vector<int> E[],int m,bool dir=0){for(int i=0,u,v;i<m;++i){rd(u,v);E[u].pb(v);if(!dir)E[v].pb(u);}}
template<typename T>void re(vector<pair<int,T>> E[],int m,bool dir=0){for(int i=0,u,v;i<m;++i){T w;rd(u,v,w);E[u].pb({v,w});if(!dir)E[v].pb({u,w});}}

const int N=105;
char s[N],t[N];
char win(char a,char b){
	if(a==b)return a;
	set<char> st={a,b};
	if(st.count('R')&&st.count('P'))return 'P';
	if(st.count('R')&&st.count('S'))return 'R';
	return 'S';
}
int main(){
	int n,k;
	rd(n,k);
	rd(s);
	for(int j=0,sz=1;j<k;j++,sz=sz*2%n){
		for(int i=0;i<n;i++)
			t[i]=win(s[i],s[(i+sz)%n]);
		for(int i=0;i<n;i++)s[i]=t[i];
	}
	printf("%c\n",s[0]);
	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 hh[200];
  for (unsigned char i = 0; i < n; i++) hh[i] = getchar_unlocked() - 80;
  for (unsigned char i = 0; i < k; i++) {
    for (unsigned char j = 0; j < n; j++) {
      if (i & 1)
        hh[j] = H[(hh[(j * 2) % n + n] * 4) + hh[((j * 2) + 1) % n + n]];
      else
        hh[j + n] = H[(hh[(j * 2) % n] * 4) + hh[((j * 2) + 1) % n]];
    }
  }
  if (k & 1)
    putchar_unlocked(hh[n] + 80);
  else
    putchar_unlocked(*hh + 80);
}


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

//shorthands
#define ll                long long
#define ld                long double
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define mkp               make_pair
#define fastio            ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (ll)((x).size())
#define fr                first
#define sc                second
#define vll               vector <ll>
#define vpll              vector < pair<ll,ll> >
#define vect(a,n)         vll a(n); rep(i,0,n) cin>>a[i];
#define rep(i,a,b)        for(ll i = a; i < b; i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define PI                3.14159265358979323846

//Debug
#define printall(a) rep(i,0,a.size()) cout<<a[i]<<" "; cout<<"\n";

//Constants
const int mod = (int) 1e9 + 7 ;
const int INF = (int) 1e18 ;

//Input-Output File
void fileio(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif
}

ll modulo_binary_exp(ll a , ll b , ll m) {
    ll res = 1;
    while(b) {
        if(b % 2 == 0) {
            b = b/2;
            a = ((a % m)*(a % m)) % m;
        }
        else
        {
            b--;
            res = ((res % m)*(a % m)) % m;
        }
    }

    return res;
}

void solve() {
    ll a,b,c;
    cin >> a >> b >> c;
    ll p = modulo_binary_exp(b , c , 100);
    p += 100;
    ll q = modulo_binary_exp(a , p , 10);
    cout << q;
}

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

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<functional>
#include<iomanip>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define bpc(x) __builtin_popcount(x)
#define bpcll(x) __builtin_popcountll(x)
#define fps(n) fixed << setprecision(n)
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define eldn endl
#define elnd endl
#define icn cin
#define cotu cout
#define Endl endl
#define EE endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b){if(b<a){a=b; return 1;} return 0;}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int a,b,c,d; cin >> a >> b >> c >> d;
    cout << b - c << endl;
    return 0;
}


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

#define ll long long int
#define pb(a) push_back(a)
#define vll vector<ll>
#define loop(i, n) for(ll i=1;i<=n;i++)
#define loop0(i, n) for(ll i=0;i<n;i++)
#define in(i) scanf("%lld", &i);
#define out(i) printf("%lld", i)
#define pll pair<ll, ll>
#define vpll vector<pair<ll, ll>>
#define mp(i, j) make_pair(i, j);
const ll mod = 1000000007;
const ll big = 2999999999999999999;
const ll small = -2999999999999999999;
void in2(ll& a, ll& b) { in(a); in(b); }
void in3(ll& a, ll& b, ll& c) { in(a); in(b); in(c); }
void swap(ll& a, ll& b) { a = a+b; b = a-b; a = a-b; }
void arrayIn(vll& a, ll& n) { loop0(i, n) in(a[i]); }

ll n;
vll a;

int main()
{
  in(n);
  a.resize(n);
  arrayIn(a, n);
  sort(a.begin(), a.end());
  ll ans = a[0]+1;
  loop(i, n-1)
  {
    ans = (ans*(a[i]-a[i-1]+1))%mod;
  }
  cout<<ans<<"\n";
}

#include<bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	int n = 1;
	for (int i = 0; i < N; i++) {
		n *= 2;
	}
	vector<int> A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	vector<pair<int, int>> v(n);
	for (int i = 0; i < n; i++) {
		v[i].first = A[i];
		v[i].second = i;
	}
	for (int i = 0; i < N - 1; i++) {
		vector<pair<int, int>> tmp;
		for (int i = 0; i < n; i += 2) {
			if (v[i].first > v[i + 1].first) {
				tmp.emplace_back(v[i].first, v[i].second);
			}
			else {
				tmp.emplace_back(v[i + 1].first, v[i + 1].second);
			}
		}
		v = tmp;
		n /= 2;
	}
	cout << (v[0].first < v[1].first ? v[0].second + 1 : v[1].second + 1) << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template<class T> using V = vector<T>;
using VI = V<int>;
using VL = V<ll>;
using VS = V<string>;
template<class T> using PQ = priority_queue<T, V<T>, greater<T>>;
using graph = V<VI>;
template<class T> using w_graph = V<V<pair<int, T>>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#ifdef _DEBUG
#define line cout << "-----------------------------\n"
#define stop system("pause")
#endif
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, V<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline V<T> vec(size_t a) { return V<T>(a); }
template<class T>inline V<T> defvec(T def, size_t a) { return V<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return V<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return V<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const V<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const V<V<T>>& v) { for (auto& a : v)print(a); }
template<class T>inline T sum(const V<T>& a, int l, int r) { return a[r] - (l == 0 ? 0 : a[l - 1]); }
template<class T>inline void END(T s) { print(s); exit(0); }
void END() { exit(0); }

int main() {
    init();

    int n; cin >> n;
    string s, t; cin >> s >> t;

    set<int> a, b;
    FOR(i, 0, n) {
        if (s[i] == '0')a.insert(i);
        if (t[i] == '0')b.insert(i);
    }
    if (a.size() != b.size())END(-1);
    int ans = 0;
    for (; !a.empty(); a.erase(a.begin()), b.erase(b.begin())) {
        ans += (*a.begin() != *b.begin());
    }
    print(ans);

    return 0;
}

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

long long res=0;
int main(){
	long double x,y,r;
	cin>>x>>y>>r;
	long long L=ceil(x-r),R=floor(x+r);
    r+=1e-14;
	for(int i=L;i<=R;i++){
		if(r*r-(1.0*i-x)*(1.0*i-x)>=0){
            long double yy=sqrt(r*r-(1.0*i-x)*(1.0*i-x));
            long long tmp=floor(y+yy)-ceil(y-yy)+1;
            res+=tmp;
		}

	}
	cout<<res;
	return 0;
}


#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front

// #define fisier 1

using namespace std;

typedef long long ll;

const int mod = 1000000007;
const double dancila = 3.14159265359; // PI
const double eps = 1e-9;

int n;
ll k;

vector<pair<ll, ll> > v;

int main()
{
	#ifdef fisier
		ifstream cin("input.in");
		ofstream cout("output.out");
	#endif

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

	cin >> n >> k;
	for(int i = 1; i <= n; ++i)
	{
		ll a, b;
		cin >> a >> b;
		v.push_back({a, b});
	}
	sort(v.begin(), v.end());
	v.push_back({(1LL<<62), 0});

	ll current_place = 0;
	for(int i = 0; i < v.size(); ++i)
	{
		if(v[i].first - current_place > k)
		{
			current_place += k;
			break;
		}

		k -= (v[i].first - current_place);
		k += v[i].second;
		current_place = v[i].first;

	}

	cout << current_place;

	return 0;
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<pll> P(N);
    REP(i,0,N) cin >> P[i].first >> P[i].second;

    ASC(P);
    ll p = 0;
    bool f = true;
    REP(i,0,N) {
        ll a = P[i].first, b = P[i].second;
        if(K >= a - p) {
            K = K - (a - p) + b;
            p = a;
        }
        else {
            p += K;
            f = false;
            break;
        }
    }
    if(f) p += K;
    PR(p);

    return 0;
}

/*

*/


/*

	Date-Time: 27-03-2021 21:01:15
	author: Pratik Jain

*/

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

/***********************competetive programming setup*******************************/

#define INF 1e9
#define all(v) v.begin() , v.end()
#define pb push_back
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define test(t) int t; cin>>t; while(t--)
#define lower(str) transform(str.begin() , str.end() , str.begin() , ::tolower)
#define upper(str) transform(str.begin() , str.end() , str.begin() , ::toupper)
#define loop(i , startloop , endloop) for(i = startloop ; i < endloop ; i++)
#define rloop(i , startloop , endloop) for(i = startloop ; i > endloop ; i--)
#define SMALL(c) c >= 'a' && c <= 'z'
#define CAP(c) c >= 'A' && c <= 'Z'
#define DIGIT(c) c >= '0' && c <= '9'
#define sz(v) v.size()
#define SORT(v) sort(v.begin() , v.end())
#define is_vowel(c) c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'
#define YN(var) if(var) cout << "YES"; else cout << "NO";
#define ln cout << '\n'
#define set_bits(n) __builtin_popcount(n)
#define trail_zero(n) __builtin_ctz(n)
#define lead_zero(n) __builtin_clz(n)

void input_output() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif
}
/* competetive programming setup */

// check whether a number is prime
bool is_prime(int n) {
	if (n < 2) return false;
	int i;
	loop(i , 2 , (int)sqrt(n) + 1) {
		if (n % i == 0)
			return false;
	}
	return true;
}

//check whether a string is a palindrome
bool is_palindrome(string s) {
	int i;
	loop(i , 0 , s.size() / 2) {
		if (s[i] != s[s.size() - i - 1])
			return false;
	}
	return true;
}

// sieve of eratosthenes
int no_of_primes = 20;
vector<bool> prime(no_of_primes + 1 , true);
vi prime_nums;
void sieve_of_erat() {
	prime[0] = false;
	prime[1] = false;
	int i , j;
	loop(i , 2 , (int)sqrt(no_of_primes) + 1) {
		if (prime[i] == false) continue;
		j = 2 * i;
		while (j <= no_of_primes) {
			prime[j] = false;
			j += i;
		}
	}
	loop(i , 0 , no_of_primes + 1) {
		if (prime[i] == true)
			prime_nums.pb(i);
	}
}
// bfs with adj matrix
vector<vector<int> > adj;
vector<bool> visited;
int bfs(int si , int n) {
	vi dist(n + 1 , -1);
	dist[si] = 0;
	queue<int> q;
	q.push(si);
	int i;
	while (!q.empty()) {
		int temp = q.front();
		q.pop();
		for (i = 0 ; i < adj[temp].size() ; i++) {
			if (!visited[adj[temp][i]]) {
				q.push(adj[temp][i]);
				dist[adj[temp][i]] = dist[temp] + 1;
				visited[adj[temp][i]] = true;
			}
		}
	}
	int ans = 0;
	loop(i , 0 , n + 1) if (dist[i] != -1) ans++;
	return ans;
}
// swap two numbers
void swap(int &a , int &b) {
	int temp = a;
	a = b;
	b = temp;
}
//sort array in reverse order
bool sort_rev(int a , int b) {
	return a > b;
}
/***********************competetive programming setup*******************************/

// "<<" is "left" shift(increase value)
// ">>" is "right" shift(decrease value)

// this is 'solve' function where main logic is written //

void solve() {
	int h , w , x , y;
	cin >> h >> w >> x >> y;
	vector<string> s(h);
	int i , j;
	loop(i , 0 , h) {
		cin >> s[i];
	}
	int ans = 1;
	loop(i , y , w) {
		if (s[x - 1][i] == '.') ++ans;
		else break;
	}
	rloop(i , y - 2 , -1) {
		if (s[x - 1][i] == '.') ++ans;
		else break;
	}
	loop(i , x , h) {
		if (s[i][y - 1] == '.') ++ans;
		else break;
	}
	rloop(i , x - 2 , -1) {
		if (s[i][y - 1] == '.') ++ans;
		else break;
	}
	cout << ans;
	ln;
}

int main() {
	// comment below line while submitting the code //
	input_output();
	// sieve_of_erat();
	// test(t)
	solve();
}

#include<bits/stdc++.h>
using namespace std;
char a[105][105];
int main(){
    int h,w,x,y,sum=0;
    cin>>h>>w>>x>>y;
    getchar();
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            scanf("%c",&a[i][j]);
        }
        getchar();
    }
    for(int i=x-1;i>=1;i--){
        if(a[i][y]=='#')break;
        else sum++;
    }

    for(int i=x+1;i<=h;i++){
        if(a[i][y]=='#')break;
        else sum++;
    }

    for(int i=y-1;i>=1;i--){
        if(a[x][i]=='#')break;
        else sum++;
    }

    for(int i=y+1;i<=w;i++){
        if(a[x][i]=='#')break;
        else sum++;
    }
    cout<<sum+1<<endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll> ;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define inf 1LL<<60;
ll min(ll a,ll b){return a>=b ? b:a;}
ll max(ll a,ll b){return a>=b ? a:b;}

ll dist[1<<18];

typedef struct{
    ll to;
    ll c;
    ll d;
}town;

vector<town> G[1LL<<18];

ll func(ll t,ll d){
    ll rd=sqrt(d);
    ll ret=d/(t+1);
    for (ll i=-10;i<=10;++i){
        if (rd+i-t-1<0) continue;
        ll k=rd-t+i-1+d/(rd+i);
        ret=min(ret,k);
    }
    return ret;
}

void dijkstra(ll st){
    priority_queue<P,vector<P>,greater<>> q;
    dist[st]=0;
    q.push(P(0,st));
    while (!q.empty()){
        ll D=q.top().first;
        ll pos=q.top().second;q.pop();
        if (dist[pos]<D) continue;
        rep(i,(ll)G[pos].size()){
            ll to=G[pos][i].to;
            ll cost=G[pos][i].c;
            ll di=G[pos][i].d;
            ll ct=func(dist[pos],di);
            if (dist[to]>dist[pos]+ct+cost){
                dist[to]=ct+cost+dist[pos];
                q.push(make_pair(dist[to],to));
            }
        }
    }
}

int main(){
    ll n,m;
    cin >> n >> m;
    rep(i,m){
        ll a,b,c,d;
        cin >> a >> b >> c >>d;
        a--;b--;
        G[a].push_back(town({b,c,d}));
        G[b].push_back(town({a,c,d}));
    }
    rep(i,n+1) dist[i]=1LL<<60;
    dijkstra(0);
    if (dist[n-1]==1LL<<60){
        cout << -1 << endl;
    }
    else cout << dist[n-1] << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

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

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  vector<vector<int>> v(26);
  vector<vector<int>> dp(h, vector<int>(w, INF));
  priority_queue<P, vector<P>, greater<P>> que;
  int gh = -1, gw = -1;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '#' || s[i][j] == '.') continue;
      if (s[i][j] == 'S') {
        que.push(make_pair(0, i * w + j));
        dp[i][j] = 0;
      } else if (s[i][j] == 'G') {
        gh = i; gw = j;
      } else {
        v[s[i][j] - 'a'].emplace_back(i * w + j);
      }
    }
  }
  vector<int> ok(26, 0);

  while (!que.empty()) {
    auto p = que.top(); que.pop();
    int i = p.second / w, j = p.second % w;
    if (dp[i][j] < p.first) continue;
    for (int k = 0; k < 4; k++) {
      int ni = i + dx[k], nj = j + dx[(k + 1) % 4];
      if (ni < 0 || nj < 0 || ni >= h || nj >= w) continue;
      if (s[ni][nj] == '#') continue;
      if (dp[ni][nj] > dp[i][j] + 1) {
        dp[ni][nj] = dp[i][j] + 1;
        que.push(make_pair(dp[ni][nj], ni * w + nj));
      }
    }
    if (s[i][j] == '.' || s[i][j] == 'S' || s[i][j] == 'G') continue;
    if (ok[s[i][j] - 'a']) continue;
    for (auto e : v[s[i][j] - 'a']) {
      if (dp[e / w][e % w] > dp[i][j] + 1) {
        dp[e / w][e % w] = dp[i][j] + 1;
        que.push(make_pair(dp[e / w][e % w], e));
      }
    }
    ok[s[i][j] - 'a'] = 1;
  }

  cout << (dp[gh][gw] == INF ? -1 : dp[gh][gw]) << endl;
  return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define arep(i, v) for (auto i : v)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
// #include <atcoder/all>
// using namespace atcoder;
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline void dump(T& v) {
    irep(i, v) { cout << (*i) << ((i == --v.end()) ? '\n' : ' '); }
}
template <class T, class U>
inline void dump(map<T, U>& v) {
    irep(i, v) { cout << i->first << " " << i->second << '\n'; }
}
inline string getline() {
    string s;
    fflush(stdin);
    getline(cin, s);
    return s;
}
inline void yn(const bool b) { b ? fin("yes") : fin("no"); }
inline void Yn(const bool b) { b ? fin("Yes") : fin("No"); }
inline void YN(const bool b) { b ? fin("YES") : fin("NO"); }
struct io {
    io() {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
template <typename Head, typename Value>
auto vectors(const Head& head, const Value& v) {
    return vector<Value>(head, v);
}
template <typename Head, typename... Tail>
auto vectors(Head x, Tail... tail) {
    auto inner = vectors(tail...);
    return vector<decltype(inner)>(x, inner);
}
const int INF = INT_MAX;
constexpr ll LLINF = 1LL << 61;
constexpr ll MOD = 1000000007;  // 998244353;
constexpr ld EPS = 1e-11;

/* --------------------   ここまでテンプレ   -------------------- */

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    rep(i, 100000) {
        if (2 * a + 100 >= i + b) chmax(ans, (int)i);
    }
    fin(ans);
}

#include <bits/stdc++.h>
using namespace std;
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,-1,0,1,1,-1,-1,1};
ll dx[8] = {-1,0,1,0,1,-1,1,-1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    int sz = a.size();
    for(auto itr = a.begin(); itr != a.end(); itr++){
		cout << *itr;
        sz--;
        if(sz) cout << " ";
	}
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){
	cout << a << " " << b << "\n";
}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
void mark() {cout << "#" << "\n";}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    string t;
    while(!s.empty()){
        if(s.back() == 'x'){
            if(s.size() >= 3){
                string u;
                u.push_back(s.back());
                s.pop_back();
                if(s.back() == 'o'){
                    u.push_back(s.back());
                    s.pop_back();
                    if(s.back() == 'f'){
                        s.pop_back();
                        ans += 3;
                        rep(j,2){
                            if(!t.empty()) s.push_back(t.back()), t.pop_back();
                        }
                    }else{
                        t += u;
                    }
                }else{
                    t += u;
                }
            }else{
                break;
            }
        }else{
            t.push_back(s.back());
            s.pop_back();
        }
    }
    cout << n - ans << "\n";
}


//Aditya_14

#include <bits/stdc++.h>
#define int long long
#define loop(a, b, c) for(int a=b; a<c; a++)
#define rev(a, b) for(int a=b-1; a>=0; a--)
#define fo(a, b) for(int a=0; a<b; a++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vvi vector<vi>
#define vii vector<pair<int, int>>
#define bs binary_search
#define pii pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define ff first
#define ss second
#define mii map<int, int>
#define chmax(a, b) a=max(a, b)
#define chmin(a, b) a=min(a, b)
const int mod=1000000007;
const int maxn=1e18+7;
using namespace std;

int power(int b,int p)
{
	b %= mod;

	int ans = 1;

	while(p > 0)
	{
		if (p%2 == 1)
		{
			ans *= b;
			ans %= mod;
		}

		b *= b;
		b %= mod;
		p /= 2;
	}

	return ans;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        vii x(n);
        vii y(n);
        fo(i, n)
        {
            cin >> x[i].first;
            cin >> y[i].first;
            x[i].ss=i;
            y[i].ss=i;
        }
        sort(all(x));
        sort(all(y));
        int a=x[n-1].ff-x[0].ff;
        int b=y[n-1].ff-y[0].ff;
        int ans=0;
        //cout << a << x[n-1].ss << x[0].ss << b << y[n-1].ss << y[0].ss << " ";
        if(((x[n-1].ss!=y[n-1].ss) || (x[n-1].ss!=y[0].ss)) && ((x[0].ss!=y[n-1].ss) || (x[0].ss!=y[0].ss)))
        {
            if(a!=b) ans=min(a, b);
        }
            int c, d, e, f;
            c=x[n-2].ff-x[0].ff;
            d=x[n-1].ff-x[1].ff;
            e=y[n-1].ff-y[1].ff;
            f=y[n-2].ff-y[0].ff;
            ans=max({ans, c, d, e, f});
            cout << ans;
    }
    return 0;
}

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

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

  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++) cin >> x.at(i) >> y.at(i);

  if (n == 3) {
    vector<int> ans;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        ans.emplace_back(max(abs(x[i] - x[j]), abs(y[i] - y[j])));
      }
    }
    sort(ans.rbegin(), ans.rend());
    cout << ans.at(1) << '\n';
    return 0;
  }

  vector<pair<int, int>> x2(n), y2(n);
  for (int i = 0; i < n; i++) {
    x2.at(i) = make_pair(x.at(i), i);
    y2.at(i) = make_pair(y.at(i), i);
  }

  sort(x2.begin(), x2.end());
  sort(y2.begin(), y2.end());

  set<int> st;
  for (auto i : {0, 1, n - 1, n - 2}) {
    st.insert(x2.at(i).second);
    st.insert(y2.at(i).second);
  }

  vector<int> ans;
  for (auto it = st.begin(); it != st.end(); it++) {
    for (auto it2 = it; it2 != st.end(); it2++) {
      if (it == it2) continue;
      ans.emplace_back(max(abs(x[*it] - x[*it2]), abs(y[*it] - y[*it2])));
    }
  }

  sort(ans.rbegin(), ans.rend());
  cout << ans.at(1) << '\n';
}


#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> xs, ys;
    for (int i = 0; i < n; ++i) {
        char c;
        cin >> c;
        if (c == '0') xs.push_back(i);
    }
    for (int i = 0; i < n; ++i) {
        char c;
        cin >> c;
        if (c == '0') ys.push_back(i);
    }

    if (xs.size() != ys.size()) {
        cout << "-1\n";
        return;
    }

    int ans = 0;
    for (int i = 0; i < (int)xs.size(); ++i) {
        if (xs[i] != ys[i]) ++ans;
    }

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

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

    solve();

    return 0;
}

#include<bits/stdc++.h>

using namespace std;

namespace Tzh{

	typedef long long ll;

	const int maxn=1000010;
	int pos[maxn];

	void work(){
		int n,ans=0;
		cin>>n;
		string a,b;
		cin>>a>>b;
		int cnt=0,tmp=0;
		for(int i=1;i<=n;i++) if(a[i-1]=='0') pos[++cnt]=i;
		for(int i=1;i<=n;i++) if(b[i-1]=='0'){
			tmp++;
			ans+=(i!=pos[tmp]);
		}
		if(cnt!=tmp) cout<<-1;
		else cout<<ans;
		return ;
	}
}

int main(){
	Tzh::work();
	return 0;
}


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

int main() {

    int  k;
    string n;

    cin >> n >> k;

    string s = n;
    rep(i,k) {

        string s1,s2;

        sort(s.begin(), s.end());
        s1 = s;
        sort(s.begin(), s.end(), greater<char>());

        s2 = s;

        int x = stoi(s2) - stoi(s1);

        s = to_string(x);

    }

    cout << s << endl;

}

#include <iostream>
using namespace std;

int main() {

	int a;
  cin >> a;

  int b;
  cin >> b;

  int c;
  c = 2 * a + 100 - b;

  cout << c;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(void){
    int cnt;
    string S;
    string buf,zone = "ZONe";
    cin >> S;

    for(int i=0;i<9;i++){
        buf = S.substr(i,4);
        if(buf==zone){
            cnt++;
        }
    }

    cout << cnt << endl;
}

#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cctype>
#include<cstdlib>
#include<map>
#include<algorithm>
#include<set>
#define fs(i,x,y) for(int i=(x),_=(y);i<=_;++i)
#define fn(i,x,y) for(int i=(x),_=(y);i>=_;--i)
#define tor(i,v,x) for(int i=head[x],v=to[i];i;i=nxt[i],v=to[i])
#define Li inline
#define R register int
#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define mpi(x,y) make_pair(x,y)
#define pi pair<int,int>
//#define int ll
#define DEBUG printf("HHHH,%d\n",__LINE__)
using namespace std;
typedef long long ll;
template<typename T>
void read(T &x){
	x=0;char ch=getchar();bool f=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	x=f?-x:x;
}

const int N=2e3+7;
int n,m;
int a[N];
set<int>b;

int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}

void fctize(int x){
	int sqr=sqrt(x);
	fs(i,1,sqr){
		if(x%i==0){
			b.insert(i);
			b.insert(x/i);
		}
	}
}

signed main(){
	read(n);fs(i,1,n){
		read(a[i]);fctize(a[i]);
	}
	int ans=0;
//	cout<<tot<<endl;
	for(auto v:b){
		int now=0,mn=1e9+7;
		fs(j,1,n){
			if(a[j]%v==0)now=gcd(a[j],now);
			else mn=min(mn,a[j]);
		}
		if(now==v&&v<=mn)++ans;
	}
	cout<<ans;
	return 0;
}


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

int main(){
    ll n,k,m;
    cin >> n >> k >>m;
    int i,j;
    ll yotei = m*n;
    for(i=0;i<n-1;i++){
        ll ten;
        cin >> ten;
        yotei-=ten;
    }
    if(yotei<=0)cout << 0 <<endl;
    else if(yotei>k)cout << -1 << endl;
    else cout << yotei << endl;

    return 0;
 }

#include <bits/stdc++.h>
typedef long long int   LL;
typedef long double     LD;
#define nl              '\n'
#define ff              first
#define ss              second
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define PI              2.0*acos(0.0)
#define pii             pair<int,int>
#define pll             pair<long long,long long>
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define FOR(i,a)        for(int i=0;i<a;i++)
//#pragma                 GCC optimize("Ofast,no-stack-protector")
//#pragma                 GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma                 GCC optimize("unroll-loops")
#define boost           ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define sss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)
using namespace std;
int dx[]={0,0,-1,1};
int dy[]={1,-1,0,0};

//--------------------------code starts here---------------------------------------
const int maxn=1e5+5;

void solve(int test)
{
    LL a,b,c,d;
    cin>>a>>b>>c>>d;
    int cnt=0;
    LL r=0;
    Rep(i,1,1e6)
    {
        if(a<=d*r)
        {
            break;
        }

        a+=b;
        r+=c;
        cnt++;
    }

    if(cnt==1e6)
        cnt=-1;

    cout<<cnt<<nl;
}

int main()
{
	int test=1;
    //si(test);
    Rep(i,1,test)
    {
        solve(test);
    }

	return 0;
}


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

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

    int a, b, c;
    cin >> a >> b >> c;
    cout << (7-a) + (7-b) + (7-c);

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define M1 1000000007
#define M2 998244353
#define INF 1e18
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<int>
#define vlli vector <long long>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
/********************************************************************/
const double pi = 3.1415926535;
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
/********************************************************************/
ll int gcd(ll int a,ll int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main() {
	// your code goes here
	FAST();
	int a,b,c;
	cin>>a>>b>>c;
	cout<<21-(a+b+c)<<endl;

	return 0;
}


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

#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
int powmod(int a,int l, int md){a%=md; int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
int invmod(int a, int md){return powmod(a,md-2,md);}
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector< ii > vii;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return (((a%md)*(b%md))%md+md)%md;}
int addmod(int a, int b, int md) {return ((a%md+b%md)%md+md)%md;}
int submod(int a, int b, int md) {return (((a%md-b%md)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
priority_queue<int, vector<int>, greater<int> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

signed main(void)
{
	IOS;
	string s; cin>>s;
	int n = s.length();
	int sum=0;
	for(int i = 0; i < n; i++)
		sum += (s[i]-'0')%3;
	if(sum%3==0) {
		cout<<0<<endl;
		return 0;
	}
	if(n==1) {
		cout<<-1<<endl;
		return 0;
	}
	for(int i = 0; i < n; i++) {
		if((sum-(s[i]-'0'))%3==0) {
			cout<<1<<endl;
			return 0;
		}
	}
	if(n==2) {
		cout<<-1<<endl;
		return 0;
	}
	for(int i = 0; i < n; i++) {
		for(int j = i+1; j < n; j++) {
			if((sum-(s[i]-'0')-(s[j]-'0'))%3==0) {
				cout<<2<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}

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

int digitnum(long long int n) {
    int ans = 0;
    while (1) {
        n /= 10;
        ans++;
        if (n == 0) return ans;
    }
}

int main() {
    long long int n;
    long long int a = 0, b = 0, c = 0, ans=0;
    cin >> n;
    long long int m = n;
    while (m > 0) {
        if ((m % 10) % 3 == 0)
            a++;
        else if ((m % 10) % 3 == 1)
            b++;
        else
            c++;
        m /= 10;
    }
    if (n % 3 == 0)
        ans = 0;
    else if (n % 3 == 1) {
        if (b > 0) {
            if (digitnum(n) == 1)
                ans = -1;
            else
                ans = 1;
        } else {
            if (digitnum(n) <= 2)
                ans = -1;
            else
                ans = 2;
        }
    } else {
        if (c > 0) {
            if (digitnum(n) == 1)
                ans = -1;
            else
                ans = 1;
        } else {
            if (digitnum(n) <= 2)
                ans = -1;
            else
                ans = 2;
        }
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(40)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

bool solve(vector<ll> &A) {
    ll N = A.size();
    vector<ll> ans;
    REP(i, N * N) {
        bool sorted = true;
        REP(j, N - 1) {
            if (A[j] > A[j + 1]) {
                sorted = false;
                break;
            }
        }
        if (sorted)
            break;
        bool update = false;
        REP(j, N) {
            if (i % 2 != j % 2)
                continue;
            if (j + 1 >= N)
                break;
            if (A[j] > A[j + 1]) {
                update = true;
                swap(A[j], A[j + 1]);
                ans.push_back(j);
                break;
            }
        }
        if (!update) {
            for (ll j = N - 2; j >= 0; --j) {
                if (j % 2 == i % 2) {
                    swap(A[j], A[j + 1]);
                    ans.push_back(j);
                    break;
                }
            }
        }
#if false
        REP(j, N) {
            cout << A[j] << " ";
        }
        cout << endl;
#endif
    }

    cout << ans.size() << endl;
    REP(i, ans.size()) {
        cout << ans[i] + 1 << " ";
    }
    cout << endl;
    {
        bool sorted = true;
        REP(j, N - 1) {

            if (A[j] > A[j + 1]) {
                sorted = false;
                break;
            }
        }
        return sorted;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
#if true
    ll Q;
    cin >> Q;
    REP(_, Q) {
        ll N;
        cin >> N;
        vector<ll> A(N);
        REP(i, N) {
            cin >> A[i];
        }
        if (!solve(A)) {
            assert(false);
        }
    }
#else
    vector<ll> A;
    ll N = 8;
    REP(i, N) {
        A.push_back(i + 1);
    }
    do {
        vector<ll> v;
        REP(i, N) {
            v.push_back(A[i]);
        }
        if (!solve(v)) {
            assert(false);
        }
    } while (next_permutation(A.begin(), A.end()));
#endif
    return 0;
}

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll dp[73][(1ll<<20)+5];
int prime[73];vector<ll>req_prime;
vector<ll>bit_mask;
void init(){
  prime[0]=prime[1]=1;
  for(int i=2;i<=72;i++){
    if(prime[i]==0){
      for(int j=i*i;j<=72;j+=i)
        prime[j]=1;
    }
  }
  for(int i=2;i<=72;i++){
    if(prime[i]==0)
      req_prime.push_back(i);
  }
}
ll solve(int i,ll mask){
  if(mask!=0 && mask&(mask+1)==0)return 1;
  if(i==bit_mask.size())return 1;
  if(dp[i][mask]!=-1)return dp[i][mask];
  ll ans=0;
  ans+=solve(i+1,mask);
  if((bit_mask[i]&mask)==0)ans+=solve(i+1,(bit_mask[i]|mask));
  return dp[i][mask]=ans;
}
int main(){
  ll a,b;
  cin>>a>>b;ll j=0;
  init();
  for(ll i=a;i<=b;i++){
    ll mask=0;
    for(int j=0;j<req_prime.size();j++){
      if((i%req_prime[j])==0)
        mask=(mask|(1<<j));
    }
    bit_mask.push_back(mask);
  }
  for(int i=0;i<=72;i++){
    for(int j=0;j<=(1<<20)+4;j++)
      dp[i][j]=-1;
  }
  ll ans=solve(0,0);
  cout<<ans<<endl;
}


#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
using namespace std;
int n,m,i,j,f[200005],s[200005];
vector<int> g[200005];
int l,r,mid,ans;
void dfs(int x,int fa){
	int i,mx=0,mi=0;s[x]=0;
	for(i=0;i<g[x].size();i++){
		if(g[x][i]==fa) continue;
		dfs(g[x][i],x);
		mx=max(mx,f[g[x][i]]);
		mi=min(mi,f[g[x][i]]);
		s[x]+=s[g[x][i]];
	}
	if(mx+mi<0){
		f[x]=mi+1;
	}
	else{
		f[x]=mx+1;
		if(f[x]>mid){
			f[x]=-mid;
			s[x]++;
		}
	}
}
bool check(){
	dfs(1,0);
	return (s[1]+(f[1]>0))<=m;
}
int main(){
	cin>>n>>m;
	if(n==m){
		puts("0");
		return 0;
	}
	rep(i,n-1){
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	l=0;r=ans=n;
	while(l<r){
		mid=(l+r+1)/2;
		if(check()){
			r=mid-1;
			ans=mid;
		}
		else l=mid;
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

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

const char newl = '\n';

int cnt;

void dfs(int i,int p,vector<vector<int>>& edges,vector<int>& a,int l) {
    int mn = l,mx = -l-1;
    bool f = false;
    for (int j : edges[i]) if (j != p) {
        dfs(j,i,edges,a,l);
        if (a[j] > 0) mn = min(mn,a[j]-1);
        if (a[j] <= 0) mx = max(mx,a[j]-1);
        if (a[j] == 1) f = true;
    }
    if (f) {
        a[i] = 0;
        cnt++;
    } else if (mx == -l-1 && mn == l) {
        a[i] = l;
    } else if (mx > -l-1 && -mn <= mx) {
        a[i] = mx;
    } else {
        a[i] = mn;
    }
}

int main() {
    int n,k;
    cin >> n >> k;
    vector<vector<int>> edges(n);
    vector<int> a(n);
    for (int i = 0;i < n-1;++i) {
        int u,v;
        scanf("%d%d",&u,&v);
        u--;v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    int ok = n,ng = 0;
    while (abs(ok-ng) > 1) {
        int mid = (ok+ng)/2;
        cnt = 0;
        dfs(0,-1,edges,a,mid);
        if (a[0] > 0) cnt++;
        (cnt <= k ? ok : ng) = mid;
    }
    cout << ok << newl;
}


//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word
//Incase of close mle change language to c++17 or c++14

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007ll //998244353ll
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=10005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
vector <pii> v[N], ed;
int ans[N];
bool vis[N];
void dfs(int u)
{
    vis[u]=true;
    for(auto p:v[u])
    {
        if(ans[p.ss]==-1)
        {
            if(ed[p.ss].ss==u && !vis[p.ff])
            dfs(p.ff);
        }
        else if(ans[p.ss]==1)
        {
            if(ed[p.ss].ff==u && !vis[p.ff])
            dfs(p.ff);
        }
        else
        {
            if(ed[p.ss].ff==u)
            ans[p.ss]=1;
            else
            ans[p.ss]=-1;
            if(!vis[p.ff])
            dfs(p.ff);
        }
    }
}
int32_t main()
{
    IOS;
    fill(vis, false);
    int n, m;
    cin>>n>>m;
    fill(ans, 0);
    rep(i,0,m)
    {
        int a, b;
        cin>>a>>b;
        v[a].pb({b, i});
        v[b].pb({a, i});
        ed.pb({a, b});
    }
    int c[n+1];
    rep(i,1,n+1)
    cin>>c[i];
    rep(i,0,m)
    {
        int a=ed[i].ff, b=ed[i].ss;
        if(c[a]>c[b])
        ans[i]=1;
        else if(c[a]<c[b])
        ans[i]=-1;
    }
    rep(i,1,n+1)
    {
        if(!vis[i])
        dfs(i);
    }
    rep(i,0,m)
    {
        if(ans[i]==1)
        cout<<"->\n";
        else
        cout<<"<-\n";
    }
}

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
//#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int mod= 1e9+7;
long double pi = acosl(-1);
//const ll infl = LLONG_MAX;
const int inf = 1e9+2;
const int nmax = 1e5+5;
//const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;

int n,m;
int ans[nmax]; /// +1 for -> , -1 for <-
bool vis[nmax];
pii c[nmax];
int cval[nmax];

struct ejj{
    int v, val, idx;
};

vector<ejj>g[nmax];

void dfs(int u){
    vis[u] = true;
    for(ejj e : g[u]){
        int v = e.v;
        if(cval[v]>cval[u]){
            ans[ e.idx ] = e.val*-1;
        }
        else if(cval[v]==cval[u] and !vis[v]){
            ans[ e.idx ] = e.val;
            dfs(v);
        }
        else if(cval[v]==cval[u]){
            ans[ e.idx ] = e.val;
        }
        else if(cval[v]<cval[u]){
            if(!ans[e.idx])
                ans[ e.idx ] = e.val;
        }
    }
}

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

    cin>>n>>m;
    for(int i=1; i<=m; i++){
        int a,b;
        cin>>a>>b;
        ejj e;
        e.v = b, e.val = 1, e.idx = i;
        g[a].emplace_back( e );
        e.v = a, e.val = -1;
        g[b].emplace_back( e );
    }
    for(int i=1; i<=n; i++){
        cin>>c[i].first;
        cval[i] = c[i].first;
        c[i].second = i;
    }
    sort(c+1, c+1+n);
    for(int i=1; i<=n; i++){
        int u = c[i].second;
        if(!vis[u]){
            dfs(u);
        }
    }
    for(int i=1; i<=m; i++){
        if(ans[i]>0) cout<<"->\n";
        else cout<<"<-\n";
        assert(ans[i]!=0);
    }
}
/*
*/


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

int aa[210000];
int n,m;
int f(int x,int y)
{
	if(x%y)
	return x/y+1;
	else
	return x/y;
}
int main()
{
	cin>>n>>m;
	if(m==n)
	{
		cout<<0<<endl;
		return 0;
	}
	if(m==0)
	{
		cout<<1<<endl;
		return 0;
	}
	aa[0]=0;
	for(int i=1;i<=m;i++)
	{
		scanf("%d",aa+i);
	}
	sort(aa+1,aa+m+1);
	int k=n;
	if(aa[1]>1)
	k=aa[1];
    for(int i=2;i<=m;i++)
	{
		if(aa[i]-aa[i-1]>1)
		k=min(k,aa[i]-aa[i-1]);
	}
	k=k-1;
	int ans=0;
	for(int i=1;i<=m;i++)
	{
	   int temp=aa[i]-aa[i-1];
	   ans+=f(temp-1,k);
	}
	ans+=f(n-aa[m],k);
	cout<<ans<<endl;
	return 0;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define ll long long
#define T() long long t;cin>>t;for(long long o=1;o<=t;o++)
#define INF INT_MAX
#define INFS INT_MIN
#define mod 1000000007
#define FOR(a, b, n) for(int a = b; a < n; a++)
#define REP(a,c, b) for(int a = c; a < b; a++)
#define FORD(a, b, c) for(int a = b; a >= c; a--)
#define REPR(a, c,b) for(int a = b-1; a >= c; a--)
#define IOS  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define RESET(a, b) memset(a, b, sizeof a)
#define EPS 1e-9
#define m_p make_pair
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define  rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define ALL(x, y) x, x+y
#define SZ(x) ((int)x.size())
#define  pi(a)  pair<a, a>
#define  vi(a)  vector<a>
#define  vii(a) vector<pi(a)>
#define  vs vector<string>
template<class T> T sqr(T x){ return x*x; }
template<class T> T binPow(T p, int q, int MOD) {
    if(q == 1) return p % MOD;
    if(q & 1) return p*(binPow(p, q-1, MOD) % MOD) % MOD;
    else return sqr(binPow(p, q/2, MOD) % MOD) % MOD;
}
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout << name << " : " << arg1 << endl;
	//use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

ll nxt() {
    ll temporaryVariable;
    cin >> temporaryVariable;
    return temporaryVariable;
}
const double PI = acos(-1.0);
#define MAXN 100001
const int G = 2e5 + 5;

 int N=10000000;

int main(){
    IOS

     ll n,m,cnt=0;;cin>>n>>m;
     vi(int) a(m),v;
      REP(i,0,m)
      cin>>a[i];

     if(n==m){
         cout<<0<<endl;
         return 0;
     }

     if(m==0){
         cout<<1<<endl;
         return  0;
     }
     sort(all(a));

      if(a[0]-1>0)
      v.pb(a[0]-1);

      if(n-a[m-1]>0)
      v.pb(n-a[m-1]);

      REP(i,1,m){
          int p=a[i]-a[i-1]-1;
          if(p>0)
          v.pb(p);
      }
      sort(all(v));

      int k=v[0];
      REP(i,0,SZ(v)){
          cnt+=v[i]/k;
          if(v[i]%k!=0)cnt++;
      }

      cout<<cnt<<endl;

    #ifdef HOHderr, "%.3lf\n", clock() / (double) CLOCKS_PER_SEC );
#endif
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(i,a,b) for(int i = a; i<b ; i++)
#define FIO ios_base::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);
#define pb push_back
#define M 1000000007
int mod(int x){
return ((x%M + M)%M);
}
int add(int a,int b){
return mod(mod(a)+mod(b));
}
int mul(int a,int b){
return mod(mod(a)*mod(b));
}
// ****************************************************************************
bool isValid(double l,double r,double x,double y){
    if(l>=x && l<=y)
    return true;
    if(x>=l && x<=r)
    return true;
    return false;
}
void solve(){
    int n;
    cin>>n;
    vector<pair<double,double>>v;
    double temp = 0.1;
    fo(i,0,n){
        int x;
        cin>>x;
        double l,r;
        cin>>l>>r;
        if(x==2)
        v.pb({l,r-temp});
        else if(x==3)
        v.pb({l+temp,r});
        else if(x==4) v.pb({l+temp,r-temp});
        else v.pb({l,r});
    }
    int ans = 0;
    fo(i,0,n){
        fo(j,i+1,n){
            if(isValid(v[i].first,v[i].second,v[j].first,v[j].second)){
            // cout<<v[i].first<<" "<<v[i].second<<"\n"<<v[j].first<<" "<<v[j].second<<"\n";
            ans++;
            }
        }
    }
    cout<<ans;
}
signed main()
{
FIO
int t;
t=1;
// cin>>t;
while(t--)
{
solve();
}
}

#include <bits/stdc++.h>
using namespace std;
#define DBG cerr << __LINE__ << ' ' << __FUNCTION__ << endl
#define CLOSE ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mem(t, v) memset ((t) , v, sizeof(t))
#define pb push_back
#define mk make_pair
#define sz(x) (int)(x).size()
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define eps 1e-8
#define LL long long
#define ULL unsigned long long
#define LF putchar('\n')
#define SP putchar(' ')

template<typename T>
void read(T &x) {x = 0;char ch = getchar();LL f = 1;while(!isdigit(ch)){if(ch == '-')f *= -1;ch = getchar();}while(isdigit(ch)){x = x * 10 + ch - 48; ch = getchar();}x *= f;}
template<typename T, typename... Args>
void read(T &first, Args& ... args) {read(first);read(args...);}
template<typename T>
void write(T arg) {T x = arg;if(x < 0) {putchar('-'); x =- x;}if(x > 9) {write(x / 10);}putchar(x % 10 + '0');}
template<typename T, typename ... Ts>
void write(T arg, Ts ... args) {write(arg);if(sizeof...(args) != 0) {putchar(' ');write(args ...);}}
using namespace std;

const LL mod = 1e9 + 7;
const int N = 1e5 + 50;

LL n, a[N], f[N][2];

int main() {
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	LL x = 1, y = 1;
	f[1][1] = a[1];
	for(int i = 2; i <= n; ++i) {
		f[i][1] = (f[i-1][0] + f[i-1][1] + x * a[i] % mod) % mod;
		f[i][0] = (f[i-1][1] + y * ((-1LL * a[i] + mod) % mod) % mod) % mod;
		LL t = x;
		x = (x + y) % mod;
		y = t;
	}
	cout << (f[n][1] + f[n][0]) % mod << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
int N;
char S[100'100];
int dp[100'100];
int mn[222];
signed main()
{
    cin.tie(0)->sync_with_stdio(false);
    memset(dp, 0x3F, sizeof dp);
    memset(mn, 0x3F, sizeof mn);
    dp[0] = 0;
    cin>>N;
    cin >>(S + 1);
    for (int i = 1; i <= N; ++i)
    {
        for (char c = 'a'; c <= 'z';++c)
        {
            if (c == S[i]) continue;
            dp[i] = min(dp[i], mn[c] + 1);
        }
        mn[S[i]] = min(mn[S[i]], dp[i - 1]);
    }
    if (dp[N] >= 1e9) cout << "-1\n";
    else cout << dp[N] << '\n';
    return 0;
}

#include <bits/stdc++.h>
const int N = 1e5 + 5;
int n; char str[N];
int main() {
	scanf("%d%s", &n, str + 1);
	if (str[1] != str[n]) puts("1");
	else {
		for (int i = 1; i < n; i++)
			if (str[i] != str[1] && str[i + 1] != str[n]) { puts("2"); return 0; }
		puts("-1");
	}
	return 0;
}


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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
    string sep = " ";
    if(v.size()) os << v[0];
    for(int i=1; i<v.size(); i++) os << sep << v[i];
    return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
    for(int i=0; i<v.size(); i++) is >> v[i];
    return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
    cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    int n, m; cin >> n >> m;
    vector<ll> a(n);
    cin >> a;

    vector<vector<int>> g(n);
    for(int i=0; i<m; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;

        g[y].push_back(x);
    }

    vector<ll> maxdp(n, -1e18);
    for(int i=n-1; i>=0; i--){
        for(int v: g[i]){
            maxdp[v] = max(maxdp[v], maxdp[i]);
            maxdp[v] = max(maxdp[v], a[i]);
        }
    }

    ll ans = -1e18;
    for(int i=0; i<n; i++){
        ans = max(ans, maxdp[i]-a[i]);
    }

    cout << ans << endl;

    return 0;
}

#include<bits/stdc++.h>
#define pb           push_back
#define pf           push_front
#define in           insert
#define ff           first
#define ss           second
#define int          long long
#define rep(i,x,m)   for(int i=x;i<m;i++)
#define MOD          1000000007
#define endl         "\n"
#define all(v)       v.begin(),v.end()
#define rall(v)      v.rbegin(),v.rend()
#define vi           vector<int>
#define pi           pair<int,int>
#define sz(x)       (int)x.size()
#define pq           priority_queue<int>
#define fix(y)       fixed<<setprecision(y)
#define print(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";cout<<endl
#define FIO         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

int power(int n,int m)
{int p=1;if(m==0)return 1;p=(power(n,m/2)%MOD);p=(p%MOD*p%MOD)%MOD;
return(m&1?((p%MOD*n%MOD)%MOD):(p%MOD));}
int n,m;
vi graph[200001];
int vis[200001];
vector<pi>v;
int cost[200001];
int mx=-1e15;

void dfs(int child,int par,int M)
{
    vis[child]=1;
    //cout<<child<<" "<<par<<endl;
    if(child!=par)
    mx=max(mx,cost[child]-M);

    for(auto x:graph[child])
    {

      mx=max(mx,cost[x]-M);
      if(vis[x]==0)
        dfs(x,child,M);
    }
}

void solve()
{
    cin>>n>>m;
    rep(i,1,n+1){
        int x;
        cin>>x;
        cost[i]=x;
        v.pb({x,i});
    }
    //cout<<n<<m<<endl;
    sort(all(v));
    rep(i,0,m)
    {
        int x,y;
        cin>>x>>y;
        graph[x].pb(y);

    }
    rep(i,0,n)
    {
        if(vis[v[i].ss]==0)
        {

            dfs(v[i].ss,v[i].ss,v[i].ff);
        }
    }
    cout<<mx;

}

signed main()
{
        FIO

        int t=1;
        //cin>>t;
        while(t--)
        solve();
        cerr<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;

        return 0;
}


//clear adj and visited vector declared globally after each test case
//check for long long overflow
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Incase of close mle change language to c++17 or c++14
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007ll //998244353ll
#define lld long double
#define mii map<int, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
const long long N=200005, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int h[n];
    rep(i,0,n)
    cin>>h[i];
    mii mp;
    mp[0]++;
    int sum=0, ans=0;
    rep(i,0,n)
    {
        if(i&1)
        sum+=h[i];
        else
        sum-=h[i];
        ans+=mp[sum];
        mp[sum]++;
    }
    cout<<ans;
}

#include "bits/stdc++.h"
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define all(V) (V).begin(), (V).end()
using namespace std;
typedef long long ll;

int main() {fio;
	int N;
	cin >> N;
	vector <int> A(N);
	ll ans = 0;
	for(int i = 0; i < N; i++) {
		cin >> A[i];
		if(i % 2) A[i] *= -1;
	}
	map <ll, int> cnt;
	cnt[0] = 1;
	ll S = 0;
	for(int i = 0; i < N; i++) {
		S += A[i];
		ans += cnt[S];
		cnt[S]++;
	}
	cout << ans;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>
#include <cassert>
#include <random>
#include <chrono>

/* #include <atcoder/all> */
/* using namespace atcoder; */
using namespace std;

void debug_out(){ cout << "\n"; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1000000007;
/* const ll MOD = 998244353; */
const ll INF = 1ll<<60;
const double PI = acos(-1);

struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

signed main() {
  string s;
  cin >> s;

  bool ans = true;
  REP(i, s.size()){
    if(i%2 == 0){
      if('A' <= s[i] && s[i] <= 'Z') ans = false;
    }else{
      if('a' <= s[i] && s[i] <= 'z') ans = false;
    }
  }

  if(ans) Yes;
  else No;

  return 0;
}

#include<iostream>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(i%2==0)
        {
            if(s[i]<'a'||s[i]>'z')
            {
                cout<<"No";return 0;
            }
        }
        else{
            if(s[i]<'A'||s[i]>'Z')
            {
                cout<<"No";return 0;
            }
        }
    }
    cout<<"Yes";
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll> pql;
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef map<ll, ll> ml;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {return (a % b + b) % b;}
ll quo(ll a, ll b) {return (a - mod(a, b)) / b;}
template <typename T, typename U> bool chmin(T &a, const U b) {if(a > b) {a = b; return 1;} return 0;}
template <typename T, typename U> bool chmax(T &a, const U b) {if(a < b) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 2e5;
const ld eps = 1e-9;
const char newl = '\n';

ll t, n;
bool f;
vl p, inv, ans;

void op(ll num) {
  ans.push_back(num);
  swap(p[num], p[num+1]);
  inv[p[num]] = num;
  inv[p[num+1]] = num+1;
  f = !f;
}

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

  cin >> t;
  rep(_, t) {
    cin >> n;
    f = 0;
    p = vl(n);
    inv = vl(n);
    ans = vl(0);
    rep(i, n) {
      cin >> p[i];
      p[i]--;
      inv[p[i]] = i;
    }
    if(n >= 5) {
      rep3(i, n-1, 4) {
        if(inv[i] == i) continue;
        else if(f ^ (inv[i] & 1)) {
          if(inv[i] >= 3) op(inv[i] - 3);
          else op(inv[i] + 1);
        }
        while(inv[i] != i) op(inv[i]);
      }
    }
    if(n >= 4 && p[3] != 3) {
      if(f) op(1);
      if(inv[3] == 0) {op(0); op(1); op(2);}
      if(inv[3] == 1) {op(2); op(1); op(2);}
      if(inv[3] == 2) {op(2);}
    }
    while(p[0] != 0 || p[1] != 1) {
      if(f) op(1);
      else op(0);
    }
    cout << ans.size() << newl;
    rep(i, ans.size()) cout << ans[i] + 1 << ' ';
    cout << newl;
  }
  return 0;
}

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

void sub(int n, int *p, vector<int> &ans, int k){
    for(int c = 0; c < 20; c++){
        bool f = true;
        for(int i = n - 3; i < n; i++){
            if(p[i] != i) f = false;
        }
        if(f) return;
        else{
            if(k % 2 == (n - 2) % 2){
                ans.push_back(n - 2);
                swap(p[n - 2], p[n - 1]);
                k++;
            }
            else{
                ans.push_back(n - 3);
                swap(p[n - 3], p[n - 2]);
                k++;
            }
        }
    }
}

void query(int n, int *p){
    if(n == 2){
        if(p[0] == 0){
            cout << 0 << endl;
        }
        else{
            cout << 1 << endl << 1 << endl;
        }
        return;
    }
    vector<int> ans;
    int k = 0;
    for(int c = 0; c < n - 3; c++){
        for(int i = c; i < n; i++){
            if(i == c) continue;
            if(p[i] == c){
                if((i - 1) % 2 != k % 2){
                    if(i != n - 1){
                        ans.push_back(i);
                        swap(p[i], p[i + 1]);
                        k++;
                        ans.push_back(i - 1);
                        swap(p[i - 1], p[i]);
                        k++;
                        i++;
                    }
                    else{
                        ans.push_back(i - 2);
                        swap(p[i - 2], p[i - 1]);
                        k++;
                    }
                }
                for(int j = i - 1; j >= c; j--){
                    ans.push_back(j);
                    swap(p[j], p[j + 1]);
                    k++;
                }
            }
        }
    }
    sub(n, p, ans, k);
    cout << (int)ans.size() << endl;
    for(int i : ans) cout << i + 1 << " ";
    cout << endl;
}

int main()
{
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        int p[505];
        for(int i = 0; i < n; i++){
            cin >> p[i];
            p[i]--;
        }
        query(n, p);
    }
}


#include<bits/stdc++.h>
using namespace std;
int n,a[100010];
inline int read()
{
	int x=0,w=0;char ch=0;
	while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
	while(isdigit(ch)){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return w?-x:x;
}
int gcd(int N,int M)
{while(N^=M^=N^=M%=N);return M;}
int main()
{
	n=read();
	for(int i=1;i<=n;i++){
		a[i]=read();
		a[1]=gcd(a[1],a[i]);
	}
	cout<<a[1]<<'\n';
}

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

const int N = 1e5 + 10;
int a[N]; int n;

int gcd(int x,int y){return (y==0) ? x : gcd(y,x%y);}

signed main() {
  scanf("%lld",&n);
  for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
  int s = a[1]; for(int i=2;i<=n;i++) s = gcd(s,a[i]);
  printf("%lld\n",s);
}


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

long long dp[205][12];
int n;

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
        dp[i][1] = 1;
    }
    for(int i = 2; i <= 12; i++) {
        for(int j = 1; j <= n; j++) {
            for(int k = 1; k < j; k++) {
                dp[j][i] += dp[k][i - 1];
            }
        }
    }
    cout << dp[n][12];
    return 0;
}

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

int main(){
  int L;
  cin >> L;
  L --;
  long long answer = 1;
  vector<bool> check(12, true);
  for(int n = L-10; n <= L; n++){
    int n_before = n;
    for(int r = 11; r >= 2; r--){
      if(check.at(r)){
        if(n_before % r == 0){
          n_before /= r;
          check.at(r) = false;
        }
      }
    }
    answer *= n_before;
  }
  for(int i = 2; i <= 11; i++){
    if(check.at(i)){
      answer /= i;
    }
  }
  cout << answer << "\n";
}


//Codeforcesで128bit整数を使いたいとき
//→__int128_tを使う&GNU C++17 (64)で提出する

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//イテレーション
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//x:コンテナ
#define ALL(x) x.begin(),x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf
#define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf
#define MOD 1000000007 //問題による
//略記
#define F first
#define S second
//出力(空白区切りで昇順に)
#define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()<<endl;

//aをbで割る時の繰上げ,繰り下げ
ll myceil(ll a,ll b){return (a+(b-1))/b;}
ll myfloor(ll a,ll b){return a/b;}

int ri() {int n;cin >> n;return n;}
#define ro(a) {cout << a << endl;}

void printVector(const std::vector<int>& vec) {
	for (int value : vec) {
		cout << value << " ";
	}
	cout << endl;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	} else {
		return a.first < b.first;
	}
}

ll factorial(ll N) {
	ll f = 1;
	REP(i, N) {
		f *= i+1;
	}
	return f;
}

signed main() {
	float A = ri(), B = ri(), C = ri(), D = ri();
	if (C * D - B <= 0) {
		ro(-1);
		return 0;
	}
	float tmp = A / (C * D - B);
	ro(ceil(tmp));
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

const ll mod = 998244353;

vector<int> par, rnk;
void init(int N){ par.resize(N); rnk.assign(N,0); rep(i,N) {par[i] = i;} }
int root(int x) { return par[x] == x? x : par[x] = root(par[x]); }
bool same(int x, int y) { return root(x) == root(y); }
void unite(int x, int y){
  x = root(x); y = root(y);
  if(x==y) return;
  if(rnk[x] < rnk[y]) par[x] = y;
  else{
    par[y] = x;
    if(rnk[x] == rnk[y]) rnk[x]++;
  }
}

ll mpow(ll a, ll x){
  ll res = 1;
  while(x > 0){
    if(x & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    x >>= 1;
  }
  return res;
}

int main(){
  ll N; cin >> N;
  vector<ll> f(N); rep(i,N) cin >> f[i];
  rep(i,N) f[i]--;
  init(N);
  ll cnt = 0;
  rep(i,N){
    unite(i,f[i]);
  }
  set<int> st;
  rep(i,N) st.insert(root(i));
  cnt=sz(st);
  cout << (mpow(2,cnt)+mod-1)%mod << endl;
  return 0;
}


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

int n, t, a[100];
vector<int> l, r;

void dfs(int dep, int sum) {
	if (sum > t) return;
	if (dep > (n >> 1)) {
		l.push_back(sum);
		return;
	}
	dfs(dep + 1, sum);
	dfs(dep + 1, sum + a[dep]);
}

void dfs2(int dep, int sum) {
	if (sum > t) return;
	if (dep > n) {
		r.push_back(sum);
		return;
	}
	dfs2(dep + 1, sum);
	dfs2(dep + 1, sum + a[dep]);
}

int main(void) {
	scanf("%d%d", &n, &t);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}
	dfs(1, 0);
	dfs2((n >> 1) + 1, 0);
	sort(r.begin(), r.end());
	int ans = 0;
	for (auto i : l) {
		ans = max(ans, i + *(upper_bound(r.begin(), r.end(), t - i) - 1));
	}
	printf("%d\n", ans);
	return 0;
}

#include <algorithm>
#include <iostream>
#include <cstring>

using namespace std;

char cc[64];

int maxdigit(int n) {
	return n == 0 ? 0 : max(maxdigit(n - 1), cc[n - 1] - '0');
}

bool ok(int n, long long b, long long m) {
	long long x = 0;
	for (int i = 0; i < n; i++) {
		if (x > (m - (cc[i] - '0')) / b)
			return false;
		x = x * b + cc[i] - '0';
	}
	return true;
}

int main() {
	long long m; cin >> cc >> m;
	int n = strlen(cc);
	if (n == 1) {
		cout << (cc[0] - '0' <= m ? 1 : 0) << '\n';
		return 0;
	}
	int d = maxdigit(n);
	long long lower = d, upper = m + 1;
	while (upper - lower > 1) {
		long long b = (lower + upper) / 2;
		if (ok(n, b, m))
			lower = b;
		else
			upper = b;
	}
	long long b = lower;
	cout << b - d << '\n';
	return 0;
}


//----AUTHOR:developer.eeshan----/
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ff first
#define ss second
#define it(a, x) for (auto &a : x)
#define ll long long
#define ld long double
#define pb push_back
#define ppb pop_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vs vector<string>
#define gi greater<int>
#define vc vector<char>
#define vvi vector<vi>
#define vvb vector<vb>
#define vvd vector<vd>
#define vvll vector<vll>
#define vvc vector<vc>
#define mii map<int, int>
#define us unordered_set
#define um unordered_map
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int> >
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x)  \
    int x;    \
    cin >> x; \
    for (ll tc = 1; tc <= x; tc++)
#define deb(x) cout << #x << "=" << x << endl;
#define deb1(x, y) cout << #x << "=" << x << ' ' << #y << "=" << y << endl;
#define in(i, x, y) for (ll i = x; i < y; i++)
#define rin(i, x, y) for (ll i = x; i >= y; i--)
#define all(a) begin(a), end(a)
#define rall(a) rbegin(a), rend(a)
#define lb lower_bound
#define ub upper_bound
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());  //random shuffler
ll fxp(ll a, ll b) {
    a %= mod;
    ll res = 1;
    while (b > 0) {
        if (b % 2 == 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
        b /= 2;
    }
    return res % mod;
}

inline ll minv(ll x) { return fxp(x, mod - 2); }
inline ll mmul(ll a, ll b) {
    if (a >= mod) a = a % mod;
    if (b >= mod) b = b % mod;
    if (a * b >= mod) return (a * b) % mod;
    return (a * b);
}
inline ll madd(ll a, ll b) {
    if (a >= mod) a = a % mod;
    if (b >= mod) b = b % mod;
    if (a + b >= mod) return (a + b) % mod;
    return (a + b);
}
inline ll msub(ll a, ll b) {
    if (a >= mod) a = a % mod;
    if (b >= mod) b = b % mod;
    return (((a - b) % mod + mod) % mod);
}
inline ll mdiv(ll a, ll bb) {
    if (a >= mod) a = a % mod;
    ll b = minv(bb);
    if (b >= mod) b = b % mod;
    if (a * b >= mod) return (a * b) % mod;
    return (a * b);
}

void c_p_c() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
}

const int mXn = 3e5 + 5;
ll BIT[mXn], a[mXn], n;

//add "delta" at index "x"
void update(ll x, ll delta) {
    for (; x <= n; x += x & -x)
        BIT[x] += delta;
}

//when atlast you want final array then just take prefix Sum
void range_update(int l, int r, int val) {
    update(l, val);
    update(r + 1, -val);
}

ll sum(ll x) {
    ll sum = 0;
    for (; x > 0; x -= x & -x)
        sum += BIT[x];
    return sum;
}

ll sum(ll l, ll r) {
    return sum(r) - sum(l - 1);
}

void solve() {
    cin >> n;
    ll cnt = 0;

    in(i, 1, n + 1) cin >> a[i], a[i]++;

    in(i, 1, n + 1) {
        cnt += sum(a[i] + 1, n);
        update(a[i], 1);
    }

    in(i, 1, n + 1) {
        cout << cnt << endl;
        cnt += (n - 1 - 2 * (a[i] - 1));
    }
}

int main(int argc, char const *argv[]) {
    c_p_c();
    solve();
    return 0;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <unordered_map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int a[300010];
int c[300010];
int n;

int lowbit(int x) {
  return x & -x;
}

void add(int x) {
  while (x <= n) {
    c[x] = c[x] + 1;
    x = x + lowbit(x);
  }
}

int getsum(int x) {
  int ans = 0;
  while (x >= 1) {
    ans = ans + c[x];
    x = x - lowbit(x);
  }
  return ans;
}

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    long long ans = 0;
    for (int i = n-1; i >= 0; --i) {
        ans += getsum(a[i]);
        add(a[i]+1);
    }
    printf("%lld\n", ans);
    for (int i = 0; i < n-1; ++i) {
        //printf("move %d\n", a[i]);
        ans -= a[i];
        ans += n - a[i] - 1;
        printf("%lld\n", ans);
    }

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;

struct City {
    int x, y, z;
    City() {}
    City(int x, int y, int z) {
        this->x = x;
        this->y = y;
        this->z = z;
    }
};

int dist(City c1, City c2) {
    return abs(c2.x - c1.x) + abs(c2.y - c1.y) + max(0, c2.z - c1.z);
}

int main() {
    int n;
    cin >> n;
    vector<City> city(n);
    for (int i = 0; i < n; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        city[i] = {x, y, z};
    }
    vector<vector<int>> dp(n, vector<int>(1<<n, INF));
    dp[0][0] = 0;
    for (int i = 0; i < (1<<n); i++) {
        for (int j = 0; j < n; j++) {
            if (not (i & (1<<j))) {
                for (int k = 0; k < n; k++) {
                    dp[j][i | (1<<j)] = min(dp[j][i | (1<<j)], dp[k][i] + dist(city[k], city[j]));
                }
            }
        }
    }
    int ans = dp[0][(1<<n) - 1];
    cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=2e18;
ll MOD=1000000007;
ll mod=998244353;

int main() {
   int n;
   cin >> n;
   vector<int> x(n),y(n),z(n);
   vector<int> t(n+1);
   rep(i,n) t[i]=pow(2,i);
   rep(i,n) cin >> x[i] >> y[i] >> z[i];
   int e=pow(2,n);
   vector<vector<int>> a(n,vector<int>(e,inf));
   a[0][1]=0;
   rep(i,n-1){
       rep(j,e){
           int u=j;
           rep(k,n){
               if (u%2==0){
                   rep(ii,n){
                       a[k][j+t[k]]=min(a[k][j+t[k]],a[ii][j]+abs(x[ii]-x[k])+abs(y[ii]-y[k])+max(0,z[k]-z[ii]));
                   }
               }
               u/=2;
           }
       }
   }
   int ans=inf;
   rep(i,n) ans=min(ans,a[i][e-1]+abs(x[0]-x[i])+abs(y[0]-y[i])+max(0,z[0]-z[i]));
   cout << ans << endl;
}


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

int main()
{
    int n;
    cin>>n;
    int a[n+1];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    int ans=0;
    int m=-1;
    sort(a,a+n);
    int mx=a[n-1];
    for(int i=2; i<=mx; i++){
            int c=0;
        for(int j=0; j<n; j++){
            if(a[j]%i==0){
                c++;
            }
        }
        if(c>=m){
            m=c;
            ans=i;
        }

    }
    cout<<ans<<endl;

}

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

using ll = long long;

#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

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

	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif

	int n;
	cin>>n;
	string s;
	cin>>s;

	if(s=="1"){
		cout<<2LL*ll(1e10)<<endl;
		return 0;
	}

	for(int i=0; i<3; i++){
		bool w=1;
		for(int j=0; j<n; j++){
			if(j%3 == i){
				if(s[j] != '0'){
					// if(!w) cout<<i<<" "<<j<<endl;
					w=0;
				}
			}

			else{
				if(s[j] != '1'){
					// if(!w) cout<<i<<" "<<j<<endl;
					w=0;
				}
			}

			if(j==n-1 && w){

				ll ans = ll(3e10)-n;

				if(i==0){
					// we end at n+2, n+5, ...
					ans++;
				}

				if(i==1){
					// we end at n+1, n+4, ...
					ans+=2;
				}

				if(i==2){
					ans+=3;
				}

				cout<<ll(ans/3LL)<<endl;
				return 0;
			}
		}
	}

	cout<<0<<endl;
}