#include<bits/stdc++.h>

#define PI 3.14159265359

using namespace std;

/******** Utility ***************/
int bsize(int bits, int _max){
  int c = 0;
  for(int ix=0; ix!=_max; ++ix)
    if((bits&(1<<ix)) !=0){
      ++c;
    }
  return c;
}

long factrial(long n){
  assert(n >= 0);
  if(n <= 1)
    return 1;
  long _sum = 1;
  for(int ix=0; ix!=(n-1); ++ix)
    _sum *= n-ix;
  return _sum;
}

template<typename T>
void show(vector<T> v)
{
  for(auto _v: v)
    cout << _v << " ";
  cout << endl;
}

template<typename T>
void show2(vector<vector<T>> v)
{
  for(auto __v: v){
    cout << "(";
    for(auto _v: __v){
      cout << _v << ", ";
    }
    cout << ")" << endl;
  }
}
/******** end of Utility ***************/

int main(void)
{
  // input
  long count = 0;
  long N;
  stringstream s8,s10;
  cin >> N;

  // main
  for(int ix=7; ix<=N; ++ix){
    s8.str("");
    s10.str("");
    s8 << oct << ix;
    s10 << dec << ix;
    if(s10.str().find("7")!=string::npos || s8.str().find("7")!=string::npos){
      ++count;
    }
  }
  cout << N - count << endl;
}

#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<cmath>
#define rep(i ,n) for(int i = 1; i <= n; ++i)
#define Rep(i ,n) for(int i = n; i >= 1; --i)
using namespace std;
typedef long long ll;
typedef vector<int>  vi;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 100;
const int mod = 1e9 + 7;

int main(){
    ll T = 10000000000;
    int n;string s;cin >> n >> s;
    string p = "";
    while(p.size() < n + 10) p += "110";
    ll ans = 0;
    for(int i = 0;i <3;i++){
        if(s != p.substr(i,n)) continue;
        ans += T - (n + i - 1) / 3;
    }
    cout << ans << endl;
    return 0;
}


#include <cstdio>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iostream>
#include <sstream>
#include <ostream>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <map>
#include <iomanip>
#include <set>
#include <bitset>
#include<unordered_map>
#define INT_MINs -2000000000
#define INT_MAXs 1000000001
#define MID int mid=(l+r)/2
#define REP1(i,x,y) for(int i=x;i<y;i++)
#define REP2(i,x,y) for(int i=x;i<=y;i++)
#define ls (2*k)
#define rs (2*k+1)
#define lson l,mid,2*k
#define rson mid+1,r,2*k+1
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define IOS ios::sync_with_stdio(0);cin.tie(NULL);
#define pb(a) push_back(a)
#define pi acos(-1)
#define endl '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod=998244353;
const ll ba=131;
ll qk(ll x,ll y){ll ans=1;while(y){if(y&1) ans=ans*x%mod;y>>=1;x=x*x%mod;}return ans;}
const int dx[8] = { 0,-1,0,1,-1,-1,1,1}, dy[8] = { -1,0,1,0,-1,1,-1,1};
const int dxx[8]= {2,1,-1,-2,-2,-1, 1, 2},dyy[8]= {1,2,2,1, -1,-2,-2,-1};
int a[200005];
ll ans=0;
int vis[200005];
int f[200005];
int finds(int x){
    return f[x]==x?f[x]:f[x]=finds(f[x]);
}
void solve()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        f[i]=i;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        vis[a[i]]=1;
    }
    for(int i=1;i<=n;i++){
        //if(vis[i]) continue;
        f[finds(i)]=finds(finds(a[i]));
    }
    for(int i=1;i<=n;i++){
        if(vis[i]&&f[i]==i)
            ans++;
    }
    cout<<qk(1ll*2,ans)-1<<endl;
}

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

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define io ios::sync_with_stdio(false); cin.tie(0)

const int mod = 998244353;

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

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

int main()
{
    io;
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) {
        cin >> v[i];
        v[i]--;
    }
    UnionFind uf(n);
    rep(i, n) uf.unite(i, v[i]);
    set<ll> s;
    rep(i, n) s.insert(uf.find(i));
    ll ans = modpow(2, s.size(), mod)-1;
    cout << ans << endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
int H,W;
char s[10005];
int numa[10005],numb[10005],numd[100005];
int main(){
	scanf("%d%d",&H,&W);
	for(int i=1;i<=H;i++){
		cin>>s+1;
		for(int j=1;j<=W;j++){
			if(s[j]=='R') numa[i+j]++;
			if(s[j]=='.') numd[i+j]++;
			if(s[j]=='B') numb[i+j]++;
		}
	}
	ll ans=1;
	for(int i=2;i<=H+W;i++){
		if(numa[i]==0&&numb[i]==0) ans*=2;
		else{
			if(numa[i]!=0&&numb[i]!=0) ans*=0;
		}
		ans%=998244353;
	}
	printf("%lld\n",ans);
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <map>
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 2079;
vector<int> f(maxn, 0);
ll gcd(ll a, ll b)
{
    if (a < b) swap(a, b);
    while (b)
    {
        ll c = a % b;
        a = b;
        b = c;
    }
    return a;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    map<int, vector<int> > d;
    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j * j <= a[i]; j++)
        {
            if (a[i] % j == 0)
            {
                d[j].push_back(i);
                if (j * j < a[i]) d[a[i] / j].push_back(i);
            }
        }
    }
    int ans = 0;
    for (const pair<int, vector<int> >& i : d)
    {
        for (int j : i.second) f[j] = 1;
        int mini = 2e9;
        for (int j = 0; j < n; j++)
        {
            if (!f[j])
            {
                mini = a[j];
                break;
            }
        }
        int g = 0;
        for (int j : i.second) g = gcd(g, a[j]);
        if (g == i.first && mini >= i.first)
        {
            //cout << i.first << " ";
            ans++;
        }
        for (int j : i.second) f[j] = 0;
    }
    //cout << "\n";
    cout << ans << "\n";
    return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <bitset>
#include <cassert>
#include <math.h>
#include <complex>
#include <iomanip>
#include <unordered_map>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#ifdef _OLIMPOLOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1337
#endif
void debug_out() { cout << "\n";}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B) { cout << " " << A; debug_out(B...); }
int test = 1;
#define out(x) {cout << x << "\n";return;}
#define all(N) N.begin(),N.end()
#define allr(N) N.rbegin(),N.rend()
template<typename T1>
void print(vector<T1> V, int add = 0, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = V.size() - 1;
    for (int i = start; i <= end; i++) {
        cout << V[i] + add << ((i == end) ? "\n" : " ");
    }
}
template<typename T1>
T1 chmin(T1 &x, const T1 v) { return x = min(x,v); }
template<typename T1>
T1 chmax(T1 &x, const T1 v) { return x = max(x,v); }
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repsr(i, s, n) for (int i = n-1; i >= s; i--)
#define PI pair<int,int>
//-------------------------- ^ DONT TOUCH ^-----------------------------------------------------------------
#define MAX 100001
#define MOD 1000000007ll

int gcd(int x, int y) {
    if (x == 0 || y == 0)
        return x+y;
    return gcd(y, x % y);
}

void solve() {
    int n;
    cin >> n;
    vector<int> N(n);
    rep(i,n) {
        cin >> N[i];
    }
    int m = 35000;
    map<int, int> M;
    int s = INT_MAX;
    rep(i,n) {
        chmin(s, N[i]);
        for(int j = 1; j * j <= N[i]; j++)
            if ((N[i] % j) == 0) {
            M[j] = gcd(M[j], N[i]);
            M[N[i]/j] = gcd(M[N[i]/j], N[i]);
        }
    }
    int c = 1;
    for(auto &p : M) {
        if (p.first == p.second && p.first < s)
            c++;
    }
    out(c);
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int test = 1;
    //cin >> test;
    rep(testCase, test) {
        #ifdef _OLIMPOLOCAL
            cout << "------------------ TESTCASE: " << testCase << " -------------\n";
        #endif
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define int long long
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define moca(a, s, b) a=((a)s(b)+MOD)%MOD
#define rep(i,n) for (int i=0;i<n;i++)
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
template<class T>bool chmax(T &a, const T &b) {if(a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a) {a=b; return 1;} return 0;}
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

//for(i=0; i<N; i++) cin >> a[i];

signed main(void) {
  int n,m;
  cin>>n>>m;
  vector<vector<int>> root(n+1,vector<int>(n+1,0));
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a-=1;
    b-=1;
    root[a][b]=1;
    root[b][a]=1;
  }
  vector<int> dp(1<<n,100000000);
  for (int s=1;s<(1<<n);s++){
    int bit[n];
    rep(i,n){
      bit[i]=(s>>i)&1;
    }

    bool flag=true;
    rep(l,n-1){
      for (int r=l+1;r<n;r++){

        if ((bit[l]==1 && bit[r]==1) && root[l][r]==0){

          flag=false;
        }
      }
    }
    if (flag==true){
      dp[s]=1;
      continue;
    }
    int t=(s-1)&s;
    while (t>0){
      dp[s]=min(dp[s],dp[s-t]+dp[t]);
      t=(t-1)&s;
    }

  }
  pt(dp[pow(2,n)-1]);
}

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

#define ll long long
#define ar array

const int mxN = 18;
int n, m, dp[1 << mxN];
bool e[mxN][mxN], trans[1 << mxN];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b, --a, --b;
		e[a][b] = e[b][a] = 1;
	}
	for (int i = 1; i < (1 << n); ++i) {
		vector<int> v; v.reserve(n);
		for (int j = 0; j < n; ++j) if (i & (1 << j)) v.push_back(j);
		trans[i] = 1;
		for (int j = 0; j < v.size() && trans[i]; ++j) for (int k = j + 1; k < v.size() && trans[i]; ++k)
			trans[i] &= e[v[j]][v[k]];
	}
	fill(dp, dp + (1 << n), 1e9);
	dp[0] = 0;
	for (int i = 0; i < (1 << n); ++i) {
		int mask = i ^ ((1 << n) - 1);
		for (int s = mask; s; s = (s - 1) & mask)
			if (trans[s])
				dp[i | s] = min(dp[i | s], dp[i] + 1);
	}
	cout << dp[(1 << n) - 1];
	return 0;
}


#include <iostream>
using namespace std;

int absfunc(int a) {
  if (a > 0) return a;
  else return -a;
}

int main() {
  int N;
  cin >> N;
  pair<int,int> arr[1001];
  for (int i=0; i<N; i++) {
    int A,B;
    cin >> A >> B;
    arr[i] = {A,B};
  }

  int ans = 0;
  for (int i=0; i<N-1; i++) for (int j=i+1; j<N; j++) {
    int deltaX = arr[j].first - arr[i].first;
    int deltaY = arr[j].second - arr[i].second;
    if (absfunc(deltaX) >= absfunc(deltaY)) ans++;
  }

  cout << ans;
}

#include<bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds;
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define here cout<<"here:\n"
#define inf 1e18+1
const long double PI = acos(-1.0L);
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
//const int mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
VL dx={1,0,-1,0};
VL dy={0,1,0,-1};
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    VL x(n),y(n);
    fr(i,0,n)
    {
        cin>>x[i]>>y[i];
    }
    ll ct=0;
    fr(i,0,n)
    {
        fr(j,i+1,n)
        {
            double res=(double)(y[j]-y[i])/(double)(x[j]-x[i]);
            if(res>=-1.00&&res<=1.00)
            {
                ct++;
            }
        }
    }
    cout<<ct<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1,pp;
    //cin>>t;
    pp=t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<": ";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
        * BE CAREFUL REGARDING THE DEFAULT VALUES IN segement trees etc
        * BE very careful in int vs long long vs unsigned long long
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithmQ


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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> s(h);
  for(int i=0;i < h;i++){
    cin >> s.at(i);
  }

  long long ans = 0;
  for(int i=0;i < h;i ++){
    int mae = 0;
    for(int j = 0;j < w;j++){
      if(s.at(i).at(j) == '.'){
        if(mae == 1){
          ans ++;
        }
        mae = 1;
      }
      else{
        mae = 0;
      }
    }
  }
    for(int i=0;i < w;i ++){
    int mae = 0;
    for(int j = 0;j < h;j++){
      if(s.at(j).at(i) == '.'){
        if(mae == 1){
          ans ++;
        }
        mae = 1;
      }
      else{
        mae = 0;
      }
    }
  }
  cout << ans << endl;
}

// どこが間違っているか分からない時は,簡単なミス(型,スペル,入力or出力など)をしていたり問題文の見落としがあったりする. 一度落ち着いて頭をリセットしよう.
// 計算途中のオーバーフローに注意しよう

#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define PP(val, pre) cout<<fixed<<setprecision(pre)<<val<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    ll N, M;
    cin >> N >> M;
    ll odd = 0, even = 0;
    REP(i, 0, N){
        string S;
        cin >> S;
        int cnt=0;
        REP(i, 0, M) if(S[i]=='1') cnt++;
        if(cnt%2==0){
            even++;
        }else{
            odd++;
        }
    }
    P(N*(N-1)/2-even*(even-1)/2-odd*(odd-1)/2);
}


#include <bits/stdc++.h>
#define INF 2000000000000000000
#define ll long long
#define ld long double
#define pll pair<ll, ll>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, A, B;
  cin >> N >> A >> B;
  cout << N - A + B << "\n";
}

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

double dp[101][101][101];

double f(int x, int y, int z) {
    if (dp[x][y][z] > 0)  return dp[x][y][z];
    if (x == 100 || y == 100 || z == 100) return 0;

    double ret = 0;
    ret += x * (f(x + 1, y, z) + 1);
    ret += y * (f(x, y + 1, z) + 1);
    ret += z * (f(x, y, z + 1) + 1);
    ret /= x + y + z;
    return dp[x][y][z] = ret;
}

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << setprecision(10) << f(a, b, c) << "\n"s;
    return 0;
}


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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const int INF = 1e9 + 47;
const LL LINF = 1LL * INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int where[1 << 20];
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	VI a(n), b(n), p(n);
	FOR(i, 0, n)
		cin >> a[i];
	FOR(i, 0, n)
		cin >> b[i];
	vector<PII> arr;
	FOR(i, 0, n)
	{
		cin >> p[i];
		p[i]--;
		where[p[i]] = i;
		if(i == p[i]) continue;
		if(a[i] <= b[p[i]])
		{
			cout << "-1" << endl;
			return 0;
		}
		arr.PB(MP(a[i], i));
	}
	vector<PII> ans;
	sort(ALL(arr));
	FOR(j, 0, SZ(arr))
	{
		int i = arr[j].Y;
		if(p[i] == i) continue;
		ans.PB(MP(i, where[i]));

		where[p[i]] = where[i];
		swap(p[i], p[where[i]]);
	}

	cout << SZ(ans) << endl;
	FOR(i, 0, SZ(ans))
		cout << ans[i].X + 1 << " " << ans[i].Y + 1 << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template<class T>
class BIT {
    vector<T> bit;
public:
    BIT(int n): bit(vector<T>(n+1, 0)){}

    T sum(int k){
        T ret = 0;
        for (++k; k > 0; k -= (k & -k)) ret += bit[k];
        return ret;
    }

    void add(int k, T x){
        for (++k; k < bit.size(); k  += (k & -k)) bit[k] += x;
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    auto u = v;
    sort(u.begin(), u.end());
    u.erase(unique(u.begin(), u.end()), u.end());
    for (int i = 0; i < n; ++i) {
        v[i] = lower_bound(u.begin(),u.end(), v[i])-u.begin();
    }
    BIT<int> bit(n);
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += i-bit.sum(v[i]);
        bit.add(v[i], 1);
    }
    vector<int> S(u.size()+1);
    for (int i = 0; i < n; ++i) {
        S[v[i]+1]++;
    }
    for (int i = 0; i < u.size(); ++i) {
        S[i+1] += S[i];
    }
    for (int i = 0; i < n; ++i) {
        printf("%lld\n", ans);
        ans += (n-S[v[i]+1]-S[v[i]]);
    }
    return 0;
}


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

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

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

signed main(){
    int a; cin>>a;
    int b; cin>>b;
    int c; cin>>c;
    cout<<21-a-b-c<<endl;

    return 0;
}

#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back;
#define ll long long
using namespace std;
typedef pair<int,int> pii;

///const int maxn=;

int main(){

    ///freopen("test.txt","r",stdin);
    ///freopen("moj.txt","w",stdout);

    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    printf("%d\n",21-a-b-c);

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int t,N,ans;
    cin >> t >> N;
   ans = ceil(N * 100 + t - 1) / t + N - 1;
   cout << ans << endl;
}

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

using namespace std;

void solve(int test, istream &in) {
    int64_t t, n;
    in >> t >> n;
    n--;
    vector<int64_t> p(101);
    for (int i = 0; i < 101; i++) {
        p[i] = i * (100 + t) / 100;
    }
    int64_t cnt100 = p[100] - p[0] - 100;
    int64_t x0 = (n / cnt100) * (100 + t);
    int64_t x = x0;
    n = n % cnt100;
    for (int i = 0; i < 100; i++) {
        int64_t cnt = p[i + 1] - p[i] - 1;
        x = x0 + p[i] + 1;
        if (n >= cnt) {
            n -= cnt;
        }
        else
            break;
    }
    x += n;
    printf("%lld\n", x);
}

int main(int argc, char* argv[])
{
#ifdef VLAD_LOCAL
	//FILE *f = fopen("in.txt", "r");
    ifstream f("in.txt");
    auto start = std::chrono::steady_clock::now();
#else
	//FILE *f = stdin;
    istream &f = cin;
#endif
    int tests = 1;
    //f >> tests;
    for (int test = 0; test < tests; test++) {
        solve(test, f);
    }
#ifdef VLAD_LOCAL
    auto end = std::chrono::steady_clock::now();
    double seconds = (double)std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() / 1000;
    printf("\n%.3lf seconds\n", seconds);
#endif
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const int inf = 1 << 30;
const ll infll = 1LL << 60;
const int mod = 1000000007;
const int mod9 = 998244353;

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

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

int main(){
    int a, b; cin >> a >> b;

    vector<int> ans;

    if(a > b){
        for(int i=1; i<=a; i++){
            ans.push_back(i);
        }
        for(int i=1; i<=b-1; i++){
            ans.push_back(-i);
        }
        ans.push_back((b-1)*b/2 - a*(a+1)/2);
    }
    else if(a == b){
        for(int i=1; i<=a; i++){
            ans.push_back(i);
        }
        for(int i=1; i<=b; i++){
            ans.push_back(-i);
        }
    }
    else{
        for(int i=1; i<=a-1; i++){
            ans.push_back(i);
        }
        for(int i=1; i<=b; i++){
            ans.push_back(-i);
        }
        ans.push_back((b+1)*b/2 - a*(a-1)/2);
    }

    for(int i=0; i<a + b; i++){
        if(i != a+b -1) cout << ans[i] << " ";
        else cout << ans[i] << endl;
    }
}

#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define reps(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define prl(a) cout << (a) << endl
#define allrange(a) a.begin(),a.end()

bool solve_translated(vector<pair<int,int>> &S,vector<pair<int,int>> &T){
    int N = S.size();
    int dx = S[0].first-T[0].first;
    int dy = S[0].second-T[0].second;
    bool flg = true;
    reps(i,1,N){
        if(!((S[i].first==T[i].first+dx) && (S[i].second==T[i].second+dy))){flg = false; break;}
    }
    return flg;
}
vector<pair<int,int>> Pitagora_rot(vector<pair<int,int>> &S,int a, int b , int c){
    int N = S.size();
    vector<pair<int,int>> PS(N);
    auto pt0 = S[0];
    PS[0] = pt0;
    bool flg = true;
    int dx,dy,x,y;
    reps(i,1,N){
        dx = S[i].first - pt0.first;
        dy = S[i].second - pt0.second;
        x=dx*a-dy*b;
        y=dx*b+dy*a;
        if(((x%c)!=0) || ((y%c)!=0)) {flg = false; break;}
        PS[i] = make_pair(x/c+pt0.first, y/c+pt0.second);
    }
    if(flg) return PS;
    else return vector<pair<int,int>>();
}

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

    vector<pair<int,int>> S(N),T(N);
    rep(i,N)
    {
        int x,y;
        cin >> x >> y;
        S[i].first = x;S[i].second = y;
    }

    rep(i,N)
    {
        int x,y;
        cin >> x >> y;
        T[i].first = x;
        T[i].second = y;
    }
    sort(allrange(T));

/*ピタゴラ三角形
    5	12	13
    8	15	17
    3	4	5
*/
    constexpr int tri[12][3] ={
    {3,4,5},
    {4,3,5},
    {-3,4,5},
    {-4,3,5},
    {0,1,1},
    {1,0,1},
    {-1,0,1},
    {0,-1,1},
    {-3,-4,5},
    {-4,-3,5},
    {3,-4,5},
    {4,-3,5}
    };

 /*
    vector<vector<int>> tri(0);
    tri.push_back(vector<int>({3,4,5}));
    tri.push_back(vector<int>({4,3,5}));
    tri.push_back(vector<int>({-3,4,5}));
    tri.push_back(vector<int>({-4,3,5}));
    tri.push_back(vector<int>({0,1,1}));
    tri.push_back(vector<int>({1,0,1}));
    tri.push_back(vector<int>({-1,0,1}));
    tri.push_back(vector<int>({0,-1,1}));
    tri.push_back(vector<int>({-3,-4,5}));
    tri.push_back(vector<int>({-4,-3,5}));
    tri.push_back(vector<int>({3,-4,5}));
    tri.push_back(vector<int>({4,-3,5}));
 //   tri.push_back(vector<int>({-5, -12, 13}));
 //   tri.push_back(vector<int>({-12, -5, 13}));
 //   tri.push_back(vector<int>({-8,-15,17}));
 //   tri.push_back(vector<int>({-15,-8,17}));
 //   tri.push_back(vector<int>({5, 12, 13}));
 //   tri.push_back(vector<int>({12, 5, 13}));
 //   tri.push_back(vector<int>({8,15,17}));
 //   tri.push_back(vector<int>({15,8,17}));
 //   tri.push_back(vector<int>({-5, 12, 13}));
 //  tri.push_back(vector<int>({-12, 5, 13}));
  //  tri.push_back(vector<int>({-8,15,17}));
  //  tri.push_back(vector<int>({-15,8,17}));
 //   tri.push_back(vector<int>({5, -12, 13}));
 //   tri.push_back(vector<int>({12, -5, 13}));
 //   tri.push_back(vector<int>({8,-15,17}));
 //   tri.push_back(vector<int>({15,-8,17}));

 */
    bool flg;

    if(N==2){
        auto sx = S[0].first-S[1].first;
        auto sy = S[0].second-S[1].second;
        auto tx = T[0].first-T[1].first;
        auto ty = T[0].second-T[1].second;
        flg= (sx*sx+sy*sy==tx*tx+ty*ty);
    } else {
        rep(j,12){
            auto S2 = Pitagora_rot(S,tri[j][0],tri[j][1],tri[j][2]);
            if(S2.empty()) continue;
            sort(allrange(S2));
            flg = solve_translated(S2,T);
            if(flg) break;
        }
    }
    if(flg) prl("Yes"); else prl("No");
}


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

#define fastio                  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define input_output            freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

template <typename Arg1>
void prn(Arg1&& arg1) { cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void prn(Arg1&& arg1, Args&&... args) { cout<<arg1<<" "; prn(args...); }

template <typename Arg1>
void prs(Arg1&& arg1) { cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void prs(Arg1&& arg1, Args&&... args) { cout<<arg1<<" "; prs(args...); }

template <typename Arg1>
void read(Arg1&& arg1) { cin>>arg1; }
template <typename Arg1, typename... Args>
void read(Arg1&& arg1, Args&&... args) { cin>>arg1; read(args...); }

#define int                     long long
#define all(ds)                 ds.begin(), ds.end()
#define uniq(v)                 (v).erase(unique(all(v)),(v).end())
#define gcd(x,y)                __gcd(x,y)
#define rep(i,a,b)              for(int i=a;i<b;i++)
#define precise(x)              cout<<fixed<<setprecision(x)
#define endl                    "\n"

const long long INF = 1e18;
const int32_t MOD = 1e9+7;
const int N = 2e5+5;

int n, m, k, q, r, l, x, y, z;
int a[N], b[N], c[N];
string s, t;
int ans ;

unordered_map<int, int>dp;

int recur(int y){

    if(dp.find(y) != dp.end())return dp[y];

    dp[y] = abs(y-x);
    if(y == 1){
        return dp[y];
    }
    if(y%2 == 0){
        dp[y] = min(dp[y], 1 + recur(y/2));
    }
    else{
        dp[y] = min(dp[y], 1 + min(recur(y-1), recur(y+1)));
    }
    return dp[y];

}
void solve(){
    read(x,y);
    // ans = abs(x-y);
    prn(recur(y));
}

signed main()
{
#ifndef ONLINE_JUDGE
    input_output
#else
    fastio
#endif

#ifdef SIEVE
    sieve();
#endif

#ifdef NCR
    init();
#endif

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

    return 0;
}

#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 810;

int a[N][N], sum[N][N];
int n, k, ju;

bool check(int mid) {
    for (int i = 1; i <= n; i ++) {
        for (int j = 1; j <= n; j ++) {
            int t = (a[i][j] > mid);
            sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + t;
        }
    }
    for (int i = k; i <= n; i ++)
    for (int j = k; j <= n; j ++) {
        int t = sum[i][j] - sum[i][j - k] - sum[i - k][j] + sum[i - k][j - k];
        if (t < ju)   return 1;
    }
    return 0;
}

int main() {
    cin >> n >> k;
    ju = k * k / 2 + 1;
    for (int i = 1; i <= n; i ++)
        for (int j = 1; j <= n; j ++)   cin >> a[i][j];

    int l = 0, r = 1e9;
    while (l < r) {
        int mid = l + r >> 1;
        if (check(mid)) r = mid;
        else l = mid + 1;
    }
    cout << l;
    return 0;
}


#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define RNG(i, s, n) for(int i = s;i <= n;i++)
#define _RNG(i, e, s) for(int i = e;i >= s;i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define dup(x, y) (x + y - 1) / (y)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define lb(x, key) lower_bound(all(x) , (key))
#define ub(x, key) upper_bound(all(x) , (key))
#define _size(v) int((v).size())

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

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pi>;
using vpl = vector<pl>;

#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a, b) cout<<"["<<#a<<","<<#b<<"] = "<<"["<<a<<","<<b<<"]\n"
#define debug3(a, b, c) cout<<"["<<#a<<","<<#b<<","<<#c<<"] = "<<"["<<a<<","<<b<<","<<c<<"]\n"

template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr) {
    cout << "{";
    for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i];
    cout << "}";
    return out;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T> > &arr) {
    cout << "{\n";
    for (auto &vec : arr)cout << "  " << vec << ",\n";
    cout << "}";
    return out;
}

template<class S, class T>
ostream &operator<<(ostream &out, const pair<S, T> &p) {
    cout << "{" << p.first << "," << p.second << "}" << '\n';
    return out;
}

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

template<class S, class T>
istream &operator>>(istream &in, pair<S, T> &p) {
    cin >> p.first >> p.second;
    return in;
}

template<class T>
T binom_lucas(T n, T k, T p) {
    auto f = [&](T n, T k) {
        if (n < 0 || k < 0 || n < k) return 0;
        T res = 1;
        for (int i = 1; i <= k; i++) {
            res = (res * T(n + 1 - i));
            res /= T(i);
            res %= p;
        }
        return res;
    };
    T res = 1;
    while (n) {
        res = res * f(n % p, k % p);
        n /= p;
        k /= p;
        res %= p;
    }
    return res;
}

int main(int argc, char const *argv[])
{
	int N;
	string s;
	cin >> N >> s;

	map<char , int> M;
	M['R'] = 0,M['B'] = 1,M['W'] = 2;

	ll sum = 0;
	REP(i,N)
	{
		sum += binom_lucas(N-1,i,3) * M[s[i]];
		// debug(binom_lucas(N-i,i,3));
		sum %= 3;
	}

	// debug(sum);

	if(N % 2 == 0)
	{
		sum = (3 - sum) % 3;
	}

	string A = "RBW";
	cout << A[sum] << endl;

	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9+7;
ll modpow(ll a, ll n, ll p) {
    ll res = 1;
    while (n) {
        if (n & 1) res = res * a % p;
        a = a * a % p;
        n >>= 1;
    }
    return res;
}
ll modinv(ll a, ll p = MOD) { return modpow(a, p-2, p); }

vvll cross(vvll &a, vvll &b) {
  int n = (int)a.size();
  int m = (int)b.size();
  int nm = (int)a[0].size();
  vvll res(n,vll(m,0));
  rep(i,n) rep(j,m) rep(k,nm) ( res[i][j] += a[i][k] * b[k][j] ) %= MOD;
  return res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n, m, k; cin >> n >> m >> k;
    vvll a(n,vll(1)); rep(i,n) cin >> a[i][0];
    vvll dp(n,vll(n,0)); rep(i,n) dp[i][i] = 1;
    rep(i,m) {
      ll s, t; cin >> s >> t; s--; t--;
      ( dp[s][s] -= modinv( 2 * m ) - MOD ) %= MOD;
      ( dp[s][t] += modinv( 2 * m ) ) %= MOD;
      ( dp[t][t] -= modinv( 2 * m ) - MOD ) %= MOD;
      ( dp[t][s] += modinv( 2 * m ) ) %= MOD;
    }
    while ( k ) {
      if ( k & 1 ) a = cross( dp, a );
      dp = cross( dp, dp );
      k >>= 1;
    }
    rep(i,n) cout << a[i][0] << endl;
    return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if((c*b)%a==0) cout << c*b/a-1 <<endl;
  else cout << c*b/a << endl;
}

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

#define   fi(a,b) for(int i=a;i<b;i++)
#define   fj(a,b) for(int j=a;j<b;j++)
#define   ff first
#define   ss second
#define   ll long long
#define   ld long double
#define   ull unsigned long long
#define   bp(x) __builtin_popcount(x)
#define   pr(x) for(auto it: x) cout<<it<<" "; cout<<endl;
#define   getMax(x) max_element(x.begin(),x.end())
#define   getMin(x) min_element(x.begin(),x.end())
#define   endl "\n"
typedef   vector<int> vi;
typedef   vector< pair<int,int> > vii;
typedef   vector<long long> vl;
typedef   pair<int,int> pii;
typedef   pair<ll,ll> pll;
typedef   vector< pair<ll,ll> > vll;
//int dx[]={1,0,-1,0};
//int dy[]={0,1,0,-1};
//int dx[]={-1,0,1,1,1,0,-1,-1};
//int dy[]={-1,-1,-1,0,1,1,1,0};

void nikal_pehli_fursat_mai(){
    ll x, y, z;
    cin>>x>>y>>z;
    ll low = 0, high = 1e18;
    while(low<high){
    	ll mid = low + (high-low+1)/2;
    	ld tmp = (ld)y/x;
    	ld tmp1 = (ld)mid/z;
    	if(tmp>tmp1){
    		low = mid;
    	}
    	else{
    		high = mid-1;
    	}
    }
	// ld tmp = (ld)y/x;
	// ld tmp1 = (ld)z/593;
	// cout<<tmp<<" "<<tmp1<<endl;
    cout<<low<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int tc=1;
    // cin>>tc;
    while(tc--){
    nikal_pehli_fursat_mai();
    }
}


// Template
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <tuple>
#include <utility>
#include <queue>
#include <set>
#include <map>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll infll = 3003003003003003003LL;
template <typename T>
inline bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &element : vec) is >> element;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    for (int i = 0, vec_len = (int)vec.size(); i < vec_len; ++i) {
        os << vec[i] << (i + 1 == vec_len ? "" : " ");
    }
    return os;
}
struct IOSET {
    IOSET() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    }
} ioset;

// Main
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m), c(m);
    rep(i, m) {
        int u, v;
        char ch;
        cin >> u >> v >> ch;
        a[i] = u - 1;
        b[i] = v - 1;
        c[i] = ch - 'a';
    }

    vector<vector<int>> g(n * n);
    rep(i, m) rep(j, m) {
        if (c[i] == c[j]) {
            g[a[i] * n + a[j]].push_back(b[i] * n + b[j]);
            g[a[i] * n + b[j]].push_back(b[i] * n + a[j]);
            g[b[i] * n + a[j]].push_back(a[i] * n + b[j]);
            g[b[i] * n + b[j]].push_back(a[i] * n + a[j]);
        }
    }

    vector<int> dist(n * n, inf);
    queue<int> que;
    rep(i, n) {
        dist[i * n + i] = 0;
        que.push(i * n + i);
    }
    rep(i, m) {
        if (chmin(dist[a[i] * n + b[i]], 1)) que.push(a[i] * n + b[i]);
        if (chmin(dist[b[i] * n + a[i]], 1)) que.push(b[i] * n + a[i]);
    }
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int u : g[v]) {
            if (chmin(dist[u], dist[v] + 2)) que.push(u);
        }
    }

    int ans = dist[n - 1];
    if (ans == inf) ans = -1;
    cout << ans << "\n";
}

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

struct edge {
	int to;
	int c;
	edge(int to, int c) : to(to), c(c) {}
};

const int INF = 1001001001;

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<edge>> g(n);
	for(int i = 0; i < m; i++) {
		int a, b;
		char c;
		cin >> a >> b >> c;
		a--;
		b--;
		g[a].emplace_back(b, c - 'a');
		g[b].emplace_back(a, c - 'a');
	}
	vector<vector<int>> dp(n, vector<int>(n, INF));
	queue<pair<int, int>> q;
	auto push = [&](int a, int b, int x) {
		if(dp[a][b] != INF) return;
		dp[a][b] = x;
		q.emplace(a, b);
	};
	push(0, n - 1, 0);
	while(!q.empty()) {
		auto [a, b] = q.front();
		q.pop();
		for(auto&& ea : g[a]) {
			for(auto&& eb : g[b]) {
				if(ea.c != eb.c) continue;
				push(ea.to, eb.to, dp[a][b] + 1);
			}
		}
	}
	int ans = INF;
	for(int i = 0; i < n; i++) {
		ans = min(ans, dp[i][i] * 2);
		for(auto&& e : g[i]) ans = min(ans, dp[i][e.to] * 2 + 1);
	}
	if(ans == INF) ans = -1;
	cout << ans << endl;
	return 0;
}


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

int main()
{
	int N;
	cin >> N;
	int A[N];
	for(int i = 0; i < N; i++){
		cin >> A[i];
	}
	sort(A, A + N);
	for(int i = 1; i <= N; i++){
		if(i != A[i - 1]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

                              ////JAI SHREE RAM////
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
const long long int INF = (long long)1e15;
const long long int mod = 1e9+7;
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define sd second
#define ft first
//
bool cmp(const pair<int,int> &a, const pair<int,int> &b)
{
    //return (a.sd>=b.sd);
    return abs(a.ft)+abs(a.sd) < abs(b.ft)+abs(b.sd);
}

void solve()
{
    int n;cin>>n;
    string s;cin>>s;
    if(n>1 && s[0]!=s[n-1]){
        cout<<1<<endl;
        return;
    }
    f(i,1,n-1){
        if(s[i]!=s[0] && s[i+1]!=s[n-1]){
            cout<<2<<endl;
            return;
        }
    }
    cout<<-1<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}


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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll = int64_t;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<int>(1e9 + 7);

//.data
constexpr int MAXN = 105;

char dp[MAXN][MAXN];

bool Win(char a, char b) {
    if (a == b) {
        return true;
    }
    if (a == 'R') {
        return b == 'S';
    }
    if (a == 'P') {
        return b == 'R';
    }
    return b == 'P';
}

int Mul(int x, int y, int mod) {
    return int(1LL * x * y % mod);
}

int Add(int x, int y, int mod) {
    x += y;
    return x < mod ? x : x - mod;
}

int FastPow(int x, int p, int mod) {
    int res = 1;
    while (p > 0) {
        if (p & 1) {
            res = Mul(res, x, mod);
        }
        p >>= 1;
        x = Mul(x, x, mod);
    }
    return res;
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n, k;
    string s;
    cin >> n >> k >> s;
    loop(n) {
        dp[0][i] = s[i];
    }
    for (int i = 1; i <= k; ++i) {
        for (int j = 0; j < n; ++j) {
            int x = FastPow(2, i - 1, n);
            dp[i][j] = Win(dp[i - 1][j], dp[i - 1][Add(j, x, n)]) ? dp[i - 1][j] : dp[i - 1][Add(j, x, n)];
        }
    }
    cout << dp[k][0] << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

#include <iostream>
#include <vector>
#include <math.h>
#include <bits/stdc++.h>

#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;

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

int main() {
	int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    // R .. グー P .. パー S .. チョキ
    string t = s + s;
    rep(a, k){
        string t = s + s;
        for(int i = 0; i < n; i++){
            if(t[i*2] == 'R' and t[i*2+1] == 'R'){
                s[i] = 'R';
            }else if(t[i*2] == 'R' and t[i*2+1] == 'P'){
                s[i] = 'P';
            }else if(t[i*2] == 'R' and t[i*2+1] == 'S'){
                s[i] = 'R';
            }else if(t[i*2] == 'P' and t[i*2+1] == 'R'){
                s[i] = 'P';
            }else if(t[i*2] == 'P' and t[i*2+1] == 'P'){
                s[i] = 'P';
            }else if(t[i*2] == 'P' and t[i*2+1] == 'S'){
                s[i] = 'S';
            }else if(t[i*2] == 'S' and t[i*2+1] == 'R'){
                s[i] = 'R';
            }else if(t[i*2] == 'S' and t[i*2+1] == 'P'){
                s[i] = 'S';
            }else if(t[i*2] == 'S' and t[i*2+1] == 'S'){
                s[i] = 'S';
            }
        }
    }
    cout << s[0] << endl;
}


#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T, class 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) {
#ifdef LOCAL
	os << "{";
#endif
	rep(i, v.size()) {
		if (i) os << " ";
		os << v[i];
	}
#ifdef LOCAL
	os << "}";
#endif
	return os;
}
template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
	rep(i, v.size()) { is >> v[i]; }
	return is;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
#ifdef LOCAL
#define dbg(x) cerr << #x << ": " << (x) << '\n'
#define say(x) cerr << (x) << '\n'
#else
#define dbg(x)
#define say(x)
#endif
void init_main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
}
string solve(bool a) { return ((a) ? "Yes" : "No"); }
int main() {
	init_main();
	int a,b;
	double ans = 0.0;
	cin >> a>>b;
	ans = (double)b * a / 100.0;
	cout<< fixed << setprecision(15) << ans << '\n';
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
constexpr long long INF = 1000000000 + 100;
constexpr long long LINF = 1000000000000000000 + 100;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }

int main(){
    int t; cin >> t;
    string a = "atcoder";
    vector<int> ans;
    while(t--){
        string s; cin >> s;
        if(s>a)ans.push_back(0);
        else{
            int first_index = -1;
            rep(i, s.size()){
                if(s[i]!='a'){
                    first_index = i;
                    if(s[i]<='t')first_index++;
                    break;
                }
            }
            if(first_index==-1)ans.push_back(-1);
            else ans.push_back(first_index-1);
        }
    }
    for(auto a:ans)cout << a << ln;
}


#include<bits/stdc++.h>
template <typename _Tp>void read(_Tp &x){
	char ch(getchar());bool f(false);while(!isdigit(ch))f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch))x=x*10+(ch&15),ch=getchar();
	if(f)x=-x;
}
template <typename _Tp,typename... Args>void read(_Tp &t,Args &...args){read(t);read(args...);}
const int N=200005;
typedef long long ll;
int a[N];
int main(){
	int n;read(n);
	int mx=0;
	ll s=0,S=0;
	for(int i=1;i<=n;++i){
		read(a[i]),mx=std::max(a[i],mx);
		s+=a[i],S+=s;
		printf("%lld\n",S+1LL*i*mx);
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int main(){

  int n,m; cin>>n>>m;
  ll a{},b{};
  for(int i=0; i<n; i++){
    string s; cin>>s;
    int cnt{};
    for(auto i:s)if(i=='1')cnt++;
    if(cnt%2) a++;
    else b++;
  }
  cout<<a*b<<endl;

}


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

#ifdef LOCAL
#include "/debug.h"
#else
#define db(...)
#endif

#define all(v) v.begin(), v.end()
#define pb push_back
using ll = long long;
const int NAX = 2e5 + 5, MOD = 1000000007;

class UnionFind
{ // OOP style
private:
    vector<int> p, rank, setSize; // remember: vi is vector<int>
    int numSets;

public:
    UnionFind(int N)
    {
        setSize.assign(N, 1);
        numSets = N;
        rank.assign(N, 0);
        p.assign(N, 0);
        for (int i = 0; i < N; i++)
            p[i] = i;
    }
    int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
    bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
    bool unionSet(int i, int j)
    {
        if (!isSameSet(i, j))
        {
            numSets--;
            int x = findSet(i), y = findSet(j);
            // rank is used to keep the tree short
            if (rank[x] > rank[y])
            {
                p[y] = x;
                setSize[x] += setSize[y];
            }
            else
            {
                p[x] = y;
                setSize[y] += setSize[x];
                if (rank[x] == rank[y])
                    rank[y]++;
            }
            return true;
        }
        return false;
    }
    int numDisjointSets() { return numSets; }
    int sizeOfSet(int i) { return setSize[findSet(i)]; }
};

void solveCase()
{
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> adj(n);
    UnionFind U(n);
    for (size_t i = 0; i < m; i++)
    {
        int u, v, c;
        cin >> u >> v >> c;
        --u, --v;
        if (U.unionSet(u, v))
        {
            adj[u].pb({v, c});
            adj[v].pb({u, c});
        }
    }
    if (U.sizeOfSet(0) != n)
    {
        cout << "No\n";
        return;
    }
    vector<int> mexes(n), res(n, -1);
    for (size_t i = 0; i < n; i++)
    {
        set<int> ss;
        for (auto &x : adj[i])
            ss.insert(x.second);
        mexes[i] = 1;
        while (ss.count(mexes[i]))
            mexes[i]++;
    }
    function<void(int, int)> dfs = [&](int node, int par) -> void {
        if (res[node] == -1)
            res[node] = mexes[node];
        for (auto &x : adj[node])
            if (x.first != par)
            {
                if (x.second != res[node])
                    res[x.first] = x.second;
                dfs(x.first, node);
            }
        db(node, par, res[node], mexes[node]);
        db(adj[node]);
    };
    dfs(0, 0);
    for (size_t i = 0; i < n; i++)
        cout << res[i] << '\n';
}

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; ++i)
        solveCase();
    return 0;
}

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

vector<pair<int,int>> G[100010];
int A[100010];
void bfs(int s){
  queue<int> q;
  A[s]=1;
  q.push(s);

  while(!q.empty()){
    int t=q.front();
    q.pop();

    for(auto x:G[t]){
      if(A[x.first]!=0) continue;

      if(x.second==A[t]){
        if(x.second!=1) A[x.first]=1;
        else A[x.first]=2;
      }
      else{
        A[x.first]=x.second;
      }
      q.push(x.first);
    }
  }
}

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

  rep(i,m){
    int u,v,c;
    cin>>u>>v>>c;
    G[u].push_back({v,c});
    G[v].push_back({u,c});
  }

  bfs(1);

  for(int i=1;i<=n;i++) cout<<A[i]<<endl;

  return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >>n;
    int a[n];
    int b[n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(int j=0; j<n; j++)
    {
         cin >>b[j];
    }
    int s=0;
    for(int i=0; i<n ;i++)
    {
        s=s+(a[i]*b[i]);
    }
    //cout <<s;
     if(s==0)
            cout<<"Yes";
        else
            cout <<"No";
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S,class T>auto&operator<<(ostream&os,map<S,T>mp){bool a=1;for(auto p:mp){os<<(a?"":", ")<<p;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vl a(n),b(n);cin>>a>>b;
    ll ans=0;
    rep(i,n)ans+=a[i]*b[i];
    Yn(ans==0);
    return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define f first
#define s second
#define pii pair<int,int>

const int N =3e5+5;
const int MOD = 1e9+7;

ll qpow(ll a, ll b, ll m)
{
    ll  ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}

//vector<int>adj[200005];
//vector<int>a,val;
//vector<bool>vis;
int a[200005];
int val[200005];
bool vis[200005];
vector<int>adj[200005];
ll ans = -1e18;

void dfs(int v, int par){
    vis[v] = true;
    for(int u:adj[v]){
        if(u!=par){
            ans = max(ans, (ll)a[u]-val[v]);
            val[u] = min(val[v], a[u]);
            if(!vis[u])
              dfs(u, v);
        }
    }
}

ll x,y;
map<ll,ll>m;

ll func(ll v){
    if(v<=x){
        return m[v] = x-v;
    }
    if(m[v]) return m[v];
    ll val = v-x;
    if(v%2){
        val = min(val, func(v-1)+1);
        val = min(val, func(v+1)+1);
    }
    else{
        val = min(val, func(v/2)+1);
    }
    return m[v] = val;
}

int main()
{
	IOS;

	int t=1; //cin>>t;
	while(t--){
	    cin>>x>>y;
	    cout<<func(y);

	}
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll x,y;
map<ll,ll>f;
ll dfs(ll u)
{
	if(!u)		return x;
	if(f[u])	return f[u];
	ll	&ans=f[u];
	ans=abs(x-u);
	if(u%2==0)	ans=min(ans,1+dfs(u/2));
	else		ans=min(ans,min(1+dfs(u-1),1+dfs(u+1)));
	return ans;
}
int main()
{
	cin>>x>>y;
	printf("%lld\n",dfs(y));
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define sz(x) ((int) x.size())
#define all(x) x.begin(), x.end()
#define debug if (true) cerr
using ll = long long;

ll N;

void solve() {
    cin >> N;
    ll answer = N;
    rep(b, 0, 60) {
        ll B = 1LL << b;
        if (B > N) continue;
        ll A = N / B;
        ll C = N - A * B;
        // cout << A << " " << B << " " << C << endl;
        answer = min(A+b+C, answer);
    }
    cout << answer << '\n';
}

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

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

typedef long long LL;

LL n;

void into(){
  scanf("%lld",&n);
  LL a=(1LL<<60)-1,b=0,c=0;
  for (LL y=0;1LL<<y<=n;++y){
	LL x=n>>y,z=n&(1LL<<y)-1;
	if (x+y+z<a+b+c) a=x,b=y,c=z;
  }
  //printf("%lld %lld %lld\n",a,b,c);
  printf("%lld\n",a+b+c);
}

void work(){
}

void outo(){
}

int main(){
  int T=1;
  //scanf("%d",&T);
  for (;T--;){
    into();
    work();
    outo();
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL Num;
LL Cnt[3],Loc;

int main() {
    cin>>Num;
    LL Temp=Num%3;
    while(Num) {
        Loc++;
        Cnt[Num%10%3]++;
        Num/=10;
    }
    if(Temp==0) printf("0\n");
    else if(Temp==1) {
		if(Cnt[1] >= 1 && 1 < Loc) printf("1\n");
		else if(Cnt[2]>=2 && 2<Loc) printf("2\n");
		else printf("-1\n");
	}
    else
	{
		if(Cnt[2]>=1 && 1<Loc) printf("1\n");
		else if(Cnt[1]>=2 && 2<Loc) printf("2\n");
		else printf("-1\n");
	}
    return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <cmath>
#include <set>
#include <map>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int inf = 10111111;

int main() {
	string s; cin >> s;
	vector<int>c(3);
	int n = s.size();
	rep(i, n)c[(s[i] - '0') % 3]++;
	int x = 0;
	rep(i, 3)x += c[i] * i;
	int ans = inf;
	rep(i1, 3)rep(i2, 3) {
		if (c[1] < i1)continue;
		if (c[2] < i2)continue;
		if (i1 + i2 == n)continue;
		int cal = x;
		cal -= 1 * i1;
		cal -= 2 * i2;
		if (cal % 3 == 0) {
			ans = min(ans, i1 + i2);
		}
	}
	if (ans == inf)ans = -1;
	cout << ans << endl;
}


#include <iostream>
using namespace std;
int main(void){
    int A, B;
    cin >> A >> B;
    int sum = 0;
    int i, j;
    for (i = 1; i < A; i++) {
        cout << i << " ";
        sum += i;
    }
    for (j = 1; j < B; j++) {
        cout << -j << " ";
        sum -= j;
    }
    if(sum > 0){
        cout << i << " " << -(sum + i) << endl;
    } else {
        cout << -j << " " << j - sum << endl;
    }
}

/*
Author : DEBAPRIYA CHANDRA
    [JGEC]

*/

#include<bits/stdc++.h>
#define ll  long long int
#define dbl long double
#define loop(i,n) for(int i=0;i<n;i++)
#define test(t) int t;cin>>t;while(t--)
#define debo ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<ll>
#define sz size()
#define iss is_sorted
#define bs binary_search
#define mx INT_MAX
#define mi INT_MIN
#define gcd(a,b)  __gcd(a,b)
#define sw(a,b) swap(a,b)

using namespace std;
bool isPalindrome(string  s,int i,int j)
{
     if(i>j) return true;
     if(s[i]!=s[j]) return false;
     else return isPalindrome( s, i+1, j-1);
}
bool isPrime(ll  n)
{
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
 signed main(){
     debo;
     ll a,b;
     cin>>a>>b;
     if(a>=b)
     {
         for(ll i=1;i<=a;i++)cout<<i<<" ";
         for(ll i=1;i<b;i++)cout<<-i<<" ";
         ll sum=0;
         for(ll i=b;i<=a;i++){
             sum+=i;
         }
         cout<<-sum<<endl;
     }
     else {
         ll bb[b];
         for(ll i=1;i<a;i++)cout<<i<<" ";
         for(ll i=1;i<=b;i++)bb[i-1]=-i;
         ll sum=0;
         for(ll i=a;i<=b;i++){
             sum+=i;
         }
         cout<<sum<<" ";
         for(ll i=0;i<b;i++)cout<<bb[i]<<" ";

     }

     return 0;
 }


#include<iostream>
#include<cmath>
using namespace std;
#define ll long long
ll k,ans,cnt[10],s[10],t[10],cntt[10],cnts[10];
string S,T;
ll che(int x,int y) {
	int st=0,ss=0;
	cnts[x]++,cntt[y]++;
	for(int i=1; i<10; i++) {
		ss+=i*pow(10,cnts[i]);
		st+=i*pow(10,cntt[i]);
	}
	cnts[x]--,cntt[y]--;
	if(ss<=st)return 0;
	if(x==y)return cnt[x]*(cnt[x]-1);
	else return cnt[x]*cnt[y];
}
int main() {
	cin>>k>>S>>T;
	for(int i=1; i<10; i++)cnt[i]=k;
	for(int i=1; i<5; i++) {
		s[i]=S[i-1]-'0';
		t[i]=T[i-1]-'0';
		cnt[s[i]]--,cnt[t[i]]--;
		cnts[s[i]]++,cntt[t[i]]++;
	}
	for(int i=1; i<10; i++)
		for(int j=1; j<10; j++)
			ans+=che(i,j);

	double lans=1.0*ans/((9*k-8)*(9*k-9));
	printf("%.9f",lans);
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define lowbit(x) x&(-x)
int tr[N],h,w,m,r[N],c[N];
void upd(int x,int v){
	while(x<=h){
		tr[x]+=v,x+=lowbit(x);
	}
}
int que(int x){int s=0;
	while(x){
		s+=tr[x],x-=lowbit(x);
	}
	return s;
}
int main(){
	scanf("%d%d%d",&h,&w,&m);
	fill(r+1,r+h+1,w+1);	//初始化
	fill(c+1,c+w+1,h+1);
	while(m--){
		int x,y;scanf("%d%d",&x,&y);
		r[x]=min(r[x],y),c[y]=min(c[y],x);
	}ll ans=0;bool jg=0;
	for(int i=1;i<=h;i++){
		if(jg){
			r[i]=1;continue;
		}
		if(r[i]==1){
			jg=1;continue;
		}
		ans+=r[i]-1;
	}
	vector<int>v[w+2];
	for(int i=1;i<=h;i++) v[r[i]].pb(i);
	for(int i=1;i<=w;i++){
		if(c[i]==1) break;
	 	ans+=que(c[i]-1);
	 	for(int j:v[i]) upd(j,1);
	}printf("%lld\n",ans);
	return 0;
}


#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define INP "solve"
#define OUT "solve"

const long long INF_LL = 4e18;
const int INF = 1e9 + 100;
const int MOD = 1e9 + 7;
const long double EPS = 1e-10;
const int BLOCK = 550;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, 1, 0, -1};
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());

void open_file() {
    #ifdef THEMIS
        freopen(INP ".inp","r",stdin);
        freopen(OUT ".out","w",stdout);
    #endif // THEMIS
}
const int maxN = 1e2 + 100;

void sol() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> dp(n + 1, INF);
    vector<int> mn(26, INF);
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        int c = s[i - 1] - 'a';
        for (int nc = 0; nc < 26; nc++) {
            if (c == nc) continue;
            dp[i] = min(dp[i], mn[nc] + 1);
        }
        mn[c] = min(mn[c], dp[i - 1]);
    }
    if (dp[n] == INF) cout << -1 << '\n';
    else cout << dp[n] << '\n';
}

void solve() {
    clock_t begin = clock();
    int T;
    //cin >> T;
    T = 1;
    int TestCase = 0;
    while (T--) {
        TestCase += 1;
        //cout << "Case #" << TestCase << ": ";
        //cout << "Test " << TestCase << ": ";
        sol();
        //if (T) cout << '\n';
    }
    clock_t end = clock();
    cerr << "Time: " << fixed << setprecision(10) << (double)(end - begin) / (double)CLOCKS_PER_SEC << '\n';
}

int main(int argc,char *argv[]) {
    ///srand(Time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    open_file();
    solve();
}

#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define pii pair <int , int>
#define mp make_pair
#define fs first
#define sc second
using namespace std;
typedef long long LL;

template <typename T>
void read(T &x) {
	T f=1;x=0;char s=getchar();
	while(s<'0'||s>'9') {if(s=='-') f=-1;s=getchar();}
	while(s>='0'&&s<='9') {x=(x<<3)+(x<<1)+(s^'0');s=getchar();}
	x *= f;
}

template <typename T>
void write(T x , char s='\n') {
	if(!x) {putchar('0');putchar(s);return;}
	if(x<0) {putchar('-');x=-x;}
	T t = 0 , tmp[25] = {};
	while(x) tmp[t ++] = x % 10 , x /= 10;
	while(t -- > 0) putchar(tmp[t] + '0');
	putchar(s);
}

const int MAXN = 1e5 + 5;

int n , f[MAXN] , val[30];
char s[MAXN];

int main() {
	read(n);
	scanf("%s" , s + 1);
	memset(val , 127 , sizeof val);
	val[s[n] - 'a'] = 0;
	for (int i = n - 1; i >= 1; --i) {
		f[i] = 1e9;
		for (int j = 0; j < 26; ++j) if(val[j] < (int)(1e9) && s[i] - 'a' != j) f[i] = min(f[i] , val[j] + 1);
		if(f[i] < (int)1e9) val[s[i - 1] - 'a'] = min(val[s[i - 1] - 'a'] , f[i]);
	}
	if(f[1] < (int)1e9) write(f[1]);
	else puts("-1");
	return 0;
}


#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
#define mod 1000000007
#define mod2 998244353
#define pb push_back
#define ll long long
#define fi first
#define lb lower_bound
#define test ll int t;cin>>t;while(t--)
#define se second
#define pll pair<long long,long long>
#define icc ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

ll gcd(ll a, ll b){
    if(!a)return b;
    return gcd(b%a,a);
}
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a);}
                a=(a*a);
                b>>=1;
        }
    return ans;
}
vector<ll> spf,prime;
void primes(ll n){
    spf.assign(n+1,0);
    spf[1] = 1;
    for(ll i=2; i<=n; i++){
        if (!spf[i]){
         spf[i]=i;prime.pb(i);
         for (ll j=i*i; j<=n; j+=i)
         if (!spf[j])
         spf[j] = i;
        }
    }
}
ll fact[1000001];
void factorial(ll n){
	fact[0]=1;
	for(ll i=1;i<=n;i++){
		fact[i]=fact[i-1]*i;
		if(fact[i]>=mod)
			fact[i]%=mod;
	}
}
priority_queue<ll,vector<ll>,greater<ll> > qqqqq;

void solve(){
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   if(c*d-b<0){cout<<"-1";return;}
   for(ll i=0;i<10000000;i++){
       if(a<=(c*d-b)*i){
           cout<<i;
           return ;
       }
   }
   cout<<"-1";
}
int main(){
    icc;
    //test
    solve();
	return 0;
}
// ll op;
// 	cin>>op;
// 	for(ll fff=1;fff<=op;fff++){

// 		cout<<"Case #"<<fff<<": "<<ans<<endl;
// 	}

//#include <atcoder/maxflow.hpp>
#include <memory>
#include <iostream>
#include <map>
#include <list>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
#include <complex>
#include <thread>
#include <bitset>

#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s

typedef long long ll;

using namespace std;
//using namespace atcoder;

//ll modd = (1000LL * 1000LL * 1000LL + 7LL);
ll modd = 998244353;

ll binary_search(function<bool(ll)> func, ll start, ll end) {
    /*      func:int ->bool
            returns smallest int x where func(x) evaluates to true, searches in [start,end), it is assumed the values are false, .. , false, true ...
             */
    if (end <= start) {   return end;  }   // has to be here, otherwise func(end-1) in next line could be a problem
    if (!func(end-1)) {  return end;  }
    while (end-start>1) {
        ll mid = (start+end)/2;
        if (func(mid)) {  end = mid;  } else { start = mid;   }
    }
    if (func(start)) {  return start;  } else {  return end;   }
};

int main(int argc, char *argv[])   {

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

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    auto start = chrono::steady_clock::now();

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(n); readint(m);
        vector<vector<pair<int,ll>>> adj(n);
        forr(i,0,m) {
            readint(aa); readint(bb); readll(cc); --aa; --bb;
            adj[aa].push_back(make_pair(bb,cc));
        }

        vector<vector<ll>> dist;
        forr(i,0,n) {
            priority_queue<pair<ll,int>> todo;
            for(auto nn : adj[i]) {
                todo.push(make_pair(-nn.second, nn.first));
            }
            dist.push_back(vector<ll>(n, modd*modd));
            while (!todo.empty()) {
                auto curr = todo.top(); todo.pop();
                if (-curr.first < dist.back()[curr.second]) {
                    dist.back()[curr.second] = -curr.first;
                    for(auto nn : adj[curr.second]) {
                        todo.push(make_pair(-nn.second+curr.first, nn.first));
                    }
                }
            }
            cout << ((dist.back()[i] == modd*modd) ? -1 : dist.back()[i]) << endl;
        }

    }

//        auto stop = chrono::steady_clock::now();
//        auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start);
//        cout << "Duration: " << duration.count() << endl;
    return 0;
}


#include "bits/stdc++.h"

using namespace std;

#define pi               acos(-1)
#define inc(a)           a.begin(), a.end()
#define dec(a)           a.rbegin(), a.rend()
#define Unique(n)        (n).erase(unique(inc(n)), (n).end())
#define what_is(x)       cerr << #x << " is " << x << '\n';
#define to(i, a, n)      for(ll i=a; i<=n; i++)
#define fr(i, a, n)      for(int i=a; i>=n; i--)
#define read(arr, l, r)  for(int i=l; i<r; cin >> arr[i++])
#define prnt(arr, l, r)  for(int i=l; i<r; cout << arr[i++] << " \n"[i==r])

typedef long long ll;
typedef long double ld;

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

ll n, res, l, r, mid, sum;
ll check(ll x, ll y, ll ans = 0){
    x--;
    if(x & 1) ans = - ((x + 1) / 2) * x;
    else ans = - (x + 1) * (x / 2);
    if(y & 1) ans += ((y + 1) / 2) * y;
    else ans += (y + 1) * (y / 2);

    return  ans;
}

bool bin(ll x){
    l = 1, r = n/x + 1;
    while (l <= r){
        mid = (l+r) / 2;
        sum = check(mid, mid+x-1);
        if(sum == n) return true;
        else if(sum > n) r = mid-1;
        else l = mid+1;
    }
    return false;
}

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

    cin >> n;
    to(i, 1, 10000000)
        if(bin(i)) res += 2;

    cout << res;

    return 0;
}

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define fst ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
#define pb                            push_back
#define mp                            make_pair
#define gcd                           __gcd
#define f                             first
#define s                             second
#define mm(arr)                       memset(arr, 0, sizeof(arr))
#define scanArray(a,n)                for(int i = 0; i < n; i++){cin >> a[i];}
#define coutArray(a,n)                for(int i = 0; i < n; i++){cout << a[i] << " ";};cout << endl;
#define mod                           1000000007
typedef long long ll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
int fact(int n);
int nCr(int n, int r)  {return fact(n) / (fact(r) * fact(n - r));}
int fact(int n){
    int res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}
bool isPrime(int n){
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    if (n % 2 == 0 || n % 3 == 0)
        return false;

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

    return true;
}

void solve(){
	int k;
	cin >> k;
	int ans = 0;

	for(int i = 1; i <= k; i++){
		for(int j = 1; j <= (k / i) + 1; j++){
			if (i * j <= k){
				ans += (k / (i * j));
			}
		}
	}
	cout << ans << "\n";

}
//const int k = 2e5 + 5;
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif

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


#include<bits/stdc++.h>
#define fastcall __attribute__((optimize("-O3")))
#pragma GCC optimize(1)
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#define db double
#define il inline
#define iL (1<<20)
#define re register
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define TEM template<class T>il void
#define Write(x,LC) write((x)),*iter++=LC
#define Writeneg(x,LC) writeneg((x)),*iter++=LC
#define flush() fwrite(Out,1,iter-Out,stdout),iter=Out
#define gc() ((iS==iT)?(iT=(iS=ibuf)+fread(ibuf,1,iL,stdin),(iS==iT)?EOF:*iS++):*iS++)
using namespace std;
namespace IO{
	char ibuf[iL],*iS=ibuf+iL,*iT=ibuf+iL,Out[iL],*iter=Out;
	TEM read(re T &x){re char c;for(c=gc();!isdigit(c);c=gc());for(x=0;isdigit(c);x=(x<<1)+(x<<3)+(c^48),c=gc());}
	TEM write(re T x){re T c[35],l;for(l=0;!l||x;c[l++]=x%10,x/=10);for(;l;*iter++=c[--l]+'0');flush();}
}
using namespace IO;
// int a,b,w;
int n,m,T;
struct Node{
	int w,v;
}a[55];
struct Box{
	int v,id;
}b[55];
bool vis[55];
il bool CMP(Box x,Box y){return x.v<y.v;}
il bool cmp(Node x,Node y){return x.v>y.v||(x.v==y.v&&x.w<y.w);}
int main(){
	// cin>>a>>b>>w;w=w*1000;
	// if(w<a){printf("UNSATISFIABLE");return 0;}
	// int fl=0;
	// while(w>b)++fl,w-=b;
	// if(w<a){
	// 	w+=b,--fl;
	// 	if(w>=a+a){
	// 		cout<<fl+2;
	// 		return 0;
	// 	}
	// }
	scanf("%d%d%d",&n,&m,&T);
	for(re int i=1;i<=n;++i)scanf("%d%d",&a[i].w,&a[i].v);
	for(re int i=1;i<=m;++i)scanf("%d",&b[i].v),b[i].id=i;
	sort(a+1,a+1+n,cmp),sort(b+1,b+1+m,CMP);
	for(re int _=0,l,r;_<T;++_){
		scanf("%d%d",&l,&r);
		int ans=0;
		for(re int i=1;i<=m;++i)vis[i]=false;
		for(re int i=1;i<=n;++i){
			for(re int j=1;j<=m;++j){
				if(b[j].id>=l&&b[j].id<=r)continue;
				if(!vis[j]&&a[i].w<=b[j].v){vis[j]=true,ans+=a[i].v;break;}
			}
		}
		printf("%d\n",ans);
	}
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}
template<class T> bool chmax(T& a, const T& b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T> bool chmin(T& a, const T& b) {
	if (a > b) { a = b; return 1; }
	return 0;
}

typedef pair<int, int> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M, Q;
	cin >> N >> M >> Q;
	vector<P> V(N);
	REP(i, N) {
		cin >> V[i].first >> V[i].second;
	}
	vi X(M);
	REP(i, M) {
		cin >> X[i];
	}
	REP(i, Q) {
		int L, R;
		cin >> L >> R;
		L--;R--;
		vi curX;
		for (int i = 0; i < L;i++) {
			curX.push_back(X[i]);
		}
		for (int i = R + 1;i < M;i++) {
			curX.push_back(X[i]);
		}
		so(curX);
		int ans = 0;
		vector<P> curV = V;
		REP(i, SZ(curX)) {
			int ind = -1;
			int maxV = 0;
			REP(j, SZ(curV)) {
				if (curX[i] >= curV[j].first && maxV < curV[j].second) {
					ind = j;
					maxV = curV[j].second;
				}
			}
			if (ind != -1) {
				ans += curV[ind].second;
				curV.erase(curV.begin() + ind);
			}
		}
		cout << ans << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
int const MAXN = 2e6 + 10;
int n, m, T;
int a[MAXN];
int num[MAXN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) num[a[i]]++;
    int ans = 1e9;
    for (int i = 0; ; i++)
        if (!num[i]) {
            ans = i;
            break;
        }
    for (int i = m + 1; i <= n; i++) {
        num[a[i-m]]--;
        num[a[i]]++;
        //cout << a[i - m] << " " << a[i] << endl;
        if (!num[a[i-m]]) ans = min(ans, a[i-m]);
    }
    cout << ans;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < b; i ++ )
int n, m;
vector<int> v[1500005];
int main(void)
{
  cin >> n >> m;
  rep(i, 0, n)
  {
    int x; scanf("%d", &x);
    if (x < m) v[x].push_back(i);
  }
  rep(i, 0, m + 1)
  {
    // cout << v[i].size() << endl;
    if (v[i].empty())
    {
      cout << i << "\n";
      return 0;
    }
    bool flag = false;
    int last = -1;
    for (int it : v[i])
    {
      if (it - last <= m) last = it;
      else
      {
        flag = true;
        break;
      }
    }
    if (n - last > m) flag = true;
    if (flag) {cout << i << "\n"; return 0;}
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ss              second
#define ar              array
#define int             long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vvi             vector<vector<int>>
#define vpii            vector<pair<int,int>>
#define mii             map<int,int>
#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; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>
#define sz(s)           (int)s.size()

void KruNULL()
{
	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
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
	return (a.second < b.second);
}
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int prime(int n) {
	int flag = 1;
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) {flag = 0; break;}
	}
	return flag;
}
int power(int x, int y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
	else
		return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}

int lcm(int a, int b)
{
	return (a * b) / gcd(a, b);
}

void solve()
{
	string s;
	cin >> s;
	bool ok = true;
	for (int i = 0; i < sz(s); i++)
	{
		if (i % 2 == 0)
		{
			ok &= (s[i] >= 'a' && s[i] <= 'z');
		}
		else
		{
			ok &= (s[i] >= 'A' && s[i] <= 'Z');
		}
	}

	if (ok) cout << "Yes\n";
	else cout << "No\n";
}
int32_t main()
{
	KruNULL();
	// int JUDGE_ONLINE = 1;
	int tc = 1;
	// cin >> tc;
	for (int i = 1; i <= tc; i++)
	{
		// cout << "Case #" << i << ": ";
		solve();
		// if (JUDGE_ONLINE) {
		// 	cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
		// }

	}
}

#include <bits/stdc++.h>

using namespace std;

// clang-format off
/* accelration */
// 高速バイナリ生成
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
// cin cout の結びつけ解除, stdioと同期しない(入出力非同期化)
// cとstdの入出力を混在させるとバグるので注意
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;

/* alias */
using ull = unsigned long long;
using ll = long long;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvll = vector<vll>;
using vs = vector<string>;
using pii = pair<int, int>;

/* define short */
#define pb push_back
#define mp make_pair
#define all(obj) (obj).begin(), (obj).end()
#define YESNO(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(bool) if(bool){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

/* REP macro */
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define rrep(i, n) reps(i, 1, n + 1)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define rrepd(i,n) for(ll i=n;i>=1;i--)

/* debug */
// 標準エラー出力を含む提出はrejectされる場合もあるので注意
#define debug(x) cerr << "\033[33m(line:" << __LINE__ << ") " << #x << ": " << x << "\033[m" << endl;

/* func */
inline int in_int() {int x; cin >> x; return x;}
inline ll in_ll() {ll x; cin >> x; return x;}
inline string in_str() {string x; cin >> x; return x;}
// search_length: 走査するベクトル長の上限(先頭から何要素目までを検索対象とするか、1始まりで)
template <typename T> inline bool vector_finder(std::vector<T> vec, T element, unsigned int search_length) {
    auto itr = std::find(vec.begin(), vec.end(), element);
    size_t index = std::distance( vec.begin(), itr );
    if (index == vec.size() || index >= search_length) {return false;} else {return true;}
}
template <typename T> inline void print(const vector<T>& v, string s = " ")
    {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}
template <typename T, typename S> inline void print(const pair<T, S>& p)
    {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << "\n";}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v)
    {for (auto&& p : v) print(p);}
// 第一引数と第二引数を比較し、第一引数(a)をより大きい/小さい値に上書き
template <typename T> inline bool chmin(T& a, const T& b) {bool compare = a > b; if (a > b) a = b; return compare;}
template <typename T> inline bool chmax(T& a, const T& b) {bool compare = a < b; if (a < b) a = b; return compare;}

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

    vector<int> a(n);
    vector<int> b(n);
    vector<int> num(1000, 0);

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

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

    for(int i = 0; i < n; i++){
        int anum = a[i];
        int bnum = b[i];
        for(int j = anum; j <= bnum; j++){
            num[j]++;
        }
    }

    int count = 0;
    for(int i = 1; i <= 1000; i++){
        if(num[i] == n){
            count++;
        }
    }

    cout << count << endl;

}


#include<bits/stdc++.h>
#define fasterthanlight ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define int long long
#define vi vector<int>
#define pb push_back
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define hi "visited\n" //sasta debugging
using namespace std;

//author::@whohet-->Het Patel

void solve()
{
	char s, t;
	cin >> s >> t;
	if (s == 'Y')
	{
		if (t <= 'Z')
			cout << t;
		else
		{
			t -= 32;
			cout << t;
		}
	}
	else
	{
		if (t <= 'Z')
		{
			t += 32; cout << t;
		}
		else
		{
			cout << t;
		}
	}
}

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

	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1e9
typedef long long ll;
typedef long double ld;
int main(){
  char c, a;
  cin>>c>>a;
  if(c=='Y'){
    a-=32;
  }
  cout<<a<<endl;
  return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b,ll mod=MOD){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % mod;
      x = x * x % mod;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    cin >> res;
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

vector<ll> func(){
    int n = in();
    vector<ll> A(n);
    vector<ll> B(n);
    foreach(i,A)i=in();
    foreach(i,B)i=in();
    vector<ll> AM(n,0);
    rep(i,n){
        chmax(AM[i],A[i]);
        if(i+1<n)chmax(AM[i+1],AM[i]);
    }
    ll CM = 0;
    vector<ll> res(n);
    rep(i,n){
        chmax(CM,AM[i] * B[i]);
        res[i] = CM;
    }

    return res;
}

int main(){
    vector<ll> ans = func();
    foreach(i,ans){
        cout << i << endl;
    }
  return 0;
}

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

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

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

  for (int i = 0;i < n;i++){
    bool dup = false;
    for (int k = 0;k < n;k++){
      if (i == k) continue;
      if (y[i] == y[k]) {
        dup = true;
        break;
      }
    }
    if (dup == false)
      cout << 0 << ' ' << y[i] << ' ' << 9999 << ' ' << y[i] + 1 << endl;
    else
      cout << x[i] << ' ' << y[i] << ' ' << x[i] + 1 << ' ' << y[i] + 1 << endl;
  }

  return 0;
}


#include <iostream>
using namespace std;
inline int ksm(int x,int y,int mod)
{
	int rtn=1;
	while(y)
	{
		if(y&1) rtn=(long long)rtn*x%mod;
		x=(long long)x*x%mod,y>>=1;
	}
	return rtn%mod;
}
int main(int argc, char** argv) {
	int a,b,c;
	cin >> a >> b >> c;
	if(b<=5&&c<=5||b==1)
		cout << ksm(a,ksm(b,c,1000000000),10);
	else
	{
		cout << ksm(a,ksm(b,c,4)+4,10);
	}
	return 0;
}

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

#define fi first
#define se second
#define rng(i, a, b) for (int i = int(a); i < int(b); ++i)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); --i)
#define per(i, b) gnr(i, 0, b)
#define all(obj) begin(obj), end(obj)
#define allr(obj) rbegin(obj), rend(obj)
#define cinv(a) rep(i, (int)a.size()) cin >> a[i]
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<Pi> vp;
typedef vector<vp> vvp;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;

template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, 1, 0, -1};
const int MOD =	1e9 + 7;
const int INF = 1e9 + 9;
const ll LINF = 1e18;
const long double eps = 1e-10;
const char nl = '\n';

ll power(ll a, ll b, int mod) { return b ? power(a * a % mod, b / 2, mod) * (b % 2 ? a : 1) % mod : 1; }

ll nCk(int n, int k, int mod)
{
	ll x = 1, y = 1;
	for (int i = 1; i <= k; ++i)
	{
		x = x * (n - i + 1) % mod;
		y = y * i % mod;
	}
	return x * power(y, mod - 2, mod) % mod;
}

struct UF
{
	vi d;
	UF(int n) : d(n, -1) {}
	int root(int x)
	{
		if (d[x] < 0)
			return x;
		return d[x] = root(d[x]);
	}
	bool unite(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (d[x] > d[y]) swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -d[root(x)]; }
};

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(20);
	ll a, b, c; cin >> a >> b >> c;
	cout << power(a % 10, power(b, c, 4) + 4, 10) << nl;
}


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

using namespace std;
//using namespace atcoder;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using ld = long double;
using vld = vector<ld>;
using vb = vector<bool>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

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

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

template <class T> ostream& operator<<(ostream& s, const vector<T>& a) {
    for(auto i : a) s << i << ' ';
    return s;
}

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

void solve() {
    ll n, m;
    cin >> n >> m;
    vll cnt(1001);
    rep(_, n) {
        ll a;
        cin >> a;
        ++cnt[a];
    }
    rep(_, m) {
        ll b;
        cin >> b;
        ++cnt[b];
    }
    for(ll i = 1; i <= 1000; ++i) {
        if(cnt[i] == 1) cout << i << ' ';
    }
    cout << endl;
    return;
}

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

/*ver 7*/
#include <bits/stdc++.h>
using namespace std;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using pll = pair<ll,ll>;
using mll = map<ll,ll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
#define each(x,v) for(auto& x : v)
#define reps(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define mp make_pair
const ll INF = 1LL << 60;
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<=b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){}
template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
template <typename T> void in1(T &s) {rep(i,s.size()){in(s[i]);}}
template <typename T> void in2(T &s,T &t) {rep(i,s.size()){in(s[i],t[i]);}}
template <typename T> void in3(T &s,T &t,T &u) {rep(i,s.size()){in(s[i],t[i],u[i]);}}
template <typename T> void in4(T &s,T &t,T &u,T &v) {rep(i,s.size()){in(s[i],t[i],u[i],v[i]);}}
template <typename T> void in5(T &s,T &t,T &u,T &v,T &w) {rep(i,s.size()){in(s[i],t[i],u[i],v[i],w[i]);}}
void out(){cout << endl;}
template <typename T,class... U> void out(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; out(u...);}
void die(){cout << endl;exit(0);}
template <typename T,class... U> void die(const T &t,const U &...u){cout << t; if(sizeof...(u)) cout << " "; die(u...);}
template <typename T> void outv(T s) {rep(i,s.size()){if(i!=0)cout<<" ";cout<<s[i];}cout<<endl;}
template <typename T> void out1(T s) {rep(i,s.size()){out(s[i]);}}
template <typename T> void out2(T s,T t) {rep(i,s.size()){out(s[i],t[i]);}}
template <typename T> void out3(T s,T t,T u) {rep(i,s.size()){out(s[i],t[i],u[i]);}}
template <typename T> void out4(T s,T t,T u,T v) {rep(i,s.size()){out(s[i],t[i],u[i],v[i]);}}
template <typename T> void out5(T s,T t,T u,T v,T w) {rep(i,s.size()){out(s[i],t[i],u[i],v[i],w[i]);}}
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
template <typename T> T allSum(vector<T> a){T ans=T();each(it,a)ans+=it;return ans;}
ll ceilDiv(ll a,ll b) {return (a+b-1)/b;}
ld dist(pair<ld,ld> a, pair<ld,ld> b){return sqrt(abs(a.fi-b.fi)*abs(a.fi-b.fi)+abs(a.se-b.se)*abs(a.se-b.se));} // ２点間の距離
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
#define YES(n) ((n) ? "YES" : "NO"  )
#define Yes(n) ((n) ? "Yes" : "No"  )
#define yes(n) ((n) ? "yes" : "no"  )

int main(){
  init();
  inl(n,m);
  V<ll> a(n),b(m);
  in1(a);
  in1(b);
  set<ll> A,B;
  rep(i,n)A.insert(a[i]);
  rep(i,m)B.insert(b[i]);
  reps(i,1,1001){
    ll af=A.count(i);
    ll bf=B.count(i);
    if(af+bf==1)out(i);
  }
  return 0;
}