#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vll = vector<vl>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
const ll INF = 1LL << 60;
const double pi = acos(-1);
ll mod = 1000000007;

ll gcd(ll a, ll b){
    if(a%b == 0){
        return b;
    }else{
        return gcd(b,a%b);
    }
}

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

int main() {
    int n; cin >> n;
    string t; cin >> t;
    ll ans = 0;
    int zero = 0, one = 0, k = 0;
    for(auto i : t){
        if(i == '0') {
            zero++;
            one = 0;
        }
        if(i == '1') {
            one++;
            zero = 0;
        }
        if(k < n - 2){
            if(t[k] == '0' && t[k+1] == '1' && t[k+2] == '0') {
                cout << ans << endl;
                return 0;
            }else{
                k++;
            }
        }
        if(zero == 2 || one == 3){
            cout << ans << endl;
            return 0;
        }
    }
    if(n == 1 && t[0] == '1'){
        ans = 2 * (ll)1e10;
    }else if(n == 1 && t[0] == '0'){
        ans = (ll)1e10;
    }else if(n == 2){
        if(t[0] == '1' && t[1] == '1' || t[0] == '1' && t[1] == '0'){
            ans = (ll)1e10;
        }else{
            ans = (ll)1e10 - 1;
        }
    }else if(n%3 == 0){
        if(t[0] == '1' && t[1] == '1' && t[2] == '0'){
            ans = (ll)1e10 - n / 3 + 1;
        }else{
            ans = (ll)1e10 - n / 3;
        }
    }else{
        if(n%3==2 && t[0] == '0') ans = (ll)1e10 - n / 3 - 1;
        else ans = (ll)1e10 - n / 3;
    }
    cout << ans << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define eps 1e-9
#define rep(i,l,r) for(int i=l;i<r;i++)
#define rrep(i,r,l) for(int i=r-1;i>=l;i--)
typedef long long ll;
const int maxn=2e5+5;
int n;
char t[maxn];
void solve()
{
	if(n==1){
		if(t[0]=='1') printf("20000000000\n");
		else printf("10000000000\n");
		return ;
	}
	ll ans=0;
	bool ok=true;
	int l=0,r=n-1,x=0;;
	while(l<n&&t[l]!='0') ++l;
	while(r>=0&&t[r]!='0') --r;
	if(l<n) ++l;
	++r;
	if(l>3||r<n-2) ok=false;
	if(ok){
		rep(i,l,r){
			if(t[i]=='0'){
				if(x==2) x=0,++ans;
				else {
					ok=false;
					break;
				}
			}
			else ++x;
		}
	}
	if(x) ok=false;
	if(r!=n&&r>=l) ++ans;
	printf("%lld\n",ok?10000000000-ans:0);
}
int main()
{
	scanf("%d %s",&n,t);
	solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
const int MOD=998244353;
const int INF=1e18;
void io(string s1="input.txt",string s2="output.txt"){freopen(s1.c_str(), "r", stdin);freopen(s2.c_str(), "w", stdout);}

signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;cin>>n;
    n=(1LL<<n);
    vi v(n);
    map<int,int> id;
    for(int i=0;i<n;i++){
        cin>>v[i];
        id[v[i]]=i+1;
    }

    while(v.size()!=2){
        vi tmp;
        for(int i=0;i<v.size();i+=2){
            tmp.push_back(max(v[i],v[i+1]));
        }
        v=tmp;
    }

    cout<<id[min(v[0],v[1])];
}

#include <bits/stdc++.h>

using namespace std;

int a, b, c, d, x, y;

int main(){
    cin >> a >> b >> c >> d ;

    x = max({a, b});
    y = min({c, d}) ;
   cout << x - y;
}


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

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

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

typedef long long ll;

int main() {

    int a,b,c;cin>>a>>b>>c;
    if(c%2==0){
        if(fabs(a)> fabs(b)) cout<<">"<<endl;
        else if(fabs(a)< fabs(b)) cout<<"<"<<endl;
        else cout<<"="<<endl;
    }else{
        if(a==b) cout<<"="<<endl;
        else if(a>b)  cout<<">"<<endl;
        else cout<<"<"<<endl;
    }

    return 0;
}


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

typedef long long ll;
const long long LINF = 1LL << 60;
const long long LMINF = 1LL << 63;
const int INF = 1 << 30;

#define REP(i,n) for(int i = 0;i < n;++i)
#define REPS(i,x) for(int i = 1;i <= (int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i >= 0;i--)
#define RREPS(i,x) for(int i=((int)(x));i > 0;i--)
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cout << #x << ": " << x << "\n"
#define out(x) cout << x << endl

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

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n)cin >> a[i];

    if (n == 1) {
        cout << a[0] << endl;
        return 0;
    }

    ll min = LINF;
    int num = a.size() - 1;
	for (int bit = 1; bit < (1 << num); ++bit)
    {
        int j = 1;
        ll orp = a[0];
        vector<ll> xorp;
        for(int i = 0;i < num;i++){
            bool f = (bit & (1 << i)) ;
            if(f == 0){
				orp |= a[j];
            }else if(f == 1){
                xorp.emplace_back(orp);
                orp = a[j];
            }
            j++;
        }
        xorp.emplace_back(orp);

        ll xorpp = xorp[0];
        for(int i = 1;i<xorp.size();i++){
            xorpp ^= xorp[i];
        }

        chmin(min,xorpp);
        if(min == 0)break;

	}

    cout << min << endl;
    return 0;
}

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

#define int long long

int n, a[21] ;

int fun(int idx, int orr, int xr) {
    if (idx > n) {
        return (xr^orr) ;
    }
    int cur = fun(idx+1, orr|a[idx], xr) ;
    cur = min(cur, fun(idx+1, a[idx], xr^orr)) ;
    return cur ;
}

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

    cin >> n ;
    for (int i=1;i<=n;++i) cin >> a[i] ;
    int ans = fun(1, 0, 0) ;
    cout << ans << endl ;
    return 0;
}


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

typedef long long ll;

const int maxn=105;
const int mod=998244353;
int n,ans;
int w[maxn];
ll fac[maxn];

const int B=15000;
const int Q=40000;

int main() {
	fac[0]=1ll;
	for(ll i=1;i<=100;i++) fac[i]=fac[i-1]*i%mod;
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>w[i];
	vector<vector<int> > lst(n+5,vector<int>(Q,0));
	lst[0][B]=1;
	for(int i=1;i<=n;i++) {
		vector<vector<int> > now(n+5,vector<int>(Q,0));
		for(int j=1;j<=i;j++)
			for(int k=-10000;k<=10000;k++) {
				now[j][k+B]+=lst[j-1][k-w[i]+B];
				now[j][k+B]%=mod;
			}
		for(int j=0;j<=i;j++)
			for(int k=-10000;k<=10000;k++) {
				now[j][k+B]+=lst[j][k+w[i]+B];
				now[j][k+B]%=mod;
			}
		lst=now;
	}
	for(int i=0;i<=n;i++) {
		ans+=ll(lst[i][B])*fac[i]%mod*fac[n-i]%mod;
		ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}

/*
problem :
algorithm :
created : Programmer_juruo
*/

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

#define int long long
#define N 2000005
#define M 2005
#define lowbit(x) x & (-x)
#define F1(i, n) for(int i = 1; i <= n; i++)
#define F(i, a, n) for(int i = a; i <= n; i++)
#define F0(i, n) for(int i = 0; i < n; i++)
#define dbg(x) cout << #x << ":" << x << endl;
#define Se second
#define Fi first
#define y1 juruo
#define Mp make_pair
#define Pb push_back
#define arr vector<int>
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

typedef pair <int, int> pii;
typedef priority_queue <int> pq;
typedef long long ll;

const int inf = 0x3f3f3f3f;
const int p = 107;
const int P = 100007;
const int Mod = 1e9+7;

int n, m;

void work() {
	cin >> n;
	arr x(n+1);
	for(int i = 1; i <= n; i++) {
		cin >> x[i];
	}
	sort(x.begin()+1, x.end());
	int Ans = 1, cnt = 0;
	for(int i = 1; i < x.size(); i++) {
		Ans *= (x[i] - x[i-1] +1);
		Ans %= Mod;
	}
	cout << Ans << endl;
}

signed main() {
  //freopen("1.in", "r", stdin);
  //freopen("1.out", "w", stdout);
  int T = 1;

  //cin >> T;

  while(T--) {
  	work();
  }

  return 0;
}


#include <iostream>

using ll = long long;

int const nmax = 100000;
int const modulo = 1000000007;
std::pair<int,int> dp[5 + nmax][2];
int v[5 + nmax];

std::pair<int,int> add(std::pair<int,int> f1, std::pair<int, int> f2) {
  return {(f1.first + f2.first) % modulo,
          (f1.second + f2.second) % modulo};
}

std::pair<int,int> append(std::pair<int,int> f1, int val) {
  return {f1.first, (f1.second + 1LL * f1.first * val) % modulo};
}

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

  int n;
  std::cin >> n;

  for(int i = 1;i <= n; i++)
    std::cin >> v[i];
  dp[1][0] = {1, v[1]};
  for(int i = 2; i <= n; i++) {
    dp[i][0] = append(add(dp[i - 1][0], dp[i - 1][1]), v[i]);
    dp[i][1] = append(dp[i - 1][0], modulo -v[i]);
  }
  std::cout << add(dp[n][0], dp[n][1]).second;
  return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define rng(i,l,r) for (int i=l; i<r; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define endl "\n"
#define INF 1000000007 // 1e9+7
#define LINF 1152921504606846976 // 1LL<<60
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> using V = vector<T>;
template<class T> bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; }
struct in { template <class T> operator T() { T t; std::cin >> t; return t; } };
int dx[8] = {0,1,0,-1,1,1,-1,-1};
int dy[8] = {1,0,-1,0,1,-1,1,-1};

auto solve() {
   ll n = in();
   int m = in();

   V<string> ss(n);
   rep(i,n) {
      cin >> ss[i];
   }

   ll ans = n * (n-1) / 2;

   ll c = 1;
   int di = -1;
   rng(j,1,n) {
      int d = 0;
      rep(k,m) {
         if (ss[0][k] != ss[j][k]) d++;
      }
      if (d % 2 == 0) c++;
      else di = j;
   }

   ans -= c * (c-1) / 2;
   if (di != -1) {
      c = 1;
      rep(j,n) {
         if (j == di) continue;
         int d = 0;
         rep(k,m) {
            if (ss[di][k] != ss[j][k]) d++;
         }
         if (d % 2 == 0) c++;
      }
      ans -= c * (c-1) / 2;
   }

   return ans;
}

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout << solve() << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
using P = pair<int,int>;
int main() {
  int n,m;
  cin>>n>>m;
  vector<int> v(n),w(m);
  rep(i,n)cin>>v[i];
  rep(i,m)cin>>w[i];
  int j=0;
  rep(i,n){
    while(j<m&&w[j]<v[i]){
      cout<<w[j]<<" ";
      j++;
    }
    if(v[i]==w[j]){
      j++;
      continue;
    }
    cout<<v[i]<<" ";
  }
  for (; j < m; j++)
  {
    cout<<w[j]<<" ";
  }

  cout<<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=(int)(x);i<(int)(y);i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=3e5;
const int inf=1e9;
int main(){
	int N,M; cin>>N>>M;
	int x,y;
	pair<int,int> vp[M+1]; vp[0] = {0, N};
	map<pair<int,int>,bool> mp; mp[vp[0]] = true;
	map<int,vector<int>> record; record[N].push_back(0);
	rep(i,0,M){
		cin>>x>>y;
		vp[i+1] = {x, y};
		record[y].push_back(x);
	}
	sort(vp,vp+M+1);
	for(auto it = record.begin(); it != record.end(); it++){
		sort((it->second).begin(), (it->second).end());
      	//print((it->second),,(it->second).size());
	}
	rep(i,1,M+1){
		pair<int,int> p = vp[i];
		mp[p] = false;
		if(p.second > 0 && !record[p.second-1].empty()){
			auto it = lower_bound(record[p.second-1].begin(), record[p.second-1].end(), p.first);
			if(it != record[p.second-1].begin()){
				mp[p] |= mp[{*(it-1), p.second-1}];
			}
		}
		if(p.second < 2*N && !record[p.second+1].empty()){
			auto it = lower_bound(record[p.second+1].begin(), record[p.second+1].end(), p.first);
			if(it != record[p.second+1].begin()){
				mp[p] |= mp[{*(it-1), p.second+1}];
			}
		}//cout<<p.first<<" "<<p.second<<" "<<mp[p]<<endl;
	}
	int ans = 0;
	for(pair<int,vector<int>> pv:record){
      	if(!pv.second.empty()) ans += mp[{pv.second.back(), pv.first}];
	}
	cout<<ans<<endl;
}


#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 fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
    #define pb push_back
    #define ll long long

    #define vi vector<int>
    #define vll vector<long long>
    #define mp make_pair
    #define infi INT_MAX
    #define infl LONG_LONG_MAX
    #define infd LDBL_MAX
    #define f(i,a,b) for(ll i=a;i<b;i++)
    #define ff first
    #define ss second
    #define pll pair<ll,ll>
    #define endl "\n"
    #define ALL(v) v.begin(),v.end()
    #define nl cout<<"\n";
    #define pr(x) cout<<x;
    #define pr1(x) cout<<x<<" ";
    #define pr2(x,y) cout<<x<<" "<<y;
    #define deb printf("*****************************\n");
    #define idk printf("idk idk ! \n");
    #define hi printf("hi ! \n");
    #define bye printf("bye bye ! \n");
    #define o_set(ll) tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
    #define number_of_set_bits  __builtin_popcountll

    //template<typename T>
    //#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
    //member functions :
    //1. order_of_key(k) : number of elements strictly lesser than k
    //2. find_by_order(k) : k-th element in the set

 ll ceil(ll x,ll y){
     return (x + y-1)/y;
 }

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

        ll ntc=1;
     //  cin>>ntc;

        f(ks,1,ntc+1)
        {
          //cout<<"Case #"<<ks<<": ";
          ll a,b,c,d; cin>>a>>b>>c>>d;
          if( d*c - b > 0  ) cout<<ceil(a , (d*c - b));
          else cout<<-1;
          nl

        }

        return 0;
    }

#include <cstdio>
#include <iostream>
using namespace std;
#define mod 1000000007
#define ll long long
#define maxn 1005
ll f[maxn], g[maxn];
int n;
char cAA, cAB, cBA, cBB;

int main() {
	scanf( "%d", &n );
	cin >> cAA >> cAB >> cBA >> cBB;
	if( n == 2 ) return ! printf( "1\n" );
	f[1] = 2, f[0] = g[0] = 1;
	for( int i = 2;i <= n;i ++ )
		f[i] = ( f[i - 1] + f[i - 2] ) % mod;
	for( int i = 1;i <= n;i ++ )
		g[i] = ( g[i - 1] << 1 ) % mod;
	if( cAB == 'A' ) {
		if( cAA =='A' ) printf( "1\n" );
		else if( cBA == 'A' ) printf( "%lld\n", f[n - 3] );
			else printf( "%lld\n", g[n - 3] );
	}
	else {
		if( cBB == 'B' ) printf( "1\n" );
		else if( cBA == 'B' ) printf( "%lld\n", f[n - 3] );
			else printf( "%lld\n", g[n - 3] );
	}
	return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define inF freopen("input.txt", "r", stdin);
#define outF freopen("output.txt", "w", stdout);
#define endl '\n'
#define mm(arr) memset(arr, 0, sizeof(arr))
#define F first
#define S second
#define scanArray(a,n) for(int i = 0; i < n; i++){cin >> a[i];}
#define coutArray(a,n) for(int i = 0; i < n; i++){cout << a[i] << " ";}cout << endl;
#define ld long double
#define PI 3.141592653589793238
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define int ll

#ifndef LOCAL
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#endif
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);

struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};

#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

void solve(){
    int n; cin >> n;
    map<int, int> cnt;
    set<int> s;
    for(int i = 0; i < n; i++){
        int x; cin >> x;
        cnt[x] += 1;
        s.insert(x);
    }
    for(int x : s){
        if(cnt[x] != 1){
            cout << "No" << endl;
            return;
        }
    }
    cout << (sz(s) == n ? "Yes" : "No") << endl;
}

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

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; ++i) {
    	int x;
    	cin >> x;
    	s.insert(x);
    }
    if (s.size() == n && *s.begin() == 1 && *s.rbegin() == n) {
    	cout << "Yes\n";
    } else {
    	cout << "No\n";
    }
	return 0;
}


#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#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 repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int N, S, D;
  cin >> N >> S >> D;
  vector<int> X(N), Y(N);
  bool ans = false;
  rep(i, N) {
    cin >> X[i] >> Y[i];
    if (X[i] < S && Y[i] > D)
      ans = true;
  }
  if (ans)
    cout << "Yes\n";
  else
    cout << "No\n";
}

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

int main()
{
	int n,s,d,x,y;
	cin>>n>>s>>d;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		if(d<y && s>x)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}


/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

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

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
  void solve()
  {
int x;
cin>>x;
x=x%100;
cout<<100-x;

  }

  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
    #endif
int t=1;
while(t--)
{
  solve();
}

    return 0;
  }

#include <bits/stdc++.h>
#define ll long long
using namespace std;
namespace IO{
  inline char ch(){
    static char s[1<<16],*S,*T;
    return (S == T)&&(T = (S = s)+
      fread(s,1,1<<16,stdin),S == T)?EOF:*S++;
  }
  template<typename T> void read(T &x){
    x = 0; int f(1); char c = ch();
    for(;!isdigit(c);c = ch()) if(c == '-') f = -1;
    for(;isdigit(c);c = ch()) x = x*10+c-'0';
    x *= f;
  }
  template<typename T,typename... Args>
  inline void read(T &x,Args&... args){
    read(x); read(args...);
  }
  template<typename T> void write(T x,char f = '\n'){
    if(x < 0) putchar('-'),x = -x;
    if(x > 9) write(x/10,'\0');
    putchar('0'+x%10);
    if(f != '\0') putchar(f);
  }
}
using namespace IO;
int main(){
#ifdef LZX_CAI
  freopen("test.in","r",stdin);
  freopen("test.out","w",stdout);
#endif
  int n;
  read(n);
  write(100-n%100);
  return 0;
}


/*-------------必要なときに使うもの------------------*/
//#define _GLIBCXX_DEBUG
/*#include<atcoder/modint>
#include<atcoder/math>
using namespace atcoder;
using mint=modint1000000007;
using MINT=modint998244353;*/
/*#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")*/
/*-------------------end-----------------------------*/
#include<bits/stdc++.h>
using namespace std;
/*---------------------マクロ-------------------------*/
#define int long long
#define rep(i, n) for (int i = 0; i < (long long)(n); i++)
#define stoi stoll
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define debug(x) cout<<#x<<" : "<<x<<endl
#define endl '\n'
/*------------------------end---------------------------*/
/*-----------------------型エイリアス--------------------*/
using ll = long long;
using lint=long long;
using P=pair<long long,long long>;
using vi=vector<long long>;
using vvi=vector<vi>;
using vb=vector<bool>;
using vc=vector<char>;
using vvc=vector<vc>;
using vs=vector<string>;
using vd=vector<double>;
/*------------------------end---------------------------*/
/* ----------------よく使う数字や配列-------------------- */
constexpr long long INF = LLONG_MAX/3;
constexpr long long dx[]={1,0,-1,0},dy[]={0,1,0,-1};
constexpr long long mod = 1e9 + 7;
constexpr long long MOD=998244353;
constexpr long double pi = 3.141592653589793238462643383279;
constexpr double EPS=1e-14;
/* ----------------------end-----------------------------*/
/*---------------------template------------------------*/
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;
}
template<class T>inline void mainend(T x){cout<<x<<endl;exit(0);}
/*----------------------end-------------------------*/
void Main(){
  int N;cin>>N;
  vector<int>A(N);rep(i,N)cin>>A[i];
  vector<vector<int>>ruiseki_min(N,vector<int>(N,INF));
  int MAX=-INF;
  rep(i,N){
    ruiseki_min[i][i]=A[i];
    chmax(MAX,A[i]);
    for(int j=i+1;j<N;j++){
      ruiseki_min[i][j]=min(ruiseki_min[i][j-1],A[j]);
      chmax(MAX,ruiseki_min[i][j]*(j-i+1));
    }
  }
  cout<<MAX<<'\n';
}
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(16);
  Main();
  return 0;
}

// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD_1000000007 = 1000000007LL;
const ll MOD_998244353 = 998244353LL;

// ModInt begin

using ll = long long;
template<ll mod>
struct ModInt {
    ll v;
    ll mod_pow(ll x, ll n) const {
        return (!n) ? 1 : (mod_pow((x*x)%mod,n/2) * ((n&1)?x:1)) % mod;
    }
    ModInt(ll a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
    ModInt operator+ ( const ModInt& b ) const {
        return (v + b.v >= mod ? ModInt(v + b.v - mod) : ModInt(v + b.v));
    }
    ModInt operator- () const {
        return ModInt(-v);
    }
    ModInt operator- ( const ModInt& b ) const {
        return (v - b.v < 0 ? ModInt(v - b.v + mod) : ModInt(v - b.v));
    }
    ModInt operator* ( const ModInt& b ) const {return (v * b.v) % mod;}
    ModInt operator/ ( const ModInt& b ) const {return (v * mod_pow(b.v, mod-2)) % mod;}

    bool operator== ( const ModInt &b ) const {return v == b.v;}
    bool operator!= ( const ModInt &b ) const {return !(*this == b); }
    ModInt& operator+= ( const ModInt &b ) {
        v += b.v;
        if(v >= mod) v -= mod;
        return *this;
    }
    ModInt& operator-= ( const ModInt &b ) {
        v -= b.v;
        if(v < 0) v += mod;
        return *this;
    }
    ModInt& operator*= ( const ModInt &b ) {
        (v *= b.v) %= mod;
        return *this;
    }
    ModInt& operator/= ( const ModInt &b ) {
        (v *= mod_pow(b.v, mod-2)) %= mod;
        return *this;
    }
    ModInt pow(ll x) { return ModInt(mod_pow(v, x)); }
    // operator int() const { return int(v); }
    // operator long long int() const { return v; }
};

template<ll mod>
ModInt<mod> pow(ModInt<mod> n, ll k) {
    return ModInt<mod>(n.mod_pow(n.v, k));
}

template<ll mod>
ostream& operator<< (ostream& out, ModInt<mod> a) {return out << a.v;}
template<ll mod>
istream& operator>> (istream& in, ModInt<mod>& a) {
    in >> a.v;
    return in;
}

// ModInt end

using mint = ModInt<MOD_1000000007>;
mint dp[100010][2], sum[100010][2];

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

    dp[0][1] = mint(1);
    for(int i=0; i<N; i++) {
        int A; scanf("%d", &A);
        // 場合の数
        dp[i+1][0] += dp[i][0] + dp[i][1];
        dp[i+1][1] += dp[i][0];
        // 和
        sum[i+1][0] += sum[i][0] + sum[i][1] + dp[i+1][0] * mint(A);
        sum[i+1][1] += sum[i][0] - dp[i+1][1] * mint(A);
        // fprintf(stderr, "dp = %lld, %lld, sum = %lld, %lld\n", dp[i+1][0].v, dp[i+1][1].v, sum[i+1][0].v, sum[i+1][1].v);
    }
    mint ans = sum[N][0] + sum[N][1];
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define max(p, q) ((p) > (q) ? (p) : (q))
#define min(p, q) ((p) < (q) ? (p) : (q))
#define ALL(a) (a).begin(), (a).end()
#define INF ((1LL << 62) - (1LL << 31))
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
int main(void) {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    double n;
    cin >> n;
    double ans = 0;
    rep(i, 1, n) { ans += n / (double)(n - i); }
    cout << fixed << setprecision(12) << ans << endl;

    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

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

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

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

  ll prefix_sum = 0, ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += a[i] * i - prefix_sum;
    prefix_sum += a[i];
  }

  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"#%d (%s) = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

const int iinf = 1e9+10;
const ll inf = 1ll<<60;
const ll mod = 1e9+7 ;

void GG(){cout<<"0\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b,mo) % mo;
}

const int maxn = 1e6+5;

int a[maxn], b[maxn];
int dp[maxn][2];
int X[2][2];

signed main(){
    IOS();

    int n; cin>>n;
    ll re = 0;
    for (int i =0 ; i<n; ++i) {
        cin>>a[i];
    }vector<int> v;
    for (int i = 0; i<n; ++i) {
        cin>>b[i];
        if ( i & 1) swap(a[i], b[i]);
        re += a[i];
        v.pb({b[i] - a[i]});
    }
    sort(ALL(v));
    for (int i = 0; i<n/2; ++i) {
        re += v[SZ(v) - i - 1];
    }
    cout<<re<<endl;

}

#include<bits/stdc++.h>
#define L(i, j, k) for(int i = (j); i <= (k); i++)
#define R(i, j, k) for(int i = (j); i >= (k); i--)
#define ll long long
#define sz(a) ((int) a.size())
#define vi vector<int>
using namespace std;
const int N = 2e5 + 7;
int n, a[N], b[N], r1[N], r2[N];
ll sum;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n;
	L(i, 1, n) cin >> a[i];
	L(i, 1, n) cin >> b[i], a[i] -= b[i], sum += b[i];
	n >>= 1;
	L(i, 1, n) r1[i] = a[i * 2 - 1];
	L(i, 1, n) r2[i] = a[i * 2];
	sort(r1 + 1, r1 + n + 1);
	sort(r2 + 1, r2 + n + 1);
	L(i, 1, n) if(r1[i] + r2[i] > 0) sum += r1[i] + r2[i];
	cout << sum << '\n';
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define nl '\n'
#define debug(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T(&t)[N]) { return N; } template<typename T> int SIZE(const T& t) { return t.size(); } string to_string(const string s, int x1 = 0, int x2 = 1e9) { return '"' + ((x1 < s.size()) ? s.substr(x1, x2 - x1 + 1) : "") + '"'; } string to_string(const char* s) { return to_string((string)s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c) { return string({ c }); } template<size_t N> string to_string(const bitset<N>& b, int x1 = 0, int x2 = 1e9) { string t = ""; for (int __iii__ = min(x1, SIZE(b)), __jjj__ = min(x2, SIZE(b) - 1); __iii__ <= __jjj__; ++__iii__) { t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A(&v), int x1 = 0, int x2 = 1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B>& p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A(&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if (l_v_l_v_l == 0) res += nl; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2 - x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if (e != l) { if (rnk > 1) { res += nl; t_a_b_s = l_v_l_v_l; }; } else { t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if (l_v_l_v_l == 0) res += nl; return res; } void dbgm() { ; } template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T) { cout << to_string(H) << " | "; dbgm(T...); }

//COMMENT DEBUG

void solve()
{
	int n, x;
	cin >> n;
	long long sum = 0;
	vector<int> a(n + 1);
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		//sum+=x;
	}
	for (int i = 1; i <= n; i++)
	{
		cin >> x;
		sum += (a[i] * x);
	}
	if (sum == 0) {
		cout << "Yes\n";
		return;
	}
	cout << "No\n";
}

int main()
{

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

	ios::sync_with_stdio(0);
	cin.tie(0);
	// int t;
	// cin >> t;
	// while (t--)
	// {
	solve();
	// }
}

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

int get() {
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = -1; c = getchar(); }
	while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); }
	return x * f;
}

const int N = 2e5 + 5;
int n, m, q, a[N], b[N], ans, len, bin[N], tot;
struct Ask {
	int T, x, y;
} s[N];

struct BIT {
	int sum[N], sum0;
	int lowbit(int x) { return x & (-x); }
	void add(int x, int v) { while(x <= tot) sum[x] += v, x += lowbit(x); }
	int ask(int x) { int r(0); while(x) r += sum[x], x -= lowbit(x); return r + sum0; }
	int ask(int l, int r) { if(l > r) return 0; return ask(r) - ask(l - 1); }
} A1, B1, AS, BS;

void add1(int x) {
	ans += BS.ask(a[x] + 1, tot) + bin[a[x]] * B1.ask(1, a[x]);
	A1.add(a[x], 1), AS.add(a[x], bin[a[x]]);
}

void del1(int x) {
	ans -= BS.ask(a[x] + 1, tot) + bin[a[x]] * B1.ask(1, a[x]);
	A1.add(a[x], -1), AS.add(a[x], -bin[a[x]]);
}

void add2(int x) {
	ans += AS.ask(b[x], tot) + bin[b[x]] * A1.ask(1, b[x] - 1);
	B1.add(b[x], 1), BS.add(b[x], bin[b[x]]);
}

void del2(int x) {
	ans -= AS.ask(b[x], tot) + bin[b[x]] * A1.ask(1, b[x] - 1);
	B1.add(b[x], -1), BS.add(b[x], -bin[b[x]]);
}

signed main() {
	n = get(), m = get(), q = get();
	for(int i = 1; i <= q; i++) s[i].T = get(), s[i].x = get(), s[i].y = get(), bin[i] = s[i].y;
	bin[q + 1] = 0;
	sort(bin + 1, bin + 1 + q + 1), tot = unique(bin + 1, bin + 1 + q + 1) - bin - 1;
	for(int i = 1; i <= q; i++) s[i].y = lower_bound(bin + 1, bin + 1 + tot, s[i].y) - bin;
	for(int i = 1; i <= n; i++) a[i] = 1;
	for(int i = 1; i <= m; i++) b[i] = 1;
	A1.add(1, n), B1.add(1, m);
	for(int i = 1; i <= q; i++) {
		int T = s[i].T, x = s[i].x, y = s[i].y;
		if(T == 1) del1(x), a[x] = y, add1(x);
		else del2(x), b[x] = y, add2(x);
		printf("%lld\n", ans);
	}
	return 0;
}


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

using namespace std;
const int maxn = 1000010, inf = 1e9 + 233;
struct edge{int too, pre;}e[maxn << 1];

int n, m, tot;
int last[maxn];
char s[maxn];
bool vis[maxn];

inline void add(int x, int y) {e[++tot] = (edge){y, last[x]}; last[x] = tot;}

inline void ins(int x, int y) {add(x, y); add(y, x);}

void dfs(int x)
{
    vis[x] = 1;
    for (int i = last[x], too; i; i = e[i].pre)
        if (!vis[too = e[i].too])
            dfs(too);
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
    {
        scanf("%s", s + 1);
        for (int j = 1; j <= m; j++)
            if (s[j] == '#')
                ins(i, j + n);
    }

    ins(1, 1 + n); ins(1, m + n);
    ins(n, 1 + n); ins(n, m + n);

    int ans1 = -1;
    for (int i = 1; i <= n; i++)
        if (!vis[i])
            dfs(i), ans1++;

    memset(vis, 0, sizeof(vis));

    int ans2 = -1;
    for (int i = n + 1; i <= n + m; i++)
        if (!vis[i])
            dfs(i), ans2++;

    printf("%d\n", min(ans1, ans2));
}

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template<typename T = int> using V = vector<T>;
template<typename T = int> using VV = vector<vector<T>>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
vector<int>g[200005];
int c[20];
int dp[1<<17][17];
vector<int>d[20];
int n;
void bfs(int s){
    int k = c[s];
    queue<int> q;
    q.push(k);
    vector<int>a(n, 1<<30);
    a[k] = 0;
    while(q.size()){
        int x = q.front();
        q.pop();
        for(int t:g[x]){
            if(a[t] == 1<<30){
                a[t] = a[x] + 1;
                q.push(t);
            }
        }
    }
    d[s] = a;
}
int main(){
    int m;
    cin >> n >> m;
    while(m--){
        int a, b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int k;
    cin >> k;
    rep(i,k){
        cin >> c[i];
        c[i]--;
    }
    rep(i,k)bfs(i);
    rep(i,1<<k)rep(j,k)dp[i][j] = 1<<29;
    rep(i,k)dp[1<<i][i] = 1;
    rep(i,1<<k){
        rep(j,k){
            if(i >> j & 1){
                rep(l,k){
                    dp[i][j] = min(dp[i][j], dp[i^(1<<j)][l] + d[l][c[j]]);
                }
            }
        }
    }
    int ans = 1<<29;
    rep(j,k){
        ans = min(ans, dp[(1<<k)-1][j]);
    }
    if(ans == 1<<29)ans = -1;
    cout << ans << endl;
}


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

int main()
{
    int pre_score;

    for (int i = 0; i < 1000; i++) {

        int si,sj,ti,tj;
        cin >> si >> sj >> ti >> tj;

        string ans="";
        if (si-ti<0) {
            for (int j = 0; j < ti-si; j++) ans += 'D';
        }
        else if (si-ti>0) {
            for (int j = 0; j < si-ti; j++) ans += 'U';
        }
        if (sj-tj<0) {
            for (int j = 0; j < tj-sj; j++) ans += 'R';
        }
        else if (sj-tj>0) {
            for (int j = 0; j < sj-tj; j++) ans += 'L';
        }

        cout << ans << endl;
        if (i==999) return 0;
        cin >> pre_score;
    }
}

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;

int main() {
  long double sx,sy,gx,gy;
  cin>>sx>>sy>>gx>>gy;
  gy=-gy;
  long double k=(gx-sx)/(gy-sy);
  long double ans=sx-k*sy;
  cout<<fixed<<setprecision(30)<<ans<<endl;
}


#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <bits/stdc++.h>
using namespace std;

#define lson 2*i
#define rson 2*i+1
#define LS l,mid,lson
#define RS mid+1,r,rson
#define UP(i,x,y) for(i=x;i<=y;i++)
#define DOWN(i,x,y) for(i=x;i>=y;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define W(a) while(a)
#define gcd(a,b) __gcd(a,b)
#define ll long long
#define MAX 1000005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define EXP 1e-8
#define lowbit(x) (x&-x)
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}

void prt(vector<ll> &A) {
    sort(A.begin(), A.end());
    cout << A.size() << ' '; for (int i = 0; i < A.size(); ++i) cout << A[i] << ' ';
    cout << endl;
}

int main () {
    int n, t; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i], a[i] %= 200;

    unordered_map<int, vector<ll>> pos;
    vector<ll> js, A, B;
    js.push_back(-1);
    bool flag = false;
    for (int i = 0; i < a.size(); ++i) {
        vector<ll> tmpJs = js;
        for (auto &j : js) {
            ll newJ = (max(j, 0ll) + a[i]) % 200;
            auto prev = pos[j];
            prev.push_back(i+1);
            if (pos[newJ].size() == 0)
                pos[newJ] = prev, tmpJs.push_back(newJ);
            else {
                A = pos[newJ], B = prev;
                flag = true;
                break;
            }
        }
        if (flag) break;
        js = tmpJs;
    }
    if (flag)
        cout << "Yes"<< endl, prt(A), prt(B);
    else
        cout << "No" << endl;
    return 0;
}

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

#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1

#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li x[111];
li y[111];

inline bool check(li i, li j, li k){
    li dx1 = x[j]-x[i];
    li dy1 = y[j]-y[i];
    li dx2 = x[k]-x[i];
    li dy2 = y[k]-y[i];
    return (dx1*dy2 == dx2*dy1);
}

int main() {
    cin>>n;
    rin{
        cin>>x[i]>>y[i];
    }
    rin{
        repp(j,i+1,n){
            repp(k,j+1,n){
                if(check(i,j,k)){
                    puts("Yes");
                    return 0;
                }
            }
        }
    }
    puts("No");

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main () {
	int n;
	string s;
	cin>>s;
	int f=0;
	for (int i=0;i<s.size();i++) {
		if (i%2==0&&s[i]>='a'&&s[i]<='z') continue;
		if (i%2==1&&s[i]>='A'&&s[i]<='Z') continue;
		f=1;
	}
	if (f)
		printf("No\n");
	else
		printf("Yes\n");
}

#include <bits/stdc++.h>
using namespace std;
int main(){
  int 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;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int n,m;
string s[15];
int sz;
bool not_front[10];
ll res=0;
vector<int> VV;

void cal(){
	vector<int> v=VV;
	do{
		bool ok=true;
		for(int i=0;i<m;i++){
			if(v[i]==0 and !not_front[i])ok=false;
		}
		if(!ok)continue;
		int k=0;
		for(int j=0;j<sz;j++){
			int sum=k/10;
			for(int i=0;i<n-1;i++){
				if((int)s[i].size()>j){
					sum+=v[s[i][j]-'A'];
				}
			}
			if(sum>0 and (int)(s[n-1].size())<=j){
				ok=false; break;
			}
			if(v[s[n-1][j]-'A']!=sum%10){
				ok=false; break;
			}
			k=sum;
		}
		if(ok and k/10==0){
			for(int i=0;i<n;i++){
				reverse(s[i].begin(), s[i].end());
				for(int j=0;j<s[i].size();j++){
					cout << v[s[i][j]-'A'];
				}
				cout << endl;
				// cout << s[i] << endl;
			}
			exit(0);
		}
	}while(next_permutation(v.begin(), v.end()));
}

void solve(int sz,int cur){
	if(sz==m){
		cal(); return;
	}
	if(cur==10)return;
	VV.push_back(cur);
	solve(sz+1,cur+1);
	VV.pop_back();
	solve(sz,cur+1);
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    n=3;
    vector<char> V;
	for(int i=0;i<n;i++){
		cin >> s[i];
		for(int j=0;j<s[i].size();j++){
			s[i][j]+=(+'A'-'a');
		}
		for(char c:s[i]){
			V.push_back(c);
		}
	}
	sort(V.begin(), V.end());
	V.erase(unique(V.begin(), V.end()),V.end());
	for(int i=0;i<n;i++){
		for(int j=0;j<s[i].size();j++){
			s[i][j]='A'+(lower_bound(V.begin(), V.end(),s[i][j])-V.begin());
		}
	}
	// leading-0対策
	m=V.size();
	for(int i=0;i<m;i++){
		not_front[i]=true;
	}
	sz=0;
	for(int i=0;i<n;i++){
		if((int)s[i].size())not_front[s[i][0]-'A']=false;
		reverse(s[i].begin(), s[i].end());
		sz=max(sz,(int)(s[i].size()));
	}
	// ここから　書く
	res=0;
	solve(0,0);
	cout << "UNSOLVABLE" << endl;
}

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

using namespace std;

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 +7; const ll INF = 1e18;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

//using mint = atcoder::modint998244353;

bool f(string s1, string s2, string s3){

	VI cv(128, -1); int ct=0;
	for(auto ch: (s1+s2+s3)) if(cv[ch]==-1) cv[ch] = ct++;
	if(ct>10){/*cerr<<s1+" "+s2+" "+s3+" over 11!!! \n";*/return false;}
	vector<VI> v(3);

	for(auto ch: s1) v[0].push_back(cv[ch]);
	for(auto ch: s2) v[1].push_back(cv[ch]);
	for(auto ch: s3) v[2].push_back(cv[ch]);

	//for(auto xl: v){for(auto x :xl) cerr<<x<<" ";dbg();}

	rep(msk, 1<<10){ // ncr(10, ct) * ct! <= 10!
		VI seq;
		if(__builtin_popcount(msk) != ct) continue;
		rep(i, 10) if(msk>>i &1) seq.push_back(i);
		//for(auto x :seq) cerr<<x<<" "; dbg();
		do {
			bool ok =1;
			VL nv(3);
			rep(i, 3){
				if(seq[v[i][0]]==0){ ok=0; break;} //先頭0 対策
				for(auto ch: v[i]) nv[i] = nv[i] *10 + seq[ch];
			}
			if(ok && nv[0] + nv[1] == nv[2]){
				cout << nv[0] <<"\n";
				cout << nv[1] <<"\n";
				cout << nv[2] <<"\n";
				//for(auto x :seq) cerr<<x<<" "; dbg("OK");
				return true;
				//if(sz(cnd) > 1) return false; //複数解 認めない場合
			}
		} while ( next_permutation(all(seq)) );
	}
	 return false;
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	vector<string> v(3);
	rep(i, 3) cin >>v[i];

	auto zz= f(v[0], v[1],v[2]);

	if(!zz) cout << "UNSOLVABLE"  <<"\n";
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;
#define int long long

signed main(){
	int N; cin >> N;
	vector<int> W(N);
	int S = 0;

	for (int i=0; i<N; i++){
		cin >> W[i];
		S += W[i];
	}

	if (S % 2 != 0){
		cout << 0;
	}
	else{
		int s_ = S/2; int n_ = N/2;

		vector<vector<int>> states;
		for (int i=0; i<n_+1; i++){
			vector<int> row(s_+1);
			states.push_back(row);
		}

		states[0][0] = 1;

		for (auto w: W){
			for (int y=n_; y>0; y--){
				for (int x=0; x<s_+1-w; x++){
					states[y][x+w] = (states[y][x+w] + states[y-1][x]) % 998244353;
				}
			}
		}

		vector<int> fact(1,1);
		for (int i=1; i<N+1; i++){
			fact.push_back( (fact[i-1] * i) % 998244353 );
		}

		int total = 0;
		for (int y=1; y<n_+1; y++){
			total = (total + (fact[y] * fact[N-y] % 998244353) * states[y][s_]) % 998244353;
		}

		total = (2 * total) % 998244353;

		if (N % 2 == 0){
			total = total - (fact[n_] * fact[n_] % 998244353) * states[n_][s_] % 998244353;
		}
		total = (total + 998244353) % 998244353;

		cout << total;
	}
}

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

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

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

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

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

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

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

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<fixed<<setprecision(20);
	int n; cin >> n;
	vi x(n), y(n);
	rep(i, n) cin >> x[i] >> y[i];

	int x_min1 = INF, x_min2 = INF, y_min1 = INF, y_min2 = INF;
	int x_max1 = 0, x_max2 = 0, y_max1 = 0, y_max2 = 0;
	int index_x_max1, index_x_min1, index_y_max1, index_y_min1;

	auto two_max = [&](int &max1, int &max2, int &index, vi &vec) -> void
	{
		rep(i, n)
		{
			if (max1 < vec[i])
			{
				max2 = max1;
				max1 = vec[i];
				index = i;
			}
			else if (max2 < vec[i])
			{
				max2 = vec[i];
			}
		}
	};
	two_max(x_max1, x_max2, index_x_max1, x);
	two_max(y_max1, y_max2, index_y_max1, y);

	auto two_min = [&](int &min1, int &min2, int &index, vi &vec) -> void
	{
		rep(i, n)
		{
			if (min1 > vec[i])
			{
				min2 = min1;
				min1 = vec[i];
				index = i;
			}
			else if (min2 > vec[i])
			{
				min2 = vec[i];
			}
		}
	};
	two_min(x_min1, x_min2, index_x_min1, x);
	two_min(y_min1, y_min2, index_y_min1, y);

	if (index_x_max1 == index_y_max1 && index_x_min1 == index_y_min1)
		cout << max(max(x_max1 - x_min2, x_max2 - x_min1), max(y_max1 - y_min2, y_max2 - y_min1)) << nl;
	else
	{
		vi ans;
		ans.pb(x_max1 - x_min1);
		ans.pb(y_max1 - y_min1);
		ans.pb(x_max1 - x_min2);
		ans.pb(y_max1 - y_min2);
		ans.pb(x_max2 - x_min1);
		ans.pb(y_max2 - y_min1);
		sort(allr(ans));
		cout << ans[1] << nl;
	}
}


#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
#define MOD 1000000007
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<lint, lint>;

lint modpow(lint a, lint n, lint m = MOD){
  lint ans = 1;
  while(n>0){
    if(n%2==1) ans *= a;
    ans %= m;
    a *= a;
    a %= m;
    n /= 2;
  }
  return ans;
}

lint inv(lint a, lint m = MOD){
  return modpow(a, m-2, m);
}

lint gcd(lint a, lint b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

//////////////////////
////////////////////
// cout << fixed << setprecision(12);

int main(){
  lint n; cin>>n;
  lint ans = 0;
  for(lint i=1; i<=n; i++){
    bool ok = true;
    lint tmp = i;
    while(tmp>0){
      if(tmp%10==7){
        ok = false;
        break;
      }
      tmp/=10;
    }
    lint tmp2 = i;
    while(tmp2>0){
      if(tmp2%8==7){
        // cout << i << endl;
        ok = false;
        break;
      }
      tmp2/=8;
    }
    if(ok){
      // cout << i << endl;
      ans++;
    }
  }
  cout << ans << endl;
}

#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <float.h>

using namespace std;
using ll = long long;

#define canDbg	0

#define dbg(x)	if(canDbg) cout << x << endl;
#define rep(n, e)	for(ll n = 0;n < e;n++)

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

	stringstream ss;

	int sum = 0;

	for (int n = 1; n <= N; n++)
	{
		string d = to_string(n);

		stringstream ss;
		ss << oct << n;

		string o = ss.str();

		//cout << "dec; " << d << endl;
		//cout << "oct; " << o << endl;

		if ((d.find('7') == string::npos) && (o.find('7') == string::npos))
		{
			sum++;
		}
	}

	cout << sum;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T,class U>
inline bool chmax(T &a,U b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
template<class T,class U>
inline bool chmin(T &a,U b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
constexpr int INF=1000000000;
constexpr ll llINF=3000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
/*
vector<vector<ll>>C,sC;
void init_comb(int n,int m){
    C.resize(n+1,vector<ll>(m+1,0));
    sC.resize(n+1,vector<ll>(m+1,0));
    C[0][0]=1;
    for(int i=1;i<=n;i++){
        C[i][0]=1;
        for(int j=1;j<=m;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    rep(i,n+1){
        rep(j,m){
            sC[i][j+1]=(sC[i][j]+C[i][j])%mod;
        }
    }
}*/
ll gcd(ll a,ll b){
    while(a%b){
        a%=b;
        swap(a,b);
    }
    return b;
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
bool isprime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>primes;
void init_prime(int n){
	primes.push_back(2);
    for(int i=3;i<=n;i+=2){
        bool f=true;
        for(int j:primes){
            if(j*j>i)break;
            if(i%j==0){
                f=false;
                break;
            }
        }
        if(f)primes.push_back(i);
    }
}
ll modpow(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1){
            res*=a;
            res%=mod;
        }
        a*=a;
        a%=mod;
        b>>=1;
    }
    return res;
}
vector<ll>inv,fact,factinv;
void init_fact(int n){
    inv.resize(n+1);
    fact.resize(n+1);
    factinv.resize(n+1);
    inv[0]=0;
    inv[1]=1;
    fact[0]=1;
    factinv[0]=1;
    for(ll i=1;i<=n;i++){
        if(i>=2)inv[i]=mod-((mod/i)*inv[mod%i]%mod);
        fact[i]=(fact[i-1]*i)%mod;
        factinv[i]=factinv[i-1]*inv[i]%mod;
    }
}
ll _inv(ll a,ll m=mod){
    //gcd(a,m) must be 1
    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;
}
ll comb(int a,int b){
    if(a<b)return 0;
    if(a<0)return 0;
    return fact[a]*factinv[a-b]%mod*factinv[b]%mod;
}
ll multicomb(int a,int b){
    return comb(a+b-1,b);
}
int n,m;
vector<int>g[1010][26];
int dp[1010][1010];
#define P pair<int,int>
#define PP pair<int,P>
void solve(){
    cin>>n>>m;
    priority_queue<PP,vector<PP>,greater<PP>>q;
    rep(i,n)rep(j,n)dp[i][j]=INF;
    rep(i,n){
        dp[i][i]=0;
        q.push({0,{i,i}});
    }
    rep(i,m){
        int a,b;
        char c;
        cin>>a>>b>>c;
        a--,b--;
        g[a][c-'a'].push_back(b);
        g[b][c-'a'].push_back(a);
        if(a!=b){
            dp[a][b]=dp[b][a]=1;
            q.push({1,{a,b}});
            q.push({1,{b,a}});
        }
    }
    while(!q.empty()){
        PP p=q.top();
        q.pop();
        int l=p.second.first,r=p.second.second;
        if(dp[l][r]!=p.first)continue;
        rep(k,26){
            for(int a:g[l][k]){
                for(int b:g[r][k]){
                    if(chmin(dp[a][b],p.first+2)){
                        q.push({dp[a][b],{a,b}});
                    }
                }
            }
        }
    }
    cout<<(dp[0][n-1]==INF?-1:dp[0][n-1])<<endl;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int kmax = 1003;

struct Node {
  int x, y;
} q[kmax * kmax];

struct O {
  int to;
  char c;
} o[kmax];

int ans = 1e9;
bool l[kmax][kmax];
int n, m, d[kmax][kmax], h = 1, t;
vector<O> p[kmax];
char c;

void E(int x, int y, int z) {
  if (d[x][y]) {
    return;
  }
  d[x][y] = d[y][x] = z;
  q[++t] = {x, y};
  if (x == y) {
    ans = min(ans, z);
  } else if (l[x][y]) {
    ans = min(ans, z + 1);
  }
}

int main() {
  cin >> n >> m;
  for (int i = 1, x, y; i <= m; i++) {
    cin >> x >> y >> c;
    p[x].push_back({y, c});
    p[y].push_back({x, c});
    l[x][y] = l[y][x] = 1;
  }
  for (E(1, n, 1); h <= t; h++) {
    for (int i = 0; i < p[q[h].x].size(); i++) {
      for (int j = 0; j < p[q[h].y].size(); j++) {
        if (p[q[h].x][i].c == p[q[h].y][j].c) {
          E(p[q[h].x][i].to, p[q[h].y][j].to, d[q[h].x][q[h].y] + 2);
        }
      }
    }
  }
  cout << (ans == 1e9 ? -1 : ans - 1);
  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
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;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  double ans = 0;
  for (int i = 1; i < N; i++) {
    ans += (double)N / i;
  }
  printf("%.10f\n", ans);
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

int main() {
    init();

    int n, m; cin >> n >> m;
    VL h(n), w(m); cin >> h >> w;
    SORT(h);

    VL l(n), r(n);
    for (int i = 0; i + 1 < n; i += 2)l[i] = h[i + 1] - h[i];
    for (int i = n - 1; 0 <= i - 1; i -= 2)r[i] = h[i] - h[i - 1];
    FOR(i, 1, n)l[i] += l[i - 1];
    rFOR(i, 0, n - 1)r[i] += r[i + 1];

    ll ans = LLINF;
    FOR(j, 0, m) {
        int i = lower_bound(all(h), w[j]) - h.begin();
        ll res = 0;
        if (i & 1) {
            res = (0 <= i - 2 ? l[i - 2] : 0) + w[j] - h[i - 1] + (i < n ? r[i] : 0);
        }
        else {
            res = (0 <= i - 1 ? l[i - 1] : 0) + h[i] - w[j] + (i + 1 < n ? r[i + 1] : 0);
        }
        chmin(ans, res);
    }
    print(ans);

    return 0;
}


#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc
#define next          sdNNNmNNNNNNNmds
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot
#define read               tyhyt
#define rank              ytmNmo
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

const int N = 1111;
int a[N], b[N];
int n;

int solve() {
    cin >> n;
    rep(i, 1, n) {
        cin >> a[i] >> b[i];
    }
    int ans = 1e9;
    rep(i, 1, n) {
        rep(j, 1, n) {
            int cur = i == j ? a[i] + b[j] : max(a[i], b[j]);
            ans = min(ans, cur);
        }
    }
    cout << ans << endl;
    return 0;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}

//
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;

int main ()
{
    ios_base::sync_with_stdio (0); cin.tie (0); cout.tie (0);
    ll n, m, q;
    cin >> n >> m >> q;
    pair<ll, ll> a[n], b[m];
    for (auto& x : a) cin >> x.S >> x.F;
    for (ll i = 0; i < m; ++i)
    {
        cin >> b[i].F;
        b[i].S = i + 1;
    }
    sort (a, a + n, greater<pair<ll, ll>> ());
    sort (b, b + m);
    while (q--)
    {
        ll l, r, v = 0;
        cin >> l >> r;
        unordered_set<ll> s;
        for (ll i = 0; i < n; ++i)
        {
            for (ll j = 0; j < m; ++j)
            {
                if (s.count (b[j].S) || (b[j].S >= l && b[j].S <= r)) continue;
                if (b[j].F >= a[i].S)
                {
                    v += a[i].F;
                    s.insert (b[j].S);
                    break;
                }
            }
        }
        cout << v << "\n";
    }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forin(in) for(ll i=0; i<(ll)in.size(); i++) cin>>in[i]
#define forout(out) for(ll i=0; i<(ll)out.size(); i++) cout<<out[i]<<" "
#define rep(i, n) for(ll i=0; i<(n); i++)
#define rep_up(i, a, n) for (ll i = a; i < n; ++i)
#define rep_down(i, a, n) for (ll i = a; i >= n; --i)
#define P pair<ll, ll>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define vvvll vector<vector<vector<ll>>>
#define vvll vector<vector<ll>>
#define vll vector<ll>
#define pqll priority_queue<ll>
#define pqllg priority_queue<ll, vector<ll>, greater<ll>>
constexpr ll INF = (1ll << 60);
constexpr ll mod = 1000000007;

int main() {
	long double R, X, Y; cin >> R >> X >> Y;
	long double d = sqrt(X*X+Y*Y);
	if(d == R) cout << 1 << endl;
	else if(d <= 2*R) cout << 2 << endl;
	else cout << ceil(d/R) << endl;
}

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

int main(){
  double r,x,y;
  ll hosu = 0;
  cin >> r >> x >> y;
  if(sqrt(x * x + y * y) / r < 1){
    hosu = 2;
  }
  else{
    hosu = ceil(sqrt(x * x + y * y) / r);
  }
  cout << hosu;
}


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

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

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    ll ans = 0;
    REP(i, 0, n) {
        ll a, b;
        cin, a, b;
        ans += b * (b + 1) / 2 - a * (a - 1) / 2;
    }
    print(ans);
    return 0;
}

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

typedef long long ll;
typedef const int ci;
typedef vector<int> vi;
typedef pair<ll, ll> pll;

#define INF (2e12)
#define fori(i, s, e) for(int i = s; i < ((int)e); ++i)
#define forj(i, s, e) for(int i = s; i >= ((int)e); --i)
#define all(s) (s).begin(), (s).end()
#define sz(s) ((int)s.size())

template <class T> void minify(T &a, const T &b) {if(a > b) a = b;}
template <class T> void maxify(T &a, const T &b) {if(a < b) a = b;}
void python() {ios_base::sync_with_stdio(false); cin.tie(0);}

// Code...

void solve() {
    ll n;
    ll sum = 0;
    cin >> n;
    fori(i, 0, n) {
        ll a, b;
        cin >> a >> b;
        sum += (a + b)*(b - a + 1)/2;
    }
    cout << sum << endl;
}

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


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

namespace mymtx{
  const int dim = 3;
  template<class T> array<array<T,dim>,dim> mult(array<array<T,dim>,dim> a, array<array<T,dim>,dim> b){
    array<array<T,dim>,dim> ret{};
    for(int i=0;i<dim;i++) for(int j=0;j<dim;j++) for(int k=0;k<dim;k++)
      ret[i][j] += a[i][k]*b[k][j];
    return ret;
  }
  template<class T> array<T,dim> mult(array<array<T,dim>,dim> a, array<T,dim> b){
    array<T,dim> ret{};
    for(int i=0;i<dim;i++) for(int k=0;k<dim;k++)
      ret[i] += a[i][k]*b[k];
    return ret;
  }
}

int main(){

  std::cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int64_t n; cin >> n;
  vector<array<int64_t,3>> x(n);
  for(int64_t i=0;i<n;i++){
    cin >> x[i][0] >> x[i][1];
    x[i][2] = 1;
  }

  int64_t m; cin >> m;
  vector<array<array<int64_t,3>,3>> mtx(m+1);
  mtx[0] = {{ {1,0,0}, {0,1,0}, {0,0,1} }};
  for(int64_t i=1;i<=m;i++){
    int64_t op[2]={0,0};
    cin >> op[0];
    array<array<int64_t,3>,3> tmp{{ {0,0,0},{0,0,0},{0,0,1} }};
    if(op[0]==1){
      tmp[0][1]=1; tmp[1][0]=-1;
    }else if(op[0]==2){
      tmp[0][1]=-1; tmp[1][0]=1;
    }else if(op[0]==3){
      cin >> op[1];
      tmp[0][0]=-1; tmp[0][2]=2*op[1]; tmp[1][1]=1;
    }else if(op[0]==4){
      cin >> op[1];
      tmp[0][0]=1; tmp[1][1]=-1; tmp[1][2]=2*op[1];
    }
    mtx[i] = mymtx::mult( tmp ,mtx[i-1]);
  }

  int64_t q; cin >> q;
  array<int64_t,3> ans{0,0,0};
  for(int64_t i=0,a,b;i<q;i++){
    cin >> a >> b;
    ans = mymtx::mult(mtx[a],x[b-1]);
    cout << ans[0] << " " << ans[1] << "\n";
  }

  return 0;
}

//yukicoder@cpp14
//coder:luckYrat(twitter:@luckYrat_)
//競技プログラミングから逃げるな
//https://www.youtube.com/watch?v=z_B9iJ8r4ic

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>

//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define mkp make_pair
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {mkp(0,1),mkp(0,-1),mkp(1,0),mkp(-1,0)};
P ar8[8] = {mkp(-1,-1),mkp(-1,0),mkp(-1,1),mkp(0,-1),mkp(0,1),mkp(1,-1),mkp(1,0),mkp(1,1)};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
int pc[100001];
int neko[100001];
bool lck[100001];
vector<int> ed[100001];
vector<int> ans;

struct dta{
  int n,ss[100001];
};
void dfs(int n,int* ss){
  for(int i = 0; ed[n].size() > i; i++){
    if(!lck[ed[n][i]]){
      //cout << ed[n][i] << endl;
      lck[ed[n][i]] = true;
      if(!ss[pc[ed[n][i]]]){
        ans.push_back(ed[n][i]);
      }
      ss[pc[ed[n][i]]]++;
      dfs(ed[n][i],ss);
      ss[pc[ed[n][i]]]--;
    }
  }
}
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int n;cin>>n;
  for(int i = 0; n > i; i++){
    cin>>pc[i];
  }
  for(int i = 0; n-1 > i; i++){
    int a,b;cin>>a>>b;a--;b--;
    ed[a].push_back(b);
    ed[b].push_back(a);
  }
  ans.push_back(0);
  neko[pc[0]]++;
  lck[0] = true;
  dfs(0,neko);
  sort(ans.begin(),ans.end());
  for(int i = 0; ans.size() > i; i++){
    cout << ans[i]+1 << endl;
  }
  return 0;
}


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

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

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

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

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

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

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

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

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

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

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

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

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

void debug_out() { cerr << endl; }

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

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

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

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

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

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

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

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

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

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

	}
	debug(camino);

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

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define eb emplace_back
#define mp make_pair
typedef pair<int,int> pii;
#define f first
#define s second

#define min(a,b) ((a<b)?a:b)

//const int mod=1000000007;
bool debug=0;

vector<int> adjl[200005];

int dis[200005],prevv[200005];
pii fur;
void furth(int node,int prev=-1){
  prevv[node]=prev;
  fur=max(fur,mp(dis[node],node));
  //if(debug)cout<<dis[node]<<' '<<node<<"kool\n";
  for(int x:adjl[node]){
    if(x==prev)continue;
    dis[x]=dis[node]+1;
    furth(x,node);
  }
}

bool mark[200005];
int num[200005],cur=1;
void dfs(int node,int prev=-1){
  //if(debug)cout<<"search "<<node<<'\n';
  num[node]=cur++;
  for(int x:adjl[node]){
    if(x==prev)continue;
    if(mark[x])continue;
    dfs(x,node);
  }
  if(mark[node])
    for(int x:adjl[node]){
      if(x==prev)continue;
      if(mark[x]){
        dfs(x,node);break;
      }
    }
  cur++;
}

int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int n,a,b;
  cin>>n;
  for(int i=1;i<n;i++){
    cin>>a>>b;
    adjl[a].push_back(b);
    adjl[b].push_back(a);
  }
  fur=mp(-1,-1);
  dis[1]=1;furth(1);
  a=fur.s;

  fur=mp(-1,-1);
  dis[a]=1;furth(a);
  b=fur.s;
  do{
    mark[b]=true;
    b=prevv[b];
  }while(b!=-1);
  //fur.f=-1;
  //dis[fur.s]=1;furth(fur.s);
  if(debug)cout<<"ENDPoint "<<fur.s<<'\n';
  dfs(a);//one end of diameter...

  for(int i=1;i<=n;i++){
    cout<<num[i];
    if(i<n)cout<<' ';
    else cout<<'\n';
  }
  return 0;
}
/*

*/


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

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

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

  vector<ll> sum1, sum2;
  ll sum;
  for (ll bit = ((ll)1 << (n / 2)) - 1; bit >= 0; bit--) {
    sum = 0;
    for (int i = 0; bit >> i; i++) {
      sum += a[i] * ((bit >> i) & 1);
      if (sum > t) break;
    }
    if (sum == t) {
      cout << t;
      return 0;
    } else if (sum <= t) sum1.push_back(sum);
  }
  for (ll bit = ((ll)1 << (n - n / 2)) - 1; bit >= 0; bit--) {
    sum = 0;
    for (int i = 0; bit >> i; i++) {
      sum += a[i + n / 2] * ((bit >> i) & 1);
      if (sum > t) break;
    }
    if (sum == t) {
      cout << t;
      return 0;
    } else if (sum <= t) sum2.push_back(sum);
  }
  sort(sum1.begin(), sum1.end());
  sort(sum2.begin(), sum2.end());

  ll dif, ans = 0;
  auto itr = sum2.end();
  for (auto s : sum1) {
    dif = t - s;
    itr = upper_bound(sum2.begin(), itr, dif);
    if (itr == sum2.begin() && ans < s) ans = s;
    else if (itr != sum2.begin() && ans < s + *(itr - 1)) ans = s + *(itr - 1);
  }
  cout << ans;
}

#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define vi vector<int>
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size()
#define PI 3.14159265358979323846

const int N =2e5+10;

int mod= 1e9+7;
int dx[4]={0,0,+1,-1};
int dy[4]={+1,-1,0,0};

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

set<int> cal(vi a) {
   set<int> st;

   int n=sz(a);
   for(int i=0;i<(1<<n);i++) {
   	 int sm=0;
      for(int j=0;j<n;j++) {
      	 if(i&(1<<j)) {
      	 	 sm+=a[j];
      	 }
      }
      st.insert(sm);
   }
   return st;
}

void solve(){
  int n,k;
  cin>>n>>k;
  vi a(n,0);
  rep(i,0,n) cin>>a[i];

  int dn=n/2;
  vi b,c;
  rep(i,0,dn) {
  	 b.pb(a[i]);
  }

  rep(i,dn,n) {
  	 c.pb(a[i]);
  }

  set<int> x=cal(b);
  set<int> y=cal(c);

  int ans=k;

  for(auto to:x) {
  	 auto  it=y.ub(k-to);
  	 if(it==y.begin()) continue;
  	 it--;
  	 int mn=k-to-*it;
  	 if(mn<ans) ans=mn;
  }

  cout<<k-ans<<endl;

}

int32_t main() {
cool;
int t=1;
	 // cin>>t;

while(t--)
   solve();

   return 0;
}


//#include <bits/stdc++.h>
#include <queue>
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#define F(i, a, b) for(register int i = a, i##end = b; i <= i##end; i++)
#define UF(i, a, b) for(register int i = a, i##end = b; i >= i##end; i--)
#define ll long long
using namespace std;
inline int read()
{
    int x = 0;
    bool fu = 0;
    char ch = 0;
    while(ch > '9' || ch < '0')
    {
        ch = getchar();
        if(ch == '-')
            fu = 1;
    }
    while(ch <= '9' && ch >= '0')
        x = (x * 10 - 48 + ch), ch = getchar();
    return fu ? -x : x;
}
int main()
{
    int ans = read();
    ans = min(ans, read());
    ans = min(ans, read());
    ans = min(ans, read());
    cout << ans;
    getchar();
    return 0;
}

//#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <ctime>
#include <cassert>
#include <complex>
#include <cstring>
#include <chrono>
#include <random>

#define  pb          push_back
#define  f           first
#define  s           second
#define  pi          acos(-1.0)
#define  LCM(a,b)    a*b/__gcd(a,b)
#define  GCD(a,b)    __gcd(a,b)
#define  mod         1000000007
#define  test        int t; cin>>t; while(t--)
#define  sof         sizeof
#define  endl        '\n'

typedef long long ll;
using namespace std;

/*
          Run, Rabbit run
          Dig that hole, forget the sun
          And when at last the work is done
          Don't sit down,
          it's time to dig another one
          _Breathe(Pink Floyd)
*/

int main()
{

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

         int a,b,c,d;
         cin>>a>>b>>c>>d;
         cout<<min(min(a,b),min(c,d));

     return 0;

}


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

int main() {
	int a,b,c,d,ans;

	cin>>a>>b>>c>>d;
	ans = max(a-c, max(a-d, max(b-c, b-d)));
	cout<<ans;
	return 0;
}

#include<bits/stdc++.h>
#define int long long
#define REP(i,a,n) for(int i=a;i<(n);i++)
#define REP_sz(i,s) for(int i=0;i<s.size();i++)
#define gcd(a,b) __gcd(a,b)
#define RE return
#define FILL(a,b) memset(a,b,sizeof(a))
#define SO(a) sort(all(a))
#define all(a) a.begin(),a.end()
#define pb push_back
#define sz(a) a.size()
#define V vector
#define ld long double
#define viit(a) vector<int>::iterator a
#define IT iterator
#define SET setprecision
#define FOR(i,a,n) for(int i=a;i<=(n);i++)
#define ER1(a) a.erase(a.begin())
#define ER0(a) a.erase(a.end())
#define pii pair<int,int>
#define pause system("PAUSE")
#define cls system("CLS")
#define mod1 1000000007
#define mod2 998244353
#define infmod 9223372036854775783
using namespace std;
int n;
int a[200005],b[200005],ma[200005],c[200005];
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
	cin>>n;
	REP(i,0,n)
	cin>>a[i];
	REP(i,0,n)
	cin>>b[i];
	ma[0]=a[0];
	REP(i,1,n)ma[i]=max(a[i],ma[i-1]);
	c[0]=a[0]*b[0];
	REP(i,1,n)c[i]=max(c[i-1],b[i]*ma[i]);
	REP(i,0,n)cout<<c[i]<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e8;
int n,m,res=0,cnt=0,tot=0;
int b[300005];
ll pp[300005],qq[300005];
int h[300005],to[600005],ver[600005];
inline int read() {
	register int x=0,f=1;register char s=getchar();
	while(s>'9'||s<'0') {if(s=='-') f=-1;s=getchar();}
	while(s>='0'&&s<='9') {x=x*10+s-'0';s=getchar();}
	return x*f;
}
inline void add(int x,int y) {
	to[++cnt]=y;
	ver[cnt]=h[x];
	h[x]=cnt;
}
void work(int x,int fa,int mid) {
	pp[x]=-INF;qq[x]=INF;
	for(register int i=h[x];i;i=ver[i]) {
		int y=to[i];
		if(y==fa) continue;
		work(y,x,mid);
		pp[x]=max(pp[x],pp[y]+1);
		qq[x]=min(qq[x],qq[y]+1);
	}
	if(pp[x]+qq[x]<=mid) pp[x]=-INF;
	if(qq[x]>mid&&b[x]==1) pp[x]=max(pp[x],(long long)0);
	if(pp[x]==mid) pp[x]=-INF,qq[x]=0,++tot;
}
int check(int x)
{
	tot=0;
	work(1,-1,x);
	if(pp[1]>=0) ++tot;
	return tot<=m;
}
int main()
{
	n=read(),m=read();
	for(register int i=1;i<=n;++i) b[i]=1;
	for(register int i=1;i<n;++i)
	{
		int x=read(),y=read();
		add(x,y);add(y,x);
	}
	int L=0,R=n;
	while(L<=R) {
		int mid=L+R>>1;
		if(check(mid)) R=mid-1,res=mid;
		else L=mid+1;
	}
	printf("%d\n",res);
	return 0;
}

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

const int N=10,M=100005;

struct Node {
	int L,V;
	bool operator <(const Node& b) const {
		return L==b.L ? V<b.V : L<b.L;
	}
	bool operator <(const int& b) const {
		return V<b;
	}
}b[M];

int n,m;
int Max;
int c[N];
int p[N];
int f[N];
int Maxx[M];
int sum[N];
int ans=0x7f7f7f7f;

inline int rd()
{
	char ch=getchar();
	int x=0,f=1;
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int main()
{
	scanf("%d%d",&n,&m);
	for(Re int i=1;i<=n;i++)
	{
		c[i]=rd();
		p[i]=i;
		Max=max(Max,c[i]);
	}
	for(Re int i=1;i<=m;i++)
	{
		b[i].L=rd();
		b[i].V=rd();
		if(Max>b[i].V)
		{
			printf("-1");
			return 0;
		}
	}
	sort(b+1,b+m+1);
	for(Re int i=m-1;i>0;i--)
	{
		b[i].V=min(b[i].V,b[i+1].V);
	}
	do
	{
		memset(f,0,sizeof f);
		for(Re int i=1;i<=n;i++)
		{
			sum[i]=sum[i-1]+c[p[i]];
		}
		for(Re int i=2;i<=n;i++)
		{
			f[i]=f[i-1];
			for(Re int j=1;j<i;j++)
			{
				int x=lower_bound(b+1,b+m+1,sum[i]-sum[j-1])-b-1;
				f[i]=max(f[i],f[j]+b[x].L);
			}
		}
		ans=min(ans,f[n]);
	}while(next_permutation(p+1,p+n+1));
	printf("%d",ans);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define INF 1111111111111111
typedef long long ll;
struct gogo
{
    ll to,nt,st;
};
ll n,m,x,y,a,b,t,k,d[101010];
vector<gogo> vec[101010];
void bfs()
{
    queue<ll>que;
    que.push(x);
    while(!que.empty())
    {
        int from=que.front();
        que.pop();
        for(ll i=0; i<vec[from].size(); i++)
        {
            ll to=vec[from][i].to;

            {
                if(d[to]>((d[from]-1+vec[from][i].st)/vec[from][i].st)*vec[from][i].st+vec[from][i].nt)
                {
                    d[to]=((d[from]-1+vec[from][i].st)/vec[from][i].st)*vec[from][i].st+vec[from][i].nt;
                    if(to!=y)que.push(to);
                }
            }
            /*else
            {
                if(d[to]>d[from]+vec[from][i].nt)
                {
                    d[to]=d[from]+vec[from][i].nt;
                }
            }*/
        }
    }
}
int main()
{
    scanf("%lld%lld%lld%lld",&n,&m,&x,&y);
    for(ll i=0; i<m; i++)
    {
        scanf("%lld%lld%lld%lld",&a,&b,&t,&k);
        gogo gogo1,gogo2;
        gogo1.to=b;
        gogo1.nt=t;
        gogo1.st=k;
        gogo2.to=a;
        gogo2.nt=t;
        gogo2.st=k;
        vec[a].push_back(gogo1);
        vec[b].push_back(gogo2);
    }
    for(ll i=0; i<=n; i++)d[i]=INF;
    d[x]=0;
    bfs();
    //for(ll i=0;i<=4;i++)printf("%lld\n",d[i]);
    if(d[y]!=INF)printf("%lld",d[y]);
    else printf("-1");
    return 0;
}

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

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

    const li n = 4;
    vector<li> xs(n);
    for (int i = 0; i < n; ++i) {
        cin >> xs[i];
    }
    const li sum = accumulate(xs.begin(), xs.end(), 0LL);
    bool ok = false;
    for (int mask = 0; mask < 1 << n; ++mask) {
        li subsum = 0;
        for (int i = 0; i < n; ++i) {
            if ((mask >> i) & 1) {
                subsum += xs[i];
            }
        }
        ok |= subsum == sum - subsum;
    }
    cout << (ok ? "Yes" : "No") << endl;
    return 0;
}


#include <iostream>
using namespace std;

int main() {
	int v, t, s, d; cin >> v >> t >> s >> d;
	cout << (d <= (s * v) && d >= (t * v) ? "No" : "Yes") << '\n';
	cin.ignore(2); return 0;
}

//Code Written by Pinaki Bhattacharjee
#include<bits/stdc++.h>
using namespace std;

// typedef
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

// #define
#define LOCAL
#define INF 1e18
#define MAX 10000
#define PI 2*acos(0.0)
#define endl "\n"
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define set_bits __builtin_popcountll
#define DEBUG(x) cerr << #x << " = " << x << endl;
#define pinakipb2 ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// constants
const int MOD = (int) 1e9 + 7;

// debugger
#ifdef LOCAL
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
    #define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

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

#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x<<" "; _print(x); cerr << endl;
#else
    #define debug(x);
#endif

void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(ld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}

template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.first); cerr << ","; _print(p.second); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

void google(int t) {cout << "Case #" << t << ": ";}
ll mod_add(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}
ll mod_sub(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}

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

int main()
{
    pinakipb2;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
    // Code begins

    ll v,t,s,d;
    cin>>v>>t>>s>>d;
    ld hit = d/double(v);
    if(hit<t || hit>s)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    // Code ends
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}void __print(long x) {cout << x;}void __print(long long x) {cout << x;}void __print(unsigned x) {cout << x;}void __print(unsigned long x) {cout << x;}void __print(unsigned long long x) {cout << x;}void __print(float x) {cout << x;}void __print(double x) {cout << x;}void __print(long double x) {cout << x;}void __print(char x) {cout << '\'' << x << '\'';}void __print(const char *x) {cout << '\"' << x << '\"';}void __print(const string &x) {cout << '\"' << x << '\"';}void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define loop(i,a,b)     for (ll i=a;i<=(ll)b;i++)
#define rloop(i,a,b)    for (ll i=a;i>=(ll)b;i--)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           ((a)*(a))
#define sz(a)           a.size()
#define mod             1000000007
#define PI              (2*acos(0.0))

int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
      ll n;
      cin>>n;
      ll a[n],b[n];
      ll mx=0;
      loop(i,0,n-1)
      {
        cin>>a[i];
        mx=max(mx,a[i]);
        a[i]=mx;
      }
      mx=0;
      loop(i,0,n-1)
      {
        cin>>b[i];
        mx=max(mx,b[i]*a[i]);
        cout<<mx;
        nl;
      }
    }
    return 0;
}

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,tune=native")
#include <bits/stdc++.h>

using namespace std;

#define all(v) (v).begin(), (v).end()
#define sz(a) ((long long)(a).size())
#define X first
#define Y second

using ll = long long;
using ull = unsigned long long;
using dbl = long double;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll mod) {
    return (ull)rng() % mod;
}

const string atcoder = "atcoder";
string s;

void solve() {
    cin >> s;
    int i = 0;
    while (i < sz(s) && s[i] == 'a') {
        ++i;
    }
    if (i == sz(s)) {
        cout << "-1\n";
        return;
    }
    if (s > atcoder) {
        cout << "0\n";
        return;
    }
    if (i == 0) {
        assert(false);
        cout << "0\n";
        return;
    }
    if (s[i] > 't') {
        cout << i - 1 << "\n";
        return;
    }
    cout << i << "\n";
}

signed main() {
#ifdef LOCAL
    assert(freopen("input.txt", "r", stdin));
    // assert(freopen("output.txt", "w", stdout));
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(20);

    int T = 1;
    cin >> T;
    for (int numt = 0; numt < T; ++numt) {
        solve();
    }

#ifdef LOCAL
    cout << endl << endl << "time = " << clock() / (double)CLOCKS_PER_SEC << endl;
#endif
}


#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int n,m,num[105][105],ans=0;
char s[105][105];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]);
		for(int j=1;j<=m;j++)
		{
			if(s[i][j-1]=='#')continue;
			if(i>1&&s[i][j-1]==s[i-1][j-1])ans++;
			if(j>1&&s[i][j-1]==s[i][j-2])ans++;
		}

	}
	printf("%d",ans);
	return 0;
}

#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

ll dp[101][101];

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

	ll N, X;
	cin >> N >> X;
	int A[100];
	rep(i, N) cin >> A[i];

	ll kotae = 2e18;
	ll b = 0;
	rep1(s, N) {
		b += 2000000000;
		ll amari = X % s;
		dp[0][0] = b;
		rep(i, N) {
			ce(i);
			for (int j = min(i, s - 1); j >= 0; j--) {
				int t0 = A[i] % s;
				int t = t0;
				rep(k, s - t0) {
					if (dp[j][k] >= b) chmax(dp[j + 1][t], dp[j][k] + A[i]);
					t++;
				}
				t -= s;
				for (int k = s - t0; k < s; k++) {
					if (dp[j][k] >= b) chmax(dp[j + 1][t], dp[j][k] + A[i]);
					t++;
				}
			}
		}
		if (dp[s][amari] >= b) {
			chmin(kotae, (X - dp[s][amari] + b) / s);
		}
	}
	co(kotae);

	Would you please return 0;
}