#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif

#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <vector>

using namespace std;

typedef long long LL;

class BIT {
	std::vector<LL> bit;
	LL size;
public:
	BIT() { }
	BIT(LL sz) { init(sz); }
	void init(LL sz) {
		bit = std::vector<LL>((size = sz) + 1);
	}
	LL sum(LL i) {
		LL s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
}
	void add(LL i, LL x) {
		while (i <= size) {
			bit[i] += x;
			i += i & -i;
		}
	}
};

int main() {
	LL N, Q, a, t, x, y;
	cin >> N >> Q;
	BIT bit(N);
	for (LL i = 1; i <= N; ++i) {
		cin >> a;
		bit.add(i, a);
	}
	for (LL i = 0; i < Q; ++i) {
		cin >> t >> x >> y;
		if (t == 0) {
			bit.add(x + 1, y);
		} else {
			cout << (bit.sum(y) - bit.sum(x)) << endl;
		}
	}
	return 0;
}

#include <bits/stdc++.h>
#include <atcoder/fenwicktree>
using namespace std;
using namespace atcoder;
int main(){
  int N, Q;
  cin >> N >> Q;
  fenwick_tree<long long> a(N);
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    a.add(i, x);
  }
  for (int i = 0; i < Q; i++){
    int t;
    cin >> t;
    if (t == 0){
      int p, x;
      cin >> p >> x;
      a.add(p, x);
    }
    if (t == 1){
      int l, r;
      cin >> l >> r;
      cout << a.sum(l, r) << endl;
    }
  }
}


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

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

int main() {
  int n;
  cin >> n;
  queue<int> que;
  rep(i, n) {
    int p;
    cin >> p;
    if(i == 0) que.push(p);
    else {
      if(que.back() > p) que.push(p);
    }
  }
  cout << que.size() << endl;
}

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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

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

    int mn = n + 1, ans = 0;
    while (n--) {
        int x;
        cin >> x;
        if (x < mn) mn = x, ans++;
    }

    cout << ans;
}

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

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


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

int main() {
	long long n;
	cin >> n;
	string name = "";
	while (1) {
		n--;
		name += (n % 26 + 'a');
		n /= 26;
		if (n == 0) break;
	}
	reverse(name.begin(), name.end());
	cout << name;
}

#include<stdio.h>
#define ll long long

int main()
{
	ll n, j = 0;
	char str[255];

	scanf("%lld", &n);

	while(n != 0){
		--n;
		str[j++] = n % 26 + 'a';
		n /= 26;
	}
	for(int i = j - 1; i >= 0; i--){
		printf("%c", str[i]);
	}
}


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

int main()
{
    int n;
    double sum = 0;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            sum += sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
        }
    }
    cout << fixed;
    cout << setprecision(7) << sum / n << endl;
    return 0;
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N), B(N), S(N);
    rep(i, 0, N){
        cin >> A[i] >> B[i];
        S[i] = A[i] + B[i];
    }
    sort(S.begin(), S.end(), greater<ll>());
    ll taka = 0;
    rep(i, 0, N){
        if(i % 2 == 0) taka += S[i];
    }

    ll ans = taka - accumulate(B.begin(), B.end(), 0LL);
    cout << ans << endl;
    return 0;
}


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

int main() {
    long long N; cin >> N;
    string ans="";
    while(N){
        N--;
        int r=N%26;
        N=N/26;
        ans+='a'+r;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
}

#include <algorithm>

#include <bitset>

#include <tuple>

#include <cstdint>

#include <cstdio>

#include <cctype>

#include <assert.h>

#include <stdlib.h>

#include <stdio.h>

#include <cassert>

#include <cfloat>

#include <climits>

#include <cmath>

#include <complex>

#include <ctime>

#include <deque>

#include <fstream>

#include <functional>

#include <iomanip>

#include <iostream>

#include <iterator>

#include <list>

#include <limits>

#include <map>

#include <memory>

#include <queue>

#include <random>

#include <set>

#include <stack>

#include <string>

#include <unordered_map>

#include <unordered_set>

#include <utility>

#include <vector>

#include <math.h>
#define int long long
using namespace std;
signed main() {
    string S, T;
    cin >> S >> T;
    cout << T + S << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807
//https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_D
//区間加算　区間和クエリ
//演算の定義
auto query = [](ll x, ll y) { return x+y; };
//単位元
const ll unit = 0;
struct LazySegTree
{
private:
  ll n;
  vector<ll> node,lazy;

public:
  LazySegTree(vector<ll> v)
  {
    node.resize((1LL << 64 - __builtin_clzll(v.size())) * 2 - 1, unit);
    lazy.resize((1LL << 64 - __builtin_clzll(v.size())) * 2 - 1,-1);
    n = 1LL << 64 - __builtin_clzll(v.size());
    for (ll i = 0; i < v.size(); i++)
      node[i + n - 1] = v[i]; //最下段から構築
    for (ll i = n - 2; i >= 0; i--)
      node[i] = query(node[2 * i + 1], node[2 * i + 2]);
  }

  // k 番目のノードについて遅延評価を行う
  void eval(int k, int l, int r){
    // 遅延配列が空でない場合、自ノード及び子ノードへの
    // 値の伝播が起こる
    if (lazy[k] != -1){
      node[k] = lazy[k];
      // 最下段かどうかのチェックをしよう
      // 子ノードは親ノードの 1/2 の範囲であるため、
      // 伝播させるときは半分にする
      if (r - l > 1){
        lazy[2 * k + 1] = lazy[k] / 2;
        lazy[2 * k + 2] = lazy[k] / 2;
      }
      // 伝播が終わったので、自ノードの遅延配列を空にする
      lazy[k] = -1;
    }
  }

  void update(int a, int b, ll x, int k = 0, int l = 0, int r = -1){
    if (r < 0)
      r = n;
    // k 番目のノードに対して遅延評価を行う
    eval(k, l, r);
    // 範囲外なら何もしない
    if (b <= l || r <= a)
      return;
    // 完全に被覆しているならば、遅延配列に値を入れた後に評価
    if (a <= l && r <= b){
      lazy[k]= (r - l) * x;
      eval(k, l, r);
    }
    // そうでないならば、子ノードの値を再帰的に計算して、
    // 計算済みの値をもらってくる
    else{
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      node[k] = node[2 * k + 1] + node[2 * k + 2];
    }
  }

  // 要求区間 [a, b) 中の要素の和を答える k := 自分がいるノードのインデックス 対象区間は [l, r) にあたる
  ll get(ll a, ll b, ll k = 0, ll l = 0, ll r = -1)
  {
    // 最初に呼び出されたときの対象区間は [0, n)
    if (r < 0)
      r = n;
    // 要求区間と対象区間が交わらない -> 適当に返す
    if (r <= a || b <= l)
      return unit;
    // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
    // 関数が呼び出されたら評価！
    eval(k, l, r);
    if (a <= l && r <= b)
      return node[k];
    // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
    // 左側の子を vl ・ 右側の子を vr としている
    // 新しい対象区間は、現在の対象区間を半分に割ったもの
    ll vl = get(a, b, 2 * k + 1, l, (l + r) / 2);
    ll vr = get(a, b, 2 * k + 2, (l + r) / 2, r);
    return query(vl, vr);
  }
};

int main()
{
ll n , q ;
cin >> n >> q ;

vector<ll> t(n,(1LL<<31)-1);
LazySegTree s(t);
vector<ll> ans;
rep(i,q){
  ll a  ;
  cin >> a  ;
  if(!a){
    ll b , c , d ;
    cin >> b >> c >> d ;
    s.update(b, c+1, d);
  }
  else {
    ll b ;
    cin >> b ;
    ans.push_back(s.get(b, b+1));
  }
}

rep(i,ans.size())cout<<ans[i]<<"\n";

return 0;
}

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;

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

int main() {

	int N;
	vector<int> s(123),t;

	scanf("%d", &N);

	REP(i, N *(N - 1) / 2) {
		int A, B, C, D;
		scanf("%d %d %d %d", &A, &B, &C, &D);
		s[A-1] += (C > D) ? 3 : 0;
		s[B-1] += (C < D) ? 3 : 0;
		if (C == D) {
			s[A-1]++;
			s[B-1]++;
		}
	}

	t = s;
	sort(t.begin(), t.begin() + N);

	REP(i, N) {
		printf("%d\n", N - distance(t.begin(), upper_bound(t.begin(), t.begin() + N, s[i])) + 1);
	}

	return 0;
}


#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//??¨????????????????????????
//n??\????????£??´??°????´???°???????????°???????????????is_prime[]???????´?
void eratos(int n, bool is_prime[]) {
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i*i <= n; i++)
		if (is_prime[i]) {
			int j = i + i;
			while (j <= n) {
				is_prime[j] = false;
				j = j + i;
			}
		}
}

signed main() {
	bool is_prime[10010] = {};
	eratos(10010, is_prime);
	for (int n; cin >> n&&n;) {
		rrep(i, 0, n + 1) {
			if (is_prime[i] && is_prime[i - 2]) {
				cout << i - 2 << " " << i << endl; break;
			}
		}
	}
	return 0;
}

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

#define int long long

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int sta[maxn],top,a[maxn],n;

signed main() {
    read(n);
    for(int i=1;i<=n;i++) read(a[i]);
    int ans=0,lst=n+1;
    for(int i=n;i;i--) {
        int x=a[lst]-(lst-i);
        if(a[i]==x) continue;
        if(a[i]<x||a[i]>=i) return puts("-1"),0;
        ans+=a[i],lst=i;
    }
    write(ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(){
    string s;
    cin >> s;
    for(int i=1;i<s.size();i++){
        if(1<i && s[i-2]==s[i]){
            cout << i-1 << " " << i+1 << endl;
            return 0;
        }

        if(s[i-1]==s[i]){
            cout << i << " " << i+1 << endl;
            return 0;
        }
    }

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

#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string S; cin >> S;
    OUT(S.substr(0,S.size()-8))

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  double K=0;
  vector<int> X(N),Y(N);
  for(int i=0;i<N;i++){
    cin >> X.at(i) >> Y.at(i);
  }
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      int X2=X.at(i)-X.at(j);
      int Y2=Y.at(i)-Y.at(j);
      K+=sqrt(X2*X2+Y2*Y2);
    }
  }
  cout << fixed << setprecision(10) << 2*K/N << endl;
}

#include <bits/stdc++.h>
#define fi first
#define se second

using namespace std;

typedef pair <int,int> pi;
typedef pair <int,pi> pii;

struct point{
    point(int x, int y, int ind){
        this->x=x;
        this->y=y;
        this->ind=ind;
    }
    int x,y;
    int ind;
};

int getdist(int i,int j, vector <pi> &a){
    return min(abs(a[i].fi-a[j].fi),abs(a[i].se-a[j].se));
}

int par[100005],Size[100005];

int root(int i)
{
    while (par[i] != i)
    {
        par[i] = par[par[i]];
        i = par[i];
    }
    return i;
}

void wunion(int A, int B)
{
    int root_A = root(A);
    int root_B = root(B);
    if (Size[root_A] < Size[root_B])
    {
        par[root_A] = par[root_B];
        Size[root_B] += Size[root_A];
    }
    else
    {
        par[root_B] = par[root_A];
        Size[root_A] += Size[root_B];
    }

}

bool Find(int A, int B)
{
    if (root(A) == root(B))       //if A and B have same root,means they are connected.
        return true;
    else
        return false;
}

int main(){
    int n;
    cin >> n;
    vector <pi> a(n);
    vector <point> st;
    for(int i=0;i<n;i++){
        cin >> a[i].fi >> a[i].se;
        st.emplace_back(a[i].fi,a[i].se,i);
    }
    sort(st.begin(),st.end(),[](const point &l,const point &r){
        return l.x<r.x;
    });
    set <pii> e;
    for(int i=1;i<n;i++){
        e.insert({getdist(st[i].ind,st[i-1].ind,a),{st[i].ind,st[i-1].ind}});
        e.insert({getdist(st[i].ind,st[i-1].ind,a),{st[i-1].ind,st[i].ind}});
    }
    sort(st.begin(),st.end(),[](const point &l,const point &r){
        return l.y<r.y;
    });
    for(int i=1;i<n;i++){
        e.insert({getdist(st[i].ind,st[i-1].ind,a),{st[i].ind,st[i-1].ind}});
        e.insert({getdist(st[i].ind,st[i-1].ind,a),{st[i-1].ind,st[i].ind}});
    }
    for(int i=0;i<n;i++){
        par[i]=i;
        Size[i]=1;
    }
    long long ans=0;
    for(auto x:e){
        int i=x.se.fi, j =x.se.se;
        if(!Find(i,j)){
            wunion(i,j);
            ans+=x.fi;
        }
    }
    cout << ans << endl;
    return 0;
}


#include<iostream>
#include<algorithm>
using namespace std;
int main (void)
{

  string s;
  cin>>s;
  if(s=="SUN")cout<<"7"<<endl;
  if(s=="MON")cout<<"6"<<endl;
  if(s=="TUE")cout<<"5"<<endl;
  if(s=="WED")cout<<"4"<<endl;
  if(s=="THU")cout<<"3"<<endl;
  if(s=="FRI")cout<<"2"<<endl;
  if(s=="SAT")cout<<"1"<<endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl

void Suhaib_Sawalha (){

    vector <string> v = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin >> s;
    cout << v.end() - find(v.begin(),v.end(),s);

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}


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

int main(int argc, char *argv[])
{
    int w, h, diag, i, j;
    while (cin >> w >> h, w | h) {
        diag = w * w + h * h;
        i = 0;
        while (1) {
            i++;
            j = sqrt(diag - i * i);
            if (i >= j) {
                diag++;
                i = 0;
                continue;
            } else {
                if ((diag == w * w + h * h && i <= w) || j * j != diag - i * i)
                    continue;
                cout << i << ' ' << j << endl;
                break;
            }
        }
    }
    return 0;
}

#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

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

	vector<pair<int, pair<int,int>>>v;
	for (int i = 1; i <= 150; i++) {
		for (int j = i + 1; j <= 150; j++) {
			v.push_back({ i*i + j*j ,{i,j} });
		}
	}
	sort(v.begin(), v.end());
	cin >> H >> W;
	while (H) {
		bool flag = false;
		for (auto i : v) {
			if (flag) {
				cout << i.second.first << " " << i.second.second << endl;
				break;
			}
			if (i.second.first == H&&i.second.second == W) {
				flag = true;
			}
		}
		cin >> H >> W;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+10;
struct node{
	int pos,num;
	bool operator<(const node& a)const{
		return num<a.num;
	}
};
struct node1{
	int pos,num;
	bool operator<(const node1& a)const{
		return pos<a.pos;
	}
};
char s[maxn];
bool vis[maxn]={0};
node p[maxn]={0},p1[maxn]={0};
node1 p2[maxn]={0};
ll ans[maxn]={0};
ll sum[maxn]={0};
int k[100];
int main()
{
	int n;
	scanf("%d %s",&n,s+1);
	int q;
	scanf("%d",&q);
	for(int i=1;i<=q;i++){
		scanf("%d",&k[i]);
	}
	int num=0;
	int now1=0,now2=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='M')num++;
		else if(s[i]=='D'){
			p1[++now1].pos=i;
			p1[now1].num=num;
		}
		else if(s[i]=='C'){
			p[++now2].pos=i;
			p[now2].num=num;
			p2[now2].pos=i;
			p2[now2].num=num;
		}
	}
	for(int i=1;i<=now2;i++){
		sum[i]=sum[i-1]+p[i].num;
	}
	for(int j=1;j<=q;j++)
	{
		ll sum1=0;
	for(int i=1;i<=now1;i++){
		node aa;
		node1 bb;
		aa.num=p1[i].num+1;
		bb.pos=p1[i].pos+k[j];
		int x=lower_bound(p+1,p+now2+1,aa)-p;
		int y=lower_bound(p2+1,p2+now2+1,bb)-p2;
		y--;
		if(x==now2+1)continue;
		sum1+=sum[y]-sum[x-1]-p1[i].num*1ll*(y-x+1);
	}
	ans[j]=sum1;
}
	for(int i=1;i<=q;i++){
		printf("%lld\n",ans[i]);
	}
}

#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int INF=1e9;
const long double eps=1e-9;
const double Pi=acos(-1.0);
const int maxn=1e2+10;
struct node{
	int x,y,id;
}a[maxn];
inline bool cmp(const node &lhs,const node &rhs){
	return lhs.x==rhs.x?lhs.y>rhs.y:lhs.x<rhs.x;
}
inline bool Cmp(const node &lhs,const node &rhs){
	return lhs.id<rhs.id;
}
int stk[maxn],ans[maxn],vis[maxn];
double Ans[maxn],slp[maxn];
inline int read(){
	int x=0,flag=1;
	char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')flag=-1,ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	return x*flag;
}
inline double Slope(int idx,int idy){
	if(a[idx].x==a[idy].x)return -INF;
	return (a[idx].y-a[idy].y)*1.0/(a[idx].x-a[idy].x);
}
inline double arcle(int idx,int idy){
	if(a[idx].x==a[idy].x){
		if(a[idx].y>a[idy].y)return 0;
		else return Pi;
	}
	if(a[idx].y==a[idy].y){
		if(a[idx].x<a[idy].x)return Pi/2;
		else return 3*Pi/2;
	}
	double slope=-1.0/Slope(idx,idy),arc=atan(slope);
	if(arc<0)arc+=Pi;
	if(a[idx].x<a[idy].x)return arc;
	else return arc+Pi;
}
int main(){
	int i,j,k,m,n,pos;
	n=read();
	for(i=1;i<=n;i++){
		a[i].x=read();a[i].y=read();a[i].id=i;
	}
	sort(a+1,a+n+1,cmp);
	stk[1]=1;stk[2]=2;int top=2;
	for(i=3;i<=n;i++){
		while(top>1 && Slope(stk[top],stk[top-1])>=Slope(i,stk[top]))top--;
		stk[++top]=i;
	}
	for(i=1;i<top;i++)ans[i]=a[stk[i]].id,vis[a[stk[i]].id]=1;pos=top;
	vis[a[1].id]=0;
	reverse(a+1,a+n+1);
	stk[1]=1;stk[2]=2;top=2;
	for(i=3;i<=n;i++){
		if(vis[a[i].id])continue;
		while(top>1 && Slope(stk[top],stk[top-1])>=Slope(i,stk[top]))top--;
		stk[++top]=i;
	}
	for(i=pos;i<pos+top-1;i++)ans[i]=a[stk[i-pos+1]].id;pos=pos+top-2;
	sort(a+1,a+n+1,Cmp);
	ans[0]=ans[pos];ans[pos+1]=ans[1];
	for(i=0;i<=pos;i++)slp[i]=arcle(ans[i+1],ans[i]);
	for(i=1;i<=pos;i++)Ans[ans[i]]=slp[i]-slp[i-1];
	for(i=1;i<=n;i++){
		if(Ans[i]<0)Ans[i]+=2*Pi;
		printf("%.15lf\n",Ans[i]/(2*Pi));
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

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

ll p(ll n) {
	if (n == 0) { return 1; }
	return 2 * p(n - 1);
}

int main() {

	ll N;
	cin >> N;

	vector<ll> A(N + 1);

	repn(i, N) cin >> A[i];

	sort(++A.begin(), A.end(), greater<ll>());

	vector<vector<ll>> d(N + 1,vector<ll>(60));

	vector<ll> count1(60);

	repn(i, N) {
		ll t = A[i];
		rep(j,60){
			d[i][59-j] = t%2;
			count1[59-j]+= d[i][59-j];
			t /= 2;
		}
	}

	repn(i, N) {
		rep(j, 60) {
			if (count1[j] % 2 == 1) { d[i][j] = 0; }
		}
	}

	/*
	repn(i, N) {
		rep(j, 60) {
			cout << d[i][j];
		}
		cout << endl;
	}
	*/

	repn(i, N) {
		ll K=-1;
		rep(j,60){
			if (d[i][j] == 1) { K = j; break; }
		}

		//cout << i << K << endl;

		if (K == -1) { continue; }

		repn(l, N) {
			if (l == i) { continue; }

			if (d[l][K] == 1) {
				for (int j = K; j < 60; j++) {
					d[l][j] = (d[i][j] + d[l][j]) % 2;
				}
			}
		}

		/*
		repn(i, N) {
			rep(j, 60) {
				cout << d[i][j];
			}
			cout << endl;
		}
		*/

	}

	vector<ll> sum(60, 0);

	repn(i, N) {
		rep(j, 60) {
			sum[j]+=d[i][j];
		}
	}

	//rep(j, 60) { cout << count1[j] << endl; }

	ll ans=0;

	rep(j, 60) {
		ans += (count1[j]%2+2*(sum[j]%2)) * p(59-j);
	}

	cout << ans;

	system("PAUSE");

}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 100100;
const int A = 60;
ll w[MN];
ll fr[A];
int main() {
	ll n;
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> w[i];
		for(int j=0;j<A;j++) {
			if(w[i]&(1LL<<j)) {
				fr[j]++;
			}
		}
	}
	ll res = 0;
	ll tot = 0;
	ll ms = 0;
	int st = 0;
	for(int b=A-1;b>=0;b--) {
		if(fr[b]&1) {
			tot += 1LL<<b;
			continue;
		}
		ms |= 1LL<<b;
		ll ma = -1,mi = -1;
		for(int i=st;i<n;i++) {
			if((w[i]&(1LL<<b)) && w[i] > ma) {
				ma = w[i];
				mi = i;
			}
		}
		if(mi >= 0) {
			swap(w[mi],w[st]);
			mi = st;
			for(int i=0;i<n;i++) {
				if((w[i]&(1LL<<b)) && (i != mi)) {
					w[i] ^= ma;
				}
			}
			st++;
		}
	}
	for(int i=0;i<n;i++) {
		res ^= w[i];
	}
	tot += (res&ms)*2;
	cout << tot << '\n';
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  ll a,b,m;
  cin>>a>>b>>m;
  ll A[a];ll B[b];ll Maxa=MOD,Maxb=MOD;
  rep(i,a){
    cin>>A[i];
    Maxa=min(Maxa,A[i]);
  }
  rep(i,b){
    cin>>B[i];
    Maxb=min(Maxb,B[i]);
  }
  ll ans=Maxa+Maxb;
  rep(i,m){
    ll x,y,c;
    cin>>x>>y>>c;
    ans=min(ans,A[x-1]+B[y-1]-c);
  }
  cout<<ans;
}

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

int main(){
  int A,B,M;
  cin >> A >> B >> M;

  vector<int> a(A);
  vector<int> b(B);

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

  vector<vector<int>> ju(M,vector<int>(3));

  for(int i=0;i<M;i++){
    for(int j=0;j<3;j++){
      cin >> ju[i][j];
    }
  }

  int c=200000;

  for(int i=0;i<M;i++){
    c=min(c,a[ju[i][0]-1]+b[ju[i][1]-1]-ju[i][2]);
  }

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

  c=min(c,a[0]+b[0]);

  cout << c << endl;
}


#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

ll dp[41][1<<16][2];

int main(int argc, char* argv[])
{
    int n,x,y,z;
    scanf("%d%d%d%d", &n, &x, &y, &z);

    int s=(1<<(x+y+z))+(1<<(y+z))+(1<<z);
    int s2=s/2;

    dp[0][0][0]=1;
    int i,j,p,k;
    for(i=0; i<n; i++) {
        for(j=0; j<(1<<16); j++) {
            for(p=0; p<2; p++) {
                if(dp[i][j][p]) {
                    for(k=1; k<=10; k++) {
                        ll tmp=((ll)((j<<1)+1)<<(k-1));
                        int flag=p;
                        if(flag==0 && (tmp&s2)==s2) {
                            flag=1;
                        }
                        int j2=tmp%(1<<16);
                        dp[i+1][j2][flag]=(dp[i+1][j2][flag]+dp[i][j][p])%MOD;
                    }
                }
            }
        }
    }
    ll ans=0;
    for(j=0; j<(1<<16); j++) {
        ans=(ans+dp[n][j][1])%MOD;
    }
    printf("%lld\n", ans);

    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#define N 100010
#define mod 1000000007
#define ll long long
using namespace std;
ll fac[N],inv[N],f[N];
ll ksm(ll a,ll b=mod-2)
{
	ll ans=1;
	for(;b;b>>=1)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
int main()
{
	int n,l,r,lt,rt;
	scanf("%d%d%d%d%d",&n,&l,&r,&lt,&rt);
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	inv[n]=ksm(fac[n]);
	for(int i=n-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	f[0]=1;
	for(int i=l;i<=r;i++)
		for(int j=min(i*rt,n);j>=i*lt;j--)
		{
			ll u=ksm(inv[i],lt);
			int v=j-i*lt;
			for(int k=lt;k<=rt;k++)
			{
				f[j]=(f[j]+fac[j]*u%mod*inv[v]%mod*inv[k]%mod*f[v])%mod;
				v-=i,u=u*inv[i]%mod;
				if(v<0) break;
			}
		}
	printf("%d\n",f[n]);
	return 0;
}


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

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

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int col[100005];
graph g;
bool color(int x){
  bool ok = true;
  for(auto nx:g[x]){
    if(col[nx]!=-1) {
      if(col[nx]==col[x]) ok = false;
      else continue;
    }
    else {
      col[nx] = 1-col[x];
      if(!color(nx)) ok = false;
    }
  }
  return ok;
}

int main() {
  ll N,M;
  cin>>N>>M;
  g.resize(N);
  rep(i,100005) col[i] = -1;
  col[0]=0;
  rep(i,M){
    int x,y;
    cin>>x>>y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  bool can = color(0);
  if(!can) cout<<N*(N-1)/2-M<<endl;
  else{
    ll cnt0 = 0,cnt1 = 0;
    rep(i,N) {
      if(col[i]==0) cnt0++;
      if(col[i]==1) cnt1++;
    }
    cout<<cnt0*cnt1-M<<endl;
  }
}

#include <bits/stdc++.h>
//#include <ext/numeric>

using namespace std;
//using namespace __gnu_cxx;

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

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

    int log = ceil(log2(n));
    vector<vector<int>> par(n, vector<int>(log + 1));
    auto build = [&]() {
        int j = n - 1;
        for (int i = n - 1; ~i; --i) {
            while (arr[j] - arr[i] > l)
                --j;
            par[i][0] = j;
        }
    };
    build();

    for (int v = n - 1; ~v; --v) {
        for (int p = 1; p <= log; ++p)
            par[v][p] = par[par[v][p - 1]][p - 1];
    }

    int q;
    cin >> q;
    while(q--) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        if (u > v)
            swap(u, v);
        int ans = 0;
        for (int p = log; ~p; --p) {
            if (par[u][p] < v) {
                ans += (1 << p);
                u = par[u][p];
            }
        }
        cout << ans + 1 << '\n';
    }

    return 0;
}


// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename A, typename B>
bool cemax(A &a, const B &b) {
  return a <= b ? (a = b, true) : false;
}

void solve() {
  int m, mi, ma;
  while (cin >> m >> mi >> ma, m) {
    mi--, ma--;
    vi p(m);
    rep(i, m) cin >> p[i];
    int c = 0, r = 0;
    for (int i = mi; i <= ma; i++) {
      if (cemax(c, p[i] - p[i + 1])) r = i;
    }
    cout << r + 1 << endl;
  }
}

#include<iostream>

using namespace std;

int main() {
    while (1) {
        int m, nmin, nmax;
        cin >> m >> nmin >> nmax;

        if (m == 0) break;

        int ans = 0;
        int tmp;
        cin >> tmp;
        int maxgap = 0;
        for (int i = 1; i < m; ++i) {
            int s;
            cin >> s;
            if (maxgap <= tmp - s && i >= nmin && i <= nmax) {
                maxgap = tmp - s;
                ans = i;
            }
            tmp = s;
        }

        cout << ans << endl;
    }
}


#include<bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    vector<unsigned long> uf(2 * N), sz(2 * N);
    iota(uf.begin(), uf.end(), 0UL);
    fill(sz.begin(), sz.begin() + N, 1);
    const auto& find = [&uf](unsigned long i) -> unsigned long {
        while(i != uf[i])i = uf[i] = uf[uf[i]];
        return i;
    };
    const auto& unite = [&uf, &sz, &find](unsigned long i, unsigned long j) -> unsigned long {
        i = find(i);
        j = find(j);
        if(i == j)return 0;
        if(sz[i] < sz[j])swap(i, j);
        sz[i] += sz[j];
        uf[j] = i;
        return 1;
    };
    const auto& add_edge = [&N, &unite](unsigned long i, unsigned long j) -> void { unite(i, j + N); unite(i + N, j); };
    for(unsigned long i{0}, u, v; i < M; ++i){
        cin >> u >> v;
        add_edge(u - 1, v - 1);
    }
    if(find(0) == find(N))cout << N * (N - 1) / 2 - M << endl;
    else cout << sz[find(0)] * sz[find(N)] - M << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("in.txt", "r", stdin);
	int n, m;
	cin >> n >> m;
	vector<vi> adj(n);
	rep(i,0,m) {
		int a,b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	vi side(n, -1);
	bool is_bipartite = true;
	queue<int> q;
	q.push(0);
	side[0] = 0;
	while(!q.empty()) {
		int v = q.front();
		q.pop();
		for(int u : adj[v]) {
			if(side[u] == -1) {
				side[u] = (side[v] ^ 1);
				q.push(u);
			} else {
				is_bipartite &= (side[u] != side[v]);
			}
		}
	}
	if(is_bipartite) {
		int b, w;
		b = w = 0;
		rep(i,0,n) {
			if(side[i] == 0) {
				b++;
			} else {
				w++;
			}
		}
		cout << (ll)b * w - m << '\n';
	} else {
		cout << (ll)(n-1)*n / 2 - m << '\n';
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int r,g;
  cin>>r>>g;
  cout<<2*g-r<<endl;
  return(0);
}

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b;
  cin >> a >> b;
  cout << b - a + b << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
int main(){
    long x,y;cin>>x>>y;
    if(x<0&&y==0){
        cout<< -x;
    }
    if(x>=0&&y>=0){
        (y>x)?cout<<y-x:cout<<min(2+x-y,1+y+x);return 0;
    }
    else if(x<0&&y>0){
        (-x>y)?cout<<-x-y+1:cout<<1+x+y;return 0;
    }
    else if(x<0&&y<0){
        (y>x)?cout<<y-x:cout<<2+x-y;return 0;
    }
    else if(x>=0&&y<0){
        (-y>x)?cout<<-y-x+1:cout<<x+y+1;return 0;
    }
}

#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int a, b;
  cin >> a >> b;

  cout << (a > 8 || b > 8 ? ":(" : "Yay!");
}

int main()
{
  fastio;
  solve();

  return 0;
}


#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int main() {
  int N; cin >>N;
  if(N == 2){
    int a, b; cin >>a >>b;
    FOR(i, 1, max(a, b) + 1) if(a % i == 0 && b % i == 0) cout <<i <<endl;
  } else{
    int a, b, c; cin >>a >>b >>c;
    FOR(i, 1, max(a, max(b, c)) + 1) if(a % i == 0 && b % i == 0 && c % i == 0) cout <<i <<endl;
  }
  return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define sz(obj) ((int)(obj).size())
#define pf push_front
#define pb push_back

int main()
{
  int n;
  cin >> n;
  int a[3] = {0};
  REP(i, n) cin >> a[i];
  if (n == 2){
    FOR(i, 1, min(a[0], a[1]) + 1){
      if (a[0] % i == 0 && a[1] % i == 0) cout << i << endl;
    }
  }
  else {
    FOR(i, 1, min(min(a[0], a[1]), a[2]) + 1){
      if (a[0] % i == 0 && a[1] % i == 0 && a[2] % i == 0) cout << i << endl;
    }
  }
}


#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 M;
    cin >> M;
    vector<pair<ll,ll>> A;
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        A.push_back(make_pair(a,b));
    }
    ll sum = 0;
    ll dig = 0;
    for (int i = 0; i < M; ++i) {
        sum += A[i].first * A[i].second;
        dig += A[i].second;
    }
    cout << (dig-1) + (sum-1)/9 << endl;
}

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

ll n, sum, ans, res;
ll a[N], p[70];

void rd(ll &ans)
{
    ans = 0; ll f = 1;
    char x = getchar();
    while(x > '9' || x < '0') {if(x == '-') f = -1; x = getchar();}
    while(x >= '0' && x <= '9') ans = ans * 10 + x - '0', x = getchar();
    ans *= f;
}

void insert(ll x)
{
    for(int i = 60; ~i; i --)
        if(x & (1LL << i))
        {
            if(p[i]) x ^= p[i];
            else {p[i] = x; break;}
        }
}

int main()
{
    rd(n);
    for(int i = 1; i <= n; i ++) rd(a[i]), sum ^= a[i];
    for(int i = 0; i < 60; i ++)
    {
        if((sum & (1LL << i)) == 0) continue;
        ans += (1LL << i);
        for(int j = 1; j <= n; j ++)
            if(a[j] & (1LL << i)) a[j] ^= (1LL << i);
    }
    for(int i = 1; i <= n; i ++) insert(a[i]);
    for(int i = 60; ~i; i --) res = max(res, res ^ p[i]);
    printf("%lld", ans + (res << 1));
    return 0;
}


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

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

  if(s.size()%2)cout << "No" << endl;
  else{
    bool ok = true;

    for(int i=0; i<s.size(); i++){
      if(i%2==0 && s[i]!='h'){
        ok = false;
        break;
      }
      if(i%2==1 && s[i]!='i'){
        ok = false;
        break;
      }
    }
    if(ok)cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    if(S.length() == 3)
        reverse(S.begin(), S.end());
    cout << S << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x,k;
    cin>>x>>k;
    ll y[x];
    for (int i=0;i<x;i++){
            cin>>y[i];
    }
    ll ans=1e18;
    for (int i=0;i<x-k+1;i++){
        ll l=y[i],r=y[i+k-1];
        if (l<0&&r<0)
            ans=min(ans,-l);
        else if (r>0&&l>0)
            ans=min(ans,r);
        else if (abs(l)>abs(r))
            ans=min(ans,2*abs(r)+abs(l));
        else
            ans=min(ans,abs(r)+2*abs(l));
    }
    cout<<ans;
    return 0;
}

#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

int main() {
    ll L, R;
    cin >> L >> R;
    if (R - L >= 2050) cout << 0 << endl;
    else {
        ll ans = 2018;
        for (ll i = L; i < R; i++)
            for (ll j = i + 1; j <= R; j++) {
                ans = min(ans, (i * j) % 2019);
            }
        cout << ans << endl;
    }
}


#include<bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;++i)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
using namespace std;
using point = pair< int,int >;
using ll = long long;

int main(){
    int n;
    int m, e, j;
    bool hund;
    while (~scanf("%d", &n)) {
        REP(i, n) {
            hund = false;
            scanf("%d%d%d", &m, &e, &j);
            if (m == 100 || e == 100 || j == 100) hund = true;
            if (hund || (m + e) / 2 >= 90 || (m + e + j) / 3 >= 80) {
                puts("A");
            } else if ((m + e + j) / 3 >= 70 || (m + e + j) / 3 >= 50 && (m >= 80 || e >= 80)) {
                puts("B");
            } else {
                puts("C");
            }
        }
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define forn(i, a, b) for (int i = a; i < b; ++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

int a, b;
string s;

int main() {
#ifdef LOCAL
  freopen("c.txt", "r", stdin);
// freopen("main.txt", "w", stdout);
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#define dbg(...) 18
#endif
  bool ans = true;
  cin >> a >> b >> s;
  if (SZ(s) <= a)
    ans = false;
  else if (s[a] != '-')
    ans = false;
  dbg(ans);
  for (int i = 0; i < SZ(s) && ans; i++) {
    if (i == a) continue;
    ans = s[i] >= '0' && s[i] <= '9';
  }
  dbg(ans);
  ans = ans && (SZ(s) == (a + b + 1));
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i] << " "
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
bool isPerfectSquare(long double x) {
    long double sr = sqrt(x);
    return ((sr - floor(sr)) == 0);
}
bool isPrime(int x){
    for(int i = 2; i * i <= x; ++i){
        if(x % i == 0) return 0;
    }
    return 1;
}
int fun(int n){
    if(n & 1) return 3 * n + 1;
    else return n/2;
}
int32_t main(){
    SPEED;
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    int cnt = 0;
    for(char c: s) if(c == '-') cnt++;
    a--;
    if(s[a + 1] == '-' && cnt == 1) cout << "Yes";
    else cout << "No" ;
}


// Written by newbiechd
#include <cstring>
#include <iostream>
#include <string>

const int maxN = 13;
int n;
char col[maxN][maxN];
bool vis[26];
void dfs(int x, int y, char c) {
  if (x > n) {
    int val = 0;
    memset(vis, 0, sizeof(vis));
    for (int j = 1; j <= n; ++j) vis[col[1][j] - 'a'] = 1;
    for (char t = 'a'; t <= c; ++t) val += vis[t - 'a'];
    if (val != 3)
      return ;
    for (int i = 2; i <= n; ++i) {
      memset(vis, 0, sizeof(vis));
      int tmp = 0;
      for (int j = 1; j <= n; ++j) vis[col[i][j] - 'a'] = 1;
      for (char t = 'a'; t <= c; ++t) tmp += vis[t - 'a'];
      if (tmp != val)
        return ;
    }
    for (int j = 1; j <= n; ++j) {
      memset(vis, 0, sizeof(vis));
      int tmp = 0;
      for (int i = 1; i <= n; ++i) vis[col[i][j] - 'a'] = 1;
      for (char t = 'a'; t <= c; ++t) tmp += vis[t - 'a'];
      if (tmp != val)
        return ;
    }
    for (int i = 1; i <= n; ++i)
      printf("%s\n", col[i] + 1);
    putchar('\n'), fflush(stdout);
    return ;
  }
  if (y > n) {
    dfs(x + 1, 1, c);
    return ;
  }
  if (col[x][y - 1] == '.') {
    col[x][y] = col[x][y - 1] = c;
    dfs(x, y + 1, c + 1);
    col[x][y] = col[x][y - 1] = '.';
  }
  if (col[x - 1][y] == '.') {
    col[x][y] = col[x - 1][y] = c;
    dfs(x, y + 1, c + 1);
    col[x][y] = col[x - 1][y] = '.';
  }
  dfs(x, y + 1, c);
}

const std::string ans[][7] = {
  {
    "aabc",
    "ddbc",
    "efgg",
    "efhh"
  },
  {
    "aabbd",
    "ccf.d",
    "eefgg",
    "..hij",
    "..hij"
  },
  {
    "aabbcc",
    "ddeeff",
    "ghi...",
    "ghi...",
    "...jkl",
    "...jkl"
  },
  {
    "aabbcc.",
    "ddee..h",
    "ffgg..h",
    "....ijk",
    "....ijk",
    "....lmn",
    "....lmn"
  }
};

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cin >> n;
  /*
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      col[i][j] = '.';
  dfs(1, 1, 'a');
  */

  if (n < 3) {
    printf("-1\n");
    return 0;
  }
  if (n == 3) {
    std::cout << "aa.\n..a\n..a\n";
    return 0;
  }

  int k = (n & 3) + 4;
  for (int i = 0; i < n - k; ++i) {
    std::string str(n, '.');
    str.replace(i / 4 * 4, 4, ans[0][i % 4]);
    std::cout << str << '\n';
  }
  for (int i = n - k; i < n; ++i) {
    std::string str(n, '.');
    str.replace(n - k, k, ans[k - 4][i + k - n]);
    std::cout << str << '\n';
  }
  return 0;
}

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

class dice
{
public:
    int F[6];
    int q1, q2;
    dice();
	void input();
    void roll_a();
    void roll_b();
    bool check(const dice& d);
    bool equal(const dice& d);
};

dice::dice(){}

void dice::input()
{
    int i;
    for(i = 0; i < 6; i++) cin >> F[i];
    q1 = F[0] + F[1] + F[2] + F[3] + F[4] + F[5];
    q2 = F[0] * F[5] + F[1] * F[4] + F[2] * F[3];
}

void dice::roll_a()
{
    int i;
    i = F[0]; F[0] = F[2]; F[2] = F[1]; F[1] = i;
    i = F[3]; F[3] = F[4]; F[4] = F[5]; F[5] = i;
}

void dice::roll_b()
{
    int i;
    i = F[0]; F[0] = F[5]; F[5] = i;
    i = F[1]; F[1] = F[3]; F[3] = i;
    i = F[2]; F[2] = F[4]; F[4] = i;
}

bool dice::check(const dice& d)
{
    int l, m;
    if((d.F[0] != F[0]) || (d.F[5] != F[5])) return false;

    for(l = 1; l <= 4; l++){
        for(m = 1; m <= 4; m++){
            if(d.F[m] != F[(l * m) % 5]) break;
        }
        if(m == 5) return true;
    }
    return false;
}

bool dice::equal(const dice& d)
{
    bool eq;
    if((q1 != d.q1) || (q2 != d.q2)) return false;
    for(int i = 0; i < 2; i++){
        eq = check(d);
        if(!eq){ roll_a(); eq = check(d); }
        if(!eq){ roll_a(); eq = check(d); }
        if(eq || i == 1) break;
        roll_b();
    }
    return eq;
}

int main()
{
    dice d[100];
    int n, i, j;

    cin >> n;
    for(i = 0; i < n; i++){ d[i].input(); }

    for(i = 0; i < n; i++){
        for(j = i + 1; j < n; j++){
            if(d[i].equal(d[j])) break;
        }
        if(j < n) break;
    }
    if(i + j == 2 * n){ cout << "Yes"; }else{ cout << "No"; }
    cout << endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
const long long lim = 2e5+100;
typedef long long int lld;
typedef long long ll;

#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define mset(a, v) memset(a, v, sizeof(a))
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }

#define popcount __builtin_popcountll

ll powP(ll x, ll y) {
    ll ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}

vector<ll> Ans, Adj[lim];
ll Array[lim], C[lim],dp[600][600];
pair<ll,ll> P[lim];

int main(){

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

    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
    #endif

    lld T,i,p,j,l,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum=0,val,countA=0,indicator=0,pos,h,minA,maxA,type,n,ans=0,left,right;
    string A,B; a=b=0;
    cin>>n>>k;
    rep(i,1,k) { cin>>x; Array[x]=1; }
    while(1) {
        val=n; indicator=0;
        while(val>0) {
            if(Array[val%10]==1) indicator=1;
            val/=10;
        }

        if(indicator==0) break;
        n++;
    }

    cout<<n<<endl;
    return 0;
}

#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  vi v(n); rep(i,n) cin >> v[i];
  map<int,int> odd,even;
  rep(i,n){
    if(i % 2 == 0) even[v[i]]++;
    else odd[v[i]]++;
  }
  int mx_odd1 = 0, mx_even1 = 0, num_odd1, num_even1;
  for(auto x : odd) if(chmax(mx_odd1,x.second)) num_odd1 = x.first;
  for(auto x : even) if(x.first != num_odd1 && chmax(mx_even1,x.second)) num_even1 = x.first;

  int mx_odd2 = 0, mx_even2 = 0, num_odd2, num_even2;
  for(auto x : even) if(chmax(mx_even2,x.second)) num_even2 = x.first;
  for(auto x : odd) if(x.first != num_even2 && chmax(mx_odd2,x.second)) num_odd2 = x.first;

  int res = max(mx_odd1+mx_even1,mx_odd2+mx_even2);
  cout << n - res;
  cout << "\n";
  return 0;
}


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

void solve(){
  int main,temp,count=0;
  cin>>main;

  temp=floor(main/500);
  main=main-temp*500;
  count=count+temp*1000;
  count=count+floor(main/5)*5;
  cout<<count;
  return;

}

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

#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>

#define REP(i, n) for(int i = 0;i < (n); i++)
#define REP2(i, x, n) for(int i = (x); i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================

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

	string S; cin >> S; reverse(ALL(S)); cout << S << "\n";
	return 0;
}


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

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

  if(n < 10){
    cout << m + (10 - n)*100 << endl;
  }else{
    cout << m << endl;
  }
}

#include<stdio.h>

int main(){

	int N;
	int R;
	scanf("%d %d",&N,&R);
	int x;
	x = 10 - N;
	int inner;
	inner = 100 * x;

	if(N>100 || N<1 || R<0 || R>4111){
		printf("eror");
	}
	else if(N<10){
		printf("%d",inner + R);
	}
	else if(N>=10){
		printf("%d",R);
	}

	return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ((A + B) > (C + D)){
    cout << "Left" << endl;
  }
  if ((A + B) == (C + D)){
    cout << "Balanced" << endl;
  }
  if ((A + B) < (C + D)){
    cout << "Right" << endl;
  }
}

#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN(s);
  if(s.size()==3){
    REV(s);
    OUT(s);
  } else OUT(s);
}


#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int a,b,azb,abb,amb;
    cin>>a>>b;
    azb=a*b;
    abb=a+b;
    amb=a-b;
    cout << fmax(fmax(azb,abb),amb);
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

int main() {
  int N; cin >> N;
  int result = 180 * (N-2);
  cout << result << endl;
  return 0;
}


#include<cstdio>
#include<cmath>
#include <stdlib.h>
#include<algorithm>

using namespace std;

int main(){
	int ans;
	char sen[100];
	while( scanf("%s",&sen) != EOF ){
		ans=0;
		for(int i=0;sen[i]!='\0';i++){
			if(sen[i]=='I'){
				if(sen[i+1]=='V'||sen[i+1]=='X'){
					ans--;
				}
				else{
					ans++;
				}
			}
			if(sen[i]=='V'){
				ans+=5;
			}
			if(sen[i]=='X'){
				if(sen[i+1]=='L'||sen[i+1]=='C'){
					ans-=10;
				}
				else{
					ans+=10;
				}
			}
			if(sen[i]=='L'){
				ans+=50;
			}
			if(sen[i]=='C'){
				if(sen[i+1]=='D'||sen[i+1]=='M'){
					ans-=100;
				}
				else{
					ans+=100;
				}
			}
			if(sen[i]=='D'){
				ans+=500;
			}
			if(sen[i]=='M'){
				ans+=1000;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<vector>
using namespace std;
#define INF (1<<20)
map<string,int> m;
vector<int> num;
main(){
  m["I"]=1;
  m["II"]=2;
  m["III"]=3;
  m["IV"]=4;
  m["V"]=5;
  m["VI"]=6;
  m["VII"]=7;
  m["VIII"]=8;
  m["IX"]=9;
  m["X"]=10;

  m["XI"]=11;
  m["XII"]=12;
  m["XIII"]=13;
  m["XIV"]=14;
  m["XV"]=15;
  m["XVI"]=16;
  m["XVII"]=17;
  m["XVIII"]=18;
  m["XIX"]=19;
  m["XX"]=20;

  m["XXX"]=30;
  m["XL"]=40;
  m["L"]=50;
  m["LX"]=60;
  m["LXX"]=70;
  m["LXXX"]=80;
  m["XC"]=90;
  m["C"]=100;
  m["D"]=500;
  m["M"]=1000;
  string str;
  while(cin >> str){
    int res=0;
    int tmp;
    for(int i=0;i<(int)str.size();i++){
      for(int j=4;j>0;j--){
	if(i+j>str.size()) continue;
	if(m[str.substr(i,j)]>0){
	  num.push_back(m[str.substr(i,j)]);
	  i+=(j-1);
	  break;
	}
      }
    }
    int i=0;
    for(i=0;i<num.size()-1;i++){
      // cout << num[i] << endl;
      if(num[i]>=num[i+1]) res += num[i];
      else{ res += (num[i+1]-num[i]); i++;}
    }

    //   cout << num.back() << endl;
    if(i==num.size()-1)
      res += num.back();
    cout << res << endl;
    num.clear();
  }
}


#include<iostream>
using namespace std;

int x, i = 1;
int n;

void check_num();
void include3();
void end_check_num();

void check_num() {
	x = i;
	if (x % 3 == 0){
		cout << " " << i;
		end_check_num();
	}else include3();
}

void include3() {
	if (x % 10 == 3){
		cout << " " << i;
		end_check_num();
	}else{
		x /= 10;
		if (x)include3();
		else end_check_num();
	}
}

void end_check_num() {
	if (++i <= n) check_num();
}

int main() {
	cin >> n;
	check_num();
	cout << endl;
	char c;
	cin >> c;
}

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

int main(){
    int n;
    scanf("%d",&n);
    for (int i=3;i<=n;i++) {
        int x=i;
        if (i%3==0 || i%10==3) {
            printf(" %d",i);
        } else {
            while (x>0) {
                if (x%10==3) {
                    printf(" %d",i);
                    break;
                }
                x/=10;
            }
        }
    }
    printf("\n");
    return 0;
}


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

int main(){

    int n;
    cin >> n;
    cout << 0 << endl;
    string ss;
    cin >> ss;
    if (ss == "Vacant") return 0;
    int l = 0, r = n;
    while(true){
        int mid = (l+r)/2;
        cout << mid << endl;
        string s;
        cin >> s;
        if (s == "Vacant") return 0;
        if (mid % 2 == 1 && s != ss || mid % 2 == 0 && s == ss)
            l = mid + 1;
        else
            r = mid;
    }
}

#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 all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  auto bsearch = [&]() {
    bool fin = false;
    string s0;

    auto query = [&](int k) {
      cout << k << endl;
      string s;
      cin >> s;
      return s;
    };
    auto test = [&](int k) {
      string s = query(k);
      if(s == "Vacant") {
        return fin = true;
      } else if((k%2==1 && s!=s0) || (k%2==0 && s==s0)) {
        return true;
      } else {
        return false;
      }
    };

    int ok = 0, ng = N;
    s0 = query(0);
    while(abs(ok-ng)>1) {
      int mid = (ok+ng)/2;
      if(test(mid)) {
        if(fin) return;
        ok = mid;
      } else {
        ng = mid;
      }
    }
  };
  bsearch();
  return 0;
}


#include<queue>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include <cstring>
#include <string.h>
#include <cmath>
#include <math.h>
#include <time.h>
#define ll long long
#define N 100003
#define M 103
#define db double
#define P putchar
#define G getchar
#define inf 998244353
using namespace std;
char ch;
void read(int &n)
{
	n=0;
	ch=G();
	while((ch<'0' || ch>'9') && ch!='-')ch=G();
	ll w=1;
	if(ch=='-')w=-1,ch=G();
	while('0'<=ch && ch<='9')n=(n<<3)+(n<<1)+ch-'0',ch=G();
	n*=w;
}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}
ll abs(ll x){return x<0?-x:x;}
ll sqr(ll x){return x*x;}
void write(ll x){if(x>9) write(x/10);P(x%10+'0');}

int n,a[N],ans,s;
bool pd;

int gcd(int x,int y){return y==0?x:gcd(y,x%y);}

bool dfs(int x)
{
	s=pd=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==1)pd=1;
		if(a[i]&1)s++;
	}

	if((n-s)&1)return x;
	if(pd || s>1)return !x;

	for(int i=1;i<=n;i++)
		if(a[i]%2)
		{
			a[i]--;
			break;
		}

	int gc=a[1];
	for(int i=2;i<=n;i++)
		gc=gcd(gc,a[i]);
	for(int i=1;i<=n;i++)
		a[i]/=gc;
	return dfs(!x);
}

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

	read(n);
	for(int i=1;i<=n;i++)
		read(a[i]);

	if(dfs(1))puts("First");
		else puts("Second");

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }

#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define sp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

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

const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}

void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}

}

void solve()
{
	int n;
	cin >> n;
	ll a[n];
	vector<ll> p;
	rep(i, n) cin >> a[i];
	sort(a, a + n);
	rep(i, n){
		if(i && a[i] == a[i - 1]) p.pb(a[i++]);
	}
	sort(p.rbegin(), p.rend());
	if(sz(p) <= 1) cout << 0;
	else cout << p[0] * p[1];
}

int main()
{
	// freopen("crosses.in", "r", stdin);
	// freopen("crosses.out", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}

#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  int n,q;
  cin >> n >> q;
  vector <int> res;
  int a[n];
  int sq = sqrt(n);
  int nsq = n/sq+1;
  int lazy[nsq];
  fill(a,a+n,2147483647);
  fill(lazy,lazy+nsq,-1);
  REP(i,q){
    int z;
    cin >> z;
    if(z == 0){
      int s,t,x;
      cin >> s >> t >> x;

      /*if(s == t){
	a[s] = x;
	}*/
      if(t/sq == s/sq){
	if(lazy[t/sq] >= 0){
	  fill_n(a+(t/sq)*sq,sq,lazy[t/sq]);
	  lazy[t/sq] = -1;
	}
	if(t-s+1 == sq){
	  lazy[t/sq] = x;
	}
	else{
	  fill_n(a+s,t-s+1,x);
	}
	//cout << "debug1" <<endl;
      }

      else{
	//cout << "debug3" << endl;
	int f = s,to = t;
	while(to%sq != (sq - 1)){
	  to--;
	}
	while(f%sq != 0){
	  f++;
	}
	if(lazy[t/sq] >= 0){
	  fill_n(a+(t/sq)*sq,sq,lazy[t/sq]);
	}
	if(lazy[s/sq] >= 0){
	  fill_n(a+(s/sq)*sq,sq,lazy[s/sq]);
	}
	fill_n(a+to+1,t-to,x);
	lazy[t/sq] = -1;
	fill_n(a+s,f-s,x);
	lazy[s/sq] = -1;
	f = f/sq;
	to = to/sq;
	if(f <= to){
	  fill_n(lazy+f,to-f+1,x);
	}

      }
      /*REP(i,n)
	cout << a[i] << "  ";
	cout << endl;*/
    }
    else{
      int x;
      cin >> x;
      int te = x / sq;

      if(lazy[te] < 0){
	//cout << a[x] << endl;
	res.pb(a[x]);
      }
      else{
	fill_n(a+te*sq,sq,lazy[te]);
	lazy[te] = -1;
	//cout << a[x] << endl;
	res.pb(a[x]);

      }

    }

  }
  for(int i = 0;i < res.size();i++){
    cout << res[i] << endl;
  }
  //cout << res.size() << endl;
  return 0;
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n, k; cin >> n >> k;
	vector<int> a(n);
	REP(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	bool odd, even;
	odd = even = true;
	REP(i, n) {
		if (a[i] % 2) even = false;
		else odd = false;
	}
	bool allSame = true;
	bool diffFlag = true;
	int diff = INT_MAX;
	REP(i, n - 1) {
		if (abs(a[i] - a[i+1]))
			diff = min(diff, abs(a[i] - a[i+1]));
	}
	REP(i, n - 1) {
		if (a[i] != a[i+1])
			allSame = false;
		if (abs(a[i] - a[i+1]) % diff)
			diffFlag = false;
	}

	if (k > *max_element(a.begin(), a.end())) {
		cout << "IMPOSSIBLE" << '\n';
	}
	else if (find(a.begin(), a.end(), k) != a.end()) {
		cout << "POSSIBLE" << '\n';
	}
	else if (allSame) {
		cout << ((k == a[0]) ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
	}
	else if (diffFlag) {
		cout << ((k % diff == 0) ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
	}
	else {
		if (k % 2) {
			bool ok = true;
			if (even) ok = false;
			if (k == 1 && (even || odd)) ok = false;
			cout << ((ok) ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
		}
		else {
			cout << "POSSIBLE" << '\n';
		}
	}
    return 0;
}

/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

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

// std::cout << std::setprecision(20) << 1.1 << endl;

int64_t GreatestCommonDivisor(const int64_t a, const int64_t b) {
  // GCD. O(log(min(a, b))). 最大公約数.
  int64_t result = -1LL;
  if (a < 0) {
    std::cerr << "ERROR: GreatestCommonDivisor(): a is out of range: " << a << std::endl;
    throw 1;
  } else if (b < 0LL) {
    std::cerr << "ERROR: GreatestCommonDivisor(): b is out of range: " << b << std::endl;
    throw 1;
  } else if (a == 0LL) {
    result = b;
  } else if (b == 0LL) {
    result = a;
  } else {
    const int64_t new_a = std::min(a, b);
    const int64_t new_b = std::max(a, b) % new_a;  // Euclidean Algorithm
    result = GreatestCommonDivisor(new_a, new_b);
  }
  return result;
}

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

  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> A(N);
  for (int64_t i = 0; i < N; ++i) {
    cin >> A[i];
  }
  int64_t temp = A[0];
  for (int64_t i = 1; i < N; ++i) {
    temp = GreatestCommonDivisor(temp, A[i]);
  }
  if (K % temp == 0 && K <= (*max_element(A.begin(), A.end()))) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }

  return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<ll,ll>pll;

ll n,x[100010]={0},y[100010]={0};
vector<pll>vx,vy;
vector<pll>edge[100010];
priority_queue<pll,vector<pll>,greater<pll>>q;
//priority_queue<pll>q;
bool used[100010];
ll res=0;

signed main(){

    cin>>n;
    for(int i=0;i<n;++i){
        cin>>x[i]>>y[i];
        vx.push_back(pll(x[i],i));
        vy.push_back(pll(y[i],i));
    }

    sort(vx.begin(),vx.end());
    sort(vy.begin(),vy.end());
    for(int i=0;i<n-1;++i){
        ll j=vx[i].second,k=vx[i+1].second;
        ll wj=vx[i].first,wk=vx[i+1].first;
        edge[j].push_back(pll(wk-wj,k));
        edge[k].push_back(pll(wk-wj,j));
        j=vy[i].second,k=vy[i+1].second;
        wj=vy[i].first,wk=vy[i+1].first;
        edge[j].push_back(pll(wk-wj,k));
        edge[k].push_back(pll(wk-wj,j));
    }

    for(int i=0;i<n;++i){
        used[i]=false;
    }
    int c=1;
    for(int i=0;i<edge[0].size();++i)q.push(edge[0][i]);
    used[0]=true;
    while(c<n){
        pll t=q.top();
        q.pop();
        if(!used[t.second]){
            res+=t.first;
            for(int i=0;i<edge[t.second].size();++i){
                q.push(edge[t.second][i]);
            }
            used[t.second]=true;
            c++;
            //cout<<t.first<<" "<<t.second<<endl;
        }
    }

    cout<<res<<endl;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

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(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string a,b,c;
	cin>>n>>a>>b>>c;
	int ans=0;
	rep(i,n){
		set<char> cnt;
		cnt.insert(a[i]),cnt.insert(b[i]),cnt.insert(c[i]);
		if(cnt.size()==3) ans+=2;
		else if(cnt.size()==2) ans+=1;
	}
	cout<<ans<<endl;
}


#include <iostream>
#include<algorithm>
using namespace std;
int g[100],jyunni[100];
int n;
void katimake(int a,int b,int c,int d){
	if(c>d){g[a-1]+=3;}
	else if(d>c){g[b-1]+=3;}
	else{
		g[a-1]++;
		g[b-1]++;
	}
	}
int main() {
	cin>>n;
	for(int i = 0;i<100;i++){
		g[i]=0;
	}
	int p,q,r,s;
	while(cin>>p>>q>>r>>s){katimake(p,q,r,s);}
	int jyu = 1;
	int saidai=0;
	for(int i= 0;i<n;i++){saidai=max(saidai,g[i]);}
	for(int p=saidai;saidai>=0;saidai--){
		int y=0;
		for(int i =0;i<n;i++){
		if(g[i]==saidai){
			jyunni[i]=jyu;
			y++;
			}
		}
		jyu+=y;
	}
	for(int i = 0;i<n;i++){
		cout<<jyunni[i]<<endl;
	}
	return 0;
}

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

int main()
{
	int n, team1, team2, score1, score2, point[101] = {0};
	vector<int> rank;
	cin >> n;
	for(int i = 0; i < n * (n - 1) / 2; i++){
		cin >> team1 >> team2 >> score1 >> score2;
		if(score1 > score2)
			point[team1] += 3;
		else if(score1 < score2)
			point[team2] += 3;
		else{
			point[team1]++;
			point[team2]++;
		}
	}

	for(int i = 0; i < n; i++)
		rank.push_back(point[i + 1]);

	stable_sort(rank.begin(), rank.end(), greater<int>());

	for(int i = 1; i <= n; i++){
		for(int j = 0; j < n; j++){
			if(point[i] == rank[j]){
				cout << j + 1 << endl;
				break;
			}
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

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

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

i64 pow(i64 x, i64 n, i64 m) {
	i64 ret = 1;
	while(n) {
		if(n & 1) (ret *= x) %= m;
		(x *= x) %= m;
		n >>= 1;
	}
	return ret;
}

i64 inv(i64 n, i64 m) {
	return pow(n, m - 2, m);
}

int main() {
	i64 n, m; scanf("%lld%lld", &n, &m);

	i64 N = 1;
	for(i64 i = 1; i <= 3 * n; i++) N = N * i % m;

	std::vector<int> tan(3 * n + 1);
	for(i64 i = 0; i < tan.size(); i++) tan[i] = inv(i, m);

	int offset = 3 * n;
	auto dp = make_v<int>(3 * n + 1, 6 * n + 1); dp[0][offset] = N;
	for(int i = 0; i < 3 * n; i++) {
		for(int j = 0; j < 6 * n; j++) {
			i64 from = dp[i][j];
			if(!from) continue;

			if(i + 1 <= 3 * n) (dp[i + 1][j + 1] += from * tan[i + 1] % m) %= m;
			if(i + 2 <= 3 * n)(dp[i + 2][j - 1] += from * tan[i + 2] % m) %= m;
			if(i + 3 <= 3 * n)(dp[i + 3][  j  ] += from * tan[i + 3] % m) %= m;
		}
	}

	i64 ans = 0;
	for(int i = offset; i < 6 * n + 1; i++) (ans += dp[3 * n][i]) %= m;
	printf("%lld\n", ans);
	return 0;
}

#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

int main() {
  Cinint(n);
  Cinstring(s);
  int64_t count = 0;
  int64_t Rcount = 0;
  int64_t Gcount = 0;
  int64_t Bcount = 0;
  rep(i, n) {
    if (s.at(i) == 'R') {
      Rcount++;
    }
    else if (s.at(i) == 'G') {
      Gcount++;
    }
    else {
      Bcount++;
    }
  }
  count = Rcount*Gcount*Bcount;
  rep(i, n-2) {
    for (int j = i+1; j < n-1; j++) {
      int sa = j-i;
      int k = j+sa;
      if (k <= n-1) {
        if (s.at(i) == 'R') {
          if (s.at(j) == 'G') {
            if (s.at(k) == 'B') {
              count--;
            }
          }
          else if (s.at(j) == 'B') {
            if (s.at(k) == 'G') {
              count--;
            }
          }
        }
        else if (s.at(i) == 'G') {
          if (s.at(j) == 'B') {
            if (s.at(k) == 'R') {
              count--;
            }
          }
          else if (s.at(j) == 'R') {
            if (s.at(k) == 'B') {
              count--;
            }
          }
        }
        else {
          if (s.at(j) == 'R') {
            if (s.at(k) == 'G') {
              count--;
            }
          }
          else if (s.at(j) == 'G') {
            if (s.at(k) == 'R') {
              count--;
            }
          }
        }
      }
    }
  }
  cout << count << endl;
}


#include <bits/stdc++.h>
using namespace std;
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(15);

    int a,b;
    cin>>a>>b;
    a--;
    b--;
    cout<<(b+a-1)/a<<endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k=1;
  cin >> a >> b;
  for(int i=0;i<100000;i++){
    if(a*i+k-->=b){
      cout << i << endl;
      break;
    }
  }
}


#include<bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<int>so;
  vector<bool>un(N + 1, true);
  const long long mo = 1e9 + 7;
  for (int i = 2; i <= N; i ++) {
    if (un[i]) {
      so.push_back(i);
      for (int j = 0; j <= N / i; j ++) {
        un[i * j] = false;
      }
    }
  }
  long long ans = 1;
  int si = (int)so.size();
  for (int i = 0; i < si; i ++) {
    int n = N;
    long long kj = 0;
    while (n) {
      kj += (long long) n / so[i];
      n /= so[i];
      kj %= mo;
    }
    ans *= kj + 1;
    ans %= mo;
  }
  cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define MOD 1000000007
#define all(c) c.begin(), c.end()
#define peek(v)      \
	for (auto i : v) \
		cout << i << ' ';

void solve()
{
	vector<ll> v(1001, 0);
	ll n, k;
	cin >> n;
	for (ll i = 2; i <= n; i++)
	{
		k = i;
		for (ll j = 2; k > 1;)
		{
			if (k % j == 0)
				k /= j, v[j]++;
			else
				j++;
		}
	}
	ll res = 1;
	for (ll i : v)
		res = res * (i + 1) % MOD;
	cout << res;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	solve();
	cerr << "\n\n~" << 500 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

ll y[10000005];

int main() {
    string s; cin >> s;
    int n = s.size();

    map<char,int> mp;
    rep(i,n) mp[s[i]]++;

    rep(i,26){
        if(!mp[char (i+97)]){
            cout << s + char(i+97) << endl;
            return 0;
        }
    }
    if(s == "zyxwvutsrqponmlkjihgfedcba") cout << -1 << endl;
    else {
        for(int i = n-1; i >= 1; i--){
            if(s[i-1] < s[i]){
                rep(j,i-1){
                    cout << s[j];
                }
                for(int j = n-1; j>=1;j--){
                    if(s[i-1] < s[j]){
                        cout << s[j];
                        return 0;
                    }
                }
                return 0;
            }
        }
    }
}

/**
*    author:  souzai32
*    created: 05.08.2020 01:20:01
**/

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

int main() {

    string s;
    cin >> s;

    int n=s.size();
    vector<bool> alphabet(26);

    if(n==26){
        int i=1;
        while(1){
            if(s.at(n-i)<s.at(n-1-i)) i++;
            else{
                int j=0;
                while(1){
                    if(s.at(n-1-i)<s.at(n-1-j)){
                        s.at(n-1-i)=s.at(n-1-j);
                        break;
                    }
                    else j++;
                }

                for(int j=0; j<i; j++) s.pop_back();
                break;
            }

            if(i==26){
                s="-1";
                break;
            }
        }
    }
    else{
        rep(i,n){
            alphabet.at(s.at(i)-'a')=true;
        }

        int i=0;
        char a='a';
        while(1){
            if(alphabet.at(i)) i++;
            else{
                a+=i;
                s.push_back(a);
                break;
            }
        }
    }

    cout << s << endl;
    //cout << s.size() << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}

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

// #define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#include <bits/stdc++.h>

// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
using ll = long long;
using P = pair<int, int>;
using V = vector<int>;
using VV = vector<V>;

template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
//~ int A = (1<<2) | (1<<3) | (1<<5) | (1<<7);
//~ for (int bit=A; ; bit=(bit-1)&A){
//~ if (!bit) break;
//~ }
int next_combination(int sub) {
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}
//~ int n=5;
//~ int k=3; // nCkの組み合わせ、ただしk=0には対応してない
//~ int bit=(1<<k)-1; // 1000 -> 0111
//~ for(; bit < (1<<n); bit=nex_combination(bit){
//~ }
bool isPrime(int a) {
    if (a == 2) return true;
    if (a <= 1 || a % 2 == 0) return false;

    for (int i = 3; i * i <= a; i += 2) {
        if (a % i == 0) return false;
    }
    return true;
}
//~ vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};
vector<int> aaa;
// index が条件を満たすかどうか
bool isOK(int index, int key) {
    if (aaa[index] >= key)
        return true;
    else
        return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
    int ng = -1;  //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok =
        (int)aaa
            .size();  // 「index =
                      // a.size()-1」が条件を満たさないこともあるので、初期値は
                      // a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

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

//~ int v[100100];
//~ int INF = 1 << 30;
//~ vector<vector<int>> dp(310, vector<int>(310));
//~ ll dp[110][100100];
//~ vector<int> dp(100100, 0));

//~ int seen[110];
//~ int ans[110][2];
//~ ll MOD = 1e9 + 7;

void memo() {
    // int n = 100;
    // vector<int> a(n);
    // rep(i, n) {
    //     cin >> a[i];
    //     a[i]--;
    // }

    // vector<int> ans(n);
    // iota(ans.begin(), ans.end(), 0);
    // sort(ans.begin(), ans.end(), [&](int i, int j) { return a[i] < a[j]; });

    // double t1 = 0.1;
    // cout << fixed << setprecision(6) << t1 << endl;

    // int x;
    // cin >> x;

    // int n1 = 200001;
    // vector<int> ans1;
    // vector<int> primes(n, 1);
    // int i;
    // for (i = 2; i * i <= n; i++) {
    //     if (primes[i]) ans1.push_back(i);
    //     for (int j = i; j <= n; j += i) { primes[j] = 0; }
    // }
    // for (; i < n; i++) {
    //     if (primes[i]) { ans1.push_back(i); }
    // }

    // cout << *lower_bound(ans1.begin(), ans1.end(), x) << endl;
}

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

    vector<int> a(n);
    rep(i, n) cin >> a[i];

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

    vector<int> acted(n, 0);
    rep(i, n) {
        if (a[i] <= x) {
            x -= a[i];
            acted[i] = a[i];
        } else {
            break;
        }
    }
    acted.back() += x;

    int ans = 0;
    rep(i, n) {
        if (a[i] == acted[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    map<ll,ll> mp;
    ll ans=0;
    vector<ll> a(n);
    REP(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    reverse(ALL(a));
    REP(i,n){
        bool f=false;
        REPR(j,32){
            if((1LL<<j)<=a[i]){
                break;
            }
            if(mp[(1LL<<j)-a[i]]){
                ans++;
                mp[(1LL<<j)-a[i]]--;
                f=true;
                break;
            }
        }
        if(!f){
            mp[a[i]]++;
        }
    }
    cout << ans << endl;
}

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

int main()
{
	string A;
	cin >> A;
	ll ans = A.size() * (A.size() - 1) / 2;
	char c = 'a';
	rep(i,26)
	{
		ll cnt = 0;
		rep(j,A.size())
		{
			if (A[j] == c) cnt++;
		}
		if (cnt != 0) ans -= cnt * (cnt - 1) / 2;
		c++;
	}
	ans++;
	cout << ans << endl;
	return 0;
}


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

vector<long long int>D;

int main() {
	long long int N;
	D.push_back( 1 );
	D.push_back( 1 );
	D.push_back( 2 );
	D.push_back( 4 );
	while( cin >> N, N ) {
		while( D.size() <= N ) {
			D.push_back( D[D.size() - 1] + D[D.size() - 2] + D[D.size() - 3] );
		}
		cout << D[N] / 3650 + 1 << endl;
	}
}


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

int main() {
  int N,K; cin >> N >> K;
  int D[K]; rep(i,K) cin >> D[i];

  int ans = N;
  while (true) {
    int tmp = ans;
    bool check = true;
    while (check && tmp >0) {
      int a = tmp % 10;
      rep(i,K) if (a == D[i]) {
        check = false;
        break;
      }
      if (check) {
        tmp /= 10;
      } else {
        ans++;
        break;
      }
    }
    if (check) break;
  }
  cout << ans << endl;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(int i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(int i=(a);i<(n);i++)cout<<(arr)[i]<<' ';

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

int main(){
	fast;
	ll n, k;
	cin>>n>>k;
	ll d;
	map<ll, ll> m;
	forn(i, 0, k){
		cin>>d;
		m[d]++;
	}
	ll ans;
	forn(i, n, n+100000){
		ll x = i, f = 1;
		while(x){
			if(m[x%10]>0){
				f = 0;
				break;
			}
			x/=10;
		}
		if(f == 1){
			ans = i;
			break;
		}
	}
	cout<<ans<<endl;
}


#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

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

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

const int INF = 1001001001;
int n;
vector<int> to[1005];

vector<int> bfs(int sv) {
    vector<int> dist(n,INF), pre(n,-1);
    queue<int> q;
    dist[sv] = 0;
    q.push(sv);
    while (!q.empty()) {
        int v = q.front(); q.pop();
        for (int u : to[v]) {
            if(dist[u] != INF) continue;
            pre[u] = v;
            dist[u] = dist[v] + 1;
            q.push(u);
        }
    }

    pair<int, int> best(INF, -1);
    rep(v,n) {
        if (v == sv) continue;
        for (int u : to[v]) {
            if (u == sv) {
                best = min(best, make_pair(dist[v],v));
            }
        }
    }
    if(best.first == INF) return vector<int>(n+1);
    int v = best.second;
    vector<int> res;
    while(v != -1){
        res.push_back(v);
        v = pre[v];
    }
    return res;
}

int main(){
    int m;
    cin >> n >> m;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
    }

    vector<int> ans(n+1);
    rep(s, n){
       auto now =  bfs(s);
       if(now.size() < ans.size()) ans = now;
    }
    if(ans.size() == n + 1){
        cout << -1 << endl;
        return 0;
    }
    cout << ans.size() << endl;
    for (int v: ans){
        cout << v+1 << endl;
    }

}

#include<cstdio>
#include<utility>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int, int> P;

const int INF = 1050;
struct vertex {
    vector<int> to;
    int dist = INF;
};

int n, m;
int sd[1000], prv[1000];
vertex ver[1000];
priority_queue<P, vector<P>, greater<P>> q;

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        ver[a - 1].to.emplace_back(b - 1);
    }
    for (int i = 0; i < n; i++) sd[i] = INF;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) ver[j].dist = INF;
        ver[i].dist = 0;
        q.emplace(0, i);
        while(!q.empty()) {
            P p = q.top(); q.pop();
            if (p.second != i && ver[p.second].dist != p.first) continue;
            if (p.second == i && p.first != 0 && sd[i] != p.first) continue;
            for (auto &j : ver[p.second].to) {
                if (j != i && p.first + 1 < ver[j].dist) {
                    ver[j].dist = p.first + 1;
                    q.emplace(ver[j].dist, j);
                }
                if (j == i && p.first + 1 < sd[i]) {
                    sd[i] = p.first + 1;
                    q.emplace(sd[i], i);
                }
            }
        }
    }

    int minsd = INF, ind;
    for (int i = 0; i < n; i++) {
        if (sd[i] < minsd) {
            minsd = sd[i];
            ind = i;
        }
    }
    if (minsd == INF) {
        printf("-1\n");
        return 0;
    }

    for (int i = 0; i < n; i++) ver[i].dist = INF;
    ver[ind].dist = 0;
    sd[ind] = INF;
    q.emplace(0, ind);
    while(!q.empty()) {
        P p = q.top(); q.pop();
        if (p.second != ind && ver[p.second].dist != p.first) continue;
        if (p.second == ind && p.first != 0 && sd[ind] != p.first) continue;
        for (auto &i : ver[p.second].to) {
            if (i != ind && p.first + 1 < ver[i].dist) {
                ver[i].dist = p.first + 1;
                q.emplace(ver[i].dist, i);
                prv[i] = p.second;
            }
            if (i == ind && p.first + 1 < sd[ind]) {
                sd[ind] = p.first + 1;
                q.emplace(sd[ind], ind);
                prv[i] = p.second;
            }
        }
    }

    printf("%d\n", minsd);
    for (int i = 0, j = ind; i < minsd; i++) {
        printf("%d\n", j + 1);
        j = prv[j];
    }
    return 0;
}


//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

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

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

#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define FORE(i,c) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void mxze(T &x, U y) { if(x < y) x = y; }

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(_i, (x)) cerr <<*_i <<", "; cerr <<"\n"; }}
#define debuga(x, sz) {{cerr <<#x <<" = "; FOR(_i, 0, sz) cerr << x[_i] <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

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

int dig, D[46];

ll dp[50][2][2];

ll f(int d, int cl, int cr){
	int d2 = dig-1-d;
	if(d2 < d) return cl==cr;
	if(d2 == d) return (10*cl-cr == D[d])*10;
	ll &ret = dp[d][cl][cr];
	if(ret!=-1) return ret;
	ret = 0;
	FOR(dl,0,10) FOR(dr,0,10) FOR(ncl,0,2) FOR(ncr,0,2){
		if(dr - cr + 10*ncr - dl == D[d] && dl + 10*cl - ncl - dr == D[d2]){
			if(!d && !dr) continue;
			//debug(dl, dr, ncl, ncr);
			ret += f(d+1, ncl, ncr);
		}
	}
	return ret;
}

int main(){
	int d, mnd=0; scan(d);
	FOR(_,0,49){
		if(d) mnd = _+1;
		D[_] = d%10;
		d/=10;
	}
	ll ans = 0;
	FOR(i,mnd,49){
		ms(dp,-1);
		dig = i;
		ans += f(0,0,0);
	}
	printf("%lld\n", ans);
}

#include <bits/stdc++.h>

using namespace std;
using ll=long long ;

void solve() {
    ll k; cin >> k;
    ll x = k/50;
    int j = k%50;

    vector<ll> a(50, 50+x);
    j = (50-j);
    for (int i = 0; i < j; i++) {
        a[i] += -50+j-1;
    }
    for (int i = j; i < 50; i++) {
        a[i] += j;
    }

    cout << "50\n";
    for (auto& x: a) {
        cout << x << ' ';
    }
}

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