#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
using Graph=vector<vector<pair<int,int>>>;

int main(){
  int N;
  cin>>N;
  vector<int> a(N),b(N),p(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  set<pair<int,int>> s;
  for(int i=0;i<N;i++){
    cin>>b[i];
    s.insert(make_pair(-b[i],i));
  }
  map<int,int> rp;
  for(int i=0;i<N;i++){
    cin>>p[i];
    p[i]--;
    rp[p[i]]=i;
  }
  vector<pair<int,int>> ans;
  bool flag=true;
  for(auto pp:s){
    int w=-pp.first;
    int load_i=pp.second;
    int person_i=rp[load_i];
    if(person_i==load_i){
      continue;
    }
    if(a[person_i]<=b[load_i]){
      flag=false;
      break;
    }
    if(a[load_i]<=b[p[load_i]]){
      flag=false;
      break;
    }else{
      ans.push_back(make_pair(person_i,load_i));
      int load_j=p[load_i];
      p[load_i]=load_i;
      rp[load_i]=load_i;
      p[person_i]=load_j;
      rp[load_j]=person_i;
    }
  }
  if(flag==true){
    int n=ans.size();
    cout<<n<<endl;
    for(int i=0;i<n;i++){
      cout<<ans[i].first+1<<" "<<ans[i].second+1<<endl;
    }
  }else{
    cout<<-1<<endl;
  }
}

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

#define int         long long
#define ull         unsigned long long
#define ll          long long
#define M           998244353
#define pb          push_back
#define p_q         priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp          make_pair
#define lb          lower_bound
#define ub          upper_bound
#define F           first
#define S           second
#define rep(i, begin, end) for (int i=begin;i<end;i++)
#define repd(i, begin, end) for (int i=end-1;i>=begin;i--)
#define ini(a,n,b)  for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)     __builtin_popcountll(a)
#define hell        1000000007
#define re          resize
const int INF=1e18;
const int N=2e5+5;

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

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

  return res;
}

vi g[N],vis2(N,0),a(N);
int idx=0,mn=INF,cnt=0;

void dfs(int node)
{

   if(a[node]<mn)
   {
     mn=a[node];
     idx=node;
   }

   vis2[node]=1;
   cnt++;
   for(auto j:g[node])
   {
     if(!vis2[j]) dfs(j);
   }
}
signed main(void)
{ios
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);freopen("answer.txt", "w", stdout);
    #endif

    int n;
    cin>>n;
    vi b(n+1),p(n+1),vis(n+1,0),weight(n+1),have(n+1);
    int ans=0;
    int f=1;
    vii ind;

    rep(i,1,n+1) cin>>a[i];
    rep(i,1,n+1) cin>>b[i];
    rep(i,1,n+1)
    {
       cin>>p[i];
       if(p[i]==i) vis[i]=1;
       else have[p[i]]=i;
    }

    rep(i,1,n+1)
    {
       if(!vis[i]&&b[p[i]]>=a[i]) f=0;
    }

    if(!f) {cout<<-1<<endl;return 0;}
    int grp=0;
    rep(i,1,n+1)
    {
       if(p[p[i]]==i&&!vis[i]&&!vis[p[i]])
       {
         ind.pb({i,p[i]});
         ans++;
         vis[i]=1;
         vis[p[i]]=1;
       }
    }

    rep(i,1,n+1) if(!vis[i]) {g[p[i]].pb(i);g[i].pb(p[i]);}

    rep(i,1,n+1)
    {
       if(!vis2[i])
       {
         mn=INF,idx=0,cnt=0;
         dfs(i);
         ans+=(cnt-1);
         int j=have[idx],k=idx;
         rep(ii,0,cnt-1)
         {
            ind.pb({k,j});
            k=j;
            j=have[j];
         }
       }

    }

    cout<<ans<<endl;rep(i,0,sz(ind)) cout<<ind[i].F<<' '<<ind[i].S<<endl;

}


#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define MT make_tuple
typedef long long ll;
#define PA pair<ll,ll>
#define TU tuple<ll,ll,ll>
#define vi vector<ll>
#define vii vector<vector<ll> >
#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define rep2(i,m,n) for(ll (i)=(m); (i)<(ll)(n); (i)++)
const ll INF = 1ll<<55;
const ll INF2 = 1ll<<31;
const ll MOD = 998244353;

vi dist;
vector<bool> checked;
priority_queue<PA,vector<PA>,greater<PA>> pq;

void dijkstra(vector<vector<TU>> &graph) {
  while(!pq.empty()) {
    PA state = pq.top();
  pq.pop();
  ll time = state.first;
  ll destin = state.second;
  if(dist.at(destin)<time) continue;

  checked.at(destin) = true;

  for(auto nv: graph.at(destin)) {
    if(checked.at(get<0>(nv))) continue;
    ll new_time = (time/get<2>(nv))*get<2>(nv) + get<1>(nv);
    if(time%get<2>(nv)) {
      new_time += get<2>(nv);
    }
    if(new_time<dist.at(get<0>(nv))) {
      dist.at(get<0>(nv)) = new_time;
      pq.push(MP(new_time,get<0>(nv)));
    }

  }
  }
}

int main() {
  ll n,m,x,y;
  cin>>n>>m>>x>>y;
  vector<vector<TU>> graph(n,vector<TU>(0));
  rep(i,m) {
    ll a,b,t,k;
    cin>>a>>b>>t>>k;
    graph.at(a-1).push_back(MT(b-1,t,k));
    graph.at(b-1).push_back(MT(a-1,t,k));
  }

  dist.assign(n,INF);
  checked.assign(n,false);

  pq.push(MP(0,x-1));
  dist.at(x-1) = 0;

  dijkstra(graph);

  if(dist.at(y-1)==INF) cout<<-1<<endl;
  else cout<<dist.at(y-1)<<endl;
}

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

int main(){
	int a,b,x,y;
  	cin>>a>>b>>x>>y;
  	if(a>b){
      cout<<x+min(y,2*x)*(a-b-1);
    }else{
    	cout<<min(y,2*x)*(b-a)+x;
    }
	return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <tuple>
using namespace std;

void yes(){ cout << "yes" << endl; }
void Yes(){ cout << "Yes" << endl; }
void YES(){ cout << "YES" << endl; }
void no(){ cout << "no" << endl; }
void No(){ cout << "No" << endl; }
void NO(){ cout << "NO" << endl; }
#define rep(i, n)for(int i=0; i<n; i++)
#define ll long long

ll inf = 1000000007;
ll INF = 1000000000000000007;

int main(){
  ll N;
  cin >> N;
  ll A[N], B[N];
  rep(i, N)
    cin >> A[i] >> B[i];
  //

  ll ans = INF;
  rep(i, N){
    rep(j, N){
      ll time;
      if(i != j){
	time = max(A[i], B[j]);
      }
      else{
	time = A[i] + B[i];
      }
      ans = min(ans, time);
    }
  }

  cout << ans << endl;

  return 0;
}

#include <iostream>

using namespace std;

const int inf = (1 << 30);

int main()
{
    int minA1 = inf, ind_minA1, minA2 = inf, ind_minA2,
        minB1 = inf, ind_minB1, minB2 = inf, ind_minB2,
        n, x, y;
    cin >> n;

    for(int i = 1 ; i <= n ; i++)
    {
        cin >> x >> y;

        if(x < minA1)
            minA2 = minA1, ind_minA2 = ind_minA1,
            minA1 = x, ind_minA1 = i;
        else if(x < minA2)
            minA2 = x, ind_minA2 = i;

        if(y < minB1)
            minB2 = minB1, ind_minB2 = ind_minB1,
            minB1 = y, ind_minB1 = i;
        else if(y < minB2)
            minB2 = y, ind_minB2 = i;
    }

    int comb1, comb2, comb3, comb4;
    // afisare
    (ind_minA1 == ind_minB1) ? // caz 1 - A1, B1
        comb1 = minA1 + minB1 : comb1 = max(minA1, minB1);

    (ind_minA1 == ind_minB2) ? // caz 2 - A1, B2
        comb2 = minA1 + minB2 : comb2 = max(minA1, minB2);

    (ind_minA2 == ind_minB1) ? // caz 3 - A2, B1
        comb3 = minA2 + minB1 : comb3 = max(minA2, minB1);

    (ind_minA2 == ind_minB1) ? // caz 4 - A2, B2
        comb4 = minA2 + minB2 : comb4 = max(minA2, minB2);
    /*cout << "MINIME A " << minA1 << ' ' << minA2 << '\n';
    cout << "MINIME B " << minB1 << ' ' << minB2 << '\n';
    cout << comb1 << ' ' << comb2 << ' ' << comb3 << ' ' << comb4 << '\n';*/
    cout << min(comb1, min(comb2, min(comb3, comb4)));

    return 0;
}


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

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

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

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

const char newl = '\n';

int main() {
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n),b(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = n-1;i >= 0;--i) {
        b[i] = x/a[i];
        x %= a[i];
    }
    vector<ll> dp0(n+1,0),dp1(n+1,0);
    dp0[0] = 1;
    for (int i = 0;i < n;++i) {
        dp0[i+1] += dp0[i];
        if (i+1 < n && b[i]+1 == a[i+1]/a[i]) dp1[i+1] += dp1[i];
        else dp0[i+1] += dp1[i];
        if (b[i]) dp1[i+1] += dp0[i];
        if (i == n-1 || b[i]+1 < a[i+1]/a[i]) dp1[i+1] += dp1[i];
    }
    cout << dp0[n] << newl;
    // p_ary(dp0,0,n+1);
    // p_ary(dp1,0,n+1);
}


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

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define gap " "
#define ok cout<<"ok"<<endl
#define DBG(a) cerr<< "Line "<<__LINE__ <<" : "<< #a <<" = "<<(a)<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}

int main()
{

    ll n,m,ans=0;
    cin>>n>>m;
    ll ar[m+2];
    for(ll i=1;i<=m;i++)
        cin>>ar[i];
    sort(ar+1,ar+m+1);
    ll mn=1e12;
    vector<ll>v;
    if(m==0)
    {
        cout<<1<<endl;
        return 0;
    }
    if(ar[1]!=1)
    {
        v.pb(ar[1]-1);
        mn=min(mn,ar[1]-1);
    }
    if(ar[m]!=n)
    {
        v.pb(n-ar[m]);
        mn=min(mn,n-ar[m]);
    }
    for(ll i=2;i<=m;i++)
    {
        ll d=ar[i]-ar[i-1]-1;
        if(!d) continue;
        v.pb(d);
        mn=min(mn,d);
    }
    for(ll i=0;i<v.size();i++)
    {
        if(v[i]%mn==0)
            ans+=(v[i]/mn);
        else
            ans+=(v[i]/mn)+1;
    }
    cout<<ans<<endl;
    return 0;
}

#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <cstdint>
#include <chrono>
#include <hash_map>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace __gnu_pbds;
using namespace std;

#define     lp(i, a, n)       for(ll i=a;i<n;i++)
#define     lp2(i, n, a)      for(ll i=a-1;i>=n;i--)
#define     all(arr, n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pii>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            '\n'
#define     Endl            '\n'
#define     f               first
#define     s               second
#define     mem(dp, n)       memset(dp,n,sizeof dp)
#define     ordered_set     tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

template<typename T>
void max_self(T &a, T b) { a = max(a, b); }

template<typename T>
void min_self(T &a, T b) { a = min(a, b); }

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

void fast() {
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}

vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const int MAXN = 2e5 + 1, oo = 0x3f3f3f3f, MOD = 1e9 + 7;
const long double PI = acos(-1), eps = 1e-9;

void solve() {
    int n,m;
    cin>>n>>m;
    ll arr[m+3]={};
    lp(i,1,m+1)
        cin>>arr[i];
    arr[m+1]=n+1;
    sort(all(arr,m+2));
    ll mn=1e9,res=0;
    lp(i,1,m+2){
        if(arr[i]==arr[i-1]+1)continue;
        min_self(mn,arr[i]-arr[i-1]-1);
    }
    lp(i,1,m+2){
        res+=(arr[i]-arr[i-1]-1+mn-1)/mn;
    }
    cout<<res<<endl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    int t = 1;
    //cin>>t;
    while (t--)
        solve();
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define all(a) a.begin(), a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define range(i, a, b) for (ll i = (a); i < (b); i++)
#define rrange(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using pri_s = priority_queue<T, vector<T>, greater<T>>;
template<class T> using pri_b = priority_queue<T>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T> void er(T a) { cout << a << '\n'; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }
template<class T, class U> ostream &operator << (ostream &s, const pair<T, U> &p) { s << p.first << ' ' << p.second; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

const int N = ten(5) + 10;
vector<vector<int>> graph(N, vector<int>());
vector<int> sz(N, 1), dp(N, 1);

void dfs(int n) {
	vector<P> p;
	for (int i : graph[n]) {
		dfs(i);
		sz[n] += sz[i];
		p.pb({ sz[i] - 2 * dp[i],sz[i] % 2 });
		dp[n] += sz[i] - dp[i];
	}
	sort(all(p), greater<P>());
	int t = 0; int sum = 0;
	for (auto q : p) {
		if (q.first > 0 && q.second == 0) {
			dp[n] -= q.first;
		}
		if (q.second == 1) {
			if (t == 0) {
				dp[n] -= q.first;
			}
			t ^= 1;
		}
		if (q.first < 0 && q.second == 0) {
			sum += q.first;
		}
	}
	if (t == 0) dp[n] -= sum;
}

int main() {
	int n;
	cin >> n;
	for (int i = 1; i < n; i++) {
		int v;
		cin >> v;
		v--;
		graph[v].pb(i);
	}
	dfs(0);
	cout << dp[0] << '\n';
}

#include <bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a; i >-1; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a; i > b; --i)
#define repl(i, a) for (ll i = (ll)0; i < (ll)a; ++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
#define fi first
#define se second
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll mod_998244353 = 998244353;
constexpr ll INF = 1LL << 60;

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

//using lll=boost::multiprecision::cpp_int;
//using Double=boost::multiprecision::number<boost::multiprecision::cpp_dec_float<128>>;//仮数部が1024桁
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll mypow(ll x, ll n, const ll &p = -1)
{ //x^nをmodで割った余り

	if (p != -1)
	{
		x =(x%p+p)%p;
	}
	ll ret = 1;
	while (n > 0)
	{
		if (n & 1)
		{
			if (p != -1)
				ret = (ret * x) % p;
			else
				ret *= x;
		}
		if (p != -1)
			x = (x * x) % p;
		else
			x *= x;
		n >>= 1;
	}
	return ret;
}

using namespace std;
//using namespace atcoder;

void solve()
{
	int n;
	cin>>n;
	vector<vector<int>>g(n);
	rep(i,n-1){
		int p;
		cin>>p;
		p--;
		g[i+1].eb(p);
		g[p].eb(i+1);
	}
	//T君:0,A君:1
	auto rec=[&g](auto self,int v,int par=-1)->pair<int,int>{
		int size=1;
		int ret=1;//部分木の根の操作

		int turn=0;//部分木の根でコインを取るプレイヤー基準

		//なるべく小さくしたい
		vector<vector<int>>res(2);
		for(auto x:g[v]){
			if(x!=par){
				auto p=self(self,x,v);
				res[p.second&1].eb(p.first);
				size+=p.second;
			}
		}
		for(auto x:res[0]){//部分木のサイズが偶数で負
			if(x>=0)continue;
			ret+=x;
		}
		sort(all(res[1]));
		for(auto x:res[1]){//部分木のサイズが奇数
			if(!turn)ret+=x;
			else ret-=x;
			turn^=1;
		}
		for(auto x:res[0]){//部分木のサイズが偶数で0以上
			if(x<0)continue;
			if(!turn)ret+=x;
			else ret-=x;
		}
		return {ret,size};
	};
	auto ans=rec(rec,0);
	cout<<(ans.first+n)/2<<"\n";
}

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


#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
#define rep(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i <= _##i; ++i)
#define repd(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i >= _##i; --i)
#ifndef ONLINE_JUDGE
#define debug(x...) printf("["#x"]="),print(x);
#else
#define debug(x...) ;
#endif
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fcout cout<<setprecision(4)<<fixed
using namespace std;
typedef long long ll;
//======================================
namespace FastIO{
char print_f[105];void read() {}void print() {putchar('\n');}
template <typename T, typename... T2>
inline void read(T &x, T2 &... oth){x = 0;char ch = getchar();ll f = 1;while (!isdigit(ch)){if (ch == '-')f *= -1;ch = getchar();}while (isdigit(ch)){x = x * 10 + ch - 48;ch = getchar();}x *= f;read(oth...);}
template <typename T, typename... T2>
inline void print(T x, T2... oth){ll p3=-1;if(x<0) putchar('-'),x=-x;do{print_f[++p3] = x%10 + 48;}while(x/=10);while(p3>=0) putchar(print_f[p3--]);if(sizeof...(T2)) putchar(' ');print(oth...);}} // namespace FastIO

using FastIO::print;
using FastIO::read;
//======================================
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn = 1e6+5;

int main() {
#ifndef ONLINE_JUDGE
    freopen("H:\\code\\in.in", "r", stdin);
    freopen("H:\\code\\out.out", "w", stdout);
    clock_t c1 = clock();
#endif
//**************************************
    ll S,P;
    read(S,P);
    int ok=0;
    for(ll i=1;i*i<=P;i++){
        if(P%i==0){
            if(i+P/i==S) ok=1;
        }
    }
    if(ok) puts("Yes");
    else puts("No");
//**************************************

#ifndef ONLINE_JUDGE
    cerr << "Time:" << clock() - c1 << "ms" << endl;
#endif
    return 0;
}

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

/// Defining variable types.
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

/// Defining usable key words
#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

/// Defining constant variables.
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

/// Defining some useful lines.
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

/// Code of debugger.
#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}

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

    if(n%100!=0)
        cout<<((n/100)+1)<<endl;
    else
        cout<<n/100<<endl;

    ///  cout<<((n/100)+1)<<endl;

    return 0;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  vector<vector<char>> S(H, vector<char>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++)
    	cin >> S.at(i).at(j);
  }

  int count=0;

  for(int i=0; i<H; i++){
    for(int j=0; j<W-1; j++){
      if(S.at(i).at(j)=='.' && S.at(i).at(j+1)=='.')
        count++;
    }
  }

   for(int i=0; i<H-1; i++){
    for(int j=0; j<W; j++){
      if(S.at(i).at(j)=='.' && S.at(i+1).at(j)=='.')
        count++;
    }
  }

  cout << count << endl;

}

#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
//using namespace atcoder;

void solve(){
	int h,w;
	cin>>h>>w;
	vector<string>s(h);
	rep(i,h)cin>>s[i];
	int ans=0;
	rep(i,h)rep(j,w-1)if(s[i][j]=='.'&&s[i][j+1]=='.')++ans;
	rep(i,h-1)rep(j,w)if(s[i][j]=='.'&&s[i+1][j]=='.')++ans;
	cout<<ans;
}

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


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define M 1000000007

int n;
string s,x;

// bool rec(int a, int r){
// 	if(a==n){
// 		if(r==0)
// 			return 1;
// 		else
// 			return 0;
// 	}
// 	else if(x[a]=='T'){
// 		return rec(a+1,(10*r)%7) || rec(a+1,(10*r+s[a]-'0')%7);
// 	}
// 	else{
// 		return rec(a+1,(10*r)%7) && rec(a+1,(10*r+s[a]-'0')%7);
// 	}
// }

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

	cin >> n >> s >> x;
	// if(rec(0,0))
	// 	cout << "Takahashi";
	// else
	// 	cout << "Aoki";

	bool dp[n+1][7];

	for(int i=0; i<=n; i++)
		for(int j=0; j<7; j++)
			dp[i][j] = 0;

	dp[n][0] = 1;
	for(int i=n-1; i>=0; i--)
		for(int j=0; j<7; j++){
			if(x[i]=='T')
				dp[i][j] = dp[i+1][(10*j)%7] || dp[i+1][(10*j + s[i]-'0')%7];
			else
				dp[i][j] = dp[i+1][(10*j)%7] && dp[i+1][(10*j + s[i]-'0')%7];
		}

	if(dp[0][0])
    	cout << "Takahashi";
	else
		cout << "Aoki";

    return 0;
}

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

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

#define pb push_back
#define ff first
#define ss second
#define MAX 200005
#define MOD 1000000007
#define INF 1e9+100
vector<aii>adj[MAX];
vector<int> dijkstra_dag_adj[MAX];
int xMove[] = { 0,1,0,-1,1,1,-1,-1, 2, 2, -2, -2, 1, 1, -1, -1 };
int yMove[] = { 1,0,-1,0,1,-1,1,-1, 1, -1, 1, -1, 2, -2, 2, -2 };
int n;
string s,x;
int dp[MAX][8];
int solve(int i, int r)
{
    if(i==n)
        return r==0?2:1;
    if(dp[i][r]!=-1)
        return dp[i][r];

    int ans=0;
    if(x[i]=='A')
    {
        int cur=solve(i+1,(r*10+s[i]-48)%7);
        if(cur!=1)
            cur=solve(i+1,(r*10+0)%7);
        ans=cur;
    }
    else
    {
        int cur=solve(i+1,(r*10+s[i]-48)%7);
        if(cur!=2)
            cur=solve(i+1,(r*10+0)%7);
        ans=cur;
    }

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

        memset(dp,-1,sizeof dp);

        int ans=solve(0,0);
        if(ans==1)
            cout<<"Aoki\n";
        else cout<<"Takahashi\n";

    }
    return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define ll long long int
#define ld long double
#define ba boolalpha
#define F first
#define S second
#define pb push_back
string alphabets = "abcdefghijklmnopqrstuvwxyz";
const long long int mod = 1000000007;
#define loop(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b){
if(b==0){
    return a;
}
return gcd(b,a%b);
}
void solve(){
    ll n;
    cin>>n;
    vector<ll>ans(n);
    loop(i,0,n)cin>>ans[i];
    ll sum = 0 ;
    loop(i,0,n){
     if(ans[i]>10){
         sum+=ans[i]-10;
     }
    }
    cout<<sum<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    solve();
}

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

#define Fi first
#define Se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)
typedef tuple<int, int, int> t3;

char In[1010];

void solve() {
	scanf("%s", In + 1);
	string s = (string)(In + 1);
	if(s > "atcoder") {
		puts("0");
		return;
	}
	int x = -1, l = (int)strlen(In+1);
	for(int i=1;i<=l;i++) if(In[i] != 'a') {
		x = i; break;
	}
	if(x == -1) puts("-1");
	else {
		char c = In[x];
		if(c > 't') printf("%d\n", x - 2);
		else if(c < 't') printf("%d\n", x - 1);
		else {
			for(int i=x;i>2;i--) swap(In[i], In[i-1]);
			s = (string)(In + 1);
			if(s > "atcoder") printf("%d\n", x - 2);
			else printf("%d\n", x - 1);
		}
	}
}

int main() {
	int T; scanf("%d", &T);
	for(int t=1;t<=T;t++) {
		solve();
	}
	return 0;
}


//
//  main.cpp
//  abc194c
//
//  Created by Hsiu-Fen Chou on 2021/4/8.
//

#include <iostream>
using namespace std;
int A[300005];

long long solve(int L, int R) {
    if (L == R) return 0;
    int M = (L + R) / 2;
    long long sum1 = 0, sum2 = 0;
    for (int i = L; i <= M; i++) {
        sum1 += A[i];
    }
    for (int i = M+1; i <= R; i++) {
        sum2 += A[i];
    }
    long long sum = solve(L, M) + sum1 * sum2 + solve(M+1, R);
    return sum;
}

int main() {
    int N;
    cin >> N;
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i] * A[i];
    }
    cout << (N-1) * sum - 2 * solve(0, N-1) << endl;
    return 0;
}

#include<bits/stdc++.h>

using namespace std;

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

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int main(){

    int n;
    cin >> n;

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

    ll ans = 0;
    for(auto p : mp){
        for(auto q : mp){
            if(p.first == q.first) continue;
            ans += (p.first - q.first) * (p.first - q.first) * p.second * q.second;
        }
    }

    cout << ans / 2 << "\n";

    return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <list>
#include <cmath>
#include <algorithm>
#include <cassert>

using namespace std;

template <typename input_type>
input_type input() {
    input_type inp;
    cin >> inp;

    return inp;
}

const int max_sz = 5e1, max_nm = 5e1 + 5;
long long inf = 5e18;

bool come[max_nm];
int sz, arr[max_sz];
long long mn_ans = inf;
vector <int> prime;

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

   return gcd(b, a % b);
}

bool check(long long ans) {
    for (int i = 0; i < sz; i++) {
        if (gcd(arr[i], ans) == 1) {
            return false;
        }
    }

    return true;
}

void find_ans(int ands, long long ans) {
    if (ands == prime.size()) {
        if ((ans > 1) and (ans < mn_ans) and check(ans)) {
            mn_ans = ans;
        }

        return;
    }

    find_ans(ands + 1, ans * prime[ands]);
    find_ans(ands + 1, ans);
}

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

    sz = input<int>();
    for (int i = 0; i < sz; i++) {
        arr[i] = input<int>();

        int val = arr[i];
        for (int j = 2; j * j <= val; j++) {
            if (val % j == 0) {
                come[j] = true;
                while (val % j == 0) {
                    val /= j;
                }
            }
        }
        if (val > 1) {
            come[val] = true;
        }
    }
    for (int i = 0; i < max_nm; i++) {
        if (come[i]) {
            prime.push_back(i);
        }
    }

    find_ans(0, 1);

    cout << mn_ans;
    return 0;
}


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

int h, w, a, b, ans;

void dfs(int i, int mask, int a, int b) {
	if (i == h * w) {
		return (void)ans++;
	}
	if (mask & (1 << i)) return dfs(i + 1, mask, a, b);
	if (b) {
		dfs(i + 1, mask | (1 << i), a, b - 1);
	}
	if (a) {
		if (i % w != (w - 1) && ~mask & (1 << (i + 1))) dfs(i + 1, mask | (1 << i) | (1 << (i + 1)), a - 1, b);
		if (i < (h - 1) * w) dfs(i + 1, mask | (1 << i) | (1 << (i + w)), a - 1, b);
	}
}

int main() {
	cin >> h >> w >> a >> b;
	dfs(0, 0, a, b);
	cout << ans << '\n';
	return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
constexpr int INF = 1e9, MOD = 1e9 + 7;
constexpr int64_t LINF = 5e18, LMOD = 998244353;
// #include <atcoder/all>
// using namespace atcoder;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int v, t, s, d; cin >> v >> t >> s >> d;
	int l = v * t;
	int r = v * s;
	if(d < l or r < d) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}
	return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using C = complex<double>;

int main() {
    ll N;
    cin >> N;
    vector<ll> T(N);
    ll sum = 0;
    rep(n, N) {
        cin >> T[n];
        sum += T[n];
    }
    //cout << "ok" << endl;
    ll half = (sum+1)/2;
    ll ans = 0;
    vector<vector<bool>> dp(N+1, vector<bool>(sum+1));
    dp[0][0] = true;
    rep(n, N) {
        ll t = T[n];
        rep(w, sum+1) {
            if (dp[n][w]) dp[n+1][w] = true;
            if (w-t>= 0 && dp[n][w-t]) dp[n+1][w] = true;
        }
    }
    //cout << "ok" << endl;
    for(ll w = half; w <= sum; w++) {
        if (dp[N][w]) {
            ans = w;
            break;
        }
    }
    cout << ans << endl;
}

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

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

int sol(vector<int> arr, int n){
    int sum = 0;
    for(int  i = 0 ; i < n ; ++i){
        sum += arr[i];
    }
    bool dp[n + 1][sum + 1];

    for(int i = 0 ; i <= n ; ++i){
        dp[i][0] = true;
    }

    for(int i = 1 ; i <= sum ; ++i){
        dp[0][i] = false;
    }

    for(int i = 1 ; i <= n ; ++i){
        for(int j = 1 ; j <= sum ; ++j){
            dp[i][j] = dp[i - 1][j];
            if(arr[i - 1] <= j){
                dp[i][j] |= dp[i - 1][j - arr[i - 1]];
            }
        }
    }

    // int diff = INT_MAX;
    int mx = INT_MIN;

    for(int j = sum / 2 ; j >= 0 ; --j){
        if(dp[n][j] == true){
            // diff = sum - 2 * j;
            mx = max(sum - j, j);
            break;
        }
    }
    return mx;
}

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

    int n;
    cin >> n;
    vector<int> t;
    for(int i = 0 ; i < n ; ++i){
        int val;
        cin >> val;
        t.push_back(val);
    }
    cout << sol(t, n) << '\n';

    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <sstream>
#include <stack>
#include <set>
#include <bitset>
#include <deque>
#include <vector>
using namespace std;
int n, t;
long long k;
long long s[100010], q[100010];

int main() {
	scanf("%d %d", &n, &t);
	k = 0;
	for (int i = 0; i < n; i++) {
		scanf("%lld", &s[i]);
		q[i] = s[i] - k;
		k++;
	}

	while (t--) {
		scanf("%lld", &k);
		long long j = upper_bound(q, q + n, k) - q;

		if (j == 0)
			printf("%lld\n", k);
		else
			printf("%lld\n", k - q[j - 1] + s[j - 1] + 1);
	}

	return 0;
}

#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); ++i)
const int INF = 2e9;
int main() {

    int n;
    cin >> n;
    set<string> s;
    rep(i, n) {
        string t;
        cin >> t;
        s.insert(t);
    }
    string ans = "!";
    for (auto t : s) {
        if (t[0] == '!') {
            if (s.count(t.substr(1)) > 0)
                ans = t.substr(1);

        } else if (s.count('!' + t) > 0)
            ans = t;
    }
    cout << (ans != "!" ? ans : "satisfiable") << endl;
    return 0;
}


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

int main(){
	long long L;
	cin >> L;
	long long ans = 1;
	for(int i=1;i<=11;i++){
		ans *= L - i;
		ans /= i;
	}
	cout << ans << endl;
}

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

int dp[13][205];
int ways(int id, int sum){
    // cout<<id<<" "<<sum<<" ";
    if(id==0 and sum==0) return 1;
    if(id==0 or sum<=0) return 0;
    if(dp[id][sum]==-1){
        dp[id][sum]=0;
        for(int i=1;i<=200;i++){
            dp[id][sum]+=ways(id-1, sum-i);
        }
    }
    return dp[id][sum];
}
void solve(){
    int l; cin>>l;
    for(int i=0;i<13;i++){
        for(int j=0;j<204;j++){
            dp[i][j]=-1;
        }
    }
    cout<<ways(12, l);
}

signed main(){
    ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
    #endif

   int tc=1;
//    cin>>tc;
   while(tc--){
        // cout<<solve()<<"\n";
        solve();
   }
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

//#define debug(x) ;
#define debug(x) cerr << #x << " = " << x << "\n";

ostream& operator<<(ostream& cerr, vector<ll> aux) {
  cerr << "[";
  for (auto e : aux) cerr << e << ' ';
  cerr << "]";
  return cerr;
}

const int maxN = 10;
const int maxM = 100011;
const int inf = 1 << 30;

int n, m, l, v;
int w[maxN], aux[maxN], d[maxN];
vector< pair<int, int> > q;
vector<int> ord;
int ans = inf;

int find_need(int total) {
  int pos = lower_bound(q.begin(), q.end(), mp(total, 0)) - q.begin();
  if (pos == 0) return 0;
  return q[pos - 1].second;
}

int solve() {
  memset(d, 0, sizeof(d));
  for (int i = 1; i < n; i++) {
    int total = 0;

    for (int j = i; j <= n; j++) {
      total += aux[j];
      int need = find_need(total);
      d[j] = max(d[j], d[i] + need);

      if (j == i && need != 0) {
        cout << -1;
        exit(0);
      }
    }
  }

/*
  cerr << "\n\n";
  for (int i = 1; i <= n; i++) {
    cerr << aux[i] << ' ' << d[i] << '\n';
  }
  */

  return d[n];
}

int main()
{
  //freopen("test.in", "r", stdin);

  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    scanf("%d", &w[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &l, &v);
    q.pb(mp(v, -l));
  }

  sort(q.begin(), q.end());
  for (int i = 0; i < q.size(); i++)
    q[i].second = -q[i].second;
  for (int i = 1; i < q.size(); i++) {
    q[i].second = max(q[i].second, q[i - 1].second);
  }

  for (int i = 1; i <= n; i++)
    ord.pb(i);

  do {
    for (int i = 0; i < n; i++)
      aux[i + 1] = w[ord[i]];

    ans = min(ans, solve());

  } while (next_permutation(ord.begin(), ord.end()));

  cout << ans;

  return 0;
}

/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

typedef long long ll;
const int N=10,M=1e5+10;

int n,m;
int wei[N],id[N];
ll f[N];
pair<int,int> bri[M]; //(limit,length)

inline int Read(int &r){
	int b=1,c=getchar();r=0;
	while(c<'0' || '9'<c) b=c=='-'? -1:b,c=getchar();
	while('0'<=c && c<='9') r=(r<<1)+(r<<3)+(c^'0'),c=getchar();
	return r*=b;
}
int Query(int tot){
	int le=0,ri=m;
	while(le+1<ri){
		int mi=(le+ri)>>1;
		if(bri[mi].first<tot) le=mi;
		else ri=mi;
	}
	if(bri[ri].first<tot) return bri[ri].second;
	return bri[le].second;
}
int main(){
	Read(n),Read(m);
	int minbri=1e8,maxwei=0;
	for(int i=1;i<=n;i++) maxwei=max(maxwei,Read(wei[i])),id[i]=i;
	for(int i=1;i<=m;i++){
		Read(bri[i].second);
		minbri=min(minbri,Read(bri[i].first));
	}
	if(minbri<maxwei){
		printf("-1\n");
		return 0;
	}
	sort(bri+1,bri+1+m);
	for(int i=2;i<=m;i++)
		bri[i].second=max(bri[i].second,bri[i-1].second);
	ll ans=(ll)1e18;
	do{
		for(int i=1;i<=n;i++) f[i]=0;
		for(int i=1;i<=n;i++){
			int tot=wei[id[i]];
			for(int j=i+1;j<=n;j++){
				tot+=wei[id[j]];
				f[j]=max(f[j],f[i]+Query(tot));
			}
		}
		ans=min(ans,f[n]);
	}while(next_permutation(id+1,id+1+n));
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
const int maxn = 110;
int dp[maxn][maxn*maxn*maxn], n, k, M;
void add(int &a, int b) {
	a = a+b>=M?a+b-M:a+b;
}
int main() {
  	cin.tie(0)->sync_with_stdio(0);
  	cin >> n >> k >> M;
  	dp[0][0] = 1;
  	for(int i = 1; i <= n; i++) {
		for(int sm = 0; sm <= n*n*k; sm++) {
			dp[i][sm] = dp[i-1][sm];
			add(dp[i][sm], dp[i][sm-i]);
			if(sm >= (k+1)*i)
				add(dp[i][sm], M-dp[i-1][sm-(k+1)*i]);
		}
	}
	for(int avg = 1; avg <= n; avg++) {
		int ans = 0;
		for(int sm = 0; sm <= n*n*k; sm++) {
			ans = (ans + dp[avg-1][sm] * 1ll * dp[n-avg][sm])%M;
		}
		ans = ans*1ll*(k+1)%M; ans = (ans+M-1)%M;
		cout << ans << '\n';
	}
}

//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int num[100000];
int kazu[100000];
const int ma = (1 << 16) - 1;
int query(int n) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return kazu[n2];
		n2 = n2 * 2 % 99991;
	}
	return 0;
}
void add(int n, int b) {
	int n2 = (n & ma) + 1;
	while (num[n2]) {
		if (num[n2] == n + 1) return;
		n2 = n2 * 2 % 99991;
	}
	num[n2] = n + 1;
	kazu[n2] = b;
}
int li[300];

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

	int N, M;
	cin >> N >> M;
	int w[8];
	rep(i, N) cin >> w[i];

	pair<int, int> lv[100001];
	rep(i, M) {
		int l, v;
		cin >> l >> v;
		lv[i] = { v, l };
	}
	sort(lv, lv + M);
	lv[M] = { 1e9,1e9 };

	rep(i, 1 << N) {
		rep(j, N) if (i >> j & 1) li[i] += w[j];
	}
	sort(li, li + (1 << N));
	int saidai = 0;
	int k = 0;
	rep(i, 1 << N) {
		while (lv[k].first < li[i]) {
			chmax(saidai, lv[k].second);
			k++;
		}
		add(li[i], saidai);
	}

	rep(i, N) {
		if (w[i] > lv[0].first) {
			co(-1);
			return 0;
		}
	}

	int P[8], K = 1;
	rep(i, N) {
		K *= i + 1;
		P[i] = i;
	}

	ll kotae = 1e9;
	rep(k, K) {

		ll tmp[8] = {};
		rep(p, N) {
			int i = P[p];
			int omosa = w[i];
			for (int q = p + 1; q < N; q++) {
				int j = P[q];
				omosa += w[j];
				ll kari = query(omosa);
				chmax(tmp[q], tmp[p] + kari);
			}
		}
		chmin(kotae, tmp[N - 1]);
		next_permutation(P, P + N);
	}

	co(kotae);

	Would you please return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
struct UnionFind{
  vector<int> par, rank, sz, esz;
  UnionFind(int n){
    par.assign(n, 0);
    rank.assign(n, 0);
    sz.assign(n, 1);
    esz.assign(n, 0);
    rep(i, n) par[i] = i;
  }
  int find(int x){
    if(par[x]==x) return x;
    return par[x] = find(par[x]);
  }
  void merge(int x, int y){
    x = find(x);
    y = find(y);
    if(rank[x] < rank[y]) swap(x, y);
    esz[x]++;
    if(x == y) return;
    if(rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    sz[x] += sz[y];
    esz[x] += esz[y];
  }
};
int main(){
  int n, res=0;
  cin >> n;
  UnionFind uf(pow(10, 6));
  for(int i=0; i<n; i++){
    int a, b;
    cin >> a >> b;
    uf.merge(a,b);
  }
  for(int i=0; i<pow(10,6); i++){
    if(uf.par[i] == i){
      res += min(uf.sz[i], uf.esz[i]);
    }
  }
  cout << res << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define il inline
#define rg register
il int read()
{
	int re=0,k=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')k=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){re=re*10+ch-48;ch=getchar();}
	return re*k;
}
il void write(int x)
{
	if(x<0) return putchar('-'),write(-x),void();
	if(x<10)return putchar(x+48),void();
	return write(x/10),putchar(x%10+48),void();
}
int col[200005],l,n,m;
int fa[200005],head[200005],tot;
int find(int x)
{
	if(x==fa[x])return x;
	return fa[x]=find(fa[x]);
}
struct ss{
	int node,nxt,w;
}e[400005];
void add(int u,int v,int w)
{
	e[++tot].nxt=head[u];
	head[u]=tot;
	e[tot].node=v;
	e[tot].w=w;
}

void dfs(int x,int fa,int c)
{
//	cerr<<x
	col[x]=c;
	for(rg int i=head[x];i;i=e[i].nxt)
	{
		int y=e[i].node;
		if(y==fa)continue;
		if(c==e[i].w)
		{
			dfs(y,x,c%n+1);
		}
		else
		{
			dfs(y,x,e[i].w);
		}
	}
}
signed main()
{
	n=read();m=read();
	for(rg int i=1;i<=n;i++)
		fa[i]=i;
	for(rg int i=1,a,b,c;i<=m;i++)
	{
		a=read();b=read();c=read();
		int x=find(a);
		int y=find(b);
		if(x==y)continue;
		fa[x]=y;
		add(a,b,c);
		add(b,a,c);
	}

	dfs(1,0,1);
	for(rg int i=1;i<=n;i++)
		write(col[i]),puts("");
}


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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n, m; cin >> n >> m;
	vector<ll>v(n);
	for(ll i = 0; i < n; i++)cin >> v[i];
	set<ll>s;
	ump<ll,ll>mp;
	for(ll i = 0; i <= n; i++){
		s.insert(i);
	}
	for(ll i = 0; i < m; i++){
		mp[v[i]]++;
		s.erase(v[i]);
	}
	ll mex = *s.begin();
	for(ll i = m; i < n; i++){
		mp[v[i - m]]--;
		if(mp[v[i - m]] == 0)
			s.insert(v[i -m]);
		mp[v[i]]++;
		s.erase(v[i]);
		mex = min(mex,*s.begin());
	}
	cout << mex << nl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define int ll
#define ld long double
#define reps(i,s,n) for(int i=(s);i<(int)(n);i++)
#define rep(i,n) reps(i,0,n)
#define rreps(i,s,n) for(int i=(int)(s-1);i>=n;i--)
#define rrep(i,n) rreps(i,n,0)
#define all(v) (v).begin(),(v).end()
#define mset(a,n) memset(a,n,sizeof(a))
#define eras(v,n) (v).erase(remove(all(v),n),(v).end())
#define uni(v) sort(all(v));(v).erase(unique(all(v)),(v).end())
#define bcnt(i)  __builtin_popcount(i)
#define fi first
#define se second
constexpr ll INF = 1e18;
constexpr ll MOD = 1000000007;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T min(vector<T> &v) { return *min_element(v.begin(),v.end()); }
template<class T>T max(vector<T> &v) { return *max_element(v.begin(),v.end()); }
template<class T>T modpow(T a, T b, T m) { a %= m; T r = 1; while (b > 0) { if (b & 1) r = (r * a) % m; a = (a * a) % m; b >>= 1; } return r; }
ll modinv(ll a,ll m=MOD) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
template<class T>string radixconv(T n, T k){ string s; while(n/k){ s=to_string(n%k)+s; n/=k; } s=to_string(n%k)+s; return s; }

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << fixed << setprecision(11);
    cerr << fixed << setprecision(6);
    int n,k;
    cin >> n >> k;
    vector<vector<int>> a(n,vector<int>(n,0));
    rep(i,n)rep(j,n)cin>>a[i][j];
    int m=(k*k)/2+1;
    int l=-1,r=INF;
    auto f=[&](int mid){
        vector<vector<int>> csum(n+1,vector<int>(n+1,0));
        //rep(i,n)rep(j,n)if(a[i][j]>mid)csum[i+1][j+1];
        //rep(i,n)rep(j,n)csum[i][j+1]+=csum[i][j];
        //rep(i,n)rep(j,n)csum[i+1][j]+=csum[i][j];
        rep(i,n){
			rep(j,n){
				csum[i+1][j+1]=csum[i+1][j]+csum[i][j+1]-csum[i][j];
				if(a[i][j]>mid)csum[i+1][j+1]++;
			}
		}
        bool res=0;
        rep(i,n-k+1)rep(j,n-k+1)if(csum[i+k][j+k]+csum[i][j]-csum[i][j+k]-csum[i+k][j]<m)res=1;
        return res;
    };
    while(r-l>1){
        int mid=(r+l)/2;
        if(f(mid)) r=mid;
        else l=mid;
    }
    cout << r << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
typedef long long LL;
typedef pair <int, int> P;
const int N = 2e5 + 5;

int n, a[N], b[N], c[N];
LL ans, res;

int main() {
	cin>>n;
	rep (i, 1, n) scanf("%d", &a[i]), ans += a[i];
	rep (i, 1, n) scanf("%d", &b[i]), b[i] -= a[i];
	rep (i, 1, n) {
		if (i&1) b[(i + 1)>>1] = b[i];
		else c[i>>1] = b[i];
	}
	sort(b + 1, b + n/2 + 1);
	sort(c + 1, c + n/2 + 1);
	res = ans;
	per (i, n/2, 1) res += b[i] + c[i], ans = max(ans, res);
	printf("%lld\n", ans);
}

/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
int x;
void solve() {
    W(x>=0?x:0);
}
void input() {
    R(x);
}
int main(){
    input();
    solve();
    return 0;
}


//I'll always miss you like a darling.
#include <bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define ull unsigned long long
#define x first
#define y second
#define pb push_back
#define pf push_front
#define mp make_pair
#define Pair pair<int,int>
#define pLL pair<LL,LL>
#define pii pair<double,double>
#define LOWBIT(x) x & (-x)

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

const int INF=2e9;
const LL LINF=2e16;
const int magic=348;
const int MOD=1e9+7;
const double eps=1e-10;
const double pi=acos(-1);

struct fastio
{
    static const int S=1e7;
    char rbuf[S+48],wbuf[S+48];int rpos,wpos,len;
    fastio() {rpos=len=wpos=0;}
    inline char Getchar()
    {
        if (rpos==len) rpos=0,len=fread(rbuf,1,S,stdin);
        if (!len) return EOF;
        return rbuf[rpos++];
    }
    template <class T> inline void Get(T &x)
    {
        char ch;bool f;T res;
        while (!isdigit(ch=Getchar()) && ch!='-') {}
        if (ch=='-') f=false,res=0; else f=true,res=ch-'0';
        while (isdigit(ch=Getchar())) res=res*10+ch-'0';
        x=(f?res:-res);
    }
    inline void getstring(char *s)
    {
        char ch;
        while ((ch=Getchar())<=32) {}
        for (;ch>32;ch=Getchar()) *s++=ch;
        *s='\0';
    }
    inline void flush() {fwrite(wbuf,1,wpos,stdout);fflush(stdout);wpos=0;}
    inline void Writechar(char ch)
    {
        if (wpos==S) flush();
        wbuf[wpos++]=ch;
    }
    template <class T> inline void Print(T x,char ch)
    {
        char s[20];int pt=0;
        if (x==0) s[++pt]='0';
        else
        {
            if (x<0) Writechar('-'),x=-x;
            while (x) s[++pt]='0'+x%10,x/=10;
        }
        while (pt) Writechar(s[pt--]);
        Writechar(ch);
    }
    inline void printstring(char *s)
    {
        int pt=1;
        while (s[pt]!='\0') Writechar(s[pt++]);
    }
}io;

template<typename T> inline void check_max(T &x,T cmp) {x=max(x,cmp);}
template<typename T> inline void check_min(T &x,T cmp) {x=min(x,cmp);}
template<typename T> inline T myabs(T x) {return x>=0?x:-x;}
template<typename T> inline T mygcd(T x,T y) {return y==0?x:mygcd(y,x%y);}
inline int add(int x) {if (x>=MOD) x-=MOD;return x;}
inline int add(int x,int MO) {if (x>=MO) x-=MO;return x;}
inline int sub(int x) {if (x<0) x+=MOD;return x;}
inline int sub(int x,int MO) {if (x<0) x+=MO;return x;}
inline void Add(int &x,int y) {x=add(x+y);}
inline void Add(int &x,int y,int MO) {x=add(x+y,MO);}
inline void Sub(int &x,int y) {x=sub(x-y);}
inline void Sub(int &x,int y,int MO) {x=sub(x-y,MO);}
template<typename T> inline int quick_pow(int x,T y) {int res=1;while (y) {if (y&1) res=1ll*res*x%MOD;x=1ll*x*x%MOD;y>>=1;}return res;}
template<typename T> inline int quick_pow(int x,T y,int MO) {int res=1;while (y) {if (y&1) res=1ll*res*x%MO;x=1ll*x*x%MO;y>>=1;}return res;}

int n,X;

int main ()
{
#ifndef ONLINE_JUDGE
    double TIME=clock();
    freopen ("a.in","r",stdin);
    freopen ("a.out","w",stdout);
    cerr<<"Running..."<<endl;
#endif
    cin>>n>>X;int x;
    rep(i,1,n)
    {
        cin>>x;
        if (x!=X) printf("%d ",x);
    }
#ifndef ONLINE_JUDGE
    cerr<<"Exec Time: "<<(clock()-TIME)/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <tuple>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <bitset>
#include <list>
#include<iomanip>

using namespace std;
using ll = long long;
using ULL = unsigned long long;
using pll = std::pair<ll, ll>;
using vi = std::vector<int>;
using vl = std::vector<ll>;
using vb = std::vector<bool>;
using db = double;
using vdb = std::vector<db>;
using qlg= std::priority_queue<ll, vl, std::greater<ll> > ; //ascending
using qll= std::priority_queue<ll, vl, std::less<ll> > ; // descending
using qdg= std::priority_queue<db, vdb, std::greater<db> > ; //ascending
using qdl= std::priority_queue<db, vdb, std::less<db> > ; // descending
template<class T>
using vv = std::vector<std::vector<T> >;

#define REPL(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FORL(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FORL(i, 0, n)

#define MREP(i, n) for (ll i= (ll)(n)-1; i>=0; i-- )
#define MFOR(i, a, b) for (ll i = (ll)(b)-1; i >= (ll)(a); i--)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
#define INF pow(10, 10)

int main(void)
{

    ll N, x;

    cin >> N >> x;
    vl vals(N);

    REP(i, N)
    {
        cin >> vals[i];
    }

    REP(i, N)
    {
        if(vals[i]!=x) cout << vals[i] << " ";
    }
    cout << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb   push_back
#define T int time;        scanf("%d", &time); while(time--)

  int main(){
    ll sum = 0;
      T{
          ll a , b  ;
          cin >> a >> b ;
          sum+=(b*(b+1)/2 - (a*(a-1))/2) ;
         }
         cout << sum << endl ;

      }

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

#define mkp make_pair
#define mkt make_tuple
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
template <class T> void chmin(T &a, const T &b) {
    if (a > b) a = b;
}
template <class T> void chmax(T &a, const T &b) {
    if (a < b) a = b;
}

void add(ll &a, ll b) {
    a = (a + b) % MOD;
}

void mul(ll &a, ll b) {
    a %= MOD;
    b %= MOD;
    a = a * b % MOD;
}

void solve() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<ll> num_dp(2, 0);
    num_dp[0] = 1;
    vector<ll> sum_dp(2, 0);
    sum_dp[0] = A[0];
    for (int i = 1; i < N; i++) {
        vector<ll> nex_num_dp(2, 0);
        vector<ll> nex_sum_dp(2, 0);
        {
            add(nex_num_dp[1], num_dp[0]);
            add(nex_num_dp[0], num_dp[0]);
            add(nex_num_dp[0], num_dp[1]);
        }
        {
            add(nex_sum_dp[1], ((sum_dp[0] - A[i] * num_dp[0] % MOD) % MOD + MOD) % MOD);
            add(nex_sum_dp[0], ((sum_dp[0] + A[i] * num_dp[0] % MOD) % MOD + MOD) % MOD);
            add(nex_sum_dp[0], ((sum_dp[1] + A[i] * num_dp[1] % MOD) % MOD + MOD) % MOD);
        }
        swap(nex_num_dp, num_dp);
        swap(nex_sum_dp, sum_dp);
    }

    ll ans = 0;
    add(ans, sum_dp[0]);
    add(ans, sum_dp[1]);
    cout << ans << endl;
}

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

    solve();

    return 0;
}


/***Bismillahhirrahmannirrahim***/
/***coding is fun if u enjoy it***/

#include<bits/stdc++.h>

using namespace std;

/*** Input-Output ***/

#define pf   printf

#define sfi(t)     scanf("%d",&t)
#define sfi2(a,b)  scanf("%d %d",&a,&b)
#define sfl(t)     scanf("%lld",&t)
#define sfl2(a,b)  scanf("%lld %lld",&a,&b)

/*** Typedef ***/

typedef unsigned long long ull;
typedef long long ll;

/*** Some Prints ***/

#define en cout << '\n'
#define NO cout << "NO" << '\n'
#define no cout << "no" << '\n'
#define YES cout << "YES" << '\n'
#define yes cout << "yes" << '\n'
#define case(t) cout << "Case " << t << ": "

/*** Grids ***/

int drx[8]={-2,-2,-1,-1,1,1,2,2};
int dry[8]={-1,1,-2,2,-2,2,-1,1};
int dirx[4]={-1,0,1,0};
int diry[4]={0,-1,0,1};

/*** Loops ***/

#define foR0(num) for(int i=0;i<num;i++)
#define foR1(num) for(int i=1;i<=num;i++)
#define foRev(num) for(int i=num-1;i>=0;i--)
#define forIn(arr,num) for(int i=0;i<num;i++) sfi(arr[i]);
#define forIn1(arr,num) for(int i=1;i<=num;i++) sfi(arr[i]);
#define vprt(ans) for(int i=0;i<ans.size();i++) cout<< ans[i] << (i+1<ans.size() ? ' ' : '\n');
#define aprt(arr,num) for(int i=0;i<num;i++) cout<< arr[i] << (i+1<ans.size() ? ' ' : '\n');

/*** Sorts ***/

#define all(v) (v).begin(),(v).end()
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))
#define srtG(v) sort(all(v),greater<int>())

/*** STLs ***/

typedef vector <ll> vll;
typedef vector <int> vi;
typedef set <ll> sll;
typedef set <int> si;
typedef multiset <ll> msll;
typedef multiset <int> msi;
typedef stack <int> sti;
typedef stack <ll> stll;
typedef queue <ll> qll;
typedef queue <int> qi;
typedef map <ll,ll> mll;
typedef map <int,int> mii;
typedef pair <ll,ll> pll;
typedef pair <int,int> pii;
typedef vector <pll> vpll;
typedef vector <pii> vpii;

/*** Define Values ***/

#define PI 2*acos(0.0)
#define E 2.718281828
#define mod 1000000007
#define eps 1e-7
#define sz 100010
#define mx 500009

#define pb     push_back
#define pob    pob_back
#define puf    push_front
#define pof    pop_front
#define F      first
#define S      second
#define mp     make_pair
#define ins    insert

#define mem(v,val) memset(v,val,sizeof v)
#define add(v)     accumulate(v.begin(),v.end(), 0)
#define debug(x)   cout<<#x<<" = "<<x<<endl;

void solve()
{

	string s;
    cin>>s;
    for(int i=1;i<s.size();i++)
        cout<<s[i];
    cout<<s[0]<<endl;

}

int main()
{

	solve();

	/*int tc,cs=0;
	sfi(tc);
	while(tc--){

		///case(++cs);
		solve();

	}*/

 	return 0;
}

#include "bits/stdc++.h"
using namespace std;
//#include "testlib.h"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define int long long
#define ll long long
#define M 1000000007
#define MM 998244353
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define mii  map<ll ,ll >
#define msi  map<string,ll >
#define rep(a,b)    for(ll i=a;i<b;i++)
#define rep0(n)    for(ll i=0;i<n;i++)
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define vi vector<ll>
#define vs vector<string>
#define ppb pop_back
#define endl '\n'
#define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define r0 return 0;
#define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
#define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define Set(a, s) (a, s, sizeof (a))
#define FOR repi
#define vii vector<pii>
#define pii pair<int,int>
#define REVERSE(v) reverse(all(v))
#define trav(a, x) for(auto& a : x)
#define display(x) trav(a,x) cout<<a<<" ";cout<<endl
#define debug cerr<<"bhau"<<endl
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
template<typename T, typename U> static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}
template<typename T, typename U> static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

ll max(ll a, ll b) { return (a > b)? a : b;}
int min(int a, int b) { return (a < b)? a : b;}

int solve(){

    int n, k;
    cin >> n >> k;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= k; j++){
            ans += i * 100 + j;
        }
    }
    cout << ans;

    return 0;
}
signed main(){
    asdf
    // freopen("inputf.in", "w", stdout);

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


#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn=110,maxm=0,mod=998244353;
int n;
int w[maxn],cnt[maxn];
int f[2][maxn][maxn*maxn];
int C[maxn][maxn],P[maxn];
inline int read(){
    int res=0;
    char ch=getchar(),ch1=ch;
    while(!isdigit(ch))ch1=ch,ch=getchar();
    while(isdigit(ch))res=(res<<3)+(res<<1)+ch-'0',ch=getchar();
    return ch1=='-'?-res:res;
}
int qpow(int x,int k){
    int res=1;
    while(k){
        if(k&1)res=1ll*res*x%mod;
        x=1ll*x*x%mod;
        k>>=1;
    }
    return res;
}
void reset(){
    C[0][0]=1;
    for(int i=1;i<=100;++i){
        C[i][0]=1;
        for(int j=1;j<=i;++j)
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
    }
    P[0]=1;
    for(int i=1;i<=100;++i)
        P[i]=(P[i-1]*1ll*i)%mod;
}
void proc(){
    n=read();
    int tnt=0;
    for(int i=1;i<=n;++i){
        w[i]=read();
        tnt+=w[i];
        ++cnt[w[i]];
    }
    if(tnt&1){
        puts("0");return;
    }
    tnt>>=1;
    reset();
    f[0][0][0]=1;
    int flag=0;
    for(int i=1,sum=0;i<=100;++i){
        if(!cnt[i])continue;
        for(int j=0;j<=sum;++j)
            for(int k=0;k<=tnt;++k){
                f[flag^1][j][k]=0;
            }
        for(int j=0;j<=sum;++j){
            for(int k=0;k<=tnt;++k){
                if(!f[flag][j][k])continue;
                for(int l=0;l<=cnt[i];++l)
                    f[flag^1][j+l][k+l*i]=(f[flag^1][j+l][k+l*i]+1ll*f[flag][j][k]*C[j+l][l]%mod*C[sum-j+cnt[i]-l][cnt[i]-l]%mod*P[cnt[i]]%mod)%mod;
            }
        }
        sum+=cnt[i];
        flag^=1;
    }
    int ans=0;
    for(int i=0;i<=n;++i)
        ans=(ans+f[flag][i][tnt])%mod;
    cout<<ans<<endl;
}
int main(){
    int T=1;
    while(T--)proc();
    return 0;
}

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

const int mod = 998244353;

int n;
int a[110];
int dp[110][10010];

void ADD(int &x, int y) {
	x += y;
	if (x >= mod) x -= mod;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	dp[0][0] = 1;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int x = a[i]; sum += x;
		for (int j = i + 1; j >= 0; j--) {
			for (int k = sum; k >= 0; k--) {
				dp[j][k] = (1ll * dp[j][k] * (i + 1 - j) + 1ll * (k >= x && j ? dp[j - 1][k - x] : 0) * j) % mod;
			}
		}
	}
	if (sum & 1) {
		cout << 0 << endl;
		return 0;
	}
	int ans = 0;
	for (int j = 0; j <= n; j++) ADD(ans, dp[j][sum / 2]);
	cout << ans << endl;
	return 0;
}


/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;*/
#include<algorithm>
#include <bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<ctype.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define vi vector<ll>
#define pii pair<ll,ll>
#define bc __builtin_popcountll
#define vvi vector<vi>
#define vpii vector<pair<ll,ll>>
#define mll unordered_map<ll,ll>
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define f(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define fb1(i,n) for(ll i=n;i>0;i--)
#define endd cout<<'\n';
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define fr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define all(x) x.begin(), x.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define CASES  ll t;cin>>t;while(t--)
typedef long long ll;
typedef unsigned long long ull;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
//*X.find_by_order()-->returns an iterator to the k-th largest element (counting from zero)
//X.order_of_key()-->the number of items in a set that are strictly smaller than our item.
struct cmp
{
	bool operator() (ll a,ll b){
		return (a>b);
	}
};
ll ceil(const ll &a, const ll &b)
{
    if(a%b == 0)
        return a/b;
    return a/b +1;
}
ll mod=1000000007;
const ll N=200005;
int main()
{
fast;
    set<ll>s;
    f(i,N)
    {
        s.insert(i);
    }
    ll n;
    cin>>n;
    ll a[n];
    f(i,n)
    {
        cin>>a[i];
        if(s.find(a[i])!=s.end())
        {
            s.erase(a[i]);
        }
        auto it=s.begin();
        cout<<*it;
        endd;
    }

    return 0;
}

/**
*   author:  akifpathan
*   created: Saturday 10.10.2020 06:06:06 PM
**/

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

#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T>
using ordered_set= tree<T, null_type,
		less<T>,
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T>
using ordered_mset= tree<T, null_type,
		less_equal<T>,
		rb_tree_tag, tree_order_statistics_node_update> ;

*/

/*

PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)

*/

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

//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

	vector<int>vec(n);
	for(int &x: vec) cin>>x;

	set<int>st;
	for(int i=0;i<2e5+5;i++) st.insert(i);

	for(int x: vec)
	{
		if(st.find(x)!=st.end()) st.erase(x);
		cout<<*(st.begin())<<"\n";
	}
}

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

	int testcase=1;
	//cin>>testcase;

	for(int i=1;i<=testcase;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}

	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif

	return 0;
}


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

const int N = 17;
const int mod = 1e9+ 7;

int dp[(1<<N)][N];

int fx(vector<array<int,3>>&v, int mask , int last ){

    if(dp[mask][last] != -1){
      return dp[mask][last];
    }

    int n = v.size();

    if(mask == ((1<<n) -1)){

      int c = 0;
       for(int j =0;j<3;j++){

          if(j == 2){
             c += max(0LL,v[last][j] - v[0][j]);
          }else{
             c += abs(v[last][j] - v[0][j]);
          }

        }

       return c;
    }

    int ans = INT_MAX;

    for(int i = 1; i < n ; i ++){
       if( (mask&(1<<i)) == 0){
            int c = 0;
            for(int j =0;j<3;j++){

              if(j == 2){
                 c += max(0LL,v[last][j] - v[i][j]);
              }else{
                 c += abs(v[last][j] - v[i][j]);
              }

            }

            int nca = c + fx(v,mask|(1 << i) ,i);
            ans = min(ans,nca);

       }
    }

    return (dp[mask][last] = ans);
}

signed main(){

  int n;
  cin>>n;

  vector<array<int,3>>v;

  for(int i=0;i<n;i++){
    int x,y,z;
    cin>>x>>y>>z;
    v.push_back({x,y,z});
  }

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

  int ans = fx(v,1,0);
  cout<<ans<<endl;

  return 0;
}

// //
// n = 2;
// 1 2 3 4 5 ... n

// (1+2) / 2 = > 1

// n = 3
// 1 2 3

// (1+3)/2 => 2
// (2+2)/2 => 2

// n= 4
// ()

// 1 3 3
// 2 3

// 1 2 3
// 1 3
// 2

// 1 2 3 4
// 1 2 4
// 1 3
// 2

#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));

signed main() {
	int N;
	cin >> N;
	vector<int>X(N), Y(N), Z(N);
	rep(i, N)cin >> X[i] >> Y[i] >> Z[i];
	vector<vector<int>>dist(N, vector<int>(N));
	rep(i, N) {
		rep(j, N) {
			dist[i][j] = abs(X[j] - X[i]) + abs(Y[j] - Y[i]) + max(0ll, Z[j] - Z[i]);
		}
	}

	vector<vector<int>>dp(1ll << N, vector<int>(N));
	rep(i, 1ll<<N)rep(j, N)dp[i][j] = INF;
	dp[1][0] = 0;

	rep(i,(1ll << N)) {
		rep(j, N) {
			if (dp[i][j] == INF)continue;
			rep(k, N) {
				if ((i >> k) % 2 == 1)continue;
				int nexti = i | (1ll << k);
				int nextd = dp[i][j] + dist[j][k];
				dp[nexti][k] = min(dp[nexti][k], nextd);
			}
		}
	}

	int all = (1ll << N) - 1;
	int ret = INF;
	rep(i, N) {
		if (dp[all][i] == INF)continue;
		int tmp = dp[all][i] + dist[i][0];
		ret = min(ret, tmp);
	}
	cout << ret;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <math.h>
#include <random>
#include <chrono>
#include <assert.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
template<class T> using V = vector<T> ;
template<class T> using VV = V<V<T>> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
long double pie = acos(-1) ;
ll INF = 1e18 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
ll extGCD(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x = 1 ;
        y = 0 ;
        return a ;
    }
    ll d = extGCD(b,a%b,y,x) ;
    y -= a/b*x ;
    return d ;
}
void fix_cout(){cout << fixed << setprecision(20) ;}
template<class T> void chmax(T &a,T &b){if(a<b) a = b ;}
template<class T> void chmin(T &a,T &b){if(a>b) a = b ;}

int main(){
    ll a,b ;
    cin >> a >> b ;
    ll sub = 1 ;
    if(a==1){
        if(b==1){
            cout << 2 << endl ;
            return 0 ;
        }
        sub = 2 ;
        a++ ;
    }
    V<ll> p = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71} ;
    V<ll> dp(1<<(p.size()+1),0) ;
    int rem = 0 ;
    for(int i=0;i<p.size();i++) if(a%p[i]==0) rem |= 1<<i ;
    if(rem==0) rem += 1<<(p.size()) ;
    dp[0] = dp[rem] = 1 ;
    for(int i=1;i<b-a+1;i++){
        auto pre = dp ;
        rem = 0 ;
        for(int j=0;j<p.size();j++) if((a+i)%p[j]==0) rem |= 1<<j ;
        for(int j=0;j<dp.size();j++){
            if((rem&j)==0) dp[j+rem] += pre[j] ;
        }
    }
    ll ans = 0 ;
    for(int i=0;i<dp.size();i++){
        ans += dp[i] ;
    }
    cout << ans*sub << endl ;

}

#include <bits/stdc++.h>

#define ln                 '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (__typeof(to) i = 0; i < to; ++i)
#define cont(i, to)        for (__typeof(to) i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (__typeof(to) i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 74;
const int hsz = int(1e7) + 39, esz = 2e6;
bitset<nsz> g[nsz + 5];
int vis[nsz + 5], pw[nsz + 5];
num n, fm, to, ans = 1, a[nsz + 5];

struct hash_table {
	int sz, hd[hsz + 5];

	struct node {
		int nxt;
		bitset<nsz> w;

		node() {}
		node(int nxt, bitset<nsz> w): nxt(nxt), w(w) {}
	} e[esz + 5];

	int inline to_key(const bitset<nsz> &w) {
		int u = 0;
		cont (i, n) u = (u * 2 + w[i]) % hsz;
		return u;
	}

	void inline ins(const bitset<nsz> &w, int u) {
		e[++sz] = node(hd[u], w), hd[u] = sz;
	}

	bool inline qry(const bitset<nsz> &w, int u) {
		for (int i = hd[u]; i; i = e[i].nxt) {
			if (e[i].w == w) return 1;
		}
		return 0;
	}
};
hash_table dat;

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

void bfs(int s, int &sz, int *nd) {
	static int q[nsz + 5];
	int ql = 0, qr = 0;
	for (q[qr++] = s, vis[s] = s; ql != qr;) {
		int u = q[ql++];
		nd[sz++] = u;
		cont (v, n) if (g[u][v] && !vis[v]) q[qr++] = v, vis[v] = s;
	}
}

num inline calc(int s) {
	static int nd[nsz + 5], d[esz + 5];
	static bitset<nsz> q[esz + 5], p[esz + 5];
	int sz = 0, ql = 0, qr = 1, cnt = 0;
	bfs(s, sz, nd);
	if (sz == 1) return 2;
	for (; ql != qr; ++cnt) {
		bitset<nsz> cur = q[ql], ban = p[ql], nban;
		int key = d[ql]; ++ql;
		loop (i, sz) if (!ban[nd[i]]) {
			int v = nd[i], nkey = (key + pw[v]) % hsz;
			cur[v] = 1, nban = ban | g[v];
			if (!dat.qry(cur, nkey)) {
				q[qr] = cur, p[qr] = nban, d[qr] = nkey; ++qr;
				dat.ins(cur, nkey);
			}
			cur[v] = 0;
		}
	}
	return cnt;
}

void inline init() {
	pw[0] = 1;
	cont (i, n) pw[i] = pw[i - 1] * 2 % hsz;
}

int main() {
	scanf("%lld%lld", &fm, &to);
	n = to - fm + 1;
	circ (i, fm, to) a[num(i) - fm + 1] = i;
	cont (u, n) cont (v, u) g[u][v] = g[v][u] = gcd(a[u], a[v]) > 1;
	init();
	cont (u, n) if (!vis[u]) ans *= calc(u);
	printf("%lld\n", ans);
}


#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)
#define rep(i,n) for(ll i=0;i<n;i++)
int main(){
vector<pair<ll,string>> v;
ll N;
cin>>N;
rep(i,N){
    string s;ll jjj;
    cin>>s>>jjj;
    v.push_back(mkpr(jjj,s));
}

sort(ALL(v));
reverse(ALL(v));
cout<<v[1].second<<endl;

}

#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

#include <sys/time.h>

using namespace std;

class XorShift128 {
private:
	uint32_t x, y, z, w;

public:
	XorShift128() : x(123456789), y(362436069), z(521288629), w(88675123) { }
	uint32_t rnd() {
		uint32_t t = x ^ (x << 11);
		x = y;
		y = z;
		z = w;
		return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
	}

	uint32_t rnd(const int n) {
		return rnd() % n;
	}

	uint32_t rnd(const int l, const int r) { // [l, r]
		return rnd() % (r - l + 1) + l;
	}
};

long long get_time() {
	struct timeval tv;
	gettimeofday(&tv, NULL);
	long long result =  tv.tv_sec * 1000LL + tv.tv_usec / 1000LL;
	return result;
}

XorShift128 xor_shift_128;
long long start;

class Solver {
	int N, M;
	vector<string> strs;

public:
	Solver();
	void run();

private:

};

Solver::Solver() {
	cin >> N >> M;
	strs.resize(M);
	for(int i = 0; i < M; ++i) {
		cin >> strs[i];
	}
}

void Solver::run() {
	int i = 0;
	for(int hi = 0; hi < N; ++hi) {
		int l = 0;
		while(i < M && strs[i].size() + l <= N) {
			cout << strs[i];
			l += strs[i].size();
			++i;
		}

		for(int j = 0; j < N - l; ++j) {
			cout << '.';
		}

		cout << endl;
	}
}

int main() {
	start = get_time();

	Solver solver;
	solver.run();
}


#include <algorithm>
#include <iostream>
using namespace std;
using Pair = pair<double, double>;

Pair dp[200010], dpsum[200010], holesum, anssum;
int n, m, k, x;
bool hole[200010];

int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < k; i++) {
    cin >> x;
    hole[x] = true;
  }
  dpsum[0] = dp[0] = {1, 0};
  for (int i = 1; i <= n + m; i++) {
    auto tmp = dpsum[i - 1];
    if (i - m - 1 >= 0) tmp.first -= dpsum[i - m - 1].first, tmp.second -= dpsum[i - m - 1].second;
    tmp.first /= m, tmp.second /= m;
    tmp.second += tmp.first;
    if (hole[i]) {
      holesum.first += tmp.first;
      holesum.second += tmp.second;
      tmp.first = tmp.second = 0;
    }
    if (i >= n) {
      anssum.first += tmp.first, anssum.second += tmp.second;
      tmp.first = tmp.second = 0;
    }
    dp[i] = tmp;
    dpsum[i].first = dpsum[i - 1].first + dp[i].first;
    dpsum[i].second = dpsum[i - 1].second + dp[i].second;
  }
  if (anssum.first == 0) {
    cout << -1 << endl;
    return 0;
  }
  auto ans = anssum.second / anssum.first;
  if (holesum.first != 0) ans += (1 / (1 - holesum.first) - 1) * holesum.second / holesum.first;
  cout.precision(10);
  cout << fixed << ans << endl;
  return 0;
}

/*#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
*/

#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update>
*/
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define rrep(i,a,b) for(ll i=a;i>=b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second
#define all(x)  x.begin(),x.end()
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const ll INF = 1e18+7;
const ll mod = 998244353;
const ll MAXN = 1e5+10;

ll poww(ll a, ll b) {
    if(b<0) return 0LL;
    ll ans = 1;
    while (b) {
        if (b & 1)ans = ans * a;
        a = a * a;
        b >>= 1;
    }
    return ans;
}
ll binpow(ll a, ll b)
{
    if (b < 0) return 0LL;
    if (a <= 0)return 0LL;
    a %= mod;

    ll ans = 1LL;
    while (b) {
        if (b & 1)ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}
ll modinv(ll n) {
    return binpow(n, mod - 2);
}

void solve() {
    ll n,m,k; cin>>n>>m>>k;
    vector<ll> pos(n+1,0);
    FOR(i,k) {
        ll x; cin>>x;
        pos[x] = 1;
    }
    ll ct = 0, flg = 0;
    for(ll i=1; i<n; i++) {
        if(pos[i]==0) {
            if(ct>=m) flg = 1;
            ct = 0;
        }
        else ct++;
    }
    if(ct>=m) flg = 1;
    if(flg) { cout<<-1; return; }

    vector<ld> a(n+1), b(n+1);
    FOR(i,n+1) a[i] = b[i] = 0.0;

    ld r1=0.0,r2=0.0;
    for(ll i=n-1; i>=0; i--) {
        if(pos[i]) {
            a[i] = 1.0; b[i] = 0.0;
        }
        else {
            ld x = 0.0, y = 0.0;
            x = r1; y = r2;
            x /= (m*1.0); y /= (m*1.0); y += 1.0;
            a[i] = x; b[i] = y;
        }
        r1 += a[i]; r2 += b[i];
        if(i+m<=n) {
            r1 -= a[i+m]; r2 -= b[i+m];
        }
    }

    ld ans = b[0] / (1-a[0]);
    cout<<ans;
}

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

    //ll no_of_test_cases; cin>>no_of_test_cases;
    ll no_of_test_cases = 1;
    cout<<setprecision(10);

    for(ll i=1; i<=no_of_test_cases; i++) {
        solve();
    }
    return 0;
}


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

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

int n;
cin >> n;
vector<double> x(n),y(n);
rep(i,n)cin >> x[i] >> y[i];
for (int i = 0; i < n-2; i++)
{
    for (int j = i+1; j < n-1; j++)
    {
        for (int k = j+1; k < n; k++)
        {
            if(x[i]==x[j]&&x[i]==x[k]){
                cout << "Yes" << endl;
                return 0;
            }
            else if((double)(y[i]-y[j])/(x[i]-x[j])==(double)(y[i]-y[k])/(x[i]-x[k])){
             cout << "Yes" << endl;
             return 0;
            }
        }

    }

}
cout << "No" << endl;
 return 0;
}

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> index_set;
//typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update>indexed_multiset;

#define ull         unsigned long long
#define ll          long long int
#define ld          long double
#define MOD         1000000007
#define pi          3.14159265358979323846
#define N           100005
#define sz(x)       ((int)(x).size())
#define test ll t;  cin >> t; while(t--)
#define all(x)      (x).begin(), (x).end()
#define ld          long double
#define bigint      int64_t
#define vll         vector<ll>
#define vpll        vector<pair<ll,ll>>
//#define mp          make_pair
#define pb          push_back
#define pll         pair<ll,ll>
#define vvll        vector<vector<ll>>
#define fi          first
#define se          second
#define ins         insert
#define endl        "\n"
#define rep(i,a,n)  for(ll (i) = a;(i) < (n); (i)++)
#define repn(i,a,n) for(ll (i) = a;(i) <= (n); (i)++)
#define repr(i,a,n) for(ll (i) = a;(i) >= (n); (i)--)

//-------------------DEBUGGING-----------------------

vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while (!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
    vector<string> __attribute__ ((unused)) args,
    __attribute__ ((unused)) int idx,
    __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if (idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//-----------------------------------------------------------------------

//will upsolve from now on. Date: 24th Oct 2020, DIV2 round 678 upto D.

void solve() {
    ll n; cin >> n;
    vpll v;
    rep(i, 0, n) {
        ll x, y;
        cin >> x >> y;
        v.pb({x, y});
    }
    sort(all(v));
    repn(i, 0, n - 3) {
        repn(j, i + 1, n - 2) {
            repn(k, j + 1, n - 1) {
                ll a = v[i].fi, b = v[i].se;
                ll c = v[j].fi, d = v[j].se;
                ll e = v[k].fi, f = v[k].se;
                ll k1 = d - b, k2 = c - a, k3 = f - d, k4 = e - c;
                //if (k2 > 0 && k4 > 0) {
                if ((double)k1 / k2 == (double)k3 / k4 ) {
                    cout << "Yes\n";
                    return;
                }
                //}
            }
        }
    }
    cout << "No\n";
}

int main() {

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

    solve();
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) scanf("%d",&a[i]);

  vector<ll> e(n);
  vector<ll> o(n);
  rep(i,n){
    if(i%2) o[i]=a[i];
    else e[i]=a[i];
  }
  rep(i,n-1) e[i+1]+=e[i];
  rep(i,n-1) o[i+1]+=o[i];

  vector<ll> b(n+1);
  rep(i,n) b[i]=e[i]-o[i];
  n++;
  sort(b.begin(),b.end());

  ll ans=0;
  int i=0;
  while(i<n){
    ll k=b[i];
    ll c=0;
    while(b[i]==k){
      i++; c++;
      if(i==n) break;
    }
    ans+=c*(c-1)/2;
  }

  cout << ans << endl;

}

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

using namespace std;

map <int, int> d;
main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    vector <int> a(n + 1);
    int ans = 0;
    d[0] = 1;
    for (int i = 1; i <= n; ++ i){
        cin >> a[i];
        a[i] -= a[i - 1];
        if (i & 1) ans += d[a[i]];
        else ans += d[-a[i]];
        if (i & 1) d[a[i]] += 1;
        else d[-a[i]] += 1;
    }
    cout << ans;
}


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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (((a * a) + (b * b)) < (c * c))
        cout
            << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test() int t; cin>>t; while(t--)
#define all(v) v.begin(),v.end()
#define st(v) sort(all(v))
#define stA(arr,n) sort(arr,arr+n)
#define findInVec(v,key) (find(all(v),key)!=v.end())
#define findInSet(v,key) (v.find(key) != v.end())
#define findInStr(s,key) (s.find(key) != string::npos)
#define findInMap(m,key) (mp.find(key) != mp.end())
#define prt(i) cout<<i<<"\n"
#define fos(v) for(auto x:v)
#define fo(m,n,i) for(int i=m;i<n;i++)
#define Fo(m,n,i) for(int i=m;i>n;i--)
#define setbit(i) __builtin_popcount(i)
#define del(v,pos) v.erase(v.begin()+pos)
#define cnt(v,key) (count(all(v),key))
#define cnts(s,key) (s.count(key))
#define sumArr(a,s,e,sum)(accumulate(a+s,a+e,sum))
typedef long long ll;
using namespace std;
ll stringToLong(string s){stringstream raaz(s);ll x = 0;raaz >> x;return x;}
string longToString(ll k){stringstream ss;ss<<k;string s; ss>>s; return s;}
bool isPowerOfTwo(int n){if(n==0) return false; return (ceil(log2(n)) == floor(log2(n)));}
void scanArr(int *arr,int n){fo(0,n,i) cin>>arr[i];}
void printArr(int *arr,int n){fo(0,n,i) cout<<arr[i]<<" ";}
void scanVector(vector<ll> &v,int n){fo(0,n,i){int temp;cin>>temp;v.push_back(temp);}}
void printVector(vector<ll> v){fos(v) cout<<x<<" ";}
int main()
{
	IOS
	ll a,b,c;
    cin>>a>>b>>c;
    if(a*a + b*b < c*c)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
}


#include<iostream>
#include<cmath>

using namespace std;

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

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

    int p=0;
    while(pow(10, p) <= N){
        p++;
    }

    ll ans=0;
    rep(i,p){
        if(i==p-1){
            ans += i/3*(N-pow(10,i)+1);
            continue;
        }
        ans += i/3*(pow(10, i+1)-pow(10,i));
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
typedef  long long     ll ;
using namespace std;
void M(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
using namespace std;

int main()
{
    M();
    string s;
    cin>>s;

    s.push_back(s[0]);
    for(int i=1 ; i<4 ; i++)cout<<s[i];
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define IOS; ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb emplace_back
#define pi pair<int, int>
#define fi first
#define se second
#define INF 2147483647
#define mkp make_pair
using namespace std;
int min(int a, int b){return a < b ? a : b;}
int max(int a, int b){return a > b ? a : b;}
bool isprime(int k){bool is=1 ; for ( int i = 2 ; i <= sqrt(k) ; i++ ) if ( k % i == 0 ) is = 0 ; return is;}
int s[200005];
int t[200005];
int n,w;
int32_t main()
{
    IOS;
	cin >>n>>w;
	memset(s,0,sizeof(s));
	memset(t,0,sizeof(t));
	for (int i=0,a,b,c;i<n;i++)
	{
		cin >>a>>b>>c;
		s[a]+=c;
		t[b]+=c;
	}
	bool is=1;
	int sum=0;
	for (int i=0;i<=200000;i++)
	{
		sum-=t[i];
		sum+=s[i];
		//cout <<sum<<" ";
		if (sum>w) {is=0;break;}
	}
	if (is) cout <<"Yes\n";
	else cout <<"No\n";
	return 0;
}

#include "bits/stdc++.h"

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
//#define int long long;
double dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
ll idist(ll x1, ll y1, ll x2, ll y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
signed main() {
  ll N,w;
  cin >> N >> w;
  vector<pair<ll,ll>> a(N);
  vector<pair<ll,ll>> b(N);
  rep(i,N){
      ll tmp0,tmp1,tmp2;
      cin >> tmp0 >> tmp1 >> tmp2;
      a[i] = make_pair(tmp0,tmp2);
      b[i] = make_pair(tmp1,tmp2);
  }
  sort(all(a));
  sort(all(b));
  ll d = 0;
  ll m = 0;
  rep(i,N){
      while(a[i].first >= b[d].first){
          m-=b[d].second;
          d++;
      }
      m+=a[i].second;
      //cout << i << " " << d << endl;
      if(m>w){
          //cout << i <<" " << d << endl;
          cout << "No";
          return 0;
      }
  }
  cout << "Yes";
}


//~ author      : Sumit Prajapati
#include <bits/stdc++.h>
using namespace std;

#define ull                 unsigned long long
#define ll                  long long
#define int                 long long
#define pii                 pair<int, int>
#define pll                 pair<ll, ll>
#define pb                  push_back
#define mk                  make_pair
#define ff                  first
#define ss                  second
#define all(a)              a.begin(),a.end()
#define trav(x,v)           for(auto &x:v)
#define rep(i,n)            for(int i=0;i<n;i++)
#define repe(i,n)           for(int i=1;i<=n;i++)
#define read(a,n)           rep(i,n)cin>>a[i]
#define reade(a,n)          repe(i,n)cin>>a[i]
#define FOR(i,a,b)          for(int i=a;i<=b;i++)
#define printar(a,s,e)      FOR(i,s,e)cout<<a[i]<<" ";cout<<'\n'
#define curtime             chrono::high_resolution_clock::now()
#define timedif(start,end)  chrono::duration_cast<chrono::nanoseconds>(end - start).count()

auto time0 = curtime;
const int MD=1e9+7;
const int MDL=998244353;
const int INF=1e9;
const int MX=1e5+5;

void solve(){

    int a,b,c,d;
    cin>>a>>b>>c>>d;
    rep(k,MX){
        int cyan=a+k*b;
        int red=d*k*c;
        if(cyan<=red){
            cout<<k<<"\n";
            return;
        }

    }
    cout<<"-1\n";

}

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

    time0 = curtime;
    srand(time(NULL));
    int t=1;
    // cin>>t;
    repe(tt,t){
        // cout<<"Case #"<<tt<<": ";
        solve();
    }

    // cerr<<"Execution Time: "<<timedif(time0,curtime)*1e-9<<" sec\n";
    return 0;

}

#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
#define INF (1ll << 61)
ll mod = 1000000007;
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p & 1)a *= x; x *= x; p >>= 1; }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p & 1)a = a * x % mod;  x = x * x % mod; p >>= 1; }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k + 1) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
ll modinv(ll a) { ll b = mod, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); }u %= mod; if (u < 0) u += mod; return u; }

int main(void) {
	int a, b, c, d, k;
	cin >> a >> b >> c >> d;
	if (c * d <= b)puts("-1");
	else {
		k = (a + c * d - b - 1) / (c * d - b);
		if (k < 0)puts("-1");
		else printf("%d\n", k);
	}
	return 0;
}


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

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

    int n,w;
    cin >> n >> w;
    int ans = 0;
    while (n >= 0) {
        n -=w;
        if (n < 0) break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll n,w;
	cin>>n>>w;
	cout<<(n/w);
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long n;
string t;
int main() {
	cin>>n>>t;
	int p=3;
	long long q=1e10,u=200000;
	string s;
	for(int i=0;i<u;i++) {
		s+="110";
	}
	long long tmpans=0,ans=0;
	if(n==1) {
		if(t=="1") {
			ans=2*q;
		} else {
			ans=q;
		}
	}else if (n==2) {
			if(t=="11"||t=="10") {
				ans=q;
			} else if(t=="01") {
				ans=q-1;
			} else {
				ans=0;
			}
		} else if(n==3) {
			if(t=="110") {
				ans=q;
			} else if (t=="101"||t=="011") {
				ans=q-1;
			} else {
				ans=0;
			}
		} else {
			for(int i=0;i<p;i++) {
				bool ok=true;
				for(int j=0;j<n;j++) {
					if(t[j]!=s[i+j]) {
						ok=false;
						break;
					}
				}
			if(ok) {
				long long tmp=n-1;
				tmp+=i;
				tmp/=3;
				ans+=q-tmp;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

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

	string s;
	cin>>s;

	long long ans=0;

	string tt = "110";

	if(s.size() == 1)
	{
		if(s[0]=='1')
			ans = 2e10;
		else
			ans = 1e10;
	}
	else if(s.size()==2)
	{
		if(s=="11")
		{
			ans = 1e10;
		}
		else if(s=="10")
		{
			ans = 1e10;
		}
		else if(s=="01")
		{
			ans = 1e10-1;
		}
	}
	else
	{
		long long cnt = 0;
		if(s.substr(0,2)=="10")
		{
			cnt++;
			s = s.substr(2);
		}
		else if(s.substr(0,1)=="0")
		{
			cnt++;
			s = s.substr(1);
		}

		int ind = 0;
		for(int i=0;i<s.size();i++)
		{
			if(s[i]!=tt[ind])
			{
				cout<<0<<endl;
				return 0;
			}

			ind++;

			if(ind == 3)
			{
				cnt++,ind = 0;
			}
		}

		if(ind)
			cnt++;

		ans = 1e10-cnt+1;
	}

	cout<<ans<<endl;

	return 0;
}