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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

void solve(long long N, std::vector<long long> A){
    map<int, int> memo;
    REP(i, N) {
        if(memo.count(A[i]) == 0) {
            memo[A[i]] = 0;
        }

        memo[A[i]]++;
    }

    VLL beki;
    LL idx = 1;
    while(idx <= 2000000000LL) {
        beki.PB(idx);
        idx *= 2LL;
    }

    sort(ALL(A));
    A.erase(unique(ALL(A)), A.end());
    int ans = 0;
    RREP(i, A.size()-1) {
        REP(j, beki.size()) {
            int idx = beki[j] - A[i];
            if(memo.count(idx) == 1) {
                if(A[i] == idx) {
                    int add_ans = memo[idx] / 2;
                    memo[idx] -= add_ans * 2;
                    ans += add_ans;
                } else {
                    int add_ans = min(memo[idx], memo[A[i]]);
                    memo[idx] -= add_ans;
                    memo[A[i]] -= add_ans;
                    ans += add_ans;
                }
            }
        }
    }

    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

void debug_out() { cerr << endl; }

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

#define rep(i,n) for (int i = 0; i < n; ++i)
#define reps(i,s,n) for (int i = s; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define per1(i,n) for (int i = n; i >= 1; --i)
#define all(c) begin(c),end(c)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef tuple<int,int,int> Tint;
typedef pair<ll,ll> PL;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
#define print(a) cout << a << endl;
template<typename T> void printv(vector<T>&v) {
    int n = v.size() - 1;
    rep(i, n) cout << v[i] << " ";
    cout << v.back() << endl;
}
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
// if(nextH >= 0 && nextH < H && nextW >= 0 && nextW < W)
static const long double pi = acos(-1.0);
typedef complex<ld> cd;

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

    int N; cin >> N;
    vector<ll> A(N);
    unordered_map<ll, int> cnt;
    rep(i, N) {
        cin >> A[i];
        ++cnt[A[i]];
    }
    sort(all(A), greater<ll>());

    int ans = 0;
    rep(i, N) {
        ll cur = A[i];
        if(cnt[cur] == 0) continue;

        ll power = 2;
        while(power <= cur) {
            power *= 2;
        }
        ll need = power - cur;
        if(cnt[need] > (need == cur ? 1 : 0)) {
            // debug(cur, need);
            ++ans;
            --cnt[cur];
            --cnt[need];
        }
    }

    print(ans);
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
using namespace std;

typedef long long ll;
typedef short int sh;

const int inf=0x3f3f3f3f;
const int MAX=1e5+10;
const int mod=1e9+7;

int position[26][MAX],Size[26];
char str[MAX];

void Get_Pos()
{
    memset(Size,0,sizeof(Size));
    for(int i=0;str[i];i++)
    {
        int k=str[i]-'a';
        position[k][Size[k]++]=i;
    }
}

void Solve()
{
    for(int i=0;i<26;i++)
    {
        for(int j=0;j<Size[i]-1;j++)
        {
            for(int k=j+1;k<Size[i];k++)
            {
                if(((k-j+1)<<1)>position[i][k]-position[i][j]+1)
                {
                    printf("%d %d\n",position[i][j]+1,position[i][k]+1);
                    return;
                }
            }
        }
    }
    printf("-1 -1\n");
}

int main()
{
    int n;
    while(scanf("%s",str)!=EOF)
    {
        Get_Pos();
        Solve();
    }
    return 0;
}

#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

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

  if (s.size() == 2){
    if (s[0] == s[1])
      cout << 1 << " " << 2 << endl;
    else
      cout << -1 << " " << -1 << endl;
  }
  else {
    ll n = s.size();
    for (int i = 0; i < n-2; i++){
      if (s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2]){
        cout << i+1 << " " << i + 3 << endl;
        return 0;
      }
    }

    cout << -1 << " " << -1 << endl;
  }

  return 0;
}


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

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

	string s;
	cin >> s;

	cout << s.replace(0,4,"2018") << endl;
	return 0;
}

#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};

int main() {
  string s; cin >>s;
  stack<int> sta;
  rep(i, s.size()){
    if (s[i] == 'T' && sta.size() > 0 && sta.top() == 0){
      sta.pop();
    }else{
      sta.push(s[i]-'S');
    }
  }
  int res = sta.size();
  cout <<res <<endl;
}


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

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>>grid(h+2, vector<int>(w+2,0));
	queue<pair<int, int>>black;
	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++) {
			char x;
			cin >> x;
			if (x == '.')grid.at(i).at(j) = 1e9;
			else black.push({ i, j });
		}
	}
	while (black.size() >= 1) {
		int x = black.front().first;
		int y = black.front().second;
		if (grid.at(x - 1).at(y) > grid.at(x).at(y) + 1) {
			grid.at(x - 1).at(y) = grid.at(x).at(y) + 1;
			black.push({ x - 1,y });
		}
		if (grid.at(x + 1).at(y) > grid.at(x).at(y) + 1) {
			grid.at(x + 1).at(y) = grid.at(x).at(y) + 1;
			black.push({ x + 1,y });
		}
		if (grid.at(x).at(y - 1) > grid.at(x).at(y) + 1) {
			grid.at(x).at(y - 1) = grid.at(x).at(y) + 1;
			black.push({ x,y - 1 });
		}
		if (grid.at(x).at(y + 1) > grid.at(x).at(y) + 1) {
			grid.at(x).at(y + 1) = grid.at(x).at(y) + 1;
			black.push({ x,y + 1 });
		}
		black.pop();
	}
	int ans = 0;
	for (int i = 1; i < h + 1; i++) {
		for (int j = 1; j < w + 1; j++) {
			ans = max(ans, grid.at(i).at(j));
		}
	}
	cout << ans << endl;
}

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

int main(){
    std::vector<string> d(3);
    for(ll i=0;i<3;++i){
        cin>>d[i];
    }
    ll a=0,b=0,c=0;
    char now='a';
    while(1){
        switch(now){
            case 'a':
                if(a>=d[0].length()){
                    cout<<char(now+'A'-'a');
                    return 0;
                }
                now=d[0][a];
                a++;
            break;
            case 'b':
                if(b>=d[1].length()){
                    cout<<char(now+'A'-'a');
                    return 0;
                }
                now=d[1][b];
                b++;
            break;
            case 'c':
                if(c>=d[2].length()){
                    cout<<char(now+'A'-'a');
                    return 0;
                }
                now=d[2][c];
                c++;
            break;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,m,r,s,k,c1,c2,c3,c4,i;
    cin>>n;
    cout<<pow(n,2)+pow(n,3)+n<<endl;
}


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

string t1;
int main(){
	for(int i = 0 ; i < 26 ; i++) t1 += 'a'+i,t1 += 'A'+i;
	sort(t1.begin(),t1.end());
	rotate(t1.begin(),t1.begin()+26,t1.end());
	int n;
	while(cin >> n && n){
		vector<int> k(n);
		string s;
		for(int i = 0 ; i < n ; i++) cin >> k[i];
		cin >> s;
		for(int i = 0 ; i < s.size() ; i++){
			int p = k[i%n];
			int pos = t1.find(s[i]);
			int hoge = (pos - p) % 52 + 52;
			hoge %= 52;
			cout << t1[hoge];
		}
		cout << endl;
	}
}

#include<iostream>
#include<algorithm>

using namespace std;

int main(void){
    int a,b,c,n,m,i,o,p,q,r,test[1000][3],num,chk[300];
    cin >> a >> b >> c;
    m = a+b+c;
    while(m!=0){
        for(i=0; i<m; i++){
            chk[i] = 2;
        }
        cin >> n;
        num = 0;
        for(i=0; i<n; i++){
            cin >> o >> p >> q >> r;
            o--;
            p--;
            q--;
            if(r==1){
                chk[o] = 1;
                chk[p] = 1;
                chk[q] = 1;
            }else{
                test[num][0] = o;
                test[num][1] = p;
                test[num][2] = q;
                num++;
            }
        }
        for(i=0; i<num; i++){
            o = test[i][0];
            p = test[i][1];
            q = test[i][2];
            if(chk[o]==2 && chk[p]==1 && chk[q]==1){
                chk[o] = 0;
            }else if(chk[o]==1 && chk[p]==2 && chk[q]==1){
                chk[p] = 0;
            }else if(chk[o]==1 && chk[p]==1 && chk[q]==2){
                chk[q] = 0;
            }
        }
        for(i=0; i<m; i++){
            cout << chk[i] << endl;
        }
        cin >> a >> b >> c;
        m = a+b+c;
    }
    return 0;
}


#include <iostream>

using namespace std;

typedef long long ll;

const ll mod = 998244353;

int n;
int a[305];
ll dp[305][90005];
ll dp2[305][90005];

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

int main() {
  cin >> n;
  int sum = 0;
  int maxa = 0;
  for(int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
    maxa = max(maxa,a[i]);
  }

  dp[0][0] = 1;

  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= i * maxa; j++) {
      if(dp[i][j] == 0) continue;
      dp[i+1][j] = (dp[i+1][j] + dp[i][j] * 2) % mod;
      dp[i+1][j+a[i]] = (dp[i+1][j+a[i]] + dp[i][j]) % mod;

    }
  }
  dp2[0][0] = 1;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j <= i * maxa; j++) {
       if(dp2[i][j] == 0) continue;
      dp2[i+1][j] = (dp2[i+1][j] + dp2[i][j]) % mod;
      dp2[i+1][j+a[i]] = (dp2[i+1][j+a[i]] + dp2[i][j]) % mod;
    }
  }

  ll ans = p(3,n);
  for(int i = 0; i <= n * maxa; i++) {
    if(i >= sum - i) {
      ans = (ans + mod - dp[n][i] * 3 % mod) % mod;
    }
    if(i == sum - i) {
      ans = (ans + dp2[n][i] * 3 % mod) % mod;
    }
  }
  if(ans < 0 ) cout << ans + mod << endl;
  else
  cout << ans << endl;
}


#include <bits/stdc++.h>

int main() {
  int n; std::cin >> n;
  std::vector<std::string> a(n);
  for (int i = 0; i < n; ++i) std::cin >> a[i];
  // int n = 5;
  // std::vector<std::string> a{"7.5", "2.4", "17.000000001", "17", "16.000000000"};

  /* ピリオドをすべての文字列に加える */
  for (int i = 0; i < n; i++)
    if (a[i].find('.') == std::string::npos) // ピリオドの有無
      a[i].push_back('.');                   // ピリオドを末尾に加える

  /* key:val = (c2, c5):cnt */
  std::map<std::pair<int, int>, int> p;

  /* aの素因数2と5の数を数える */
  for (int i = 0; i < n; i++) {
    // a[i].length() => 文字列の長さ
    // a[i].find('.') => .(ピリオド)が存在すればその位置, なければstd::string::npos

    // std::cout << a[i] << " " <<  a[i].length() - a[i].find('.') - 1 << std::endl;
    /* 小数点以下の数 */
    int d_cnt = a[i].length() - a[i].find('.') - 1;
    int c2 = -d_cnt; // 2の数を-d_cntで初期化
    int c5 = -d_cnt; // 5の数を-d_cntで初期化

    /* 文字を数字に変換 */
    a[i].replace(a[i].find('.'), 1, ""); // .(ピリオド)を削除 str.replace(開始位置, 長さ, 置き換え後の新たな文字列)
    long long a_ll = std::stoll(a[i].c_str()); // long longに変換

    /* 2の数を取得 */
    while (a_ll%2 == 0) {
      ++c2;
      a_ll /= 2;
    }
    /* 5の数を取得 */
    while (a_ll%5 == 0) {
      ++c5;
      a_ll /= 5;
    }

    /* mapに key:val = (c2, c5):数 保持 */
    p[std::pair<int, int>(c2, c5)]++; // keyが存在しない場合は0が追加される
  }

  /* チェック */
  // for (auto itr = p.begin(); itr != p.end(); ++itr)
  //   // std::cout << "(" << (*itr).first.first << ", " << (*itr).first.second << ")"
  //   //           <<  " " << (*itr).second << std::endl;
  //   std::cout << "(" << itr->first.first << ", " << itr->first.second << ")"
  //             <<  " " << (*itr).second << std::endl;

  long long cnt = 0;
  for (auto itr_1 = p.begin(); itr_1 != p.end(); ++itr_1) {
    int c2_1 = itr_1->first.first;
    int c5_1 = itr_1->first.second;
    int cnt_1 = itr_1->second;

    if (c2_1 >= 0 && c5_1 >= 0)
      cnt += (long long)cnt_1 * (cnt_1-1)/2;

    // if (itr_1->first.first >= 0 && itr_1->first.second >= 0)
    //   cnt += itr_1->second*(itr_1->second-1)/2;

    for (auto itr_2 = std::next(itr_1, 1); itr_2 != p.end(); ++itr_2) {
    int c2_2 = itr_2->first.first;
    int c5_2 = itr_2->first.second;
    int cnt_2 = itr_2->second;
      if (c2_1 + c2_2 >= 0 && c5_1 + c5_2 >= 0)
        cnt += (long long)cnt_1 * cnt_2;
      // if (itr_1->first.first + itr_2->first.first >= 0 && itr_1->first.second + itr_2->first.second >= 0)
      //   cnt += itr_1->second * itr_2->second;
    }

  }
  std::cout << cnt << std::endl;

  return 0;
}

#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];

    vector<vector<ll> > fac(n+1, vector<ll>());
    for (int i = 1; i <= n; i++) {
        // fac[i]にiの約数を入れる
        for (int j = 1; i * j <= n; j++) {
            fac[i * j].push_back(i);
        }
    }

    vector<ll> c(n + 1);
    vector<ll> res;
    for (int i = n; i >= 1; i--) {
        int ai = a[i - 1];
        if (ai != c[i] % 2) {
            res.push_back(i);
            for (int f: fac[i]) {
                c[f]++;
            }
        }
    }

    if (res.size() <= 0) {
        put(0);
        return;
    }

    reverse(all(res));
    put(res.size());
    rep(i, res.size()) cout << res[i] << (i == res.size() - 1 ? "" : " ");
    cout << endl;
}
signed main(){ Main();return 0;}


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

string replaceAll(string s, string f, string t) {
  string r;
  for (int p = 0; (p = s.find(f)) != s.npos; ) {
    r += s.substr(0, p) + t;
    s = s.substr(p + f.size());
  }
  return r + s;
}

int main(){
  string s;
  int n;
  cin>>n;
  getline(cin,s);
  while(n--){
    getline(cin,s);
    cout<<replaceAll(s,string("Hoshino"),string("Hoshina"))<<endl;
  }
}

#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

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

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;

const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    for (auto &i : s) {
        if (i == '7') {
            cout << "Yes\n";
            rr;
        }
    }
    cout << "No\n";
}


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

int main() {
  int n,m;
  cin >> n >> m;
  if(n == m){
    cout << 2*m;
  }
  else{
    cout << 2*max(m,n)-1;
  }
}

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

int main() {
	int A,B;
	cin >> A>>B;
	int ans = 0;
	for (int n = 0;n<2; ++n) {
		if (A > B) {
			ans += A;
			--A;
		}
		else {
			ans += B;
			--B;
		}
	}
	cout << ans<<endl;
	return 0;
}


#include <string>
#include <iostream>
#include <map>

class Baseball{
    private:
        int score;
        int out;
        int runner;
        int inning;

    public:
        Baseball(); //コンストラクタ
        int getScore() { return score; }
        int addScore(int score) { score += score; }
        int getInning() { return inning; }
        bool addOut(); //アウトを加える，チェンジならtrue
        void moveOnRunner(); //ヒット時にランナーを進塁させる
        void slamHomeRun(); //ホームランを打ったとき
        void changeInning(); //イニングを変える，スコア, ランナーも0に戻す
};
Baseball::Baseball(){
    score = 0;
    out = 0;
    runner = 0;
    inning = 1;
}

bool Baseball::addOut(){
    out = (out + 1) % 3;
    return out == 0 ? true : false;
}

void Baseball::moveOnRunner(){
    if(runner < 3){
        runner++;
    } else if(runner == 3){
        runner = 3;
        score += 1;
    }
}

void Baseball::slamHomeRun(){
    score += (runner + 1);
    runner = 0;
}

void Baseball::changeInning(){
    score = 0;
    runner = 0;
    inning += 1;
}

int main(){
    Baseball b;
    int totalInning = 0;
    bool change_flag = false;
    std :: string event;
    std :: map<std :: string, int> map;

    map["HIT"] = 1;
    map["HOMERUN"] = 2;
    map["OUT"] = 3;

    std :: cin >> totalInning;
    std :: getline(std :: cin, event);
    while(b.getInning() <= totalInning){
        std :: getline(std :: cin, event);
        switch(map[event]){
            case 1:
                b.moveOnRunner();
                break;
            case 2:
                b.slamHomeRun();
                break;
            case 3:
                change_flag = b.addOut();
                break;
            default:
                break;
        }
        if(change_flag) {
            std :: cout << b.getScore() << std :: endl;
            b.changeInning();
            change_flag = false;
        }
    }
}

#include<cstdio>
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int point=0;
        int base=0;
        int out=0;
        while(out!=3){
            char s[8];
            scanf(" %s",s);
            switch(s[1]){
                case 'I':
                    base++;
                    if(base==4){
                        point++;
                        base--;
                    }
                    break;
                case 'U':
                    out++;
                    break;
                case 'O':
                    point+=base+1;
                    base=0;
                    break;
            }
        }
        printf("%d\n",point);
    }
    return 0;
}


#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main(){
	int h,w,s;
	while(true){
	cin>>h>>w;
	if(h==0&&w==0)
		break;
	bool t=true;
	s=h*h+w*w;
	h++;
	while(true){
		if(h*h>=s-h*h)
			break;
		if(s==h*h+(int)sqrt((double)s-h*h+0.0)*(int)sqrt((double)s-h*h+0.0)){
			t=false;
			break;
		}
		h++;
	}
	s++;
	if(t==true){
	while(true){
		h=1;
		while(true){
		if(h*h>=s-h*h)
			break;
		if(s==h*h+((int)sqrt((double)s-h*h+0.0)*(int)sqrt((double)s-h*h+0.0))){
			t=false;
			break;
		}
		h++;
		}
		if(t==false)
			break;
		s++;
	}
	}
	cout<<h<<" "<<(int)sqrt((double)s-h*h+0.0)<<endl;
	}
	return 0;
}

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

struct rectangle{
  int h, w;
  bool operator<(const rectangle &a)const{
    if(w*w + h*h == a.w*a.w + a.h*a.h)
      return h < a.h;
    return w*w + h*h < a.w*a.w + a.h*a.h;
  }
};

int main(){
  vector<rectangle> ans;
  for(int i = 1; i <= 150; i++) {
    for(int j = i + 1; j <= 150; j++) {
      rectangle r;
      r.h = i, r.w = j;
      ans.push_back(r);
    }
  }
  sort(ans.begin(), ans.end());
  for(int i = 0; i < 20; i++) {
    //cout << ans[i].h << " " << ans[i].w << endl;
}
  int h, w;
  while(cin >> h >> w, h){
    rectangle r;
    r.h = h, r.w = w;
    for(int i = 0; i < ans.size(); i++){
      if(r < ans[i]){
	cout << ans[i].h << " " << ans[i].w << endl;
	break;
      }
    }
  }
  return 0;
}


#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

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

  using D = tuple<int, int, int>;
  vector<D> data;
  rep(i, N) {
    int x, y;
    char d;
    cin >> x >> y >> d;

    int dir = 0;
    if (d == 'D' || d == 'U') {
      dir |= 2;
    }
    if (d == 'D' || d == 'L') {
      dir |= 1;
    }
    data.push_back(D(x, y, dir));
  }

  constexpr int INF = numeric_limits<int>::max();
  int result = INF;

  constexpr int MAX = 200'000;
  vector<vector<vector<int>>> tbl(4, vector<vector<int>>(MAX + 1));
  vector<vector<vector<int>>> cross(4, vector<vector<int>>(2 * MAX + 1)),
      cross2(4, vector<vector<int>>(2 * MAX + 1));
  rep(i, N) {
    int x, y, d;
    tie(x, y, d) = data[i];

    tbl[d][((d & 2) ? x : y)].push_back((d & 2) ? y : x);
    cross[d][x + y].push_back(x - y + MAX);
    cross2[d][x - y + MAX].push_back(x + y);
  }
  rep(i, 4) irep(j, MAX) { sort(tbl[i][j].begin(), tbl[i][j].end()); }

  rep(i, 4) irep(j, 2 * MAX) {
    sort(cross[i][j].begin(), cross[i][j].end());
    sort(cross2[i][j].begin(), cross2[i][j].end());
  }

  rep(i, 2) {
    irep(j, MAX) {
      for (int v : tbl[i << 1][j]) {
        const auto &tmp = tbl[(i << 1) ^ 1][j];
        auto iter = lower_bound(tmp.begin(), tmp.end(), v);
        if (iter != tmp.end()) {
          // cerr << i << " " << j << " " << v << " " << *iter << "\n";
          chmin(result, 5 * (*iter - v));
        }
      }
    }
  }

  rep(i, 2) {
    irep(j, 2 * MAX) {
      for (int v : cross[i][j]) {
        const auto &tmp = cross[i ^ 2][j];
        auto iter = lower_bound(tmp.begin(), tmp.end(), v);
        if (i == 0) {
          if (iter != tmp.end()) {
            cerr << i << " " << j << " " << v << " " << *iter << "\n";
            chmin(result, 5 * (*iter - v));
          }
        } else {
          if (iter != tmp.begin()) {
            chmin(result, 5 * (v - *prev(iter)));
          }
        }
      }
    }
  }

  rep(i, 2) {
    irep(j, 2 * MAX) {
      for (int v : cross2[i][j]) {
        const auto &tmp = cross2[i ^ 3][j];
        auto iter = lower_bound(tmp.begin(), tmp.end(), v);
        if (i == 0) {
          if (iter != tmp.end()) {
            chmin(result, 5 * (*iter - v));
          }
        } else {
          if (iter != tmp.begin()) {
            chmin(result, 5 * (v - *prev(iter)));
          }
        }
      }
    }
  }

  if (result == INF) {
    cout << "SAFE" << endl;
  } else {
    cout << result << endl;
  }
  return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<25)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()

int N;
int X[200000];
int Y[200000];
char U[200000];

int dir(char c) {
	return c == 'U' ? 0 : c == 'R' ? 1 : c == 'D' ? 2 : 3;
}

int near(int v, const set<int> &s) {
	int ret = INF;
	auto it = s.lower_bound(v);
	if (it != s.end()) {
		ret = min(ret, *it - v);
	}

	return ret;
}

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

	int ans = INF;

	cin >> N;
	rep(i, N)cin >> X[i] >> Y[i] >> U[i];

	{
		unordered_map<int, array<set<int>, 4>> d;
		rep(i, N) {
			int a = X[i];
			d[a][dir(U[i])].insert(Y[i]);
		}
		// U, D
		for (const auto& p : d) {
			const auto& layer = p.second;
			for (int y : layer[dir('U')]) {

				ans = min(ans, near(y, layer[dir('D')]) * 5);
 			}
		}
	}
	{
		unordered_map<int, array<set<int>, 4>> d;
		rep(i, N) {
			int a = Y[i];
			d[a][dir(U[i])].insert(X[i]);
		}
		// L, R
		for (const auto& p : d) {
			const auto& layer = p.second;
			for (int y : layer[dir('R')]) {
				ans = min(ans, near(y, layer[dir('L')]) * 5);
			}
		}
	}

	{
		unordered_map<int, array<set<int>, 4>> d;
		rep(i, N) {
			int a = X[i] + Y[i];
			d[a][dir(U[i])].insert(Y[i]);
		}

		// R, U
		for (const auto& p : d) {
			const auto& layer = p.second;
			for (int y : layer[dir('U')]) {
				ans = min(ans, near(y, layer[dir('R')]) * 10);
			}
		}
		// D, L
		for (const auto& p : d) {
			const auto& layer = p.second;
			for (int y : layer[dir('L')]) {
				ans = min(ans, near(y, layer[dir('D')]) * 10);
			}
		}
	}

	{
		unordered_map<int, array<set<int>, 4>> d;
		rep(i, N) {
			int a = X[i] - Y[i] + 200000;
			d[a][dir(U[i])].insert(Y[i]);
		}

		// L, U
		for (const auto& p : d) {
			const auto& layer = p.second;
			for (int y : layer[dir('U')]) {
				ans = min(ans, near(y, layer[dir('L')]) * 10);
			}
		}
		// D, R
		for (const auto& p : d) {
			const auto& layer = p.second;
			for (int y : layer[dir('R')]) {
				ans = min(ans, near(y, layer[dir('D')]) * 10);
			}
		}
	}

	if (ans == INF)cout << "SAFE" << endl;
	else cout << ans << endl;

	return 0;
}


#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  map<char, int> amap;
  for(int i=0;i<S.size();++i) {
    amap[S[i]]++;
  }
  char ans = 'A';
  for(char a='a';a<='z';++a) {
    if(amap[a]==0) {
      ans = a;
      break;
    }
  }
  if(ans=='A') cout<<"None"<<endl;
  else cout<<ans<<endl;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

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


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N;
    string S;
    cin >> N;

    ll D = N % 10;
    N = (N - D) / 10;
    ll C = N % 10;
    N = (N - C) / 10;
    ll B = N % 10;
    N = (N - B) / 10;
    ll A = N % 10;

    ll tmp = 0;

    bool flag = flase;

    REP(i,2){
        REP(j,2){
            REP(k,2){
                if(i==0){
                    tmp = A + B;
                }
                else{
                    tmp = A - B;
                }
                if (j == 0)
                {
                    tmp += C;
                }
                else
                {
                    tmp -= C;
                }
                if (k == 0)
                {
                    tmp += D;
                }
                else
                {
                    tmp -= D;
                }
                if(tmp==7){
                    cout << A;
                    if (i == 0)
                    {
                        cout << "+";
                    }
                    else
                    {
                        cout << "-";
                    }
                    cout << B;
                    if (j == 0)
                    {
                        cout << "+";
                    }
                    else
                    {
                        cout << "-";
                    }
                    cout << C;
                    if (k == 0)
                    {
                        cout << "+";
                    }
                    else
                    {
                        cout << "-";
                    }
                    cout << D;
                    cout << "=7" << endl;
                    flag = true;
                    break;
                }
            }
            if(flag){
                break;
            }
        }
        if (flag)
        {
            break;
        }
    }

}


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

using namespace std;

long long MOD = 1e9+7;
int MAX_INT = 1e9;

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

  int H, W, N;
  cin >> H >> W >> N;

  int max_len = max(H, W);
  if(N % max_len == 0) cout << (N / max_len) << endl;
  else cout << (N / max_len) + 1 << endl;

  return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long double ld;
typedef long long ll;
const int MOD =  1000000007;
const int IINF = INT_MAX;
const ll INF = 1LL << 60;

int main() {
    int h, w, n; cin >> h >> w >> n;

    int ans = IINF;
    for(int i = 0; i <= h; i++){
        for(int j = 0; j <= w; j++){
            int sum = i * h + j * w - i * j;
            if(sum >= n) ans = min(ans, i + j);
        }
    }
    cout << ans << endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;

using ll = long long;

const int N = (int)1e5 + 5, LOG = 60;
int n, x[N], m, a[N], d[N], per[N], jump[N][LOG], finalPos[N], updPos[N], finalD[N];
ll K, ans[N];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", x + i);
    scanf("%d %lld", &m, &K);
    for (int i = 1; i <= m; ++i) scanf("%d", a + i);

    for (int i = 1; i <= n; ++i) d[i] = x[i] - x[i - 1];

    for (int i = 1; i <= n; ++i) per[i] = i;
    for (int i = 1; i <= m; ++i) swap(per[ a[i] ], per[ a[i] + 1 ]);
    for (int i = 1; i <= n; ++i) jump[ per[i] ][0] = i;

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

    for (int i = 1; i <= n; ++i) finalPos[i] = i;
    for (int j = LOG - 1; j >= 0; --j) if ( (K >> j) & 1) {
        for (int i = 1; i <= n; ++i) updPos[i] = jump[ finalPos[i] ][j];
        swap(finalPos, updPos);
    }

    for (int i = 1; i <= n; ++i) finalD[ finalPos[i] ] = d[i];

    for (int i = 1; i <= n; ++i) cout << (ans[i] = ans[i - 1] + finalD[i]) << '\n';

    return 0;
}

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

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;
const int maxn = 100 + 5;

int32_t main() {
    fastIO();

    int n, m;
    cin >> n >> m;

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

    vector<pair<pii, pii>> op;
    for (int i = 0; i < n; ++i) {
        if (i < n-1) {
            for (int j = 0; j < m; ++j) {
                if (vec[i][j] & 1) {
                    op.pb({{i+1, j+1}, {i+2, j+1}});
                    ++vec[i+1][j];
                }
            }
        }
        else {
            for (int j = 0; j < m-1; ++j) {
                if (vec[i][j] & 1) {
                    op.pb({{i+1, j+1}, {i+1, j+2}});
                    ++vec[i][j+1];
                }
            }
        }
    }

    cout << op.size() << "\n";
    for (auto x : op) cout << x.X.X << " " << x.X.Y << " " << x.Y.X << " " << x.Y.Y << "\n";

    return 0;
}


// you can use includes, for example:
#include <iostream>
#include <vector>
#include <algorithm>
#include <memory>
#include <unordered_map>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <sstream>
#include <set>
#include <cassert>
#include <map>

using namespace std;

constexpr int64_t kMod = 1e9 + 7;

int main(void) {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;

  auto calc = [](int n) {
    int64_t cur_x = 0;
    int64_t cur_sum_x = 0;
    for (int i = 0; i < n; i++) {
      int64_t x;
      cin >> x;
      if (i) {
        cur_sum_x += x * (i) - cur_x;
      }
      cur_x += x;
      cur_x %= kMod;
      cur_sum_x %= kMod;
    }
    return (cur_sum_x + kMod) % kMod;
  };

  auto x_sum = calc(n);
  auto y_sum = calc(m);
  cout << x_sum * y_sum % kMod << endl;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n;
string s;
bool bl[200010];
int cnt1, cnt2;
int cnt;
int ans = 1;

signed main() {
	cin >> n >> s;
	bl[0] = 0;
	cnt2++;
	for (int i = 1; i < 2 * n; i++) {
		if (s[i - 1] == s[i]) {
			if (bl[i - 1])bl[i] = false;
			else bl[i] = true;
		}
		else bl[i] = bl[i - 1];
		if (bl[i])cnt1++;
		else cnt2++;
	}
	if (s[0] == 'W' || s[2 * n - 1] == 'W' || cnt1 != cnt2) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < 2 * n; i++) {
		if (!bl[i])cnt++;
		else {
			ans *= cnt;
			ans %= mod;
			cnt--;
		}
	}
	ans *= kai(n, n);
	ans %= mod;
	cout << ans << endl;
}


#include <cstdio>
#include <cstdlib>
#include <iostream>

int main() {
	const int size = 21;
	char str[size];
	std::scanf("%s", &str);

	for (int i = size - 1; i >= 0; i--)
		if (48 <= str[i] && str[i] <= 57)
			std::cout << str[i];
		else if(97 <= str[i] && str[i] <= 122)
			std::cout << str[i];

	std::cout << std::endl;
}

#include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;

int main()
{
	string s,t;
	cin >> s;
	t = s;
	for (int i = 0; i < s.size(); i++) {
		t[i] = s[s.size() - i-1];
	}
	cout << t << endl;

}


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

int main() {
    string s;
    cin >> s;
    int ans = 7;
    string w[] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN" };
    for (unsigned int i = 0; i < 7; i++) {
        if(s == w[i]) {
            ans -= i;
        }
    }
    cout << ans << endl;
}

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

int main(){
	string s;
	cin>>s;
	if(s[0]=='S'){
		if(s[1]=='U') cout<<7;
		else cout<<1;
	}
	else if(s[0]=='M') cout<<6;
	else if(s[0]=='T'){
		if(s[1]=='U') cout<<5;
		else cout<<3;
	}
	else if(s[0]=='W') cout<<4;
	else if(s[0]=='F') cout<<2;
}


#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int main() {
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=0;
    ll x[n];
    rep(i,n){
        cin>>x[i];
    }
    rep(i,n-1){
        if ((x[i+1]-x[i])*a>b){
            ans+=b;
        }
        else{
            ans+=(x[i+1]-x[i])*a;
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

int main(){

  int m,a,b,t=0,s;

  while(cin>>m>>a>>b){
    t=0;
    if(m==0){
      break;
    }

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

  for(int i=a;i<=b;i++){
    if(t<=p[i-1]-p[i]){
      t=p[i-1]-p[i];
      s=i;
    }
  }

  cout<<s<<endl;

  }

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
 int main()
 {
     int x,y,i,j,n;
     deque<int >v;
     cin >> n;
     for(i = 0 ;i<n ;i++)
     {
         cin >> x;
         deque<int >:: iterator it;
         it = upper_bound(v.begin(),v.end(),x);
         if(v.begin()== it)
            v.push_front(x);
         else
            v[it -v.begin()]==x ;
     }
     cout<<v.size()<<endl;
 }

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
ll g[10][10];

signed main(){
	//cout << fixed << setprecision(10);
	int n; cin >> n;
    vl a(n);
    rep(i,0,n)cin >> a[i];
    ll m = MOD;
    ll ans = 0;
    rep(i,0,n){
        ans += (a[i] <= m);
        chmin(m,a[i]);
    }
    cout << ans << endl;
}


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

int main() {
    int n, y;
    cin >> n >> y;
    int a = -1, b = -1, c = -1;
    for (int i=0; i<=n; i++) {
        for (int j=0; i+j<=n; j++) {
            int k = n - i - j;
            if (10000 * i + 5000 * j + 1000 * k == y) {
                a = i; b = j; c = k;
            }
        }
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e6 + 5;
char s[maxn];
int sum[maxn];
int k[maxn];
vector<int> D;
vector<int> C;
int n;
ll slove(int k) {
    if (C.empty() || D.empty())
        return 0;
    ll ans=0;
    int j = 0;
    queue<int> q;
    int a, b;
    ll temp=0;
    for (int i = 0; i < D.size(); i++) {
        //将所有C的贡献调整
        if(i>0)
            temp-=(ll)q.size()*(sum[D[i]]-sum[D[i-1]]);
        //将跳过的C贡献调整
        if(!q.empty()) {
            int ft=q.front();
            while(ft<=D[i]) {
                temp+=sum[D[i]]-sum[D[i-1]];
                temp-=sum[ft]-sum[D[i-1]];
                q.pop();
                if(q.empty())
                    break;
                ft=q.front();
            }
        }
        //将无用的C排除
        while(j < C.size() &&C[j]<D[i]){
            j++;
        }
        //增加新的C
        while (j < C.size() && C[j] - D[i] < k) {
            q.push(C[j]);
            temp+=sum[C[j]]-sum[D[i]];
            j++;
        }
        ans+=temp;
    }
    return ans;
}
int main() {
    scanf("%d", &n);
    scanf("%s", s + 1);
    int q;
    scanf("%d", &q);
    for (int i = 1; i <= q; i++)
        scanf("%d", &k[i]);
    for (int i = 1; i <= n; i++) {
        if (s[i] == 'D')
            D.push_back(i);
        if (s[i] == 'C')
            C.push_back(i);
        if (s[i] == 'M')
            sum[i] = sum[i - 1] + 1;
        else
            sum[i] = sum[i - 1];
    }
//    cout<<"D";
//    for(auto x:D)cout<<x<<" ";cout<<endl;
//    cout<<"C";
//    for(auto x:C)cout<<x<<" ";cout<<endl;
    for (int i = 1; i <= q; i++) {
        printf("%lld\n", slove(k[i]));
    }
}

#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
#define all(x) begin((x)), end((x))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}

vector<ll> a;
ll n,m,v,p;
bool chk(int idx) {
    if (a[idx]+m<a[n-p]) {
        return false;
    }
    ll cnt = 0;
    rep(i,n) {
        if (i>n-p||i<=idx) {
            cnt += m;
        }
        else {
            cnt += max(0LL, a[idx]+m-a[i]);
        }
    }
    return cnt >= m*v;
}

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m>>v>>p;
    a.assign(n,0);
    rep(i,n) cin>>a[i];
    sort(all(a));
    ll l=0,r=n-1;
    while(r>l) {
        ll mid = (l+r)/2;
        if (chk(mid)) {
            r = mid;
        } else {
            l = mid;
        }
        if (l+1==r) {
            if (chk(l)) {
                r = l;
            } else {
                l = r;
            }
        }
    }
    cout << n-l << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
using namespace std;
const int MAX = 1e5 + 10;
const int MOD = 1e9 + 7;
int N, M, K, Q;
ll xA[MAX], yA[MAX];

int main()
{
	int i, j, k;
	scanf("%d%d", &N, &M);
	for (i = 1; i <= N; ++i) scanf("%lld", &xA[i]);
	for (i = 1; i <= M; ++i) scanf("%lld", &yA[i]);
	ll xsum, ysum;
	xsum = ysum = 0;
	for (i = 1; i < N; ++i) xsum = (xsum + (xA[i + 1] - xA[i]) * (ll)(N - i) %MOD * (ll)i % MOD) % MOD;
	for (i = 1; i < M; ++i) ysum = (ysum + (yA[i + 1] - yA[i]) * (ll)(M - i) %MOD * (ll)i % MOD) % MOD;
	printf("%lld", xsum*ysum %MOD);
}

#include<bits/stdc++.h>

using namespace std;

int ans, X, Y, N, M, dp[2][102][102][102], s[102][102];
char sir[102][102];

void U (int &x, int val) {if (val > x) x = val;}
int get_sub (int a1, int b1, int a2, int b2)
{
    if (a1 < 1) a1 = 1;
    if (b1 < 1) b1 = 1;
    if (a2 > N) a2 = N;
    if (b2 > M) b2 = M;
    if (a1 > a2 || b1 > b2) return 0;
    return s[a2][b2] - s[a1 - 1][b2] - s[a2][b1 - 1] + s[a1 - 1][b1 - 1];
}
int sum_lin (int i, int j1, int j2) {return get_sub (i, j1, i, j2);}
int sum_col (int j, int i1, int i2) {return get_sub (i1, j, i2, j);}
int intersect (int a1, int b1, int a2, int b2, int &st, int &dr) {st = max (a1, a2), dr = min (b1, b2);}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d\n", &N, &M);
for (int i=1; i<=N; i++)
    scanf ("%s\n", sir[i] + 1);
for (int i=1; i<=N; i++)
    for (int j=1; j<=M; j++)
    {
        s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + (sir[i][j] == 'o');
        if (sir[i][j] == 'E') X = i, Y = j;
    }
for (int l=0; l<Y; l++)
{
    for (int r=0; r<=M - Y; r++)
        for (int u=0; u<X; u++)
            for (int d=0; d<=N - X; d++)
                dp[(l & 1) ^ 1][r][u][d] = 0;
    for (int r=0; r<=M - Y; r++)
        for (int u=0; u<X; u++)
            for (int d=0; d<=N - X; d++)
            {
                int curr = dp[l & 1][r][u][d], st, dr;
                if (curr > ans) ans = curr;
                intersect (r + 1, M - l, Y - l, Y + r, st, dr);
                U (dp[l & 1][r][u][d + 1], curr + (X + d + 1 <= N - u) * sum_lin (X + d + 1, st, dr));
                U (dp[l & 1][r][u + 1][d], curr + (X - u - 1 >= 1 + d) * sum_lin (X - u - 1, st, dr));
                intersect (d + 1 , N - u, X - u, X + d, st, dr);
                U (dp[l & 1][r + 1][u][d], curr + (Y + r + 1 <= M - l) * sum_col (Y + r + 1, st, dr));
                U (dp[(l & 1) ^ 1][r][u][d], curr + (Y - l - 1 >= 1 + r) * sum_col (Y - l - 1, st, dr));
            }
}
printf ("%d\n", ans);
return 0;
}


#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>

typedef long double ld;
typedef long long ll;

using namespace std;

struct dish {
	ll x, y;

	dish(ll tx = 0, ll ty = 0) {
		x = tx;
		y = ty;
	}

	void read() {
		cin >> x >> y;
	}

	bool operator<(const dish & d) const {
		return (x + y > d.x + d.y);
	}
};

#define MAXN (1 << 17)

dish a[MAXN];
int n;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		a[i].read();
	}
	sort(a, a + n);
	ll ret = 0;
	for (int i = 0; i < n; i++) {
		if (i & 1) {
			ret -= a[i].y;
		} else {
			ret += a[i].x;
		}
	}
	cout << ret << endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int N;
  cin >> N;
  vector<ll> A(N), B(N), C(N);
  rep(i, N) {
    cin >> A[i] >> B[i];
    C[i] = A[i] + B[i];
  }
  sort(all(C), greater<ll>());
  ll sum = 0;
  rep(i, N) if(i%2==0) sum += C[i];
  cout << sum - accumulate(all(B), 0LL) << endl;
  return 0;
}


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

#define pb push_back
#define ll long long
#define maxn 1000005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int mod = 998244353;
int pa[100005][18];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int>v(n);
    for (auto &i : v) {
        cin >> i;
    }
    int  k;
    cin >> k;
    for (int i = 0 ; i < n ; i++) {
        int l = i, r = n;
        while (r - l > 1) {
            int mid = (l + r) >> 1;
            if (v[mid] - v[i] <= k) {
                l = mid;
            }
            else {
                r = mid;
            }
        }
        pa[i][0] = l;
    }
    for (int i = 1 ; i < 18 ; i++) {
        for (int j = 0 ; j < n ; j++) {
            pa[j][i] = pa[pa[j][i - 1]][i - 1];
        }
    }
    int t;
    cin >> t;
    while (t--) {
        int x , y;
        cin >> x >> y;
        x--, y--;
        if (x > y) {
            swap(x, y);
        }
        int l = 0, r = n;
        while (r - l > 1) {
            int mid = (l + r) >> 1;
            int tx = x;
            for (int i = 0 ; i < 18 ; i++) {
                if (mid & (1<<i)) {
                    tx = pa[tx][i];
                }
            }
            if (tx >= y) {
                r = mid;
            }
            else {
                l = mid;
            }
        }
        cout << r << '\n';
    }
}

#include <bits/stdc++.h>

#define DICE_SIZE 6

#define TOP    0
#define FRONT  1
#define RIGHT  2
#define LEFT   3
#define BACK   4
#define BOTTOM 5

using namespace std;

class Dice {
	private:
		int number[DICE_SIZE];
		int work_space[DICE_SIZE];

		void reset_number(int, int, int, int, int, int);

	public:
		Dice(int *);
		void turn(char);
		void turn_horizon();
		int peek(int);
		void set_top(int);
		int get_position(int);
		bool equals(Dice *);
};

Dice::Dice(int *number) {
	for (int i = 0; i < DICE_SIZE; i++) this->number[i] = number[i];
}

void Dice::turn(char direction) {
	for (int i = 0; i < DICE_SIZE; i++) work_space[i] = number[i];

	switch (direction) {
		case 'N':
			reset_number(work_space[1], work_space[5], work_space[2], work_space[3], work_space[0], work_space[4]);
			break;
		case 'E':
			reset_number(work_space[3], work_space[1], work_space[0], work_space[5], work_space[4], work_space[2]);
			break;
		case 'S':
			reset_number(work_space[4], work_space[0], work_space[2], work_space[3], work_space[5], work_space[1]);
			break;
		case 'W':
			reset_number(work_space[2], work_space[1], work_space[5], work_space[0], work_space[4], work_space[3]);
			break;
	}
}

void Dice::turn_horizon() {
	for (int i = 0; i < DICE_SIZE; i++) work_space[i] = number[i];

	reset_number(work_space[0], work_space[3], work_space[1], work_space[4], work_space[2], work_space[5]);
}

int Dice::peek(int position) {
	return number[position];
}

int Dice::get_position(int num) {
	for (int i = 0; i < DICE_SIZE; i++) {
		if (number[i] == num) return i;
	}
}

void Dice::reset_number(int num0, int num1, int num2, int num3, int num4, int num5) {
	number[0] = num0;
	number[1] = num1;
	number[2] = num2;
	number[3] = num3;
	number[4] = num4;
	number[5] = num5;
}

void Dice::set_top(int num) {
	int current_position = get_position(num);

	if (current_position == RIGHT || current_position == LEFT) {
		while (peek(TOP) != num) {
			turn('W');
		}
	} else {
		while (peek(TOP) != num) {
			turn('N');
		}
	}
}

bool Dice::equals(Dice *dice) {
	bool eql_flg = true;
	for (int i = 0; i < DICE_SIZE; i++) {
		if (peek(i) != dice->peek(i)) {
			eql_flg = false;
			break;
		}
	}

	return eql_flg;
}

bool check_all_pattern(Dice *dice1, Dice *dice2) {
	bool eql_flg = false;

	for (int i = 0; i < DICE_SIZE; i++) {
		dice1->set_top(dice1->peek(i));

		for (int j = 0; j < DICE_SIZE; j++) {
			dice2->set_top(dice2->peek(j));

			for (int k = 0; k < 4; k++) {
				if (dice1->equals(dice2)) {
					eql_flg = true;
					goto RETURN;
				}

				dice2->turn_horizon();
			}
		}
	}

	RETURN:
		return eql_flg;
}

int main() {
	int n;
	int number[DICE_SIZE];

	cin >> n;
	Dice *dices[n];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < DICE_SIZE; j++) cin >> number[j];

		dices[i] = new Dice(number);
	}

	bool is_along_flg = true;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) continue;

			if (check_all_pattern(dices[i], dices[j])) {
				is_along_flg = false;
				goto END;
			}
		}
	}

	END:
		cout << (is_along_flg ? "Yes" : "No") << endl;

	return 0;
}


#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;

int part(int a[],int p,int r){
    int x=a[r];
    int i=p-1;
    for (int j = p; j < r; ++j) {
        if (a[j]<=x){
            i+=1;
            swap(a[i],a[j]);
        }
    }
    swap(a[i+1],a[r]);
    return i+1;
}

int main() {
    int n,a[100000];
    scanf("%d",&n);
    for (int i = 0; i < n; ++i) {
        scanf("%d",&a[i]);
    }

    int pos=part(a,0,n-1);

    for (int j = 0; j <n ; ++j) {
        if (j>0)
            printf(" ");
        if (j==pos)
            printf("[");
        printf("%d",a[j]);
        if (j==pos)
            printf("]");
    }
    printf("\n");

    return 0;
}

#include <iostream>
#include <string>
#include <sstream>

int partition(int* arr, int n)
{
    const int x = arr[n - 1];   //pivot value
    int i = 0;  //increment if swaped
    int j = 0;  //increment every loop
    for (; j < n; ++j) {   //scan start to end
        if (arr[j] <= x) {
            std::swap(arr[i], arr[j]);
            ++i;
        }
    }
    return i - 1;
}

void print(int const* arr, const int n, int q, int i)
{
    if (i == n - 1 ) {
        std::cout << arr[i] << std::endl;
        return;
    }

    if (i == q) {
        std::cout << "[" << arr[i] << "] ";
    }
    else {
        std::cout << arr[i] << " ";
    }

    return print(arr, n, q, i + 1);
}

void print(int const* arr, const int n, int q)
{
    print(arr, n, q, 0);
    return;
}

int main()
{
    int n;
    {
        std::string buf;
        std::getline(std::cin, buf);
        n = std::stoi(buf);
    }

    int arr[100000];
    {
        std::string buf;
        std::getline(std::cin, buf);
        std::stringstream stream;
        stream << buf;
        for (int i = 0; std::getline(stream, buf, ' '); ++i) {
            arr[i] = std::stoi(buf);
        }
    }

    int q = partition(arr, n);
    print(arr, n, q);

    return 0;
}


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

int res,n,d,a[200010],dpl[200010],dpr[200010];

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n>>d;
	for(int i=1;i<=n;i++){cin>>a[i];res+=a[i];}
	res+=(n-1)*d;
	dpl[1]=a[1];
	for(int i=2;i<=n;i++) dpl[i]=min(a[i],dpl[i-1]+d);
	dpr[n]=a[n];
	for(int i=n-1;i>=1;i--) dpr[i]=min(a[i],dpr[i+1]+d);
	for(int i=2;i<=n-1;i++) res+=min(dpl[i],dpr[i]);
	cout<<res<<endl;
	return 0;
}

#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    string s;
    cin >> s;
    int q;
    cin >> q;
    vl k(q);
    for (int i = 0; i < q; ++i) {
        cin >> k[i];
        k[i]--;
    }
    for (int i = 0; i < q; ++i) {
        vl dp(3, 0);
        vl cnt(3, 0);
        for (int j = 0; j < n; ++j) {
            if (s[j] == 'D') {
                dp[0]++;
                cnt[0]++;
            } else if (s[j] == 'M') {
                dp[1] += dp[0];
                cnt[1]++;
            } else if (s[j] == 'C') {
                dp[2] += dp[1];
            }

            if (j >= k[i]) {
                if (s[j - k[i]] == 'D') {
                    dp[0]--;
                    dp[1] -= cnt[1];
                    cnt[0]--;
                } else if (s[j - k[i]] == 'M') {
                    cnt[1]--;
                }
            }
        }
        cout << dp[2] << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	for(int i=0;;++i){
		int ans = 1 + (a - 1)*i;
		if(b <= ans){
			cout << i;
			return 0;
		}
	}
}

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

int main() {
    ll x, y;
    cin >> x >> y;
    if(x == y)cout << 0 << endl;
    else if(x == -y)cout << 1 << endl;
    else if(abs(x) < abs(y)){
        ll ans = abs(y) - abs(x);
        if(x < 0 && y < 0)ans += 2;
        else if(x < 0 || y < 0)ans++;
        cout << ans << endl;
    }else{
        ll ans = abs(x) - abs(y);
        if(x > 0 && y > 0)ans += 2;
        else if(x > 0 || y > 0)ans++;
        cout << ans << endl;
    }

}


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

#define INF 10000000
typedef long long ll;

//x^t
ll mypow(ll x, ll t){
  return (ll)pow((double)x, (double)t);
}

ll ans[1000001];

int main(){
  for(ll i=0; i<=1000000; i++)ans[i]=INF;
  for(ll z=0; mypow(z, 3)<=1000000; z++){
    ll tmp;
    for(ll y=0; (tmp=mypow(z,3)+mypow(y,2))<=1000000; y++)
      if(ans[tmp]>y+z)
        ans[tmp]=y+z;
  }
  while(true){
    ll e;
    cin>>e;
    if(e==0)break;
    ll mn=INF;
    for(int i=0; i<=e; i++)
      if(mn>ans[i]+(e-i))mn=ans[i]+(e-i);
    cout<<mn<<endl;
  }
  return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <map>
#include <numeric>
using namespace std;

#define FOR(i,a,b) for(long long int i=(a);i<(b);i++)
#define REP(i,n) for(long long int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()

#define PI 3.14159265358479

typedef long long ll;
typedef vector<long long int> vi;
typedef vector<long long int>::iterator vit;

int main(){
	ll d, s = 0;
	while (cin >> d){
		REP(i, 600 / d - 1){
			s += pow((i + 1)*d, 2)*d;
		}
		cout << s << "\n";
		s = 0;
	}
	return 0;
}


#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,l;
    cin>>n>>l;
    int mini;
    if(l>=0) mini=l;
    else if(n+l-1<=0) mini=n+l-1;
    else mini=0;
    cout<<(l+n+l-1)*n/2-mini;
}

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

int main(){
  int n, l;
  cin >> n >> l;
  int ans = 0;
  for(int i=l; i<l+n; ++i){
    if(l+n-1 < 0 && i == l+n-1) continue;
    if(l > 0 && i == l) continue;
    ans += i;
  }
  cout << ans << endl;
}


/*
      author : nishi5451
      created: 11.08.2020 00:36:47
*/

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

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    if(*a.rbegin()==*b.begin() && *b.rbegin()==*c.begin()){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  string A;
  cin >> A;
  map<char, ll> z;
  for (int i=0; i<(int)A.size(); i++) {
    if (z.count(A[i])) z[A[i]]++;
    else z[A[i]] = 1;
  }
  ll num = 0;
  for (auto p: z) {
    auto value = p.second;
    num += value*(value-1)/2;
  }
  cout << (ll)A.size()*(A.size()-1)/2-num+1 << endl;
  return 0;
}

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ss(x) (int) x.size()
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define per(i, l, r) for (int i = r; l <= i; --i)

using ll = long long;
using namespace std;

string s;
int cnt[26];

int main() {
	cin >> s;
	for (auto x : s)
		cnt[x - 'a']++;
	ll res = 0;
	rep(i, 0, 25)
		rep(j, i + 1, 25)
			res += 1LL * cnt[i] * cnt[j];
	cout << res + 1 << endl;
	return 0;
}


#ifndef VS
#include<bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

const int mod = 1e9 + 7;
typedef vector<LL> V;
typedef vector<V> VV;
int main() {
	string s;
	while (cin >> s) {
		VV dp(4, V(3, 0));
		dp[0][0] = 1;
		for (auto c : s) {
			VV nxt(4, V(3, 0));
			if (c == '0' || c == '?') {
				for (int i : range(4)) {
					nxt[i][1] += dp[i][0];
					nxt[i][2] += dp[i][1];
					nxt[i][1] += dp[i][2];
				}
			}
			if (c == '1' || c == '?') {
				for (int i : range(4)) {
					nxt[min(i + 1, 3)][0] += dp[i][0];
					nxt[i][0] += dp[i][1];
					nxt[i][1] += dp[i][2];
				}
			}
			for (auto &a : nxt)for (auto &b : a)b %= mod;
			swap(dp, nxt);
		}
		cout << (dp[3][0] + dp[3][1] + dp[3][2] + dp[2][0] + dp[2][1] + dp[1][0]) % mod << endl;
	}
	return 0;
}

#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>

using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int main(){
  string s;
  cin>>s;
  reverse(s.begin(),s.end());
  string ans = s.substr(8);
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
  return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <iomanip>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N;
    string A,B,C;
    cin >> N >> A >> B >> C;
    ll count = 0;
    for (int i = 0; i < N; ++i) {
        ll tmp = 0;
        if(A[i] != B[i]){
            tmp++;
        }
        if(B[i] != C[i]){
            tmp++;
        }
        if(C[i] != A[i]){
            tmp++;
        }
        if(tmp == 2){
            count++;
        }
        if(tmp == 3){
            count+=2;
        }
    }
    cout << count << endl;
}

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

using ll = long long;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

int main() {
  int N; cin >> N;
  string A, B, C; cin >> A >> B >> C;

  int cnt = 0;
  REP(i, N) {
    if(A[i] == B[i] && B[i] == C[i]) {

    }
    else if(A[i] == B[i]) {
      cnt++;
    }
    else if(A[i] == C[i]) {
      cnt++;
    }
    else if(C[i] == B[i]) {
      cnt++;
    } else {
      cnt = cnt + 2;
    }
  }

  cout << cnt << endl;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e-a>k){
    cout << ":(" << endl;
  }
  else{
    cout << "Yay!" << endl;
  }
}


#include<cstdio>

int main(){
    int n;
    bool a,b,c;
    char event[20];
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        int score=0;
        a=b=c=false;
        int out =0;
        while(1){
            scanf("%s", event);
            if(event[1]=='I'){
                if(c)score++;
                c=b;
                b=a;
                a=true;
            }else if(event[1]=='O'){
                score++;
                if(a)score++;
                if(b)score++;
                if(c)score++;
                a=b=c=false;
            }else out++;
            if(out==3){
                printf("%d\n", score);
                break;
            }
        }
    }
    return 0;
}

#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef struct{
    int count;
    string s="OUT";
}OUT;
typedef struct{
    int count;
    string s="HOMERUN";
}HOME;
typedef struct{
    int count;
    string s="HIT";
}HIT;
typedef struct{
    int count;
}RUN;
typedef pair<int, int> pii;
int main(){
    int n; cin>>n;
    int ans=0;
    OUT out; HOME home; HIT hit; RUN run;
    out.count=0; home.count=0; hit.count=0; run.count=0;
    string temp;
    while(cin>>temp){
        if(temp==home.s){
            ans+=run.count+1;
            run.count=0;
        }
        if(temp==hit.s){
            run.count++;
            if(run.count>3){ans++; run.count-=1;}
        }
    if(temp==out.s){
        out.count++;
        if(out.count%3==0){cout<<ans<<endl;ans=0;run.count=0;}
        if(out.count==(n*3))return 0;
    }
    }
}


#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<cstring>
using namespace std;
const int inf=2e9+5;
const int maxn=100;
typedef vector<int> vi;
typedef long long ll;
#define fi first
#define se second
typedef pair<int,int> P;
int d[maxn+5][maxn+5];
int v,e;

void floyd()
{
  for(int k=0;k<v;k++)
  {
    for(int i=0;i<v;i++)
    {
      for(int j=0;j<v;j++)
      {
        if(d[i][k]==inf || d[k][j]==inf) continue;
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
}

int main(void)
{
  cin >> v >> e;
  for(int i=0;i<maxn+5;i++)
  {
    for(int j=0;j<maxn+5;j++)
    {
      if(i==j) d[i][j]=0;
      else d[i][j]=inf;
    }
  }
  for(int i=0;i<e;i++)
  {
    int s,t,cost;
    cin >> s >> t >> cost;
    d[s][t]=cost;
  }
  floyd();
  bool nega=false;
  for(int i=0;i<v;i++)
  {
    if(d[i][i]<0)
    {
      nega=true;
    }
  }
  if(nega)
  {
    cout << "NEGATIVE CYCLE" << endl;
  }
  else
  {
    for(int i=0;i<v;i++)
    {
      for(int j=0;j<v;j++)
      {
        if(d[i][j]==inf) cout << "INF";
        else cout << d[i][j];
        if(j!=v-1) cout << ' ';
      }
      cout << endl;
    }
  }
}

#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

using s64 = int64_t;

constexpr s64 INF = 1'010'000'000'000'000'000LL;

template<typename T, typename U>
bool chmin(T& xmin, const U& x)
{
    if(x < xmin) {
        xmin = x;
        return true;
    }
    else {
        return false;
    }
}

#define FOR(i, start, end) for(s64 i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)

s64 N;
s64 M;
vector<vector<s64>> G;

void print_g() {
    REP(i, N) {
        REP(j, N) {
            s64 c = G[i][j];
            if(c == INF)
                cout << "INF";
            else
                cout << c;
            cout << (j==N-1 ? '\n' : ' ');
        }
    }
}

void floyd() {
    REP(k, N) {
        REP(i, N) {
            if(G[i][k] == INF) continue;
            REP(j, N) {
                if(G[k][j] == INF) continue;
                chmin(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
}

void solve() {
    floyd();

    REP(i, N) {
        if(G[i][i] < 0) {
            cout << "NEGATIVE CYCLE\n";
            return;
        }
    }

    print_g();
}

int main() {
    cin >> N;
    G.assign(N, vector<s64>(N, INF));
    REP(i, N) { G[i][i] = 0; }

    cin >> M;
    REP(_, M) {
        s64 a, b, c; cin >> a >> b >> c;
        G[a][b] = c;
    }

    solve();

    return 0;
}


/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 9e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){a=b; return true;} return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){a=b; return true;} return false; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class AThumbnail {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    in >> n;
	    double sum = 0.0;
	    vector<int> a(n);
	    for(int i=0; i<n; i++){
	        in >> a[i];
	        sum += (double)a[i];
	    }

	    double ave = sum / (double)n;

	    int res = 0;
	    double mi = inf;
	    for(int i=0; i<n; i++){
            double diff = abs(ave - (double)a[i]);
            if(diff < mi){
                mi = diff;
                res = i;
            }
	    }

	    out << res << endl;
	}
};

int main() {
	AThumbnail solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  vector<vll> a(n, vll(2));
  long double avg = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i][0];
    avg += a[i][0];
    a[i][1] = i;
  }
  avg /= n;
  ll m = -1;
  sort(all(a));
  for (ll i = 0; i < n; i++) {
    if (a[i][0] == avg) {
      cout << a[i][1] << endl;
      return 0;
    }
    if (a[i][0] > avg) {
      while (i > 0 && a[i][0] == a[i - 1][0]) i--;
      m = i;
      break;
    }
  }
  if (m == 0) {
    cout << a[m][1] << endl;
    return 0;
  }
  ll x = m - 1;
  while (x > 0 && a[x][0] == a[x - 1][0]) x--;
  //cout << a[m][0] - avg << " " << avg - a[x][0] << endl;
  if (a[m][0] - avg > avg - a[x][0]) cout << a[x][1] << endl;
  else if (a[m][0] - avg < avg - a[x][0]) cout << a[m][1] << endl;
  else {
    cout << min(a[x][1], a[m][1]) << endl;
  }
}


%:pragma GCC optimize("Ofast")
  %:pragma GCC optimize("inline")
#include <bits/stdc++.h>
#define rint register int
#define fo(i, n) for(rint i = 1; i <= (n); i ++)
#define out(x) cerr << #x << " = " << x << "\n"
#define type(x) __typeof((x).begin())
#define foreach(it, x) for(type(x) it = (x).begin(); it != (x).end(); ++ it)
  using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar(); bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
#define P pair<int, int>
#define fi first
#define se second
const int N = 633;
vector<P> vec;
int n, d1, d2;
int col1[N][N], col2[N][N], col[N][N];
inline void dfs(int x, int y, int fff) {
  if(col[x][y] != -1) return ;
  col[x][y] = fff;
  for(auto v: vec) {
    int dx = x + v.first;
    int dy = y + v.second;
    if(dx < 0 || dx >= 2 * n || dy < 0 || dy >= 2 * n)
       continue;
    dfs(dx, dy, fff ^ 1);
  }
}

inline void cal(int d) {
  vec.clear();
  for(int dx = -2 * n + 1; dx < 2 * n; dx ++) {
    for(int dy = -2 * n + 1; dy < 2 * n; dy ++) {
      if(dx * dx + dy * dy == d)
        vec.push_back(P(dx, dy));
    }
  }
  memset(col, -1, sizeof col);
  for(int x = 0; x < 2 * n; x ++)
    for(int y = 0; y < 2 * n; y ++)
      dfs(x, y, 0);
}
main(void) {
  read(n); read(d1); read(d2);
  cal(d1); memcpy(col1, col, sizeof col);
  cal(d2); memcpy(col2, col, sizeof col);
  for(int k1 = 0; k1 < 2; k1 ++) {
    for(int k2 = 0; k2 < 2; k2 ++) {
      int cnt = 0;
      for(int x = 0; x < 2 * n; x ++) {
        for(int y = 0; y < 2 * n; y ++)
          if(col1[x][y] == k1 && col2[x][y] == k2)
            ++ cnt;
      }
      if(cnt >= n * n) {
        int res = n * n;
        for(int x = 0; x < 2 * n; x ++)
          for(int y = 0; y < 2 * n; y ++)
            if(col1[x][y] == k1 && col2[x][y] == k2) {
              -- res;
              cout << x << " " << y << "\n";
              if(res == 0) return 0;
            }
      }
    }
  }
}

#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int fld[700][700];

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,D[2];cin>>N>>D[0]>>D[1];
  int d[2]={0,0};
  repeat(k,2){
    while(!(D[k]&1)){
      d[k]++;
      D[k]/=2;
    }
    D[k]<<=d[k];
  }
  //debugArray(d,2);
  vector<Pii> ans;
  repeat(i,2*N){
    repeat(j,2*N){
      bool isok=true;
      repeat(k,2){
        if(d[k]&1){
          isok &= !((i/(1<<((d[k]-1)/2)))&1);
        }else{
          isok &= !((i/(1<<(d[k]/2))+j/(1<<(d[k]/2)))&1);
        }
      }
      if(isok){
        fld[i][j]=1;
        ans.push_back({i,j});
      }
    }
  }
  /*
  if(ans.size()<N*N){
    cerr<<"!!!!!!!"<<endl;
    return 0;
  }
  */
/*
  repeat(i,2*N){
    repeat(j,2*N){
      cerr<<fld[i][j];
    }
    cerr<<endl;
  }
*/
  repeat(i,N*N){
    cout << ans[i].first<<" "<<ans[i].second<<endl;
  }
  return 0;
}


#include<iostream>
using namespace std;
int main(){
	int n,a;
	long long  sum=0;
	int max=-1000000;
	int min=1000000;
	cin>>n;
    for(int i=1;i<=n;i++){
    	cin>>a;
    	if(a>max){
    		max=a;
    	}
    	if(a<min){
    		min=a;
    	}
        sum+=a;
    }
	cout<<min<<" "<<max<<" "<<sum<<endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;

int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	ll K;

	cin >> K;

	cout << "50\n";

	V<ll> ans(50, 0);

	for (int i = 0; i < 50; ++i) {
		ans[i] = i + (K / 50);
	}

	for (int i = 50 - (K % 50); i < 50; ++i) {
		++ans[i];
	}

	for (int i = 0; i < 50; ++i) {
		cout << ans[i] << " \n"[i + 1 == 50];
	}

	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
    return 0;
}


#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int n; cin >> n;
    int k; cin >> k;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    sort(all(a));
    if(a.at(n-1) < k){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    int temp = a.at(0);
    rep(i,n-1){
        temp = __gcd(temp,a.at(i+1));
        if(temp == 1){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    if(k%temp == 0){
        cout << "POSSIBLE" << endl;
        return 0;
    }
    else{
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }

}

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  int odd = 0;
  for (int i = 0; i < m; i++) {
    cin >> a[i];
    odd += a[i] & 1;
  }
  if (odd > 2) {
    cout << "Impossible\n";
    return 0;
  }
  for (int i = 0; i < m && odd > 0; i++) {
    if (a[i] & 1) {
      swap(a[i], a[0]);
      odd--;
      break;
    }
  }
  for (int i = m - 1; i >= 0 && odd > 0; i--) {
    if (a[i] & 1) {
      swap(a[i], a[m - 1]);
      odd--;
      break;
    }
  }
  for (int i = 0; i < m; i++) {
    cout << a[i] << ' ';
  }
  cout << '\n';
  vector<int> b;
  for (int i = 0; i < m; i++) {
    b.push_back(a[i] + (i == 0 ? -1 : (i == m - 1 ? 1 : 0)));
  }
  if (m == 1) {
    b.push_back(1);
  }
  cout << (int) b.size() - (b[0] == 0) << '\n';
  for (int i = (b[0] == 0); i < (int) b.size(); i++) {
    cout << b[i] << ' ';
  }
  cout << '\n';
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  ll N;
  cin >> N;
  ll sqrN = sqrt(N);
  for (ll i = sqrN; i >= 1; i--) {
    if (N % i == 0) {
      ll a = N / i;
      string sa = to_string(a);
      cout << sa.size() << endl;
      return 0;
    }
  }
}

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

#define ll long long

ll F(ll A, ll B){
    string bufA = to_string(A), bufB = to_string(B);
    return max(bufA.size(), bufB.size());
}

int main(){
    ll N;
    ll ans = to_string(N).size();
    cin >> N;
    for(ll i = 1; i <= sqrt(N); ++i){
        if(N % i == 0) ans = min(ans, F(i, N/i));
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define str string
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second

#define vc vector<char>
#define vvc vector<vc>
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvvll vector<vvll>
#define vs vector<str>
#define vvs vector<vs>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define vb vector<bool>
#define vvb vector<vb>
#define rep(i, a, b) for (int i = (a); i < int(b); i++)
#define repi(i, a, b) for (int i = (a); i <= int(b); i++)

using namespace std;
ll INF = LONG_LONG_MAX;
ll mod = 1000000000 + 7;

template <typename T, typename L>
void readVector(vector<T> & _data, L & _size, bool _shift) {
    _data.resize(_size + (ll)_shift);
    for (ll i = (ll)_shift; i < _size + (ll)_shift; i++)
        cin >> _data[i];
}

template <typename T, typename L>
void readMatrix(vector<vector<T>> & _data, L & _rows, L & _cols, bool _shiftRows, bool _shiftCols) {
    _data.resize(_rows + (ll)_shiftRows);
    for (ll i = 0; i < _rows + (ll)_shiftRows; i++)
        _data[i].resize(_cols + (ll)_shiftCols);
    for (ll i = (ll)_shiftRows; i < _rows + (ll)_shiftRows; i++)
        for (ll j = (ll)_shiftCols; j < _cols + (ll)_shiftCols; j++)
            cin >> _data[i][j];
}

//TODO: SOLUTION

ll n;
vll a, pre, f, g;

void computeG() {
    ll j = n - 2;
    g[n - 1] = n;

    while (j >= 1) {
        int k = g[j + 1];
        while (abs(pre[n] - (2*pre[k - 1]) + pre[j - 1]) > abs(pre[n] - (2*pre[k - 2]) + pre[j - 1]))
            k--;
        g[j] = k;
        j--;
    }
}

void computeF() {
    ll j = 3;
    f[2] = 1;

    while (j <= n) {
        int k = f[j - 1];
        while (abs(pre[j] - (2*pre[k])) > abs(pre[j] - (2*pre[k + 1])))
            k++;
        f[j] = k;
        j++;
    }
}

void solve() {
    cin >> n;
    readVector(a, n, 1);
    pre.resize(n + 1, 0);

    repi(i, 1, n) {
        pre[i] = pre[i - 1] + a[i];
    }

    f.resize(n + 1);
    g.resize(n + 1);

    computeF();
    computeG();

    ll ans = INF;
    repi(i, 2, n - 2) {
        ans = min(ans, max(max(max(pre[f[i]], pre[i] - pre[f[i]]), pre[n] - pre[g[i + 1] - 1]), pre[g[i + 1] - 1] - pre[i])
                      -min(min(min(pre[f[i]], pre[i] - pre[f[i]]), pre[n] - pre[g[i + 1] - 1]), pre[g[i + 1] - 1] - pre[i]));
    }

    cout << ans << endl;
}

int main() {

    // TODO: Set value of this variable manually
    bool _multipleTestCases = false;

    if (_multipleTestCases) {
        ll t; cin >> t;
        while (t--)
            solve();
    }
    else {
        solve();
    }

    return 0;
}

#include <iostream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>

using namespace std;

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

#define FOR(i,n,m) for(int i=n; i<(int)m; i++)
#define ROF(i,n,m) for(int i=n; i>(int)m; i--)
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define ri(a) scanf("%d",&a)
#define rii(a,b) ri(a),ri(b)
#define riii(a,b,c) rii(a,b),ri(c)
#define lri(a) scanf("%lld",&a)
#define lrii(a,b) lri(a),lri(b)
#define ms(obj,val) memset(obj,val,sizeof(obj))
#define all(x) x.begin(),x.end()
#define debug true
#define dprintf debug && printf

const int INF = 0x3f3f3f3f;
const ll INFLL = 1e18;
const int MOD = 1e9+7;
const int MAXN = 2e5+5;

ll pref[MAXN];
int n;

ll sum(int l, int r){
    if(l > r) return 0;
    return pref[r] - (l == 0 ? 0 : pref[l-1]);
}

ll dif(int l, int r, int m){
    return abs(sum(l, m-1) - sum(m, r));
}

void mxze(ll &a, ll b){
    a = max(a,b);
}
void mnze(ll &a, ll b){
    a = min(a,b);
}

ll result(int m1, int m, int m2){
    ll mx = sum(0,m1-1);
    mxze(mx, sum(m1,m-1));
    mxze(mx, sum(m,m2-1));
    mxze(mx, sum(m2,n-1));

    ll mn = sum(0,m1-1);
    mnze(mn, sum(m1,m-1));
    mnze(mn, sum(m,m2-1));
    mnze(mn, sum(m2,n-1));

    return mx - mn;
}

bool check(int l, int r, int m){
    return dif(l, r, m) > dif(l,r,m+1);
}

int findBest(int l, int r){
    int lo = l + 1, hi = r;
    while(lo < hi){
        int mid = (lo + hi)>>1;
        if(check(l, r, mid)) lo = mid + 1;
        else hi = mid;
    }
    return hi;
}

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

    ri(n);
    FOR(i,0,n) lri(pref[i]);
    FOR(i,1,n) pref[i] += pref[i-1];

    ll ans = INFLL;
    FOR(m,2,n-1){
        mnze(ans, result(findBest(0,m-1), m, findBest(m, n-1)));
    }

    printf("%lld\n", ans);

    return 0;
}


/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
    	int N, p[1001]{};
        cin >> N;
		for (int i = 2; i <= N; ++i) {
		int I = i;
		for (int j = 2, n = sqrt(I) + 1; I != 1 && j != n; ++j) {
		while (I % j == 0) {
        I /= j;
        ++p[j];
      }
    }
    if (I != 1) ++p[I];
  }

  cout << accumulate(begin(p), end(p), 1ll, [&](ll a, ll x)
  {
    return a * (x + 1) % MOD;
  }) << endl;
		return 0;
}

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

int n;
string s;

bool match(int index, string pattern) {
	if (index + pattern.size() > s.size()) return false;
	for (int i = 0; i < pattern.size(); i++) {
		if (s[index + i] != pattern[i])
			return false;
	}
	return true;
}

int change() {
	string after = "Hoshina", before = "Hoshino";
	for (int i = 0; i < s.size(); i++) {
		if (match(i, before)) {
			for (int j = 0; j < before.size(); j++) {
				s[i + j] = after[j];
			}
		}
	}
	return 0;
}

int main(){
	cin >> n;
	cin.ignore();
	for (int i = 0; i < n; i++) {
		getline(cin, s);
		change();
		cout << s << endl;
	}

	return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;

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

    if(s == t) {
        cout << n << endl;
        return 0;
    }
    int ans = n * 2;
    for(int i = 0; i < n; i++){
        string tmpt = t.substr(0, i);
        string tmps = s.substr(n - i, i);
        if(tmpt == tmps) ans -= tmpt.size();
    }
    cout << ans << endl;

    return 0;
}

//Let's join Kaede Takagaki Fun Club !!
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
ll mod;
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}

ll dp[6005][9005];
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[10005],R[10005];
ll rev2[10005];
ll rev3[10005];
void make(){
	F[0] = 1;
	for(int i=1;i<10005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<10005;i++) R[i] = modpow(F[i],mod-2);
	for(int i=0;i<10005;i++) {
		rev2[i] = modpow(modpow(2LL,i),mod-2);
		rev3[i] = modpow(modpow(3LL,i),mod-2);
	}
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
int main(){
	int n, m; g(n); g(m);
	mod = m;
	make();
	ll ans = 0;
	for(int one=0;one<=3*n;one++){
		for(int two=0;two<=one;two++){
			int zan = 3*n-one-two-two;
			if(zan >= 0 && zan%3 == 0){
				int thr = zan / 3;
				add(ans, C(3*n, one) * C(3*n-one, two*2) % mod * F[two*2] % mod * R[two] % mod * rev2[two] % mod * F[thr*3] % mod * R[thr] % mod * rev3[thr] % mod);
			}
			//o(one,1); o(two,1); o(ans);
		}
	}
	o(ans);
}