#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
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;}

const int L=3e5;

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

  int N;
  ll W;
  cin>>N>>W;
  vector<int> S(N),T(N);
  vector<ll> P(N);
  rep(i,N) cin>>S[i]>>T[i]>>P[i];

  vector<ll> imos(L+10,0);
  rep(i,N){
    imos[S[i]]+=P[i];
    imos[T[i]]-=P[i];
  }

  rep(i,L) imos[i+1]+=imos[i];

  ll ma=*max_element(all(imos));
  if(ma<=W) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007

using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))

int main(){
    ll ans,a,b,c,d;
    cin>>a>>b>>c>>d;
    if(d*c-b>0){
        ans=a/(d*c-b)+((a%(d*c-b)!=0)?(1):(0));
    }else if(d*c-b==0 && a==0){
        ans=0;
    }else{
        ans=-1;
    }

    cout <<ans<<endl;

    return 0;

}


#line 1 "Contests/AtCoder_abc200/abc200_b/main.cpp"
using namespace std;
#line 2 "library/bits/stdc++.h"

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#line 3 "Contests/AtCoder_abc200/abc200_b/main.cpp"

#define ll long long

void solve(){
    // write your solution here.
}

int main() {
    ll N;
    int K;
    cin >> N >> K;
    for(int i=0; i<K; i++){
        if(N%200==0)    N/=200;
        else{
            N=N*1000+200;
        }
    }
    cout << N << endl;
    return 0;
}

#include <iostream>
#include <string>
#define mod 3
using namespace std;
int n;
string s;
int dp[400000] = { 0 };
int f[400000] = { 0 };
int g[400000] = { 0 };
void compute()
{
    dp[0] = 1;
    f[0] = 0;
    g[0] = 1;
    for (int i = 1; i < n; ++i) {
        f[i] += f[i - 1];
        int j = i;
        while (j % mod == 0) {
            f[i]++;
            j /= mod;
        }
        g[i] = (g[i - 1] * j) % mod;
    }
    for (int i = 1; i < n; ++i) {
        if (f[n - 1] > f[i] + f[n - 1 - i]) {
            dp[i] = 0;
        } else {
            dp[i] = g[n - 1] * g[n - 1 - i] * g[i];
            dp[i] %= mod;
        }
    }
}
int convert(char c)
{
    if (c == 'B')
        return 0;
    if (c == 'R')
        return 1;
    if (c == 'W')
        return 2;
}
char revert(int num)
{
    if (num == 0)
        return 'B';
    if (num == 1)
        return 'R';
    if (num == 2)
        return 'W';
}
int main()
{
    cin >> n >> s;
    compute();
    int res = 0;
    for (int i = 0; i < n; ++i) {
        res += dp[i] * (convert(s[i])) % mod;
    }
    if ((n - 1) % 2) {
        res = -res;
    }
    res = ((res % mod) + mod) % mod;
    cout << revert(res) << endl;
}


#include <bits/stdc++.h>
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;
const double PI = acos(-1.0);

int main() {
	int H, W;
	cin >> H >> W;

	vector<string> mass(H);
	int top, bottom;
	top = -1, bottom = -1;
	for (int i = 0; i < H; i++) {
		cin >> mass[i];
		//cout << mass[i] << endl;
		if (mass[i].find('#') != string::npos) {
			if (top == -1) top = i;
			bottom = i;
		}
	}
	//cout << top << ' ' << bottom << endl;

	int n = 0;
	for (int i = 0; i < H - 1; i++) {
		for (int j = 0; j < W - 1; j++) {
			int cnt = 0;
			if (mass[i][j] == '#') cnt++;
			if (mass[i][j+1] == '#') cnt++;
			if (mass[i+1][j] == '#') cnt++;
			if (mass[i+1][j+1] == '#') cnt++;
			if (cnt % 2) n++;
		}
	}
	cout << n << endl;
}

//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <set>
#include <ctime>
// #include<windows.h>
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int n, m, a[100005], b[100005], to[100005], lst, ans, v;
bool sid[100005];
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1; i <= n; ++i)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i)
    {
        cin >> b[i];
    }
    a[n + 1] = m + 1;
    a[n + 2] = INF;
    for (int i = 1; i <= n; ++i)
    {
        while (a[lst + 1] + (i - lst - 1) <= b[i] && a[lst] + (i - lst) != b[i])
        {
            ++lst;
        }
        while (a[lst + 1] + (i - lst - 1) == b[i] && abs(lst + 1 - i) < abs(lst - i))
        {
            ++lst;
        }
        to[i] = lst;
        if (a[lst] + (i - lst) != b[i])
        {
            cout << -1 << endl;
            return 0;
        }
    }
    to[0] = -1;
    for (int i = 1; i <= n; ++i)
    {
        if (to[i] < i)
        {
            sid[i] = true;
        }
    }
    for (int i = 1; i <= n; ++i)
    {
        if (to[i] == to[i - 1] && sid[i] == sid[i - 1])
        {
            v = max(v, abs(i - to[i]));
        }
        else
        {
            ans += v;
            v = abs(i - to[i]);
        }
    }
    ans += v;
    cout << ans << endl;
    return 0;
}


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

#define INF (int)1e9
#define EPS (int)1e-9
#define ll long long
#define ld long double
#define FOR(i,m,n) for(int i=m; i<n; i++)
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()
//#define endl "\n"

void solve(){
    ld n;
    cin >> n;
    vt<pair<ld,ld>> a(n);
    vt<pair<ld,ld>> sums(n);
    ld asum = 0, tsum = 0, ans = 0, ct = n-1;
    FOR(i,0,n){
        cin >> a[i].first >> a[i].second;
        asum += a[i].first;
        sums[i].first = a[i].first*2 + a[i].second;
        sums[i].second = i;
    }
    sort(all(sums));
    while(tsum<=asum){
        tsum += sums[ct].first;
        ans ++;
        ct --;
    }
    cout << ans << "\n";
}

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

#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll = int64_t; using ull = uint64_t; const ll INF = 9e18;
void print() { cout << endl; }
template<typename Head,typename... Tail> void print(Head head,Tail... tail){cout<<head;if(sizeof...(Tail)>0)cout<<" ";print(tail...);}
void print0() {}
template<typename Head,typename... Tail> void print0(Head head,Tail... tail){cout<<head;print0(tail...);}
// clang-format on

struct person {
    ll id;
    ll a;
    ll b;
};

ll check(ll N, ll start, ll end, vector<ll>& start_end, vector<ll>& start_fix, vector<ll>& end_fix) {
    if (end > 2 * N) {
        return 0;
    }
    if (start_fix[start] >= 0) {
        return 2;
    }
    if (end_fix[end] >= 0) {
        return 2;
    }
    if (start_end[start * 1000 + end] >= 0) {
        return 2;
    }
    return 1;
}

bool recursive1(ll N, ll start, ll cnt, vector<ll>& start_end, vector<ll>& start_fix, vector<ll>& end_fix, ll anypt, vector<ll>& memo) {
    if (cnt == N) {
        return true;
    }
    if (start >= 2 * N) {
        return false;
    }
    if (memo[start] >= anypt) {
        return false;
    }
    memo[start] = anypt;

    for (ll end = min(start + N, 2 * N); end >= start + 1; end--) {
        bool success = true;
        ll anyy = anypt;
        for (ll ss = start; ss <= end - 1; ss++) {
            ll ee = end - start + ss;
            ll result = check(N, ss, ee, start_end, start_fix, end_fix);
            if (result == 0) {
                success = false;
                break;
            } else if (result == 1) {
                anyy--;
                if (anyy < 0) {
                    success = false;
                    break;
                }
            } else {
                ;
            }
        }
        if (success) {
            bool ok = recursive1(N, end + end - start, cnt + (end - start), start_end, start_fix, end_fix, anyy, memo);
            if (ok) {
                return true;
            }
        }
    }
    return false;
}

bool solve(ll N, vector<person>& persons) {
    vector<ll> start_end(300000, -1);
    vector<ll> start_fix(300, -1);
    vector<ll> end_fix(300, -1);
    ll anypt = 0;
    for (auto p : persons) {
        if (p.a == -1 && p.b == -1) {
            anypt++;
        }
        if (p.a >= 0 && p.b == -1) {
            start_fix[p.a] = p.id;
        }
        if (p.a == -1 && p.b >= 0) {
            end_fix[p.b] = p.id;
        }
        if (p.a >= 0 && p.b >= 0) {
            start_end[p.a * 1000 + p.b] = p.id;
        }
    }
    vector<ll> memo(2 * N + 2, -1);
    return recursive1(N, 1, 0, start_end, start_fix, end_fix, anypt, memo);
}

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

    vector<person> persons(N);
    for (ll i = 0; i < N; i++) {
        person p;
        cin >> p.a >> p.b;
        p.id = i;
        persons[i] = p;
    }
    if (solve(N, persons)) {
        print("Yes");
    } else {
        print("No");
    }
}


#include <iostream>

using namespace std;

int main()
{
 int a,b,sumA=0,sumB=0;
 cin>>a>>b;
 while(a!=0)
 {

   sumA+= a%10;
   a/=10;
   sumB+= b%10;
   b/=10;
 }
 if(sumA>=sumB)
   cout<<sumA;
else
    cout<<sumB;

}

#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = /*1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 500'000;
const int LOGN = 19;

int n, m, k;

void solve(int test) {
  int64 n;
  cin >> n;
  int a[10] = {};
  int s = 0, t = 0;
  for (; n; n /= 10, ++t) {
    ++a[n % 10 % 3];
    s += n % 10;
  }
  if (s % 3 == 0) {
    cout << "0\n";
    return;
  }
  if (s % 3 == 1) {
    if (a[1] && t > 1) {
      cout << "1\n";
      return;
    }
    if (a[2] >= 2 && t > 2) {
      cout << "2\n";
      return;
    }
    cout << "-1\n";
    return;
  }
  if (a[2] && t > 1) {
    cout << "1\n";
    return;
  }
  if (a[1] >= 2 && t > 2) {
    cout << "2\n";
    return;
  }
  cout << "-1\n";
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


//remove #define int long long in critical cases to avoid TLE
//always use ll with constants like (1ll)<<59 otherwise ans will be zero at higher cases
//while doing question on comparing, sort elements according to the difference they produce
//when elements are unique sorting elements after inserting in vector sometimes gives TLE but inserting in set
//can help
//prefer set over map for checking presence. Map may give TLE more earlier than Sets && set::find over set::count
//even if computation takes O(logn) time in sets prefer deleting elements as soon their use is over. Reduces chances of TLE
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ff first
#define ss second
#define vi vector <int>
#define pii pair<int,int>
#define f(x,y,z) for(x=y;x<z;x++)
#define pb push_back
#define mp make_pair
#define ld long double
#define ps(x,y) fixed << setprecision(y) << x
#define PI 3.1415926535
#define mod 1000000007
#define mods 998244353
#define setbits(x) __builtin_popcountll(x)
#define all(x) (x).begin(), (x).end()
#define fill(a,b) memset(a,b,sizeof(a))
#define INF INT_MAX

// AUTHOR ALOK KUMAR
int lcm(int a,int b)
{
    return (a*b)/(__gcd(a,b));
}
int power(int a,int b,int p)
{
    int c=1;
    while(b)
    {
        if(b&1)
        c*=a;
        a*=a;
        b>>=1;
        c%=p;
        a%=p;
        b%=p;
    }
    return c%p;
}
int inverse_mod(int n, int p)
{
    return power(n,p-2,p);
}
void seive()
{
    int N;
    int prime[N+1];
    int i;
    for(i=2;i*i<=N;i++)
    {
        if(!prime[i])
        {
            for(int j=i*i;j<=N;j+=i)
            {
                prime[j] = 1;
            }
        }
    }
}

void solve()
{
    char ch1,ch2,ch3;
    cin>>ch1>>ch2>>ch3;
    if(ch1==ch2&&ch2==ch3)
    cout<<"Won\n";
    else
    cout<<"Lost\n";

}

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

#include <bits/stdc++.h>
using namespace std;
#define fast_io cin.tie(0);ios_base::sync_with_stdio(0);
string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cout << endl; }
void show() { cout << endl; }
void pret() { cout << endl; exit(0);}
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cout << " " << to_string(H); debug_out(T...);}
template <typename Head, typename... Tail> void show(Head H, Tail... T) {cout <<H<<" "; show(T...);}
template <typename Head, typename... Tail> void pret(Head H, Tail... T) {cout <<H<<" "; pret(T...);}
#define pr(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
typedef long long ll;
#define int ll
typedef long double ld;
typedef vector<int> vi;
#define disp(x) cout<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(int)b;i++)
#define fo(i,a,b) for(int i=a;i<=(int)b;i++)
#define rf(i,a,b) for(int i=a;i>=(int)b;i--)
#define mp make_pair
#define pb emplace_back
#define F first
#define S second
#define endl '\n'
//cout.setf(ios::fixed);cout.precision(18)
const int MOD = 1e9+7;
const int maxn = 300000+10;

int32_t main(){
    fast_io;
    string s;
    cin >> s;
    if(s[1] != s[0] or s[2] != s[0]){
    	pret("Lost");
    }
    else {
    	show("Won");
    }
    return 0;
}


#line 1 "/home/anqooqie/.proconlib/tools/util.hpp"

#include <bits/stdc++.h>

using i64 = ::std::int_fast64_t;
using u64 = ::std::uint_fast64_t;
using i32 = ::std::int_fast32_t;
using u32 = ::std::uint_fast32_t;

#define all(x) ::std::begin((x)), ::std::end((x))

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#line 2 "main.cpp"

int main() {
  i64 n;
  std::cin >> n;

  i64 ng = 0;
  i64 ok = 1414213561;
  while (ok - ng > 1) {
    const i64 center = (ng + ok) / 2;
    if (center * (center + 3) >= 2 * n + 4) {
      ok = center;
    } else {
      ng = center;
    }
  }

  std::cout << std::max(n + 1 - ok, ok * (ok - 1) / 2) << '\n';
  return 0;
}

#include <bits/stdc++.h>
//#include <atcoder/modint>
//using namespace atcoder;
//#pragma GCC optimize("O3")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
using P = pair<ll, ll>;
using tp = tuple<ll, ll, ll>;
const ll INF = (1LL<<61);

template<class T> bool chmin(T &a, const T b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T b){
    if(a < b) {a = b; return true;}
    else return false;
}
template<class T> void my_printv(std::vector<T> v,bool endline = true){
    if(!v.empty()){
        for(std::size_t i{}; i<v.size()-1; ++i) std::cout<<v[i]<<" ";
        std::cout<<v.back();
    }
    if(endline) std::cout<<std::endl;
}

template <class T> class BIT {
    //T has operator "+=" and can be initialized with 0.
    int n, n_2k;
    vector<T> bitree;
public:
    //make [0, n) BIT
    BIT(int _n) : bitree(_n + 1, 0) {
        n = n_2k = _n;
        while(n_2k & (n_2k - 1)) n_2k &= n_2k - 1;
    }

    //BIT[id] += x
    void add(int id, T x) {
        ++id;
        while (id <= n) {
            bitree[id] += x;
            id += id & -id;
        }
    }

    //sum of BIT[0, id]
    T sum(int id) {
        ++id;
        T temp(0);
        while (id > 0) {
            temp += bitree[id];
            id -= id & -id;
        }
        return temp;
    }

    //sum of BIT[l, r)
    T range_sum(int l, int r) {
        return sum(r-1) - sum(l-1);
    }

    //return i in [0, n]
    //i = argmin_{j} (BIT[0, j] >= x)
    //T should have bool operator '<'
    int lower_bound(T x){
        int id = n_2k;
        T temp(0);
        for(int plus = id; plus; id |= (plus>>=1)){
            if(id <= n && temp + bitree[id] < x) temp += bitree[id];
            else id ^= plus;
        }
        return id;
    }
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>N;
    vec a(N * 2);
    rep(i, N * 2) cin>>a[i];
    priority_queue<ll> pque;
    ll res{};
    rep(i, N){
        pque.push(a[N * 2 - 1 - i]);
        pque.push(a[i]);
        ll nxt = pque.top();
        pque.pop();
        res += nxt;
    }
    cout<<res<<endl;
}


#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_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 <climits>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define pb push_back

int ri() {
	int n;
	cin>>n;
	return n;
}

void solve() {
	int x = ri();
	if(x>=0) {
		cout<<x;
		return;
	}
	cout<<0<<endl;
}

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

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

}

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,sse,sse2")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j, n) for (ll i = j; i <= n; i++)
#define per(i, j, n) for (ll i = j; i >= n; i--)
#define ll long long
#define ld long double
#define ld long double
#define ii pair<ll, ll>
#define vii vector<ii>
#define vi vector<ll>
#define adj unordered_map<ll, vii>
#define MOD 1000000007
#define PI 3.14159265359
#define db1(x) cout << #x " = " << x << endl;
inline ll add(ll a, ll b) { return ((a % MOD) + (b % MOD)) % MOD; }
inline ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
inline ll sub(ll a, ll b) { return ((a % MOD) - (b % MOD) + MOD) % MOD; }

template <typename T> void i1d(vector<T> &v) {
  for (auto &i : v)
    cin >> i;
}

template <typename T> void p1d(const vector<T> &v) {
  for (auto i : v)
    cout << i << ' ';
  cout << endl;
}

ll t = 1;
ll x;

void solve() {
  // Code goes here
  cin >> x;
  if (x >= 0)
    cout << x << '\n';
  else
    cout << 0 << '\n';
}

int main() {
  ios::sync_with_stdio(false);
  // cin >> t;
  rep(i, 1, t) {
    // cout<<"Case #" << i << ": ";
    solve();
  }
}


#include <iostream>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;
ll INF = 1000000000000000;
struct segment_tree{
    int n; vector<ll> seg;
    segment_tree(vector<ll> v){
        n = v.size(); seg.resize(2*n);
        for(int i=0;i<n;i++) seg[i + n] = v[i];
        for(int i=n - 1;i>0;i--) seg[i] = seg[i<<1] + seg[i<<1|1];
    }
    void update(int p,ll val){
        for(seg[p += n] += val;p>1;p>>=1) seg[p>>1] = seg[p] + seg[p^1];
    }
    ll query(int l,int r){
        ll res = 0;
        for(l += n,r += n; l<r;l>>=1,r>>=1){
            if(l&1) res += seg[l++];
            if(r&1) res += seg[--r];
        }
        return res;
    }
    void clear(){for(int i=0;i<2*n;i++) seg[i] = 0;}
};

int t[200010],x[200010],y[200010];
int main(){
    int i,n,m,q; cin >> n >> m >> q;
    vector<int> a(n),b(m);
    map<int,int> mp;
    mp[0]++;
    for(i=0;i<q;i++){
        cin >> t[i] >> x[i] >> y[i];
        t[i]--; x[i]--; mp[y[i]]++;
    }
    vector<ll> v,u;
    for(auto x:mp) v.push_back(x.first);
    for(i=0;i<v.size();i++) mp[v[i]] = i;
    int k = v.size(); u.resize(k);
    vector<segment_tree> seg(2,segment_tree(u)),seg_num(2,segment_tree(u));
    for(i=0;i<n;i++) seg[0].update(mp[a[i]],a[i]),seg_num[0].update(mp[a[i]],1);
    for(i=0;i<m;i++) seg[1].update(mp[b[i]],b[i]),seg_num[1].update(mp[b[i]],1);
    ll ans = 0;
    for(i=0;i<q;i++){
        ll now;
        int j = x[i];
        if(t[i]==0) now = a[j];
        else now = b[j];
        ans -= seg_num[1 - t[i]].query(0,mp[now])*now + seg[1 - t[i]].query(mp[now],k);
        if(t[i]==0){
            seg[0].update(mp[a[j]],-a[j]); seg_num[0].update(mp[a[j]],-1); a[j] = y[i];
        }else{
            seg[1].update(mp[b[j]],-b[j]); seg_num[1].update(mp[b[j]],-1); b[j] = y[i];
        }
        seg[t[i]].update(mp[y[i]],y[i]); seg_num[t[i]].update(mp[y[i]],1);
        ans += seg_num[1 - t[i]].query(0,mp[y[i]])*y[i] + seg[1 - t[i]].query(mp[y[i]],k);
        cout << ans << "\n";
    }
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(i,a,b) for(int i = a; i<b ; i++)
#define FIO ios_base::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);
#define pb push_back
#define M 1000000007
int mod(int x){
return ((x%M + M)%M);
}
int add(int a,int b){
return mod(mod(a)+mod(b));
}
int mul(int a,int b){
return mod(mod(a)*mod(b));
}
// ****************************************************************************
int n,m;
map<int,vector<pair<int,int>>>mp;
int dp[1<<(19)];
int rec(int mask){
    if(mask==0)
    return 1;
    // now check the validity
    if(dp[mask]!=-1)
    return dp[mask];
    int pref = n-__builtin_popcount(mask);
    for(auto it : mp[pref]){
        int val = it.first;
        int maxnum = it.second;
        int temp = 0;
        for(int j=1;j<=n;j++){
            if(!(mask&(1<<j)) && j<=val)
            temp++;
        }
        if(temp>maxnum)
        return 0;
    }
    // now try to put every value
    int ans = 0;
    for(int i=1;i<=n;i++){
        if((mask&(1<<i))){
            ans+=rec(mask^(1<<i));
        }
    }
    return dp[mask] = ans;
}
void solve(){
    cin>>n>>m;
    while(m--){
        int x,y,z;
        cin>>x>>y>>z;
        mp[x].pb({y,z});
    }
    memset(dp,-1,sizeof dp);
    int mask = 1<<(n+1);
    mask--;
    mask^=1;
    cout<<rec(mask);
}
signed main()
{
FIO
int t;
t=1;
// cin>>t;
while(t--)
{
solve();
}
}


#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
constexpr int INF = 1001001001;

constexpr bool is_multiple = false;

i64 count_between(i64 a, i64 b) {
    return b - a + 1;
}

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

    i64 res = 0;

    i64 base = 1000;
    i64 cnt = 1;
    while (base <= n) {
        res += cnt * count_between(base, min(base*1000 - 1, n));
        base *= 1000;
        cnt++;
    }

    cout << res << endl;
}

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

#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll n;

int main(void){
	scanf("%lld",&n);
	ll ans=0;
	ll rest=n;
	int dig=1;
	ll now=9;
	ll su=0;
	while(rest>0LL){
		if(rest>=now){
			ans+=now*((dig-1)/3LL);
			rest-=now;
		}else{
			ans+=rest*((dig-1)/3LL);
			rest=0;
		}
		dig++;
		now*=10LL;
	}
	printf("%lld\n",ans);
	return 0;
}


#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <functional>
#include <cassert>
#include <stack>
#include <numeric>
#include <iomanip>
#include <limits>
#include <random>
#include <unordered_map>

typedef int64_t ll;
typedef std::pair<int, int> Pii;
typedef std::pair<ll, ll> Pll;
typedef std::pair<double, double> Pdd;

#define rip(_i, _n, _s) for (int _i = (_s); _i < (int)(_n); _i++)
#define all(_l) _l.begin(), _l.end()
#define rall(_l) _l.rbegin(), _l.rend()
#define MM << " " <<

template<typename _T>
using MaxHeap = std::priority_queue<_T>;
template<typename _T>
using MinHeap = std::priority_queue<_T, std::vector<_T>, std::greater<_T>>;

template<typename _T>
inline bool chmax(_T &_l, const _T _b) {
    if (_l < _b) {
        _l = _b;
        return true;
    }
    return false;
}
template<typename _T>
inline bool chmin(_T &_l, const _T _b) {
    if (_l > _b) {
        _l = _b;
        return true;
    }
    return false;
}

template<typename _T>
void vdeb(const std::vector<_T> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        if (i == bb.size() - 1) std::cout << bb[i];
        else std::cout << bb[i] << ' ';
    }
    std::cout << '\n';
}
template<typename _T>
void vdeb(const std::vector<std::vector<_T>> &bb) {
    for (unsigned int i = 0;i < bb.size();i++) {
        std::cout << i << ' ';
        vdeb(bb[i]);
    }
    std::cout << '\n';
}

using namespace std;

int main() {
    int n; cin >> n;
    vector<ll> da1(n), da2(n);
    ll ans = 0;
    rip(i,n,0) {
        cin >> da1[i];
    }
    rip(i,n,0) cin >> da2[i];
    reverse(all(da1));
    MinHeap<ll> pq;
    rip(i,n,0) {
        pq.push(da1[i]);
        pq.push(da2[i]);
        ans += da1[i] + da2[i];
        ans -= pq.top();
        pq.pop();
    }
    cout << ans << endl;
}

#include<bits/stdc++.h>
#define cs const
#define pb push_back
using namespace std;
typedef long long ll;
cs int N = 4e5 + 5;
int n, a[N], p[N], c[N];
ll ans;
#define mid ((l + r) >> 1)
cs int M = N << 2;
int mn[M], ta[M];
void up(int x) {
	mn[x] = min(mn[x << 1], mn[x << 1 | 1]) + ta[x];
}
void build(int x, int l, int r) {
	if(l == r) {
		mn[x] = l;
		return;
	}
	build(x << 1, l, mid);
	build(x << 1 | 1, mid + 1, r);
	up(x);
}
void mdf(int x, int l, int r, int L, int R) {
	if(L <= l && r <= R)
		return mn[x] --, ta[x] --, void();
	if(L <= mid) mdf(x << 1, l, mid, L, R);
	if(R > mid) mdf(x << 1 | 1, mid + 1, r, L, R);
	up(x);
}
int qry(int x, int l, int r, int L, int R) {
	if(L <= l && r <= R)
		return mn[x];
	int ans = 1e9;
	if(L <= mid) ans = min(ans, qry(x << 1, l, mid, L, R));
	if(R > mid) ans = min(ans, qry(x << 1 | 1, mid + 1, r, L, R));
	return ans + ta[x];
}
#undef mid

void ins(int x, int c) {
	int z = qry(1, 1, n, x, n);
	if(z) {
		ans += c;
		mdf(1, 1, n, x, n);
	}
}
int main() {
	#ifdef FSYo
	freopen("1.in", "r", stdin);
	#endif
	cin >> n;
	for(int i = 1; i <= n + n; i++)
		scanf("%d", &a[i]), p[i] = i;
	sort(p + 1, p + n + n + 1,
	[](cs int &i, cs int &j) {
		return a[i] > a[j];
	});
	build(1, 1, n);
	for(int i = 1; i <= n + n; i++) {
		int x = p[i];
		if(x <= n) {
			ins(n - x + 1, a[x]);
		}
		else {
			ins(x - n, a[x]);
		}
	}
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#define ll long long
#define lli long long int
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#include<string>
#include<cctype>
#define F first
#define S second
#include<queue>
#define ii pair<int,int>
#include <sstream>
#define lli long long int
#define pairs pair<int,int>
#define ld long double
#define mod 1000000007
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
ll pows(ll a,ll n,ll m)
{
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}
	}
	return res%m;
}
ll  gcd(ll a,ll b)
{
	if(b==0)
	return a;
	else
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
			return false;
			}
	}
	return true;
}
ll n,m;
vector<ll>a,b;
int main()
{
ios::sync_with_stdio(false);
	 cin.tie(0);
    cout.tie(0);
cin>>n>>m;
ll x;
for(ll i=0;i<n;i++)
{
	cin>>x;
	a.pb(x);
}
for(ll i=0;i<m;i++)
{
cin>>x;
b.pb(x);
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
vector<ll> diff1(n/2+1),diff2(n/2+1);
for(ll i=0;i<n/2;i++)
{
	diff1[i+1]=diff1[i]+abs(a[2*i+1]-a[2*i]);
	diff2[i+1]=diff2[i]+abs(a[2*i+1]-a[2*i+2]);
}
ll ans=1e18;
for(ll i=0;i<n;i++)
{
	ll temp=0;
	auto it=lower_bound(b.begin(),b.end(),a[i]);
	if(it==b.begin())
	{
		temp=temp+abs(*it-a[i]);
	}
	else if(it==b.end())
	{
		it--;
		temp+=abs(*it-a[i]);
	}
	else
	{
		temp=abs(*it-a[i]);
		it--;
		temp=min(temp,abs(*it-a[i]));
	}
	if(i%2==0)
	{
	temp+=diff1[i/2]+diff2[n/2]-diff2[i/2];
	}
	else
	{
		temp+=diff1[i/2]+abs(a[i+1]-a[i-1])+diff2[n/2]-diff2[(i/2)+1];
	}
	ans=min(ans,temp);
}
cout<<ans<<endl;
}

#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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; }
const long double PI = acos(-1.0);
// cout << fixed << setprecision(14);

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

	int N, M;
	cin >> N >> M;
	vector<int> H(N), W(M+2);
	rep(i,N){
		cin >> H[i];
	}
	rep(i,M){
		cin >> W[i];
	}
	W[M] = -INF;
	W[M+1] = INF;
	sort(H.begin(), H.end());
	sort(W.begin(), W.end());
	vector<int> dp1(N/2+1), dp2(N/2+1);
	rep(i,N/2){
		dp1[i+1] = H[i*2+1] - H[i*2] + dp1[i];
		dp2[i+1] = H[N-1-i*2] - H[N-2-i*2] + dp2[i];
	}
	reverse(dp2.begin(), dp2.end());
	int ans = INF;
	rep(i,N/2+1){
		int Z = dp1[i] + dp2[i];
		int botti = H[i*2];
		auto itr = lower_bound(W.begin(), W.end(), botti);
		int X = *itr;
		--itr;
		int Y = *itr;
		Z += min(abs(botti - X), abs(botti - Y));
		// cout << Z << endl;
		chmin(ans, Z);
	}
	cout << ans << endl;
	/*
	rep(i,N/2+1){
		cout << dp1[i] << ' ' <<  dp2[i] << endl;
	}
	*/
}


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

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << "Line " << __LINE__ << ": " <<  #x << " = " << (x) << "\n";
#define spa << " " <<
#define fi first
#define se second
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()

using ld = long double;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;

template<typename T> using V = vector<T>;
template<typename T> using P = pair<T, T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){os << "(" << v.first << ", " << v.second << ")"; return os;}
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>> &v){ for(auto &e : v){os << e << "\n";} return os;}
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

template <class T> void UNIQUE(vector<T> &x) {sort(ALL(x));x.erase(unique(ALL(x)), x.end());}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
void fail() { cout << -1 << '\n'; exit(0); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<"\n";}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<"\n";};

const ll INF = (1ll<<62);
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
const ll mod = (int)1e9 + 7;
//const ll mod = 998244353;

int main(){

    ll A, B, C;
    cin >> A >> B >> C;

    auto dp = make_vec(101, 101, 101, (ld)(-1));

    auto rec = [&](auto self, ll x, ll y, ll z)->ld{
        if(dp[x][y][z] >= -0.5) return dp[x][y][z];

        if(x == 100 or y == 100 or z == 100){
            return 0;
        }

        ld res = 0;
        res += ((ld)x/(x+y+z)) * (self(self, x+1, y, z) + 1.0);
        res += ((ld)y/(x+y+z)) * (self(self, x, y+1, z) + 1.0);
        res += ((ld)z/(x+y+z)) * (self(self, x, y, z+1) + 1.0);
        dp[x][y][z] = res;
        return res;
    };

    cout << rec(rec, A, B, C) << endl;

    return 0;
}

#include<bits/stdc++.h>
#include <iterator>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x)
#define gc getchar
#define pdd pair<dd,dd>
#define read_arr(a,n) for(ll i=1;i<=n;i++)cin>>a[i];
#define init_arr(a,n) for(ll i=1;i<=n;i++)a[i]=n-i+1;
#define prec(x) cout<<fixed<<setprecision(x)
#define fre freopen("input.txt","r",stdin),freopen("output.txt","w",stdout)
#define arr array
using namespace std;
dd dp[105][105][105];
ll vis[105][105][105];
dd solve(ll x,ll y,ll z){
	if(x==100 or y==100 or z==100)return 0.0;
	if(vis[x][y][z])return dp[x][y][z];
	vis[x][y][z]=1;
	dd a=0.0,b=0.0,c=0.0;

	if(x) a=1+solve(x+1,y,z);
	if(y) b=1+solve(x,y+1,z);
	if(z) c=1+solve(x,y,z+1);

	dd fa=0.0;
	dd den=(x*1.0+y*1.0+z*1.0);
	fa=a*(x*1.0)/den;
	fa+=b*(y*1.0)/den;
	fa+=c*(z*1.00)/den;
	return dp[x][y][z]=fa;

}

int main(){
	ll a,b,c;
	prec(20);
	cin>>a>>b>>c;
	cout<<solve(a,b,c);
}


#include <iostream>
#include <bits/stdc++.h>
#include <bitset>
#define ll long long int
#define pi pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vl>
#define vpi vector<pi>
#define vpll vector<pll>
#define vb vector<bool>
#define vii vector<vi>
#define ALL(v) v.begin(), v.end()
#define st string
#define si(n) cin >> n
#define dout(n) cout << n << "\n"
#define mod 1000000007
#define f(i, a, b) for (int i = a; i < b; i++)
#define fd(i, a, b) for (int i = a; i >= b; i--)

using namespace std;

bool yes = false;
st s1, s2;

ll max(ll a, ll b, ll c)
{
    return max(a, max(b, c));
}

struct comp
{

    bool operator()(const pi &a, const pi &b)
    {
        if (a.first == b.first)
            return a.second < b.second;
        return a.first < b.first;
    }
};

bool check_pal(st &s)
{
    int i = 0, j = s.length() - 1;
    while (i < j)
    {
        if (s[i] != s[j])
            return false;
        i++, j--;
    }
    return true;
}
void swap(char &a, char &b)
{
    char ch = a;
    a = b;
    b = ch;
    return;
}
int dfs(vii &g, vi &vis, vi &co, int pos)
{

    int mn = co[pos];
    vis[pos] = 1;
    f(i, 0, g[pos].size())
    {
        if (!vis[g[pos][i]])
            mn = min(dfs(g, vis, co, g[pos][i]), mn);
    }
    return mn;
}

void seive(int n, vector<bool> &isprime)
{
    isprime[0] = true;
    isprime[1] = true;
    f(i, 2, n + 1)
    {
        if (!isprime[i])
        {

            for (int j = 2; (j * i) < n + 1; j++)
                isprime[j * i] = true;
        }
    }
}
int findfact( int n , int&a , int &b){
    for( int i =2 ;i<n ; i++){
        if( n%i == 0 && i!=n/i) {
            a=i;
            b = n/i ;
            return 0;
        }
    }
    return -1;
}
ll ignoref(vi & v, int mx , int fmx , vi & con, int idx){
ll op=0;
int n = v.size();
int prev = idx == 0? v[1]:v[0];
if( fmx==1){
      f(i,1,n){
           if( v[i]!=mx){
                 op+= abs(v[i]-prev);
                 //cout<<op<<" ";
                 prev = v[i];
           }

       }
}
else {
    int index;
    int mxcon=INT_MIN;
    f(i,0,n){
        if(v[i]==mx){
            if( mxcon <con[i]){
                index =i;
                mxcon = con[i];
            }
        }
    }
    f(i,1,n){
           if( i!= index){
                 op+= abs(v[i]-prev)*1ll;
               //  cout<<op<<" "<<v[i]<<" "<<prev<<" \n";
                 prev = v[i];
           }

       }
}
return op;
}

int main()
{

 int n;
 cin>>n;
 vi v;
 f(i,0,n){
     int a;
     cin>>a;
     v.pb(a);
 }
 vector<pair<ll,ll>>pssum(n);
 ll msf=0,mx=0;
 f(i,0,n){
     msf+=v[i];
     mx = max(mx,msf);
     pssum[i].first = mx;
     pssum[i].second = msf;
 }
 ll ans = 0;
 msf =0;
 f(i,0,n){
     ans = max(msf+pssum[i].first, ans);
    msf+=pssum[i].second;

 }
 ans = max(msf,ans);
 cout<<ans<<"\n";
}

#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#define LL long long
using namespace std;
LL maxx[400000], arr[400000];
int main (){
    LL n;
    cin >> n;
    for (LL i = 1;i <= n; ++ i){
        scanf("%lld", &arr[i]);
    }
    LL max_ = arr[1];
    maxx[1] = max_;
    for (LL i = 2;i <= n; ++ i){
        arr[i] += arr[i - 1];
        maxx[i] = max_ = max(max_, arr[i]);
        // cout << arr[i]<<" "<<maxx[i]<<endl;
    }
    LL x = 0, ans = 0;
    for (LL i = 1;i <= n; ++ i){
        // cout << x;
        ans = max(ans, x + maxx[i]);
        x += arr[i];
    }
    cout << ans;
    return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;

//infの設定
#define INF32 2147483647
#define INF64 9223372036854775807
#define PRIME 1000000007
#define PI 3.141592653589793238
//repマクロ
#define rep(i,m,n) for (int i=(m); (i)<(int)(n); ++(i))
#define rrep(i,m,n) for (int i=(m); (i)>(int)(n); --(i))
//その他
#define eb emplace_back
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<long long,long long> Pl;
//#define int long long

//負閉路を含まない重み付きグラフのある点からのGraph_distを返す関数(ダイクストラ法)　↑とセット
int bfs(int n,vector<vector<int>>& g){

    queue<int> que;

    vector<bool> seen(2020,false);
    que.push(n);

    int count=0;
    while(!que.empty()){
        int v=que.front();
        que.pop();
        if(seen[v]) continue;
        seen[v]=true;
        count++;
        for(int ne:g[v]){
            que.push(ne);
        }
    }
    return count;
}

int main(){
    int N,M;
    cin>>N>>M;
    vector<vector<int>> g(2020);

    rep(i,0,M){
        int a,b; cin>>a>>b;
        g[a-1].eb(b-1);
    }
    ll ans=0;
    rep(i,0,N){
        ans+=bfs(i,g);
    }
    cout<<ans<<endl;

    return 0;
}

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <memory>
#include <list>
#include <deque>
#include <queue>
#include <iomanip>
#include <set>
#include <stack>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <string.h>
#include <functional>
#include <sstream>

using namespace std;

#define REP(i,n) for (decltype(n) i = 0; i < n; i++)
#define THE_MOD 1'000'000'007

using ll = long long;
using ivec = vector<int>;
using lvec = vector<long>;
using ipair = pair<int, int>;
using llvec = vector<ll>;
using llpair = pair<ll, ll>;

#define umap unordered_map
#define uset unordered_set

template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { auto n = v.size(); REP(i,n) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &e : v) is >> e; return is; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }

void in() {} template <typename T, typename... Args> void in(T& t, Args& ...args) { cin >> t; in(args...); }
void out() { cout << endl; } template <typename T, typename... Args> void out(const T& t, const Args& ...args) { cout << t; if (sizeof...(args)) cout << " "; out(args...); }

constexpr ll LLINF = numeric_limits<ll>::max();

template<class T> void sort(T& v) {	sort(v.begin(), v.end()); }
template<class T> void rsort(T& v) { sort(v.begin(), v.end(), greater<typename T::value_type>()); }

void YN(bool b) {	cout << (b ? "Yes" : "No") << endl; }

template <typename T = ll, typename U = ll>
vector<T> Dijkstra(const vector<vector<pair<U,T>>>& edges, U start, U numNodes)
{
	using Node = pair<U,T>;
	auto compare = [](Node a, Node b){ return a.second > b.second;};
	priority_queue<Node, vector<Node>, decltype(compare)> q{compare};

	vector<T> costs(numNodes, numeric_limits<T>::max());

	q.emplace(start, 0);
	while (!q.empty()) {
		auto [from, cost] = q.top();
		q.pop();
		if (cost > costs[from]) continue;

		for (const auto& edge : edges[from]) {
			auto to = edge.first;
			auto newCost = cost + edge.second;
			if (newCost < costs[to]) {
				costs[to] = newCost;
				q.emplace(to, newCost);
			}
		}
	}
	return costs;
}

struct Range {
	ll x;
	ll y;
	Range(ll x, ll y) : x(x), y(y)
	{
		if (y > x) swap(x,y);
	}

	struct Iterator {
		using difference_type   = ptrdiff_t;
		using value_type        = ll;
		using pointer           = ll*;
		using reference         = ll&;
		using iterator_category = std::random_access_iterator_tag;
		Iterator() = default;
		Iterator(ll n) : n(n) {}
		ll n;
		bool operator!=(const Iterator&rhs) const { return n != rhs.n; }
		bool operator==(const Iterator&rhs) const { return n == rhs.n; }
		Iterator& operator++() { n++; return *this; }
		Iterator& operator--() { n--; return *this; }
		Iterator& operator+=(ll x) { n+=x; return *this; }
		ll operator*() const { return n; }
		ptrdiff_t operator-(const Iterator&rhs) const { return n - rhs.n; }
	};

	Iterator begin() { return Iterator(x); }
	Iterator end() { return Iterator(y); }
};

ll extgcd(ll a, ll b, ll &x, ll &y)
{
/*
a = pb*q; // p = a / b, q = a % b
ax + by
 = pbx + qx + by
 = b(px + y) + qx
 = bY + qX // Y = px + y, X = x ->  y = Y - px
*/

	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	ll d = extgcd(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

ll run()
{
	ll a,b; double w;in(a,b,w);
	w *= 1000;
	ll m = ceil(w/b);
	ll M = floor(w/a);
	if (M < m) {
		out("UNSATISFIABLE");
		return 0;
	} else {
		out(m,M);
		return 0;
	}
	return 0;
}

int main()
{
	cout << fixed << setprecision(15);
	auto r = run();
	//YN(r);
	//out(r);
	//cout << r << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  n*=2;
  vector<ll> a[3];
  rep(i,n) {
    ll x;
    char c;
    cin >> x >> c;
    if(c=='R') a[0].pb(x);
    else if(c=='B') a[1].pb(x);
    else a[2].pb(x);
  }
  rep(i,3) sort(all(a[i]));
  P c[3];
  rep(i,3) c[i]=P(a[i].size()%2,i);
  sort(c,c+3,greater<P>());
  ll ans=MAXL;
  if(c[0].F) {
    ll x=c[0].S,y=c[1].S,z=c[2].S;
    rep(i,a[x].size()) {
      ll k=lower_bound(all(a[y]),a[x][i])-a[y].begin();
      if(k<a[y].size()) ans=min(ans,abs(a[x][i]-a[y][k]));
      if(k) ans=min(ans,abs(a[x][i]-a[y][k-1]));
    }
    vector<P> v[2];
    rep(i,a[z].size()) {
      ll k=lower_bound(all(a[x]),a[z][i])-a[x].begin();
      if(k<a[x].size()) {
        ll d=abs(a[z][i]-a[x][k]);
        v[0].pb(P(d,i));
      }
      if(k) {
        ll d=abs(a[z][i]-a[x][k-1]);
        v[0].pb(P(d,i));
      }
    }
    rep(i,a[z].size()) {
      ll k=lower_bound(all(a[y]),a[z][i])-a[y].begin();
      if(k<a[y].size()) {
        ll d=abs(a[z][i]-a[y][k]);
        v[1].pb(P(d,i));
      }
      if(k) {
        ll d=abs(a[z][i]-a[y][k-1]);
        v[1].pb(P(d,i));
      }
    }
    rep(i,2) sort(all(v[i]));
    rep(i,min(3,(int)v[0].size())) {
      rep(j,min(3,(int)v[1].size())) {
        if(v[0][i].S!=v[1][j].S) ans=min(ans,v[0][i].F+v[1][i].F);
      }
    }
  } else ans=0;
  pr(ans);
}

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

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

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

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

//.data
const vector<int> primes{2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71};

//.code
void SolveTask() {
    ll a, b;
    cin >> a >> b;
    vector<int> arr(b - a + 1, 0);
    for (ll i = a; i <= b; ++i) {
        for (int j = 0; j < sz(primes); ++j) {
            if (i % primes[j] == 0) {
                arr[i - a] |= 1 << j;
            }
        }
    }
    const int full_mask = 1 << sz(primes);
    vector<ll> dp(full_mask, 0);
    dp[0] = 1;
    loop(sz(arr)) {
        for (int mask = 0; mask < full_mask; ++mask) {
            if ((mask & arr[i]) == 0) {
                dp[mask | arr[i]] += dp[mask];
            }
        }
    }
    cout << accumulate(all(dp), 0LL) << endl;
}

int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int test_cases = 1;
    // cin >> test_cases;
    for (int yt = 1; yt <= test_cases; ++yt) {
        SolveTask();
    }
#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size()
#define all(v) v.begin(), v.end()
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template < typename T_container, typename T = typename enable_if < !is_same<T_container, string>::value, typename T_container::value_type >::type >
ostream & operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)

const int N = 200;

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

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

	cout << ans;

	return 0;
}

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long ll;

//infの設定
#define INF32 2147483647
#define INF64 9223372036854775807
//repマクロ
#define rep(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))

int main(){

    ll N,A;
    static ll a[202020];

    cin>>N;
    rep(i,0,N){
        cin>>A;
        a[i]=A%200;
        //cout<<a[i]<<" ";
    }

    sort(a,a+N);
    /*for(int i=0;i<N;i++){
        cout<<a[i]<<" ";
    }*/
    //cout<<endl;

    ll count=0;
    ll num=0;
    ll a0=a[0];
    a[N]=201;

    rep(i,1,N+1){
        if(a[i]==a0){
            num++;
            //cout<<i<<" "<<a[i]<<endl;
        }else{
            count+=(num*(num+1))/2;
            //cout<<a0<<" ga "<<num+1<<" ko"<<endl;
            num=0;
            a0=a[i];
        }
    }

    cout<<count<<endl;

    return 0;
}


#include <bits/stdc++.h>

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

    int n;
    std::string s;

    std::cin >> n >> s;

    int ans = 0;

    for (int i = 0; i < n; i++) {
        int at = 0, gc = 0;

        for (int j = i; j < n; j++) {
            if (s[j] == 'A') ++at;
            else if (s[j] == 'T') --at;
            else if (s[j] == 'G') ++gc;
            else --gc;

            ans += !(at || gc);
        }
    }

    std::cout << ans;

    return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ld pi = 3.141592653589793238;

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p % i == 0) return false;
	}
	return true;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}
ll nCk(ll n, ll k) {
	ll a = 1, b = 1;
	for (int h = n - k + 1; h <= n; h++) { a *= h; a %= mod; }
	for (int h = 1; h <= k; h++) { b *= h; b %= mod; }
	return a * modpow(b, mod - 2) % mod;
}
//printf("%.10f\n", n);

string s, t;
ll n, m, cnt, ans;
ll ruia[123456], ruit[123456], ruic[123456], ruig[123456];
signed main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	cin >> n >> s;
	rep(i, n) {
		ruia[i + 1] = ruia[i];
		ruit[i + 1] = ruit[i];
		ruic[i + 1] = ruic[i];
		ruig[i + 1] = ruig[i];
		if (s[i] == 'A') { ruia[i + 1]++; }
		if (s[i] == 'T') { ruit[i + 1]++; }
		if (s[i] == 'C') { ruic[i + 1]++; }
		if (s[i] == 'G') { ruig[i + 1]++; }
	}
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			ll a, t, c, g;
			a = ruia[j] - ruia[i];
			t = ruit[j] - ruit[i];
			c = ruic[j] - ruic[i];
			g = ruig[j] - ruig[i];
			//cout << a << ' ' << t << ' ' << c << ' ' << g << endl;
			if (a == t && c == g) {
				ans++;
				//cout << i << ' ' << j << endl;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
#define rall(x) (x).rbegin, (x).rend() //reverse traversal

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

int main(){
	fastio;
	int t;
	cin>>t;
	cout<<((t+100-1)/100)<<endl;
}

#include<bits/stdc++.h>
using namespace std;
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define nl "\n"
typedef pair<int,int>ii;
typedef vector<int>vi;
typedef vector<ii>vii;
typedef vector<vi>vvi;
typedef vector<long long>vl;
typedef vector <vl>vvl;
template<class T>
void print(T& a)
{
    for(auto x:a)
        cout<<x<<" ";
    cout<<"\n";
}
const int MX=2e5+5;
int to[MX];

int findto(int x)
{
    if(to[x]==x)return x;
    else to[x]=findto(to[x]);
    return to[x];
}

int main()
{

    FastIO

    int n,ans=0; cin>>n;
    int a[n];
    for(int &x:a)cin>>x;

    iota(to,to+MX,0);

    for(int i=0; i<(n/2); i++)
    {
        int x=findto(a[i]);
        int y=findto(a[n-1-i]);
        if(x==y)continue;
        else
        {
            ans++;
            to[x]=y;
        }
    }

    cout<<ans<<nl;

    return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define ALL(a)  (a).begin(),(a).end()

typedef long long int ll;
typedef string str;
typedef pair<ll, ll> P;
using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
const ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7;
ll h, w, a, b; ll sum = 0;

ll solve(ll temp, ll ya, ll xa, ll e, vector<vector<ll>> v) {

	if (e == 0) { sum++; return 0; }

	if (temp == 1) { v[ya][xa] = 1; v[ya][xa + 1] = 1; }
	if (temp == 2) { v[ya][xa] = 1; v[ya + 1][xa] = 1; }

	rep(i, h) {
		rep(j, w) {
			if (j + 1 < w)if ((v[i][j] | v[i][j + 1]) == 0)solve(1, i, j, e - 1, v);
			if (i + 1 < h)if ((v[i][j] | v[i + 1][j]) == 0)solve(2, i, j, e - 1, v);
		}
	}

	return 0;
}

int main() {
	//Code Line
	ll k=1;
	cin >> h >> w >> a >> b;
	vector<vector<ll>> v(h,vector<ll>(w,0));
	solve(0,0,0,a,v);
	srep(i, 1, a + 1)k *= i;
	cout << sum / k << endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int h,w,a,b;

ll ans = 0;

vector < vector <int> > arr;

unordered_map <string, ll > mp;

int cal(int x,int y,int a,int b,vector < vector <int> > &arr, ll mask)
{

    string s=to_string(x)+" "+to_string(y)+" "+to_string(a)+" "+to_string(b)+" "+to_string(mask);

    //cout<<" AAO MERE GAO ME BHAI LOG "<<s<<endl;

   int ans=0;

   if(mp.find(s)!=mp.end())
    return mp[s];

    if(y==w)
       return  mp[s]=cal(x+1,0,a,b,arr,mask);
    if(x==h)
    {
        if(a==b&&a==0)
        return mp[s]=1;
        return mp[s]=0;
    }

    if(arr[x][y]==1)
        return mp[s]=cal(x,y+1,a,b,arr,mask);

    //take one

    if(b)
    {
    arr[x][y]=1;
    ans+=cal(x,y+1,a,b-1,arr,(mask)|(1<<(x*w+y)));
    arr[x][y]=0;
    }

    if(a&&y+1<w&&(arr[x][y+1]==0))
    {

        arr[x][y]=1;
        arr[x][y+1]=1;

        ans+=cal(x,y+1,a-1,b,arr,(mask)|(1<<(x*w+y))|(1<<(x*w+y+1)));

        arr[x][y+1]=0;
        arr[x][y]=0;

    }

     if(a&&x+1<h&&(arr[x+1][y]==0))
    {

        arr[x][y]=1;
        arr[x+1][y]=1;

        ans+=cal(x,y+1,a-1,b,arr,(mask)|(1<<(x*w+y))|(1<<(((x+1)*w)+y)));

        arr[x+1][y]=0;
        arr[x][y]=0;

    }

    mp[s]=ans;

   // cout<<" anas is "<<ans<<endl;

    return ans;

}

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

   while(t--)
   {

     cin>>h>>w>>a>>b;

     arr.resize(h,(vector <int> (w,0)));

     cout<<cal(0,0,a,b,arr,0)<<endl;

     //cout<<ans<<endl;

   }

  return 0;

}


//khodaya khodet komak kon
# include <bits/stdc++.h>

using namespace std;

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

# define A                                               first
# define B                                               second
# define endl                                            '\n'
# define sep                                             ' '
# define all(x)                                          x.begin(), x.end()
# define kill(x)                                         return cout << x << endl, 0
# define SZ(x)                                           int(x.size())
# define lc                                              id << 1
# define rc                                              id << 1 | 1
# define InTheNameOfGod                                  ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);

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

const int xn = 2e2 + 10;
const int xm = - 20 + 10;
const int sq = 320;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const ld eps = 1e-15;
const int mod = 998244353;
const int base = 257;

ll n, f[xn], m, x, y, nn;
bool mark[xn];
vector <int> vec;

int main(){
	InTheNameOfGod;

	cin >> n, nn = n;
	f[0] = f[1] = m = 1;
	while (f[m] + f[m - 1] <= n)
		++ m, f[m] = f[m - 1] + f[m - 2];
	for (int i = m; i >= 0; -- i)
		if (f[i] <= nn)
			mark[i] = true, nn -= f[i];
	m += m % 2;
	for (int i = 0; i < m; ++ i){
		if (i % 2 == 0){
			if (mark[m - i])
				vec.push_back(1), ++ x;
			vec.push_back(4), y += x;
		}
		else{
			if (mark[m - i])
				vec.push_back(2), ++ y;
			vec.push_back(3), x += y;
		}
	}
	if (mark[0])
		++ x, vec.push_back(1);
	cout << SZ(vec) << endl;
	for (int val : vec)
		cout << val << endl;
	if (x != n)
		kill("FUCK");

	return 0;
}

#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18;
void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);}
void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);}
void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<h;perr0(t...);}
void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);}
void ioinit() { cout << fixed << setprecision(15); cerr<<fixed<<setprecision(6); ios_base::sync_with_stdio(0); cin.tie(0); }
// clang-format on

ll fibrest(ll x0, ll y0, ll n, bool isx) {
    ll iter = 0;
    vector<ll> fib = {x0, y0};
    ll x = x0;
    ll y = y0;
    ll op = 0;
    while (true) {
        if (isx) {
            x = x + y;
        } else {
            y = y + x;
        }
        if (x >= n) break;
        op++;
        isx = !isx;
    }
    return op;
}
void op(vector<ll> &ops, ll &x, ll &y, ll t) {
    if (t == 1) {
        x = x + 1;
    }
    if (t == 2) {
        y = y + 1;
    }
    if (t == 3) {
        x = x + y;
    }
    if (t == 4) {
        y = y + x;
    }
    ops.push_back(t);
}
void output(vector<ll> &ops) {
    ll k = ops.size();
    print(ops.size());
    for (auto ope : ops) {
        print(ope);
    }
}

int main() {
    ioinit();

    ll n;
    cin >> n;
    // while (fib.back() < n) {
    //     fib.push_back(fib[fib.size() - 1] + fib[fib.size() - 2]);
    // }
    // ll m = fib.size();

    ll x = 0;
    ll y = 0;

    vector<ll> ops;
    if (n < 120) {
        while (x < n) {
            op(ops, x, y, 1);
        }
        output(ops);
        return 0;
    }

    op(ops, x, y, 2);
    bool isx = true;
    while (true) {
        if (x + y > n) {
            while (x < n) {
                op(ops, x, y, 1);
            }
            break;
        }
        ll curop = fibrest(x, y, n, isx);

        {
            ll k = 0;
            while (true) {
                ll r = fibrest(x + k + 1, y, n, isx);
                if (r != curop) break;
                //perr(curop, r);
                op(ops, x, y, 1);
                k = k + 1;
            }
        }
        if (isx) {
            op(ops, x, y, 3);
        } else {
            op(ops, x, y, 4);
        }
        isx = !isx;
        if (x >= n) break;
    }
    output(ops);
}


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

int main()
{
    int n,q;
    cin >> n;
    const ll INF = ll(1)<<60;
    ll l = -INF, r = INF;
    ll s = 0;
    rep(i,n)
    {
        ll a,t;
        cin >> a >> t;
        if(t == 1)
        {
            l += a;
            r += a;
            s += a;
        }
        else if(t ==2)
        {
            l = max(l,a);
            r = max(r,a);
        }
        else
        {
            l = min(l,a);
            r = min(r,a);
        }
    }
    cin >> q;
    rep(i,q)
    {
        ll x;
        cin >> x;
        x += s;
        ll ans = x;
        if(x <= l) ans = l;
        else if(r <= x) ans = r;
        printf("%ld\n",ans);
    }

    return 0;
}

#include<algorithm>
#include<iostream>
#include<cstring>
#include<bitset>
#include<cstdio>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
#define neinf 0xc0c0c0c0c0c0c0c0ll
#define inf 0x3f3f3f3f3f3f3f3fll
#define cap(i) ((i-1)%500+1)
#define cp(i) ((i-1)/500+1)
#define uint unsigned int
#define ull unsigned ll
#define ll long long
#define reg register
#define HgS 1000000007
#define db double
#define il inline
#define gc getchar
#define pc putchar
#define len 200000
#define siz 500
il ll rd()
{
    reg ll res=0,lab=1;
    reg char ch=gc();
    while((ch<'0'||ch>'9')&&ch!=EOF)
    {if(ch=='-')lab=-lab;ch=gc();}
    while(ch>='0'&&ch<='9')
        res=(res<<3)+(res<<1)+(ch&15),ch=gc();
    return res*lab;
}
il void prt(ll x,char t='\n')
{
    char ch[70];int tp=0;
    if(!x){fputs("0",stdout);if(t)pc(t);return;}
    if(x<0)pc('-'),x=-x;
    while(x)ch[++tp]=(x%10)^48,x/=10;
    while(tp)pc(ch[tp--]);
    if(t)pc(t);
}
il ll umax(ll a,ll b){return a>b?a:b;}
il ll umin(ll a,ll b){return a<b?a:b;}
ll n,a[len+5],t[len+5],q,x[len+5];
ll mnx=inf,mxx=neinf,add;
int main()
{
    //memset(mnx,0x3f,sizeof(mnx));memset(mxx,0xc0,sizeof(mxx));
    n=rd();for(int i=1;i<=n;++i)a[i]=rd(),t[i]=rd();
    q=rd();
    for(int i=1;i<=q;++i)
        x[i]=rd(),mnx=umin(mnx,x[i]),mxx=umax(mxx,x[i]);
    for(int i=1;i<=n;++i)
    {
        switch(t[i])
        {
            case 1:
            add+=a[i];mnx+=a[i];mxx+=a[i];break;
            case 2:mnx=umax(mnx,a[i]);mxx=umax(mxx,a[i]);break;
            case 3:mnx=umin(mnx,a[i]);mxx=umin(mxx,a[i]);break;
        }
    }
    for(int i=1;i<=q;++i)prt(umin(mxx,umax(mnx,x[i]+add)));
    return 0;
}


//#pragma GCC target("avx2")
//#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(nullptr)
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define lc(x) ((x)<<1)
#define rc(x) (((x)<<1)|1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;

const ll MOD=1e9+7;
const ll LINF=1e18;
const int INF=0x3f3f3f3f;
const int MAXE=5000050;
const int MAXN=2000050;
const int bk_sz=3420;
mt19937 rnd(114514);

ll fac[MAXN],inv[MAXN];
ll mpow(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1){
            ans*=a;
            ans%=MOD;
        }
        a*=a;
        a%=MOD;
        n>>=1;
    }
    return ans;
}
void prework(int n){
    fac[1]=1;
    fac[0]=1;
    for(ll i=1;i<=n;i++){
        fac[i]=fac[i-1]*i;
        fac[i]%=MOD;
    }
    inv[0]=1;
    inv[n]=mpow(fac[n],MOD-2);
    for(ll i=n-1;i;i--){
        inv[i]=inv[i+1]*(i+1)%MOD;
    }
}
ll getC(int n,int m){
    if(n<m||n<0||m<0)return 0ll;
    return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
void mainwork(int T){
    ll n,m,k;
    scanf("%lld%lld%lld",&n,&m,&k);
    prework(n+m);
    if(m<=n-k-1){
        puts("0");
        return;
    }
    ll ans=getC(n+m,m)-getC(n+m,m+k+1);
    ans=(ans+MOD)%MOD;
    printf("%lld\n",ans);
}
signed main(){
    //IOS;
#ifndef ONLINE_JUDGE
    freopen("Ranulx.in","r",stdin);
    freopen("Ranulx.out","w",stdout);
#endif
    int t=1;
    //scanf("%d",&t);
    for(int i=1;i<=t;i++){
        mainwork(i);
    }
}

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <iomanip>
#include <functional>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i = 0; i < (ll)(n); i++)
#define REP(i,n) for (ll i = 1; i <= (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define fcout cout<<fixed<<setprecision(15)
#define PI 3.1415926s535897932384626433832795028841971693993751058209749445923078160628620899
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

ll mod(ll N, ll A) {
	return (N + INF) % A;
}

ll modpow(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) return modpow(N, P / 2, M) * modpow(N, P / 2 , M) % M;
	return N * modpow(N, P - 1, M) % M;
}

bool isPrime(ll N) {
	ll T = sqrt(N);
	REP(i, T) {
		if (N % i == 0) return false;
	}
	return true;
}

ll GCD(ll A, ll B) {
	if (A % B == 0) return B;
	return GCD(B, A % B);
}

ll LCM(ll A, ll B) {
	return A / GCD(A, B) * B;
}

ll Digit(ll N) {
	string S = to_string(N);
	return S.size();
}

ll getSumDigit(ll N) {
	string S = to_string(N);
	ll A = 0;
	rep(i, S.size()) A += S[i] - '0';
	return A;
}

ll N, C, a[200010];

int main() {
	cin >> N;
	ll P = modpow(2, N, MOD);
	ll M1 = 0;
	rep(i, P) {
		cin >> a[i];
		M1 = max(a[i], M1);
	}
	ll K;
	rep(i, P) if (M1 == a[i]) K = i;
	if (0 <= K && K <= P / 2 - 1) {
		ll M2 = 0;
		for (ll i = P / 2; i < P; i++) M2 = max(a[i], M2);
		for (ll i = P / 2; i < P; i++) if (M2 == a[i]) cout << i + 1 << endl;
	}
	else {
		ll M2 = 0;
		rep(i, P / 2) M2 = max(a[i], M2);
		rep(i, P / 2) if (M2 == a[i]) cout << i + 1 << endl;
	}
	return 0;
}


#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using pii = pair <int, int>;
using pll = pair <ll, ll>;

#define FIO() ios_base::sync_with_stdio(0);cin.tie(NULL);
#define endl '\n'

int main() {
    FIO();

    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    if (r1 == r2 and c1 == c2) {
        cout << 0 << '\n';
        return 0;
    }

    if (abs(r1 - r2) + abs(c1 - c2) <= 3) {
        cout << 1 << '\n';
        return 0;
    }

    if (r1 + c1 == r2 + c2) {
        cout << 1 << '\n';
        return 0;
    }

    if (r1 - c1 == r2 - c2) {
        cout << 1 << '\n';
        return 0;
    }

    if ((r1 + c1) % 2 == (r2 + c2) % 2) {
        cout << 2 << '\n';
        return 0;
    }

    ll ans = 9e18;
    for (int x = -3; x <= 3; x++) {
        for (int y = -3; y <= 3; y++) {
            int rr = r1 + x, cc = c1 + y;
            int d = abs(rr - r1) + abs(cc - c1);
            if (d > 3) continue;
            if ((rr + cc) % 2 != (r2 + c2) % 2) continue;

            ll temp = 1;
            if (abs(rr - r2) + abs(cc - c2) <= 3) {
                temp += 1;
            } else if (rr + cc == r2 + c2) {
                temp += 1;
            } else if (rr - cc == r2 - c2) {
                temp += 1;
            } else temp += 2;

            ans = min(ans, temp);
        }
    }

    cout << ans << '\n';
}

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

int main() {
  long long A, B, C, D;
  cin >> A >> B;
  cin >> C >> D;
  C -= A;
  D -= B;
  C = abs(C);
  D = abs(D);
  long long x = max(C,D);
  long long y = min(C,D);
  C = x;
  D = y;
  if(x == 0 && y == 0) {
    cout << "0";
  }
  else if(x==y || x+y <= 3) {
    cout << "1";
  }
  else {
    x = (C+D)/2;
    y = (C+D)/2;
    if((C==x&&D==y) || abs(C-x)+abs(D-y) <= 3 || abs(C-x)==abs(D-y)) {
      cout << "2";
    }
    else {
      cout << "3";
    }
  }
}


#include <bits/stdc++.h>
using namespace std;
signed main() {
  int n; cin >> n;
  unordered_map<int, bool> mp;
  int current = 0;
  for(int i = 0; i < n; ++i) {
    int tmp; cin >> tmp;
    mp[tmp] = true;
    while(mp[current]) ++current;
    printf("%d\n", current);
  }
  return 0;
}

#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[200010];
set<int> U;

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	for(int i=0;i<=200010;i++){
		U.insert(i);
	}
	REP(i,N){
		U.erase(A[i]);
		cout<<*U.begin()<<endl;
	}
	return 0;
}


#include <iostream>
using namespace std;

int main()
{
    char s, t;
    cin >> s >> t;
    if(s == 'Y') cout << char(t - 32) << endl;
    else cout << t << endl;
}

/*#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("inline")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")*/
#include <bits/stdc++.h>
#define int long long
#define double long double
#define x first
#define y second
#define yy cout<<"YES\n"
#define nn cout<<"NO\n"
#define rt return
#define ct continue
#define br break
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mmod 1000000007
#define pmod 998244353
using namespace std;
int gcd(int a,int b){
    while (b) b^=a^=b^=a%=b;
    return a;
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int bigmod(int b,int p,int m){
    int ans=1;
    b%=m;
    if (!b) return 0;
    while (p){
        if (p&1) ans=(ans*b)%m;
        p>>=1;
        b=(b*b)%m;
    }
    return ans;
}
int ncr(int n,int r){
	if (n<r) return 0ll;
	int ans=1,k=min(n-r,r);
	for (int i=1; i<=k; i++) ans=ans*(n-i+1)/i;
	return ans;
}
double eu(int x1,int y1,int x2,int y2){
	int dx=abs(x1-x2),dy=abs(y1-y2);
	return sqrt(dx*dx+dy*dy);
}
int ham(string s,string t){
	int ans=0;
	for (int i=0; i<s.size(); i++) ans+=(s[i]!=t[i]);
	return ans;
}
int ce(int a,int b){
	if (a%b==0) return a/b;
	else return a/b+1;
}
bool cmp(){
	return 1;
}
void gen(){

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

}
signed main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while (t--) solve();
}


#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int mod=1e9+7;
const int maxV=2e7+1;
const ll inf=1e18+1;
int main(){
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll n;
    cin>>n;
    ll p10=10;
    int cnt=0;
    for(int i=1;i<1e6;i++){
        if(i==10 || i==100 || i==1000 || i==10000 || i==100000){
            p10*=10;
        }
        if(i*p10+i<=n){
            cnt++;
        }
    }
    cout<<cnt<<"\n";
}

#include <iostream>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll N;
    cin >> N;
    for(ll i = 1; ; i++) if(stoll(to_string(i) + to_string(i)) > N){
        cout << i - 1 << endl;
        return 0;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (int)(a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>T dup(T x, T y){return (x+y-1)/y;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}
int keta(ll n) { int ret = 0; while (n>0) { n/=10; ret++; } return ret; }

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) { cerr << head; dump(); }
template <typename Head, typename... Tail> void dump(Head &&head, Tail &&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do { cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

/////////////////////////////////////////////////////////////////////

void solve()
{
  ll n,k; cin>>n>>k;
  vector<vector<ll>> dp(3, vector<ll>(n*3+1));
  for (int i=1; i<=n; i++) {
    dp[0][i] = 1;
  }

  rep(i, 2) {
    vector<ll> s = dp[i];
    rep(j, 3*n) {
      s[j+1] += s[j];
      dp[i+1][j+1] = s[j] - s[max(0LL, j-n)];
    }
  }

  vector<ll> s = dp[2];
  rep(i, 3*n) s[i+1] += s[i];

  auto it = lower_bound(s.begin(), s.end(), k);
  ll v = it - s.begin();
  ll u = k - s[v-1] - 1;

  ll a = 1;
  ll cnt = 0;
  for (ll i=1; i<=min(v, n); i++) {
    a = i;
    ll t = v - i;
    if (t < 2 || 2*n < t) continue;
    ll g = min(2*n-t+1, t-1);
    if (cnt + g > u) break;
    cnt += g;
  }
  v -= a;
  u -= cnt;
  for (ll i=1; i<=n; i++) {
    ll t = v - i;
    if (t < 1 || n < t) continue;
    if (u <= 0) {
      printf("%lld %lld %lld\n", a, i, t);
      break;
    }
    u--;
  }

}

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

  return 0;
}


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

typedef long long ll;
#ifdef LOCAL
    const int N = 105;
#else
    const int N = 2e5 + 105;
#endif

#define mid (l + r >> 1)
#define ls (rt << 1)
#define rs (rt << 1 | 1)
const int M = N + N;
int a[N], b[N], n;
int tr[M << 2];

void init(){
    set<int> se;
    for(int i = 1; i <= n; ++i) cin >> a[i], se.insert(a[i] + i);
    for(int i = 1; i <= n; ++i) cin >> b[i], se.insert(b[i] + i);
    map<int, int> ma;
    int tot = 0;
    for(auto it : se){
        ma[it] = ++tot;
    }
    for(int i = 1; i <= n; ++i) a[i] = ma[a[i] + i];
    for(int i = 1; i <= n; ++i) b[i] = ma[b[i] + i];
}
set<int>pos[N + N];
int p[N];
void add(int rt, int l, int r, int idx){
    if(l == r) { tr[rt]++; return; }
    if(idx <= mid) add(ls, l, mid, idx);
    else add(rs, mid + 1, r, idx);
    tr[rt] = tr[ls] + tr[rs];
}
int qr(int rt, int l, int r, int L ,int R){
    int res = 0;
    if(L <= l && R >= r){ return tr[rt]; }
    if(L <= mid)  res += qr(ls, l, mid, L, R);
    if(R > mid) res += qr(rs, mid + 1, r, L, R);
    return res;
}
void solve() {
    cin >> n;
    init();
    for(int i = 1; i <= n; ++i) pos[a[i]].insert(i);
    for(int i = 1; i <= n; ++i){
        if(pos[b[i]].size() == 0) {
            cout << -1 << endl; return;
        }
        auto it = pos[b[i]].begin();
        p[i] = *it;
        pos[b[i]].erase(it);
    }
    ll ans = 0;
    for(int i = 1; i <= n; ++i){
        ans += qr(1, 1, n, p[i], n);
        add(1, 1, n, p[i]);
    }
    cout << ans << endl;
}
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    cout << "start Debug" << endl;
#endif
    ios::sync_with_stdio(0), cin.tie(0);
    int _ = 1;
    // cin >> _;
    for(int i = 1; i <= _; ++i) solve();
}

#include<iostream>
#include<list>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
};

// pair 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const pair<T,S>& p){
  cout << "(" << p.first << "," << p.second << ")";
  return os;
}

// map 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const map<S,T>& mp){
  for(const pair<S,T>& x: mp){
    cout << "[" << x.first << "]=" << x.second << " ";
  }
  return os;
}

struct segtree{
  int n;
  vector<int> vec;

  segtree(int nn){
    n=nn;
    vec.resize(2*n,0);
  }

  int get(int i){ return vec[i+n]; };
  void set(li a,int i){
    i+=n;
    vec[i]=a;
    while(i>1){
      i/=2;
      vec[i]=vec[i*2]+vec[i*2+1];
    }

  };
  int sum(int i,int j){
    // [i,j)
    if(df)print(i,j);
    int s=0;
    i=i+n; j=j+n;

    while(i<j){
      if(i%2){ if(df) print(i); s+=vec[i]; i++; }
      if(j%2){ j--; s+=vec[j]; if(df) print(j); }
      i/=2; j/=2;
    }
    return s;
  }

};

std::ostream& operator<<(std::ostream& os, const segtree& s){
  rep(i,2*s.n) printf("%ld ",s.vec[i]);
  return os;
}

int judge(map<li,int>& mpa,map<li,int>& mpb){
  int f=1;
  int t=0;
  for(auto& x:mpa){
    if(mpb[x.first]!=x.second) f=0;
    if(df)print(x,mpb[x.first],"->",f);
  }
  return f;
}

int main(){
  int n; cin >>n;
  vector<li> a(n);
  map<li,int> mpa;
  rep(i,n){
    li c; cin >>c;
    a[i]=c+i;
    mpa[a[i]]++;
  }
  if(df)print(mpa);
  vector<li> b(n);
  map<li,int> mpb;
  rep(i,n){
    li c; cin >>c;
    b[i]=c+i;
    mpb[b[i]]++;
  }
  if(df)print(mpb);

  if(!judge(mpa,mpb)){
    print(-1);
    return 0;
  }
  map<li,list<int>> mp;
  rep(i,n){
    mp[b[i]].push_back(i);
  }
  if(df)print(mp);
  rep(i,n){
    int t=mp[a[i]].front();
    mp[a[i]].pop_front();
    a[i]=t;
  }
  if(df)print(a);

  segtree sgt(n);
  li ans=0;
  rep(i,n){
    ans+=sgt.sum(a[i],n);
    sgt.set(1,a[i]);
    if(df)print(sgt, sgt.sum(a[i],n));
  }
  print(ans);

}


#include <bits/stdc++.h>

using namespace std;

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

#define eps 1e-9
#define INF 2000000000              // 2e9
#define LLINF 2000000000000000000ll // 2e18 (llmax:9e18)
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))

#ifndef LOCAL
#define dmp(...) ;
#else
#define dmp(...)                                                               \
  cerr << "[ " << #__VA_ARGS__ << " ] : " << dump_str(__VA_ARGS__) << endl
#endif

// ---------------- Utility ------------------

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;

template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

// ----------------- Input -------------------

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

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

// ----------------- Output ------------------

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  return os << p.first << ',' << p.second;
}

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

template <class T>
ostream &operator<<(ostream &os, const deque<T> &d) {
  for (const T &e : d) os << e << " ";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const set<T> &s) {
  os << "{ ";
  for (const T &e : s) os << e << " ";
  return os << "}";
}

template <class T, class U>
ostream &operator<<(ostream &os, const map<T, U> &m) {
  os << "{ ";
  for (const auto &[key, val] : m) os << "( " << key << " -> " << val << " ) ";
  return os << "}";
}

template <class TupleTy, size_t... I>
void dump_tuple(ostream &os, const TupleTy t, std::index_sequence<I...>) {
  (..., (os << (I == 0 ? "" : ",") << std::get<I>(t)));
}

template <class... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t) {
  os << "(";
  dump_tuple(os, t, std::make_index_sequence<sizeof...(Args)>());
  return os << ")";
}

void dump_str_rec(ostringstream &) {}

template <class Head, class... Tail>
void dump_str_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << ", " << head;
  dump_str_rec(oss, forward<Tail>(tail)...);
}

template <class T, class... U>
string dump_str(T &&arg, U &&... args) {
  ostringstream oss;
  oss << arg;
  dump_str_rec(oss, forward<U>(args)...);
  return oss.str();
}

// --------------- Fast I/O ------------------

void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

// ------------ End of template --------------

#define endl "\n"

bool check(int x) {
  int tmp = x;
  while (tmp) {
    if (tmp % 10 == 7) return false;
    tmp /= 10;
  }
  tmp = x;
  while (tmp) {
    if (tmp % 8 == 7) return false;
    tmp /= 8;
  }
  return true;
}

void solve() {
  int ans = 0;
  int N;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    if (check(i)) ans++;
  }
  cout << ans << endl;
  return;
}

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

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int count = 0;
    for (int i = 1; i <= n; i++)
    {
        int i10 = i, i8 = i;
        bool flag = false;
        while (i10 > 0)
        {
            if (i10 % 10 == 7)
            {
                flag = true;
            }
            i10 /= 10;
        }
        while (i8 > 0)
        {
            if (i8 % 8 == 7)
            {
                flag = true;
            }
            i8 /= 8;
        }
        if (flag)
        {
            count++;
        }
    }
    cout << n - count << endl;
}


#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define deb(...)
#endif
#define int long long int
#define endl '\n'

void solve() {

    int n, k;
    cin >> n >> k;
    vector<pair<int, int>>v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }
    sort(v.begin(), v.end());
    vector<pair<int, int>>req;
    for (int i = 0; i < n; i++) {
        int sum = 0;
        int zx = v[i].first;
        while (i < n && v[i].first == zx) {
            sum += v[i].second;
            i++;
        }
        i--;
        req.push_back({zx, sum});
    }
    sort(req.begin(), req.end());
    v.clear();
    v = req;
    n = v.size();
    // deb(v)
    int ans = 0;
    if (k >= v[0].first) {
        k -= v[0].first;
        k += v[0].second;
        for (int i = 1; i < n; i++) {
            if (k >= (v[i].first - v[i - 1].first)) {

                k -= (v[i].first - v[i - 1].first);
                k += (v[i].second);
            }
            else {
                cout << v[i - 1].first + k << endl;
                return;
            }
        }
        if (k >= 0) {
            cout << v.back().first + k << endl;
        }
    }
    else {
        cout << k;
    }

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

#include<bits/stdc++.h>
using namespace std;
int main(void) {
	int n;
	long long k;
	long long x, y;
	vector<pair<long long, long long> >a;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		a.push_back({ x,y }); //a[i].first=A_i, a[i].second=B_i
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; i++) {
		if (a[i].first > k)break;
		k += a[i].second;
	}
	cout << k << endl;
	return 0;
}


#include <bits/stdc++.h>
#define PB push_back
#define MP(x,y) make_pair(x,y)
#define F first
#define S second
#define loop(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rloop(i,m,n) for(int i=(int)(m) ; i > (int) (n) ; --i )
#define lp(i,n) loop(i,0,n)
#define rlp(i,n) rloop(i,n,0)
#define mod 1000000007
using namespace std;
typedef long long int lli;
typedef pair<int,int> pii;
int main(){
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    int N;
    scanf("%d", &N);
    vector<pair<int, lli> > edges[N];
    int u, v;
    lli w;
    lp(i, N-1) {
        scanf("%d%d%lld", &u, &v, &w);
        --u; --v;
        edges[u].PB(MP(v,w));
        edges[v].PB(MP(u,w));
    }
    vector<lli> XOR(N);
    vector<bool> visited(N, false);
    queue<pair<int, lli> > q;
    lli d;
    q.push(MP(0, 0));
    visited[0] = true;
    while (!q.empty()) {
        u = q.front().F;
        d = q.front().S;
        q.pop();
        XOR[u] = d;
        for(vector<pair<int, lli> >::iterator it = edges[u].begin(); it != edges[u].end(); ++it) {
            v = it->F;
            w = it->S;
            if (visited[v]) continue;
            visited[v] = true;
            q.push(MP(v, d^w));
        }
    }
    lli ans = 0, add, cnt;
    lp(bit, 60) {
        cnt = 0;
        lp(i, N)
            if (XOR[i]&(((lli)1)<<bit)) ++cnt;
        add = ((((lli)1)<<bit)%mod)*cnt;
        add %= mod;
        add = add * (N-cnt);
        add %= mod;
        // printf("%d %lld %lld\n", bit, cnt, add);
        ans += add%mod;
        ans %= mod;
    }
    // lp(i, N) {
    //     loop(j, i+1, N) {
    //         ans += XOR[i]^XOR[j];
    //         ans %= mod;
    //     }
    // }
    printf("%lld", ans);
    return 0;
}

/*
 *
 *   1 0 0 1 1 0 A
 *   0 0 1 1 0 1 B
 *
 *   1 0 1 0 1 1 A ^ B
 *   1 0 0 1 1 0 A
 * 1 0 1 0 0 0 1 A + A^B
 *
 * 0 0 1 1 0 1 0 2B
 *
 * 1 0 0 1 1 0 0 2A
 *
 *
 * 010
 * 011
 * 001
 *
 * 001
 * 011
 * 010
 *
 */

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

#ifdef LOCAL
#include <debugger.h>
#else
#define dbg(x...) {}
#define dbg_t()   {}
#endif

using ll = long long;
using ld = long double;

const ll INF = 1e18;

const ll MOD = 1e9+7;

namespace mod_op
{
  ll madd(ll a, ll b)
  {
    return (a + b) % MOD;
  }

  ll mmul(ll a, ll b)
  {
    return ((a % MOD) * (b % MOD)) % MOD;
  }

  ll msub(ll a, ll b)
  {
    return (((a - b) % MOD) + MOD) % MOD;
  }

  ll mpow(ll a, ll b)
  {
    a %= MOD;
    ll res = 1;
    while (b > 0)
    {
      if (b & 1)
        res = mmul(res, a);
      a = mmul(a, a);
      b >>= 1;
    }
    return res;
  }

  ll minv(ll a)
  {
    return mpow(a, MOD - 2);
  }

  ll mdiv(ll a, ll b)
  {
    return mmul(a, minv(b));
  }
}

using namespace mod_op;

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

  vector<vector<array<ll, 2>>> graph(n);

  for (ll i = 0; i < n - 1; i++)
  {
    ll u, v, w; cin >> u >> v >> w;
    u--; v--;
    graph[u].push_back({v, w});
    graph[v].push_back({u, w});
  }

  vector<ll> c(n, 0);

  function<void(ll, ll)> dfs = [&](ll v, ll p)
  {
    for (auto x: graph[v])
    {
      if (x[0] != p)
      {
        c[x[0]] ^= (x[1] ^ c[v]);
        dfs(x[0], v);
      }
    }
  };

  dfs(0, -1);

  ll ans = 0;

  vector<vector<ll>> v(n, vector<ll>(62, 0));

  for (ll i = 0; i < n; i++)
  {
    bitset<62> bs(c[i]);
    for (ll j = 0 ; j < 62; j++)
    {
      v[i][j] = (bs[j] == 1);
      if (i > 0)
      {
        v[i][j] += v[i - 1][j];
        if (bs[j] == 1)
          ans = madd(ans, mmul(i - v[i - 1][j], mpow(2, j)));
        else
          ans = madd(ans, mmul(v[i - 1][j], mpow(2, j)));
      }
    }
  }

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

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

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

  ll _t = 1;
  // cin >> _t;
  for (ll i = 1; i <= _t; i++)
  {
    // cout << "Case #" << i << ": ";
    solve();
  }

  dbg_t();

  return 0;
}


#include <cstdio>

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

const int MAXN = 105;

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

template<typename _T>
void write( _T x )
{
	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }
	if( 9 < x ){ write( x / 10 ); }
	putchar( x % 10 + '0' );
}

char typ[MAXN][MAXN];
char in[MAXN];
int N, K;

char Compete( const char a, const char b )
{
	if( a == b ) return a;
	if( a == 'P' ) return b == 'R' ? a : b;
	if( a == 'S' ) return b == 'P' ? a : b;
	if( a == 'R' ) return b == 'S' ? a : b;
}

int main()
{
	read( N ), read( K );
	scanf( "%s", in + 1 );
	for( int i = 1 ; i <= N ; i ++ ) typ[i][0] = in[i];
	int stp = 1;
	for( int j = 1 ; j <= K ; j ++, stp = stp * 2 % N )
		for( int i = 1 ; i <= N ; i ++ )
			typ[i][j] = Compete( typ[i][j - 1], typ[( i + stp - 1 ) % N + 1][j - 1] );
	putchar( typ[1][K] ), putchar( '\n' );
	return 0;
}

/*
	JAI JAGANNATH!
*/
//@Author : zanj0

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

#define int 			long long int

#define ff              first
#define ss              second
#define pb              push_back
#define MOD             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define endl       		"\n"
#define timetaken cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n"

void zanj0()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
const int N = 1e5 + 5;
vector <vector <int> > graph[N];
int n;
map <int, set <int> > divs;

int dijkstra(int src) {
	priority_queue < pair <int, int>, vector < pair <int, int> >, greater < pair <int, int> > > pq;
	pq.push({0, src});
	vector <int> dist(n + 1, inf);
	while (!pq.empty()) {
		pair <int, int> node = pq.top();
		pq.pop();
		if (node.ff >= dist[node.ss]) continue;
		dist[node.ss] = node.ff;
		for (auto& it : graph[node.ss]) {
			int nxt = it[0];
			for (auto &it2 : divs[it.back()]) {
				int val = it2 + 1;
				int extra = it2 - dist[node.ss];
				int ndist = it[1] + (it.back() / val) + extra + dist[node.ss];
				if (extra < 0) {
					ndist = it[1] + (it.back() / (dist[node.ss] + 1)) + dist[node.ss];
				}
				if (ndist < dist[nxt]) {
					pq.push({ndist, nxt});
				}
			}
		}
	}
	return dist.back();
}
set <int> getDivs(int x) {
	set <int> ret;
	ret.insert(sqrt(x));
	ret.insert(sqrt(x) + 1);
	if (sqrt(x) > 0) ret.insert((sqrt(x) - 1));
	return ret;
}
void solve() {
	cin >> n;
	int m;
	cin >> m;
	for (int i = 0; i < m; i++) {
		int u, v, x, y;
		cin >> u  >> v >> x >> y;
		graph[u].pb({v, x, y});
		graph[v].pb({u, x, y});
		if (!divs.count(y)) divs[y] = getDivs(y);
	}
	int ret = dijkstra(1);
	if (ret == inf) ret = -1;
	cout << ret << endl;
}
int32_t main()
{
	zanj0();
	solve();
	timetaken;
	return 0;
}