#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll 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};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    ll T;
    cin >> N >> T;
    vi t(N);
    cin >> t;
    REP(i, N - 1) {
        if (t[i + 1] - t[i] > T)
            ans += T;
        else
            ans += t[i + 1] - t[i];
    }
    ans += T;
    cout << ans << endl;
}

#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
    int x, y, z;
    cin >> x >> y >> z;
    int ansx, ansy, ansz;
    ansx = y;
    ansy = x;
    x = y;
    y = ansy;
    ansx = z;
    ansz = x;
    cout << ansx << " " << ansy << " " << ansz << endl;
}


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

const int MAX = 2600000;
int mod = 998244353;
int n, m;
int fact[MAX];
int inv[MAX];
int factInv[MAX];

void initFact() {
	int i;

	fact[0] = fact[1] = 1;
	factInv[0] = factInv[1] = 1;
	inv[1] = 1;
	for (i = 2; i <= 3 * m + n; i++) {
		fact[i] = (i * fact[i - 1]) % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		factInv[i] = factInv[i - 1] * inv[i] % mod;
	}
}

int comb(int n, int k) {
	if (k > n) return 0;
	return fact[n] * factInv[n - k] % mod * factInv[k] % mod;
}

signed main() {
	cin >> n >> m;
	initFact();

	int x;
	int ng = 0;
	for (x = 2 * m + 1; x <= 3 * m; x++) {
		int res = n * comb(3 * m - x + n - 2, n - 2) % mod;
		ng += res;
		ng %= mod;
	}

	//奇数がx個
	for (x = m + 1; x <= n; x++) {
		if (x > 3 * m) break;
		if ((3 * m - x) % 2 != 0) continue;
		int res = comb((3 * m - x) / 2 + n - 1, n - 1) * comb(n, x) % mod;
		ng += res;
		ng %= mod;
	}

	int all = comb(3 * m + n - 1, n - 1);
	int ans = (all - ng + mod) % mod;

	cout << ans << endl;
	return 0;
}

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    int N, x;
    cin >> N >> x;
    vector<ll> a(N);
    rep(i, N) { cin >> a[i]; }

    ll cnt = 0;
    for (int i = 0; i < N - 1; i++) {
        if (a[i] + a[i + 1] > x) {
            int diff = a[i] + a[i + 1] - x;
            if (diff > a[i + 1])
                cnt += a[i + 1], a[i + 1] = 0;
            else
                cnt += diff, a[i + 1] -= diff;
        }
    }

    for (int i = 0; i < N - 1; i++) {
        if (a[i] + a[i + 1] > x) {
            int diff = a[i] + a[i + 1] - x;
            a[i] -= diff, cnt += diff;
        }
    }

    cout << cnt << endl;
}


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

const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const int N = 405;
const int INF = 1e9;
char board[N][N];
int h,w;

bool is_in(int x, int y) {
  if(0 <= x && x < h && 0 <= y && y < w) return true;
  return false;
}

signed main() {
  cin >> h >> w;

  rep(i,h) rep(j,w) cin >> board[i][j];
  vector<vector<int>> d(h, vector<int> (w, INF));

  int ans = 0;
  rep(ii,h) rep(jj,w) {
    if(board[ii][jj] != '#' || d[ii][jj] != INF) continue;
    int sx = ii, sy = jj;

    queue<P> que;
    d[sx][sy] = 0;
    que.push({sx,sy});

    int cnt = 0;
    int black = 1;
    while(!que.empty()) {
      int cx = que.front().first;
      int cy = que.front().second;
      que.pop();

      for (int i = 0; i < 4; i++) {
        int nx = cx + dx[i];
        int ny = cy + dy[i];
        if(!is_in(nx, ny)) continue;
        if(board[nx][ny] == board[cx][cy] || d[nx][ny] != INF) continue;

        if(board[nx][ny] == '.') cnt++;
        else if(board[nx][ny] == '#') black++;

        d[nx][ny] = d[cx][cy] + 1;
        que.push({nx, ny});
      }
    }

    ans += cnt * black;
  }
  cout << ans << '\n';
}

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

using T = tuple<ll, ll, ll>;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  string s;
  cin >> n >> s >> q;
  rep(_, q) {
    int k;
    cin >> k;
    vector<T> res(n);
    ll ans = 0;
    rep(i, n) {
      if (i)
        res[i] = res[i-1];
      if (i-k >= 0) {
        if (s[i-k] == 'D') {
          get<2>(res[i]) -= get<1>(res[i]);
          get<0>(res[i])--;
        }
        if (s[i-k] == 'M')
          get<1>(res[i])--;
      }
      if (s[i] == 'D')
        get<0>(res[i])++;
      if (s[i] == 'M') {
        get<1>(res[i])++;
        get<2>(res[i]) += get<0>(res[i]);
      }
      if (s[i] == 'C')
        ans += get<2>(res[i]);
    }
    cout << ans << '\n';
  }
  return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,char>> array(m);
    for(int i=0;i<m;i++) cin >> array.at(i).first >> array.at(i).second;
    int s,g;
    s = 1;
    for(int i=0;i<n-1;i++) s*=10;
    g = s * 10;
    if(n == 1) s = 0;
    for(int i=s;i<g;i++){
        string str_number = to_string(i);
        bool flag = true;
        for(int j=0;j<m;j++){
            if(str_number.at(array.at(j).first - 1) != array.at(j).second) flag = false;

        }
        if(flag){
                cout << str_number << endl;
                return 0;
            }
    }
    cout << -1 << endl;
}

// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
//#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,n,maxi=0,f=0,mini=INF;
    ll sum=0;
    string str,sub;
    ll h,w;
    ll m;
    cin>>n>>m;
    if(m==0){
        if(n==1){
            cout<<0<<endl;
        }else if(n==2){
            cout<<10<<endl;
        }else{
            cout<<100<<endl;
        }
        return 0;
    }
    vector<pair<ll,ll>> s(m);

    rep(i,m){
        cin>>a>>b;
        s[i]=make_pair(a,b);
    }
    f=0;
    sort(s.begin(),s.end());
    sum=0;
            if(s[0].first==1) {
                //sum-=100;
                if(s[0].second==0&&n!=1) f=1;

                sum+=100*s[0].second;
            }
            if(s[0].first==2){
                //if(s[0].second==0&&n==2) f=1;

                sum+=10*s[0].second;
               // sum-=10;
            }
            if(s[0].first==3){
                //sum-=1;
                sum+=1*s[0].second;
            }
    for(ll i=1;i<m;i++){
        if(s[i-1].first==s[i].first&&s[i-1].second!=s[i].second) f=1;
        else if(s[i-1].first==s[i].first&&s[i-1].second==s[i].second) continue;
        else{
            if(s[i].first==1) {
               // sum-=100;
               if(s[i].second==0&&n!=1) f=1;
                sum+=100*s[i].second;
            }
            if(s[i].first==2) {
               // sum-=10;
                sum+=10*s[i].second;
            }
            if(s[i].first==3) {
              //  sum--;
                sum+=1*s[i].second;
            }
        }
    }
    if(n==1&&sum!=0) sum/=100;
    if(n==2&&sum!=0) sum/=10;
    if(n==3&&sum!=0&&sum<100) sum+=100;
    if(n==2&&sum<10) sum+=10;
    if(f!=1&&sum==0&&n==1){
        cout<<0<<endl;
        return 0;
    }

    if(f==1){
        cout<<"-1"<<endl;
    }else{
        cout<<sum<<endl;
    }
    return 0;
}


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

int main()
{
    int m;
    cin >> m;
    ll sum = 0, n = 0;
    rep(i,m)
    {
        ll c, d;
        cin >> d >> c;
        n += c;
        sum += c * d;
    }
    cout << n - 1 + ((sum - 1) / 9) << endl;

    return 0;
}

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

typedef long long ll;
const int nax = 5010;
const ll INF = 1e18L;
ll dp[nax][nax];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  for (int i = 0; i < nax; ++i) {
    for (int j = 0; j <= i; ++j) {
      dp[i][j] = INF;
    }
  }
  dp[0][0] = 0;

  int n;
  cin >> n;
  vector<pair<int, int>> q(n);
  for (int i = 0; i < n; ++i) {
    cin >> q[i].first >> q[i].second;
    q[i].first += q[i].second;
  }
  sort(q.begin(), q.end());
  for (int i = 0; i < n; ++i) {
    q[i].first -= q[i].second;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= i; ++j) {
      if (dp[i][j] == INF) continue;
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      if (dp[i][j] <= q[i].first) {
        dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + q[i].second);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    if (dp[n][i] != INF) {
      ans = i;
    }
  }
  cout << ans << '\n';
}


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

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;

const int INFTY=1<<29;

int dfs(vvi& a,int ci,int cj,int depth)
{
	if(depth==10)
		return INFTY;

	int h=a.size(),w=a[0].size();
	int di[]={-1,1,0,0},dj[]={0,0,-1,1};
	int res=INFTY;
	rep(k,4){
		for(int i=ci+di[k],j=cj+dj[k];;i+=di[k],j+=dj[k]){
			if(i<0 || h<=i || j<0 || w<=j)
				break;
			if(a[i][j]==1){
				if(abs(i-ci)+abs(j-cj)>1){
					a[i][j]=0;
					res=min(res,dfs(a,i-di[k],j-dj[k],depth+1));
					a[i][j]=1;
				}
				break;
			}
			if(a[i][j]==3)
				return depth+1;
		}
	}
	return res;
}

int main()
{
	for(int w,h;cin>>w>>h;){
		vvi a(h,vi(w));
		rep(i,h) rep(j,w)
			cin>>a[i][j];

		rep(i,h) rep(j,w)
			if(a[i][j]==2){
				a[i][j]=0;
				int res=dfs(a,i,j,0);
				cout<<(res==INFTY?-1:res)<<endl;
			}
	}

	return 0;
}

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

using vvi = std::vector<std::vector<int>>;

void solve()
{
    using namespace std;

    constexpr int inf = (1 << 23);

    int n;
    cin >> n;

    vector<int> d(n + 1);

    for (int i = 0; i < n; ++i)
    {
        cin >> d[i];
        if(i + 1 != n)
            cin.ignore(numeric_limits<streamsize>::max(), ' ');
    }

    cin.ignore(numeric_limits<streamsize>::max(), ' ');
    cin >> d[n];

    vvi dp (n, vector<int>(n, 0));

    //自分自身との積は乗算が発生しない
    for (int i = 0; i < n; ++i)
        dp[i][i] = 0;

    for (int l = 1; l < n; ++l)
    {
        for (int i = 0; i < n - l; ++i)
        {
            int j = i + l;
            dp[i][j] = inf;
            for (int k = i; k < j; ++k)
            {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + d[i] * d[k + 1] * d[j + 1]);
            }
        }
    }

    cout << dp[0][n - 1] << endl;
}

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


#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=200000+100;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
	#define N 100000

	int fac[N+100],invfac[N+100];

	int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
	int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
	int mul(int x,int y) {return 1ll*x*y%maxd;}
	ll qpow(ll x,int y)
	{
		ll ans=1;
		while (y)
		{
			if (y&1) ans=mul(ans,x);
			x=mul(x,x);y>>=1;
		}
		return ans;
	}
	int getinv(int x) {return qpow(x,maxd-2);}

	int C(int n,int m)
	{
		if ((n<m) || (n<0) || (m<0)) return 0;
		return mul(mul(fac[n],invfac[m]),invfac[n-m]);
	}

	void math_init()
	{
		fac[0]=invfac[0]=1;
		rep(i,1,N) fac[i]=mul(fac[i-1],i);
		invfac[N]=getinv(fac[N]);
		per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
	}
	#undef N
}
using namespace My_Math;

int n,a[N];
ll sum[N];

ll calc(int l,int r) {return sum[r]-sum[l-1];}

int main()
{
	n=read();
	rep(i,1,n) a[i]=read();
	rep(i,1,n) sum[i]=sum[i-1]+a[i];
	int l=1,r=3;
	ll ans=1e18;
	rep(i,2,n-2)
	{
		while ((l+2<=i) && (abs(calc(1,l)-calc(l+1,i))>abs(calc(1,l+1)-calc(l+2,i)))) l++;
		while ((r+2<=n) && (abs(calc(i+1,r)-calc(r+1,n))>abs(calc(i+1,r+1)-calc(r+2,n)))) r++;
		ll mx=0,mn=1e18,x;
		x=calc(1,l);mx=max(mx,x);mn=min(mn,x);
		x=calc(l+1,i);mx=max(mx,x);mn=min(mn,x);
		x=calc(i+1,r);mx=max(mx,x);mn=min(mn,x);
		x=calc(r+1,n);mx=max(mx,x);mn=min(mn,x);
		ans=min(ans,mx-mn);
	}
	printf("%lld\n",ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> a(n), s(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s[i] = a[i] + (i ? s[i - 1] : 0);
    }
    ll ans = 1e18;
    int j = 0, k = 2;
    for (int i = 1; i < n - 2; i++) {
        while (j + 1 < i && s[j] < s[i] - s[j]) {
            j++;
        }
        while (k + 1 < n - 1 && s[k] - s[i] < s[n - 1] - s[k]) {
            k++;
        }
        for (int u = j - 1; u <= j; u++) {
            for (int v = k - 1; v <= k; v++) {
                if (0 <= u && i < v) {
                    vector<ll> x = {s[u], s[i] - s[u], s[v] - s[i], s[n - 1] - s[v]};
                    sort(x.begin(), x.end());
                    ans = min(ans, x[3] - x[0]);
                }
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


#include <bits/stdc++.h>

const int MAXN = 100010;
int fa[MAXN], n, dep[MAXN], ans, K;
int head[MAXN], nxt[MAXN];
int dfs(int u) {
	int res = dep[u];
	for (int i = head[u]; i; i = nxt[i]) {
		dep[i] = dep[u] + 1;
		res = std::max(dfs(i), res);
	}
	if (res - dep[u] == K - 1 && fa[u] != 1) fa[u] = 1, ++ans, res = 0;
	return res;
}
void dfs2(int u) {
	for (int i = head[u]; i; i = nxt[i])
		dep[i] = dep[u] + 1, dfs2(i);
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> K;
	for (int i = 1; i <= n; ++i) std::cin >> fa[i];
	for (int i = 2; i <= n; ++i)
		nxt[i] = head[fa[i]], head[fa[i]] = i;
	for (int i = head[1]; i; i = nxt[i]) dfs(i);
	memset(head, 0, n + 1 << 2);
	memset(dep, 0, n + 1 << 2);
	for (int i = 2; i <= n; ++i)
		nxt[i] = head[fa[i]], head[fa[i]] = i;
	for (int i = head[1]; i; i = nxt[i]) dep[i] = 1, dfs2(i);
	bool flg = true;
	for (int i = 1; i <= n; ++i) flg &= (K - dep[i]) % (dep[fa[1]] + 1) == 0;
	ans += !flg;
	std::cout << ans << std::endl;
	return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int maxn = 100010;
int n,k,head[maxn],to[maxn],nextt[maxn],tot = 1,ans;

void add(int x,int y)
{
    to[tot] = y;
    nextt[tot] = head[x];
    head[x] = tot++;
}

int dfs(int u,int faa,int from)
{
    int res = 0;
    for (int i = head[u];i;i = nextt[i])
    {
        int v = to[i];
        if (v == faa)
            continue;
        res = max(res,dfs(v,u,from) + 1);
    }
    if (u != from && res >= k - 1)
    {
        ans++;
        return -1;
    }
    else
        return res;
}

int main()
{
    scanf("%d%d",&n,&k);
    for (int i = 1; i <= n; i++)
    {
        int x;
        scanf("%d",&x);
        if (i == 1)
        {
            if (x != 1)
                ans++;
        }
        else
            add(x,i);
    }
    for (int i = head[1];i;i = nextt[i])
        dfs(to[i],1,to[i]);
    printf("%d\n",ans);

    return 0;
}


#include <iostream>

int main(){
    std::string inp;
    std::cin >> inp;
    for(char& c:inp)
        if (c == '7') {std::cout << "Yes"; return 0;}
    std::cout << "No";

    return 0;
}

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

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

    string ans;

    if(a==b){
        if(a!=c){
            ans="Yes";
        }else{
            ans="No";
        }

    }else if(b==c){
        if(a!=c){
            ans="Yes";
        }else{
            ans="No";
        }
    }else if(c==a){
        if(b!=c){
            ans="Yes";
        }else{
            ans="No";
        }
    }else{
        ans="No";
    }
    cout<<ans<<endl;

    return 0;
}


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

int main(){
  int n;
  int a[3];

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

  vector<int> can;
  for(int i=1;i*i<=a[0];i++){
    if(!(a[0]%i)){
      can.push_back(i);
      if(i*i!=a[0])can.push_back(a[0]/i);
    }
  }

  vector<int> ans;
  for(int i=1;i<n;i++){
    ans.clear();
    for(int j=0;j<can.size();j++){
      if(!(a[i]%can[j]))ans.push_back(can[j]);
    }
    can = ans;
  }

  sort(can.begin(),can.end());
  for(int i=0;i<can.size();i++)cout << can[i] << endl;
}

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

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


#include <iostream>
using namespace std;

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

    return 0;
}

#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  double d = sqrt(n);
  int i = d;
  int ans = i * i;
  cout << ans << endl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int pre_e[MAX],pre_w[MAX],suf_w[MAX],suf_e[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);

    int len;
    string s;
    cin>>len;
    cin>>s;
    for(int i=1; i<=len; i++)
    {
        pre_e[i]=pre_e[i-1];
        pre_w[i]=pre_w[i-1];
        if(s[i-1]=='E')
            pre_e[i]++;
        else
            pre_w[i]++;
    }
    for(int i=len; i>=1; i--)
    {
        suf_e[i]=suf_e[i+1];
        suf_w[i]=suf_w[i+1];
        if(s[i-1]=='E')
            suf_e[i]++;
        else
            suf_w[i]++;
    }
    int mx=INT_MAX;
    for(int i=1;i<=len;i++){
        int x=pre_w[i-1]+suf_e[i+1];
        mx=min(x,mx);
    }
    cout<<mx<<endl;

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; string S; cin >> N >> S;
	string first[262200] = {}, second[262200] = {};
	for(int i = 0; i < (1 << N); i++){
		string tmp1, tmp2;
		for(int j = 0; j < N; j++){
			if((i >> j) & 1) tmp1.push_back(S.at(j));
			else tmp2.push_back(S.at(j));
		}
		reverse(tmp2.begin(), tmp2.end());
		first[i] = tmp1 + '1' + tmp2;
	}
	for(int i = 0; i < (1 << N); i++){
		string tmp1, tmp2;
		for(int j = 0; j < N; j++){
			if((i >> j) & 1) tmp1.push_back(S.at(N+j));
			else tmp2.push_back(S.at(N+j));
		}
		reverse(tmp2.begin(), tmp2.end());
		second[i] = tmp2 + '1' + tmp1;
	}
	sort(second, second + (1 << N));
	long long int ans = 0;
	for(int i = 0; i < (1 << N); i++){
		ans += upper_bound(second, second + (1 << N), first[i]) - lower_bound(second, second + (1 << N), first[i]);
	}
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
long long M=1e9+7;
void solve(){
	int n;
	cin>>n;
	long long sum=0,ans=0,p;
	for(int i=0;i<n;i++){
		cin>>p;
		ans= (ans+(p*sum)%M)%M;
		sum=(sum+p)%M;
	}
	cout<<ans;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();

}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main(){fastio
    ll n;cin>>n;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll b=0;
    ll c=0;
    rep(i,0,n-1){
        b+=a[i];
        c+=a[i]*a[i];
        b=mod(b);
        c=mod(c);
    }
    ll ans=mod(b*b-c);
    if(ans%2==0){
        cout<<mod(ans/2)<<endl;
    }else{
        cout<<mod((ans+i_7)/2)<<endl;
    }

    return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 100000000;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
ll n;
string s;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> s;
    map<pair<string,string>,ll> count;
    rep(bit,1<<n){
        string s1,t1;
        rep(i,n){
            if (bit&(1<<i)){
                s1 += s[i+n];
            }
            else{
                t1 += s[i+n];
            }
        }
        reverse(all(t1));
        count[make_pair(t1,s1)]++;
    }
    ll ans = 0;
    rep(bit,1<<n){
        string s1,t1;
        rep(i,n){
            if (bit&(1<<i)){
                s1 += s[i];
            }
            else{
                t1 += s[i];
            }
        }
        reverse(all(t1));
        ans += count[make_pair(s1,t1)];
    }
    PRINT(ans);
}

#include <bits/stdc++.h>

using namespace std;

#define debug(a) cerr << #a << ": " << a << endl

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

#define x first
#define y second

const int N = 20;

int n;
char s[2 * N];

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	cin >> n;
	scanf("%s", s);

	vector< pair<string, string> > v1, v2;
	int mask_end = 1 << n;

	for (int mask = 0; mask < mask_end; mask++) {
		string tmp1, tmp2;
		for (int i = 0; i < n; i++) {
			if (mask & 1 << i) tmp1 += s[i];
			else tmp2 += s[i];
		}
		reverse(tmp2.begin(), tmp2.end());
		v1.push_back({tmp1, tmp2});
	}

	for (int mask = 0; mask < mask_end; mask++) {
		string tmp1, tmp2;
		for (int i = 0; i < n; i++) {
			if (mask & 1 << i) tmp1 += s[n + i];
			else tmp2 += s[n + i];
		}
		reverse(tmp2.begin(), tmp2.end());
		v2.push_back({tmp1, tmp2});
	}

	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());

	ll ans = 0LL;
	for (auto i : v1) {
		swap(i.x, i.y);
		auto res = equal_range(v2.begin(), v2.end(), i);
		ans += res.y - res.x;
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main(){
    int a, b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << endl;

}

#include <iostream>
 using namespace std ;
 int main()
 {
   int A, B, c, d, e;
   cin>>A;
   cin>>B;
   c =(A + B);
   d =(A - B);
   e =(A * B);
   if (c >= e&&c >= d)
   {
   cout<<c<<endl;
   }
else   if (e >= d&&e >= c)
   {
     cout<<e<<endl;
   }
  else  if (d >= e&&d >= c)
   {
     cout<<d<<endl;
   }
   }


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

void solve() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h+2, vector<char>(w+2));
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            cin >> a[i][j];
        }
    }
    int di[] = {1, 0, -1, 0};
    int dj[] = {0, 1, 0, -1};
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if(a[i][j] == '.') {
                continue;
            }
            int x = 0;
            for (int k = 0; k < 4; k++) {
                x += (a[i + di[k]][j + dj[k]] == '#');
            }
           if(!x) {
               cout << "No";
               return;
           }

        }
    }
    cout << "Yes";
}

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

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b
vi vx={-1,0,1,0};
vi vy={0,1,0,-1};
using pi = pair<int,int>;

signed main(){
	int a,b; cin>>a>>b;
	vvi v(a,vi(b));
	queue<pi> q;
	rep(i,0,a){
		rep(j,0,b){
			char c; cin>>c;
			if(c=='#'){
				v[i][j]=1;
				q.push(make_pair(i,j));
			}
			else v[i][j]=0;
		}
	}
	while(!q.empty()){
		pi p=q.front(); q.pop();
		int k,l; tie(k,l)=p;
		bool ok=false;
		rep(i,0,4){
			k+=vx[i]; l+=vy[i];
			if(k>=0 && k<a){
				if(l>=0 && l<b){
					if(v[k][l]==1)ok=true;
				}
			}
			k-=vx[i]; l-=vy[i];
		}
		if(!ok){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;

	return 0;
}


#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

#include<atcoder/fenwicktree>
using namespace atcoder;

int n,q;

int main(){
	cin>>n>>q;
	fenwick_tree<ll> fw(n);
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		fw.add(i,x);
	}
	for(int i=0;i<q;i++){
		int t;
		cin>>t;
		if(t==0){
			int p,x;
			cin>>p>>x;
			fw.add(p,x);
		}
		else{
			int l,r;
			cin>>l>>r;
			cout<<fw.sum(l,r)<<endl;
		}
	}
}

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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007

//ここから編集する
class Solve {
public:
    void solve() {
        Int N, M;
        cin >> N >> M;
        vector<Int> A(M);
        int ki = 0;
        for (int i = 0; i < M; ++i) {
            cin >> A[i];
            if (A[i] % 2) ki++;
        }

        if (ki > 2) {
            cout << "Impossible" << endl;
            return;
        }

        sort(all(A), [](Int a, Int b) {
            return a % 2 > b % 2;
        });

        if (A.size() > 1 && A[1] % 2 == 1) {
            swap(A[1], A.back());
        }
        vector<Int> B = A;
        if (B.size() == 1) {
            B.push_back(1);
            B[0]--;
            if (B[0] == 0) {
                swap(B[0], B[1]);
            }
        }

        B[0]--;
        B.back()++;
        if (B[0] == 0) {
            B.erase(B.begin());
        }
        if (B.back() == 0) {
            B.pop_back();
        }

        for (int i = 0; i < M; ++i) {
            cout << A[i] << " ";
        }
        cout << endl;
        cout << B.size() << endl;
        for (auto e : B) {
            cout << e << " ";
        }
        cout << endl;

    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();

    return 0;
}


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

int main(){
  int A,B,K;
  cin>>A>>B>>K;
  for(int i=0;i<K;i++){
    if(i%2==0){
      A -= A%2;
      B += A/2;
      A /= 2;
    }
    else{
      B-=B%2;
      A+=B/2;
      B/=2;
    }
  }
  cout << A <<" "<< B << endl;
}


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

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

vector<int> ball(200005,0);

void putball(int n){
  for(int i=1; i<=sqrt(n); i++){
    if(n%i==0){
      ball.at(i)++;
      if(i!=n/i)ball.at(n/i)++;
      //cout << "putball " << i << endl;
    }
  }
}

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

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

  int ballcount = 0;
  vector<int> b;

  rep(i,n){
    int j = n-i;
    if((ball.at(j)%2)!=a.at(j-1)){
      putball(j);
      b.push_back(j);
      ballcount++;
      //cout << "putball " << j << endl;
    }
  }

  if((ball.at(1)%2)==a.at(0)){
    cout << ballcount << endl;
    rep(i,b.size()) cout << b.at(i) << " ";
  }else{
    cout << "-1";
  }

  //cout << "hoge";
  //rep(i,n) cout << ball.at(i+1) << " ";
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    V<int> a(n);
    rep(i,n) cin >> a[i];
    int tot = 0;
    rep(i,n) tot += a[i];
    V<P> v(n);
    rep(i,n) {
        v[i] = make_pair(abs(tot-a[i]*n), i);
    }
    sort(all(v));
    cout << v[0].se << endl;
}


#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int x,y,tx,ty;
    cin>>x>>y>>tx>>ty;
    int n=abs(x-tx);
    int m=abs(y-ty);
    cout<<string(n,'R')<<string(m,'U');
    cout<<string(n,'L')<<string(m,'D');
    cout<<'L'<<string(m+1,'U')<<string(n+1,'R')<<'D';
    cout<<'R'<<string(m+1,'D')<<string(n+1,'L')<<'U';
    cout<<endl;

    return 0;
}

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

int main(void) {
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  for (int i = 0; i < B; i++) {
    for (int j = 0; j < A; j++) {
      cout << 0;
    }
    for (int j = A; j < W; j++) {
      cout << 1;
    }
    cout << endl;
  }
  for (int i = B; i < H; i++) {
    for (int j = 0; j < A; j++) {
      cout << 1;
    }
    for (int j = A; j < W; j++) {
      cout << 0;
    }
    cout << endl;
  }
  return 0;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const double PI = 4*atan(1);
const ll INF = 1e18;
const int MX = 100001;

string S;
int num[300001][3][2][3]; // yes even, yes odd, current parity, current num

void ad(int& x, int y) {
    x = (x+y)%MOD;
}

void solve() {
    num[0][0][0][0] = 1;
    F0R(i,sz(S)) F0R(a,3) F0R(b,2) F0R(c,3) if (num[i][a][b][c]) {
        if (S[i] != '1') ad(num[i+1][a][b][c == 2 ? 1 : c+1],num[i][a][b][c]);
        if (S[i] != '0') {
            if (c == 0) {
                if (b == 0) ad(num[i+1][max(a,1)][b^1][0],num[i][a][b][c]);
                else ad(num[i+1][a>0?2:0][b^1][0],num[i][a][b][c]);
            } else if (c == 1) {
                ad(num[i+1][a][b][0],num[i][a][b][c]);
            } else {
                ad(num[i+1][a][b^1][0],num[i][a][b][c]);
            }
        }
    }
    int ans = 0;
    F0R(a,3) F0R(b,2) F0R(c,3)
        if (a == 2 || (a == 1 && b == 1 && c == 0))
            ad(ans,num[sz(S)][a][b][c]);

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

string gen() {
    string t;
    F0R(i,5) {
        int k = rand();
        if (k % 3 == 0) t += '0';
        else if (k % 3 == 1) t += '1';
        else t += '?';
    }
    return t;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> S;
    solve();
}

// read the question correctly (is y a vowel?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

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

#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << " = " << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define SP << " " <<

typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;

const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<class T> inline T ceil(T a, T b) {return T((a + b - 1) / b);}
template<class T> inline T round(T a, T b) {return T(a / b);}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }
template <class T> inline void out(T &a) { bool flag=true; for(auto&x:a){if(flag) {flag=false;} else{ cout << ' '; } cout<<x; } cout << endl; }

//----------------------------------------------------------------
int nmax=200000; // 2*(10^5)
vvec g(nmax);

void solve4ts()
{

    int N; cin >> N;
	cout << 0 << endl;
	string first; cin >> first;

	int l = 0, r = N;
	if(first!="Vacant")while (1) {
		int m = (l + r) / 2;
		cout << m << endl;

		string s; cin >> s;
		if (s == "Vacant")break;

		if (m % 2 && s != first || m % 2 == 0 && s == first)l = m + 1;
		else r = m;
	}
}
//-----------------------------------------------------------------

signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15);
    int repeat = 1;
    // cin >> repeat;
    while(repeat--) solve4ts();
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long K, std::string S)
{

  int n = S.size();
  if (K < n)
  {
    S = S.substr(0, K);
    S += "...";
  }

  cout << S << endl;
}

int main()
{
  cout << setprecision(10);
  long long K;
  scanf("%lld", &K);
  std::string S;
  std::cin >> S;
  solve(K, S);
  return 0;
}

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   /// https://ideone.com/Fd5s8n
  int k;
  cin>>k;
  string s;
  cin>>s;
  if(s.length()<=k)
    cout << s << endl;
  else{
    for(int i=0;i<k;i++)
        cout << s[i];
cout << "..." << endl;
  }

    return 0;

}


/**
 *    author:  otera
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n, m;
vector<vector<int>> a;

void solve() {
	cin >> n >> m;
    a.assign(n, vector<int>(m));
    rep(i, n) {
        rep(j, m) {
            cin >> a[i][j];
            -- a[i][j];
        }
    }
    vector<int> used(n, 0), check(m, 1);
    int ans = n;
    int cnt = 0;
    while(true) {
        map<int, int> mp;
        rep(i, n) {
            while(used[i] < m && !check[a[i][used[i]]]) {
                used[i] ++;
            }
            mp[a[i][used[i]]] ++;
        }
        set<int> se; int ma = 0;
        for(auto p: mp) {
            if(ma == p.sc) {
                se.insert(p.fr);
            } else if(ma < p.sc) {
                se.clear();
                ma = p.sc;
                se.insert(p.fr);
            }
        }
        chmin(ans, ma);
        for(auto j: se) {
            check[j] = 0;
            ++ cnt;
        }
        if(cnt == m) break;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int main() {
  int N,M;
  cin >> N >> M;
  vvi A(N,vi(M));
  rep(i,N) {
    rep(j,M) {
      cin >> A[i][j];
      A[i][j]--;
    }
  }
  int ans = INF;
  vi except(M,0);
  while(1) {
    vi cnt(M,0);
    rep(i,N) {
      int idx=0;
      while(idx < M && except[A[i][idx]]) idx++;
      if(idx==M) {
        cout << ans << endl;
        return 0;
      }
      cnt[A[i][idx]]++;
    }
    int n = 0;
    rep(i,M) {
      n = max(n,cnt[i]);
    }
    ans = min(ans,n);
    rep(i,M) {
      if(cnt[i]==n) {
        except[i]++;
      }
    }
  }
  return 0;
}


#include <bits/stdc++.h>

#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int n = s.length();
    if(s.length()==2){
        if(s[0]==s[1]) cout<<"1 2";
        else cout<<"-1 -1";
        return 0;
    }
    bool f = false;
    for(int i=0; i+1<n; i++){
        if(s[i]==s[i+1]) {
            cout<<i+1<<" "<<i+2;
            f = true;
            break;
        }
    }
    for(int i=0; i+2<n && f!=true; i++){
        if(s[i]==s[i+1] || s[i+2]==s[i+1] || s[i]==s[i+2]) {
            cout<<i+1<<" "<<i+3;
            f = true;
            break;
        }
    }
    if(!f) cout<<"-1 -1";
    return 0;
}

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

typedef long long ll;
typedef short int sh;

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

vector<int>vec[26];
char str[MAX];

void Get_Pos()
{
    for(int i=0;str[i];i++)
    {
        int k=str[i]-'a';
        vec[k].push_back(i);
    }
}

void Solve()
{
    for(int i=0;i<26;i++)
    {
        int l=vec[i].size();
        for(int j=0;j<l;j++)
        {
            int t=vec[i].at(j);
            for(int k=j+1;k<l;k++)
            {
                int r=vec[i].at(k);
                if(((k-j+1)<<1)>r-t+1)
                {
                    printf("%d %d\n",t+1,r+1);
                    return;
                }
            }
        }
    }
    printf("-1 -1\n");
}

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


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b;
  cin >> a >> b;
  rep(i, 100) {
    ll now = i * a - i + 1;
    if(now < b) continue;
    cout << i << endl;
    return 0;
  }
}

#include <iostream>

int main()
{
	int A, B;
	std::cin >> A >> B;
	if ((B-1)%(A-1)==0) std::cout << (B-1)/(A-1) << std::endl;
	else std::cout << (B-1)/(A-1) + 1 << std::endl;
	return 0;
}


#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, A, B, i, X[100001], ans=0;

    cin >> N >> A >> B;

    for(i=1; i<=N; i++){
        cin >> X[i];

        if(i>=2){
            ans += min(A*(X[i]-X[i-1]), B);
        }
    }

    cout << ans << endl;

    return 0;
}

#include<bits/stdc++.h>

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int main()
{
    LL n, t;
    cin >> n >> t;

    LL ans = 0, x = 0;
    for(int i = 0; i < n; i++){
        LL a;
        cin >> a;

        if(x < a)
            ans += t;
        else
            ans += a + t - x;
        x = a + t;
    }

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


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#define rep(i,n) for(int i=0;i<(int)n;i++)

using namespace std;

string ten[3]={"A","B","C"};

int main()
{
	int n;
	cin>>n;
	for(;n!=0;cin>>n)
	{
		rep(i,n)
		{
			int ma,en,ja;
			int ans=2;
			cin>>ma>>en>>ja;

			if(((ma+en+ja)/3>=50&&(ma>=80||en>=80))||(ma+en+ja)/3>=70)ans=1;
			if((ma+en+ja)/3>=80||(ma+en)/2>=90||en==100||ja==100||ma==100)ans=0;

			cout<<ten[ans]<<endl;
		}

	}
}


#include <bits/stdc++.h>
using namespace std;
#define oo 1000000010
#define mod 1000000007
const int N = 100010;
int n , m , arr[N] , v , p;

bool check(int mid){
	int val = arr[mid] + m;
	if(arr[n - p] > val)
		return false;
	long long all = 0;
	for(int i = 0 ;i < n - p + 1;i++){
		all += min(m , max(0 , val - arr[i]));
	}
	all /= m;
	if(all >= v - (p - 1))
		return true;
	return false;
}

int main(){
	scanf("%d%d%d%d",&n,&m,&v,&p);
	for(int i = 0 ;i < n;i++){
		scanf("%d",&arr[i]);
	}
	sort(arr,arr+n);
	int low = 0 , high = n - 1 , res = n , mid;
	while(high >= low){
		mid = (low + high) / 2;
		if(check(mid))
			res = mid , high = mid - 1;
		else
			low = mid + 1;
	}
	cout << n - res << endl;
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
// generated from pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)

unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap){
  unsigned i,count = 0;
  for(i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}

void shell_sort(unsigned a[], unsigned n){
  int i;
  unsigned gap_num = 0;
  while(gaps[++gap_num] < n);
  gap_num--;

  unsigned count = 0;
  for(i = gap_num; i >= 0; i--) count += insertion_sort(a,n,gaps[i]);

  printf("%u\n",(gap_num+1));

  for(i = gap_num; i; i--) printf("%u ",gaps[i]);
  printf("%u\n",gaps[0]);

  printf("%u\n",count);
}

int main(){
  unsigned n,i;
  scanf("%u",&n);
  unsigned* a = (unsigned*)malloc(sizeof(unsigned)*n);
  for(i = 0; i < n; i++) scanf("%u",&a[i]);
  shell_sort(a,n);
  for(i = 0; i < n; i++) printf("%u\n",a[i]);
  free(a);
  return 0;
}


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

int main() {

    while(1){

        int m,nmin,nmax;

        cin >> m >> nmin >> nmax;

        if(m == 0 && nmin == 0 && nmax == 0) break;

        int p[m];

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

        sort(p,p+m,greater<int>());

        pair<int,int> ans = make_pair(0,0);

        for(int i=nmin; i<=nmax; i++) {
            if(ans.second <= p[i-1] - p[i]){
                ans = make_pair(i,p[i-1] - p[i]);
            }
        }

        cout << ans.first << endl;

    }

    return 0;
}

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

int main(){
    long double N,M,D;
    cin >> N >> M >> D;
    if(D==0){
        cout << setprecision(10) << (1/N)*(M-1) << endl;
    }else{
        // 1組の隣り合った項の差がDである確率は
        // 2(N-D)通り / N*N通り
        cout << setprecision(10) << 2*(M-1)*(N-D)/N/N << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O2,no-stack-protector,unroll-loops,fast-math")
#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()
#define MP make_pair
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll maxn=3e5+10, maxm=1e6+10, lg=21, mod=1e9+7, inf=1e18;

string s;
ll n,dp[maxn][3][3],ans;

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

	cin>>s;
	dp[0][0][0]=1;
	for(int i=0;i<SZ(s);i++)for(int t0=0;t0<3;t0++)for(int t1=0;t1<3;t1++){
		if(s[i]!='0'){
			if(t0) (dp[i+1][t0-1][t1]+=dp[i][t0][t1])%=mod;
			else (dp[i+1][t0][min(t1+1,2)]+=dp[i][t0][t1])%=mod;
		}
		if(s[i]!='1'){
			if(t0>1) (dp[i+1][t0-1][t1]+=dp[i][t0][t1])%=mod;
			else (dp[i+1][t0+1][t1]+=dp[i][t0][t1])%=mod;
		}
	}
	for(int t0=0;t0<3;t0++)for(int t1=t0;t1<3;t1++) (ans+=dp[SZ(s)][t0][t1])%=mod;
	cout<<ans;

	return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

const Int MO = 1000000007;
int N;
char S[300050], T[300050];
Int dp1[300050][2], lef[300050];
Int dp2[300050][2][2];

inline void add(Int& a, Int b) {
  a += b;
  if (a >= MO) a -= MO;
}

Int solve() {
  if (T[0] == '1' && T[N - 1] == '1') {
    Int ret = 1;
    for (int i = 0; i < N; ++i) {
      if (T[i] == '?') {
        (ret *= 2) %= MO;
      }
    }
    return ret;
  }
  if (T[0] == '1') {
    reverse(T, T + N);
  }

  memset(dp1, 0, sizeof(dp1));
  memset(lef, 0, sizeof(lef));
  dp1[0][0] = 1;
  for (int i = 0; i < N; ++i) {
    if (T[i] != '1') {
      add(dp1[i + 1][0], dp1[i][0]);
      add(dp1[i + 1][0], dp1[i][1]);
    }
    if (T[i] != '0') {
      add(dp1[i + 1][1], dp1[i][0]);
      add((i % 2 == 0) ? lef[i + 1] : dp1[i + 1][1], dp1[i][1]);
    }
  }

  reverse(T, T + N);
  memset(dp2, 0, sizeof(dp2));
  dp2[0][0][0] = 1;
  for (int i = 0; i < N; ++i) {
    for (int flg = 0; flg < 2; ++flg) {
      if (T[i] != '1') {
        add(dp2[i + 1][flg][0], dp2[i][flg][0]);
        add(dp2[i + 1][flg][0], dp2[i][flg][1]);
      }
      if (T[i] != '0') {
        int nflg = flg || (i == 0);
        add(dp2[i + 1][nflg][1], dp2[i][flg][0]);
        nflg |= (i % 2 == 0);
        add(dp2[i + 1][nflg][1], dp2[i][flg][1]);
      }
    }
  }

  Int ret = lef[N];
  for (int i = 1; i < N; i += 2) {
    add(ret, lef[i] * (dp2[N - i][1][0] + dp2[N - i][1][1] + dp2[N - i][0][1]) % MO);
  }

  return ret;
}

int main() {
  scanf("%s", S);
  N = strlen(S);
  if (N == 1) {
    puts(S[0] == '0' ? "0" : "1");
    return 0;
  }

  Int res = 0;
  for (int i = 0; i < 4; ++i) {
    memcpy(T, S, sizeof(T));
    if (S[0] != '?' && S[0] != (i & 1) + '0') continue;
    if (S[N-1] != '?' && S[N-1] != (i / 2) + '0') continue;
    T[0] = (i & 1) + '0';
    T[N-1] = (i / 2) + '0';
    (res += solve()) %= MO;
  }

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

  return 0;
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int h, w;
    cin >> h >> w;
    vs s(h);
    rep(i, h) cin >> s[i];
    queue<pii> q;
    vector<vi> dist(h, vi(w, INF));
    q.emplace(0, 0);
    dist[0][0] = 0;
    while (!q.empty()) {
        auto p = q.front(); q.pop();
        int y = p.first, x = p.second, d = dist[y][x];
        const vi dy = { -1, 0, 1, 0 }, dx = { 0, 1, 0, -1 };
        rep(i, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny<0||ny>=h||nx<0||nx>=w) continue;
            if (s[ny][nx] == '#') continue;
            if (dist[ny][nx] <= d+1) continue;
            q.emplace(ny, nx);
            dist[ny][nx] = d+1;
        }
    }
    int cnt = 0;
    rep(i, h) rep(j, w) if (s[i][j] == '.') ++cnt;
    if (dist[h-1][w-1] == INF) cout << -1 << endl;
    else cout << (cnt-dist[h-1][w-1]-1) << endl;
    return 0;
}

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

int main() {
  int H, W; cin >> H >> W;
  int N = H*W;
  int A[N]; string str;
  int white_num = 0;
  for (int i = 0; i < H; i++) {
    cin >> str;
    for (int j = 0; j < W; j++) {
      white_num += A[i*W+j] = (str[j] == '.');
    }
  }
  queue<pair<int, int>> Q; Q.push(make_pair(0, 1));
  bool visited[N]; for (int i = 0; i < N; i++) visited[i] = false;
  visited[0] = true;
  int score = -1;
  while (!Q.empty()) {
    auto front = Q.front(); Q.pop();
    int u = front.first, d = front.second;
    if (u == H*W-1) { score = white_num-d; break; }
    vector<int> e;
    if (u >= W) e.push_back(u-W);
    if (u % W > 0) e.push_back(u-1);
    if (u % W < W-1) e.push_back(u+1);
    if (u / W < H-1) e.push_back(u+W);
    for (int v : e) {
      if (A[v] && !visited[v]) {
        visited[v] = true;
        Q.push(make_pair(v, d+1));
      }
    }
  }
  cout << score << endl;
}


#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
#define coa cout << ans << endl; return 0;
using namespace std;
using ll = long long;
template<typename T>
using vec = vector<T>;
template<typename T>
using vvec = vector<vector<T>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;

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

    map<int, int> alphabet;
    for(auto c : s){
        alphabet[c]++;
    }

    string ans;
    for(char c = 'a'; c <= 'z'; c++){
        if(alphabet[c] == 0){
            ans.push_back(c);
        }
    }

    if(ans.empty()) ans += "None";
    else ans = ans[0];

    coa
}

#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    string az="abcdefghijklmnopqrstuvwxyz";
    string s;
    cin >> s;
    sort(s.begin(),s.end());

    int i=0,j=0;
    rep(j,s.size()){
        if(az[i]==s[j])i++;
        if(i==26){cout << "None" << endl;return 0;}
    }

    cout << az[i];

	return 0;
}


#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,y;
    cin>>n>>y;
    long long f=y/10000;
    f(i,0,f+1){
        f(j,0,n-i+1){
            if(10000*i+5000*j+1000*(n-j-i)==y){
                cout<<i<<" "<<j<<" "<<n-i-j<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vint;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<int>> vvint;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<int, vector<int>, greater<int>> spqint; //小さい順に取り出し
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;     //小さい順に取り出し
typedef priority_queue<int, vector<int>, less<int>> bpqint;    //大きい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;        //大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define PF push_front
#define TS to_string
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)

int INF = 1e9;
int NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
double EPS = 1e-9;
double PI = M_PI;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}
//-----------------------------------------

//-----------------------------------------
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::chrono::system_clock::time_point start,end;
    start = std::chrono::system_clock::now();

    ll n, k ;
    cin >> n >> k ;
    vll a(n) ;
    REP(i,n){
        cin >> a[i] ;
    }
    ll ans = LINF ;
    ll tmp ;
    REP(i,n-k+1){
        ll l = a[i] ;
        ll r = a[i+k-1] ;
        if(l*r<0){
            l = abs(l) ;
            r = abs(r) ;
            tmp = 2*min(l,r) + max(l,r) ;
            ans = min(ans,tmp) ;
        }
        else{
            l = abs(l) ;
            r = abs(r) ;
            tmp = max(l,r) ;
            ans = min(ans,tmp) ;
        }
    }

    cout << ans <<endl;

    end = std::chrono::system_clock::now();
    auto elapsed = std::chrono::duration_cast< std::chrono::milliseconds >(end - start).count();
    //std::cout << elapsed <<"ms"<< std::endl;

    return 0;
}


#include <vector>
#include <iostream>
#include <map>
using namespace std;
template<typename T, typename S> vector<T>& operator<<(vector<T>& a, S b) { a.push_back(b); return a; }
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	map<char,int> t;
	t['I']=1, t['X']=10, t['V'] = 5;
	t['L'] = 50 , t['C'] = 100 , t['M'] = 1000 , t['D'] = 500;
	string s;
	while(cin >> s){
		int ret = 0;
		ret += t[s[0]];
		rep(i,s.length()-1){
			if(t[s[i+1]] > t[s[i]])ret -= 2*t[s[i]];
			ret += t[s[i+1]];
		}
		cout << ret << endl;
	}
}

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

int main() {
  string str;
  while(getline(cin, str)) {
    int before = 0;
    int now;
    int ans = 0;
    for(int i = 0; i < str.length(); i++) {
      switch(str[i]) {
      case 'I': now = 1; break;
      case 'V': now = 5; break;
      case 'X': now = 10; break;
      case 'L': now = 50; break;
      case 'C': now = 100; break;
      case 'D': now = 500; break;
      case 'M': now = 1000; break;
      }
      if(now > before) {
	ans = ans - before + (now - before);
      } else {
	ans += now;
      }

      before = now;
    }

    cout << ans << endl;
  }
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
inline char gc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x=0;char ch=gc();bool positive=1;
	for(;!isdigit(ch);ch=gc()) if(ch=='-') positive=0;
	for(;isdigit(ch);ch=gc()) x=x*10+ch-'0';
	return positive?x:-x;
}
inline void write(ll x){
	if(x<0){
		x=-x;putchar('-');
	}
	if(x>=10) write(x/10);
	putchar('0'+x%10);
}
inline void writeln(ll x){write(x);puts("");}
inline void writep(ll x){write(x);putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=1e5+5;
int a[N],nxt[65][N];
ll id[N];
int main(){
	int n=read();
	For(i,1,n) a[i]=read(),id[i]=i;
	int m=read();ll k=read();
	For(i,1,m){
		int x=read();
		swap(id[x],id[x+1]);
	}
	For(i,1,n) nxt[0][i]=id[i];
	For(i,1,63){
		For(j,1,n) nxt[i][j]=nxt[i-1][nxt[i-1][j]];
	}
	For(i,1,n){
		id[i]=i;
		Rep(j,63,0) if(k>>j&1) id[i]=nxt[j][id[i]];
		id[i]=a[id[i]]-a[id[i]-1];
	}
	For(i,1,n){
		id[i]+=id[i-1];
		printf("%lld.0\n",id[i]);
	}
}

#include <iostream>
#include <unordered_set>

using namespace std;

typedef long long ll;

int main()	{
  ll n;
  cin >> n;
  ll a;
  unordered_set<ll> sheet;
  for (ll i = 0; i < n; i++)	{
    cin >> a;
    if (sheet.find(a) == sheet.end())	{
      //not present, insert
      sheet.insert(a);
    }
    else	{
      sheet.erase(a);
    }
  }
  cout << sheet.size() << endl;
  return 0;
}


#include <iostream>

int main(int argc, char** argv)
{
	int n;
	std::cin >> n;

	int min = 1000000;
	int max = -1000000;
	long long sum = 0;

	for (int i = 0; i < n; ++i)
	{
		int a;
		std::cin >> a;

		if (min > a)
		{
			min = a;
		}
		if (max < a)
		{
			max = a;
		}

		sum += a;
	}

	std::cout << min << " " << max << " " << sum << std::endl;
}

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

template<class T>
T input()
{
	T val;
	std::cin >> val;
	return val;
}

int main()
{
	long long n, sum = 0;

	std::cin >> n;
	std::vector<long long> b;
	for (int i = 0; i < n; ++i)
		b.push_back(input<long long>()), sum += b[i];

	std::sort(b.begin(), b.end());

	std::cout << b[0] << " " << b[n-1] << " " << sum << std::endl;

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int MAX = -1;
  int ans = MAX;
  for(int i = 1; i*i <= n; i++) {
    ans = max(ans, i*i);
  }

  cout << ans << endl;
  return 0;
}

#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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

int main() {
	int64_t N;
	cin >> N;
	int64_t ans = 1;
	for(int i=1; i<N; i++) {
		if (i*i<=N) ans = i*i;
		else {
			cout << ans << endl;
			return 0;
		}
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>

//#include <unistd.h>
//#include <iostream>

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
//#define int ll

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'
vector<int> knuth_morris_pratt(const vi &s){
  int n=s.size();
  vector<int> kmp(n+1,-1),mp(n+1,-1);
  for(int i=0,j=-1;i<n;i++){
    while(~j&&s[i]!=s[j]) j=kmp[j];
    kmp[i+1]=mp[i+1]=++j;
    if(i+1<n&&s[i+1]==s[j]) kmp[i+1]=kmp[j];
  }
  return mp;
}
// smallest d s.t. s[x] == s[x + d] for all x
vector<int> minimum_period(const vi &s){
  auto mp=knuth_morris_pratt(s);
  for(int i=1;i<(int)mp.size();i++) mp[i]=i-mp[i];
  return mp;
}
// positions for t that match s
vector<int> pattern_match(vi s,vi t){
  int n=s.size(),m=t.size();
  vector<int> kmp=knuth_morris_pratt(s);

  vector<int> res;
  int i=0,j=0;
  while(i+j<m){
    if(s[j]==t[i+j]){
      if(++j!=n) continue;
      res.emplace_back(i);
    }
    i+=j-kmp[j];
    j=max(kmp[j],0);
  }
  return res;
}

signed main() {
  int n;
  cin >> n;
  vi a(n), b(n);
  rep (i, n) cin >> a[i];
  rep (i, n) cin >> b[i];

  vi aa(n);
  vi bb(2 * n - 1);
  rep (i, 2 * n - 1) {
    int j = i % n;
    bb[i] = b[j] ^ b[(j + 1) % n];
    if (i < n) {
      aa[i] = a[j] ^ a[(j + 1) % n];
    }
  }
  DEBUG_VEC(aa);
  DEBUG_VEC(bb);

  vi ans = pattern_match(aa, bb);
  DEBUG_VEC(ans);
  vector<pii> out;
  rrep (i, ans.size()) {
    out.emplace_back((n - ans[i]) % n, a[0] ^ b[ans[i]]);
  }
  sort(all(out));
  rep (i, out.size()) {
    cout << out[i].first << " " << out[i].second << endl;
  }
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<double> mean(n);
  rep(i,n)  {
    double p; cin >> p;
    double m = (p+1) / 2;
    mean[i] = m;
  }
  double ans = 0;
  rep(i,k) ans += mean[i];
  double  r = ans;
  //rep(i,n) cout << mean[i] << ' ' ;
  for (int i = k; i < n; i++)
  {
    double now = r - mean[i-k] + mean[i];
    r = now;
    ans = max(ans, now);
  }

  cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}

//Darker and Darker
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
vector<int> dy = {1, 0, -1, 0};
vector<int> dx = {0, 1, 0, -1};
typedef pair<int, int> PII;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> grah(h);
    rep(i, h) cin >> grah.at(i);
    queue<PII> q;
    vector<vector<int>> dist(h, vector<int>(w, -1));
    rep(i,h) rep(j, w){
        if(grah.at(i).at(j) == '#'){
            q.emplace(i, j);
            dist.at(i).at(j) = 0;
        }

    }

    while(!q.empty()){
        PII v = q.front();
        q.pop();
        rep(i, 4){
            int ny = v.first + dy.at(i);
            int nx = v.second + dx.at(i);
            if(ny >= 0 && nx >= 0 && ny < h && nx < w && dist.at(ny).at(nx) == -1 && grah.at(ny).at(nx) != '#'){
                dist.at(ny).at(nx) = dist.at(v.first).at(v.second) + 1;
                q.emplace(ny, nx);
            }
        }
    }
    int res = 0;
    rep(i, h) rep(j, w){
        res = max(res, dist.at(i).at(j));
    }

    cout << res << endl;

    return 0;

}


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

int main() {
  vector<int> num(3);
  rep(i, 3) cin >> num.at(i);
  for(int i = 1; i < 3; i++) {
    int tmp = 0;
    tmp = num.at(0);
    num.at(0) = num.at(i);
    num.at(i) = tmp;
  }
  rep(i, 3) cout << num.at(i) << " ";
  cout << endl;
  return 0;
}

#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    int X,Y,Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
}

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


#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N);
  multiset<ll> B;
  rep(i,N){
    cin >> A.at(i);
    if(i==0){
      B.insert(A.at(i));
    }else{
      auto a=B.lower_bound(A.at(i));
      if(a==B.begin()){
        B.insert(A.at(i));
      }else{
        a--;
        B.erase(a);
        B.insert(A.at(i));
      }
    }
  }
  cout << B.size() << endl;
}

#include <iostream>
using namespace std;

int main(){
  int n;
  cin >> n;
  int arr[n];
  for(int i=0; i<n ; i++)
    cin >> arr[i];
  for(int j=n-1;j>=0;j--){
    if( j!=0)
      cout <<arr[j]<<' ';
    else
      cout <<arr[j];
  }
  cout << endl;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <cstdio>
#include <cstdlib>

using namespace std;

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 100000;

int query(int pos){
  cout << pos << '\n';
  cout << flush;
  string s;
  cin >> s;
  if(s == "Vacant")
    exit(0);
  else if(s == "Female")
    return 1;
  else
    return 2;
  return 0;
}

int v[1 + nmax];

void extract(int from, int to){
  if(from + 2 == to)
    v[from + 1] = query(from + 1);
  else {
    int mid = (from + to) / 2;
    if((mid - from) % 2 == 1)
      mid--;
    v[mid] = query(mid);
    if(v[from] != v[mid])
      extract(from, mid);
    else
      extract(mid, to);
  }
}

int main()
{
  int n;
  cin >> n;
  v[0] = query(0);
  v[n - 1] = query(n - 1);
  extract(0, n - 1);
  return 0;
}

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

int main()
{
  int r;

  cin >> r;

  if(r<1200)
    cout << "ABC";
  else if(r>=1200 && r<2800)
    cout << "ARC";
  else
  {
    cout << "AGC";
  }
}


#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) //printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;

const int N=305;

int qk,f[N][N][N],n;
char s[N];

int dp(int l,int r,int k){
	if(l>r)return 0;
	if(l==r)return 1;
	if(f[l][r][k]!=-1)return f[l][r][k];
	int &res=f[l][r][k];
	res=0;
	if(s[l]==s[r])res=max(res,dp(l+1,r-1,k)+2);
	res=max(res,dp(l+1,r,k));
	res=max(res,dp(l,r-1,k));
	if(k)res=max(res,dp(l+1,r-1,k-1)+2);
	Pr("f(%d,%d,%d)=%d\n",l,r,k,f[l][r][k]);
	return res;
}

int main(int argc,char *argv[]){
	scanf("%s",s+1);
	n=strlen(s+1);
	scanf("%d",&qk);
	memset(f,-1,sizeof(f));
	cout<<dp(1,n,qk)<<endl;
	return 0;
}

#include <bits/stdc++.h>

#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define ld long double
#define s second
#define vec vector<int>

using namespace std;

const int N = (int) 300 + 10;
const int M = (int) 2018 * 2018;
const int K = (int) 15;
const int INF = (int) 1e9 + 7;
const int mod = (int) 998244353;
const ld EPS = (ld) 1e-9;
const ll LINF = (ll) 1e18;

int n, k;
string s;
int dp[N][N][N];

void upd_max(int &x, int y) {
	x = max(x, y);
}

int main() {
	#ifdef sony
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	srand(time(0));
	cin >> s >> k;
	n = sz(s);
	for (int i = 0; i < n; i++) {
		dp[i][i][0] = 1;
	}
	for (int len = 2; len <= n; len++) {
		for (int i = 0; i + len - 1 < n; i++) {
			int j = i + len - 1;
			for (int sum = 0; sum <= k; sum++) {
				if (s[i] == s[j]) {
					upd_max(dp[i][j][sum], dp[i + 1][j - 1][sum] + 2);
				} else {
					if (sum)
						upd_max(dp[i][j][sum], dp[i + 1][j - 1][sum - 1] + 2);
					upd_max(dp[i][j][sum], dp[i + 1][j][sum]);
					upd_max(dp[i][j][sum], dp[i][j - 1][sum]);
				}
			}
		}
	}
	int ans = 0;
	for (int sum = 0; sum <= k; sum++) {
		ans = max(ans, dp[0][n - 1][sum]);
	}
	cout << ans;
	return 0;
}


//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

ll kai(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x;
  if(y&1){
    return (x*kai(x,y-1))%MOD;
  }else{
    ll t = kai(x,y/2);
    return (t*t)%MOD;
  }
}

ll comb(ll a,ll b,vector<ll> &p){
  if(a == 0)return 1;
  if(b == 0)return 1;
  ll ans = p[a+b];
  ans = (ans*kai(p[a],MOD-2))%MOD;
  ans = (ans*kai(p[b],MOD-2))%MOD;
  return ans;
}

ll mind(int x,vector<int> &v){
  int ok = v.size()-1,ng = -1;
  while(ok - ng > 1){
    int next = (ok+ng)/2;
    if(v[next] > x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}

ll maxd(int x,vector<int> &v){
  int ok = 0,ng = v.size();
  while(ng - ok > 1){
    int next = (ok+ng)/2;
    if(v[next] < x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}

int main(){
  string S;
  cin >> S;
  char cur = S.at(0);
  ll ans = 0;
  ll count = 0;
  if(cur == 'R')count++;
  for(int i = 1;i <= S.size()-1;i++){
    if(cur == 'R' && S.at(i) == 'R'){
      count++;
    }else if(cur == 'R' && S.at(i) == 'S'){
      cur = 'S';
      if(ans < count)ans = count;
      count = 0;
    }else if(S.at(i) == 'R'){
      count++;
      cur = 'R';
    }else{
      continue;
    }
  }
  if(count > ans)ans = count;
  cout << ans << endl;

  return 0;
}

#include<iostream>

int main()
{
    int a = 0;
    int Calc=0;

    std::cin >> a;

    Calc=a+(a*a)+(a*a*a);

    std::cout << Calc;

    return 0;
}


//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  if (a < b) {
    return b - a;
  } else {
    return a - b;
  }
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a) {
    a = b;
  }
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b) {
    a = b;
  }
}
template <class F> class fix_point : private F {
public:
  explicit constexpr fix_point(F &&f) : F(std::forward<F>(f)) {}

  template <class... Args>
  constexpr decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};
template <class F> constexpr decltype(auto) make_fix(F &&f) {
  return fix_point<F>(std::forward<F>(f));
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const usize n = scan<usize>();
  std::vector<u32> x(n);
  for (auto &e : x) {
    std::cin >> e;
  }
  const u32 l = scan<u32>();
  x.push_back(x.back() + l);

  auto dp = md_vec(17, n + 1, usize());
  for (const usize i : rep(0, n)) {
    dp[0][i] = std::distance(
        x.cbegin(),
        std::prev(std::partition_point(
            x.cbegin(), x.cend(), [&](const u32 v) { return v <= x[i] + l; })));
  }
  dp[0][n] = n;
  for (const usize k : rep(1, 17)) {
    for (const usize i : rep(0, n + 1)) {
      dp[k][i] = dp[k - 1][dp[k - 1][i]];
    }
  }

  const usize q = scan<usize>();
  for (const usize i : rep(0, q)) {
    usize a = scan<usize>() - 1;
    usize b = scan<usize>() - 1;
    if (a > b) {
      std::swap(a, b);
    }
    usize ans = 0;
    for (const usize k : revrep(0, 17)) {
      if (dp[k][a] < b) {
        a = dp[k][a];
        ans += static_cast<usize>(1) << k;
      }
    }
    std::cout << ans + 1 << std::endl;
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 2005;
int f[N][N];
int tot[N][N];
int up[N][N];
int lef[N][N];

int tqr(int il, int jl, int ir, int jr){
  if(il > ir || jl > jr) return 0;
  return tot[ir][jr] - tot[ir][jl - 1] - tot[il - 1][jr] + tot[il-1][jl-1];
}

int uqr(int il, int jl, int ir, int jr){
  if(il > ir || jl > jr) return 0;
  return up[ir][jr] - up[ir][jl - 1] - up[il - 1][jr] + up[il-1][jl-1];
}

int lqr(int il, int jl, int ir, int jr){
  if(il > ir || jl > jr) return 0;
  return lef[ir][jr] - lef[ir][jl - 1] - lef[il - 1][jr] + lef[il-1][jl-1];
}

int main(){
  fastIO;
  int n, m, q;
  cin >> n >> m >> q;
  char k;
  for(int i = 1; i <= n; i ++ ){
    for(int j = 1; j <= m ; j ++ ){
      cin >> k;
      f[i][j] = k - '0';
      tot[i][j] = f[i][j] + tot[i-1][j] + tot[i][j-1] - tot[i-1][j-1];
      up[i][j] = (f[i][j] & f[i-1][j]) + up[i-1][j] + up[i][j-1] - up[i-1][j-1];
      lef[i][j] = (f[i][j] & f[i][j-1]) + lef[i-1][j] + lef[i][j-1] - lef[i-1][j-1];
    }
  }
  int ci, cj, ri, rj;
  for(int i = 0 ; i < q; i ++ ){
    cin >> ci >> cj >> ri >> rj;
    cout << tqr(ci, cj, ri, rj) - uqr(ci + 1, cj, ri, rj) - lqr(ci, cj + 1, ri, rj) << "\n";
  }
  return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;
typedef __int128 LL;
char buf[1<<21],*p1=buf,*p2=buf;
#define getchar() (p1==p2 && (p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
LL read()
{
	LL x=0,f=1;
	char c=getchar();
	while(c<'0' || c>'9')
	{
		if(c=='-')	f=-1;
		c=getchar();
	}
	while(c>='0' && c<='9')	x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
void write(LL x)
{
	if(x<0)	putchar('-'),x=-x;
	if(x>9)	write(x/10);
	putchar(x%10+'0');
}
const LL MOD=998244353;
LL QuickPow(LL x,LL p)
{
	LL base=x,ans=1;
	while(p)
	{
		if(p&1)	ans*=base,ans%=MOD;
		p>>=1;
		base*=base;
		base%=MOD;
	}
	return ans;
}
LL n,m,fac[1000005],inv[1000005];
LL C(LL n,LL m){return fac[n]*inv[m]%MOD*inv[n-m]%MOD;}
int main(){
	n=read(),m=read();
	fac[0]=fac[1]=1;
	for(LL i=2;i<=1000000;++i)	fac[i]=fac[i-1]*i%MOD;
	inv[1000000]=QuickPow(fac[1000000],MOD-2);
	for(LL i=1000000-1;~i;--i)	inv[i]=inv[i+1]*(i+1)%MOD;
	LL ans=0;
	for(LL i=1;i<=min(n,m);++i)
	{
		ans+=C(2*i,i)*C(n-i+m-i,n-i)%MOD;
		ans%=MOD;
	}
	ans*=inv[2];
	/*
	C(2n,n)
	*/
	ans*=inv[n+m];
	ans%=MOD;
	ans*=fac[n];
	ans%=MOD;
	ans*=fac[m];
	ans%=MOD;
	ans+=max(n,m);
	ans%=MOD;
	write(ans);
	puts("");
	return 0;
}

#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <string>
#include <functional>
#include <cassert>
#include <cmath>
#define SIZE 200005
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

char str[SIZE];

int main(){
    int n;
    scanf("%d", &n);
    scanf("%s", &str);

    char pre_s = str[0];
    int left = 1;
    int right = 0;
    int reverse = 1;
    ll ret = 1;
    for(int i=1; i<2*n; i++)
    {
        if(pre_s == str[i]) reverse *= -1;
        if(reverse == 1) left++;
        else if(reverse == -1)
        {
            ret = (ret * (left - right)) % MOD;
            right++;
        }
        pre_s = str[i];
    }
    if(left == right && (str[0] == 'B' || str[2*n-1] == 'B'))
    {
        for(int i=1;i<=n;i++) ret = (ret * i) % MOD;
    }
    else ret = 0;
    printf("%lld\n", ret);

    return 0;
}


#include<bits/stdc++.h>
#define	INF	0x3f3f3f3f
#define	LL	long long
#define	MAXN	310
#define	mod	998244353
using namespace std;
int n, f[2][MAXN * MAXN / 2], sum, a[MAXN], ans;

template <typename T> void chkmin(T &x, T y){x = min(x, y);}
template <typename T> void chkmax(T &x, T y){x = max(x, y);}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

int mul(const int &x, const int &y){return 1ll * x * y % mod;}
int inc(const int &x, const int &y){return (x + y >= mod) ? (x + y - mod) : (x + y);}
void update(int &x, const int &y){x = (x + y >= mod) ? (x + y - mod) : (x + y);}
int dec(const int &x, const int &y){return (x - y < 0) ? (x - y + mod) : (x - y);}

int qpow(int a, int b){
	int ret = 1;
	while (b) {
		if (b & 1) ret = mul(ret, a);
		a = mul(a, a);
		b >>= 1;
	}
	return ret;
}

int main(){
	read(n);
	for (int i = 1; i <= n; ++i)
		read(a[i]), sum += a[i];
	int cur = 0, old = 1;
	f[cur][0] = 1;
	for (int i = 1; i <= n; ++i){
		swap(cur, old);
		memset(f[cur], 0, sizeof(f[cur]));
		for (int j = 0; j <= sum / 2; ++j){
			if (!f[old][j]) continue;
			int tmp = f[old][j];
			if (j + a[i] <= sum / 2) update(f[cur][j + a[i]], mul(tmp, 2));
			update(f[cur][j], tmp);
		}
		/*for (int j = 0; j <= sum / 2; ++j)
			printf("%d ", f[cur][j]);
		puts("");*/
	}
	for (int i = 0; i <= sum / 2; ++i)
		update(ans, f[cur][i]);
	//printf("%d\n\n", ans);
	ans = mul(ans, 3);
	ans = dec(qpow(3, n), ans);
	if (!(sum & 1)){
		memset(f, 0, sizeof(f));
		int cur = 0, old = 1;
		f[cur][0] = 1;
		for (int i = 1; i <= n; ++i){
			swap(cur, old);
			memset(f[cur], 0, sizeof(f[cur]));
			for (int j = 0; j <= sum / 2; ++j){
				if (!f[old][j]) continue;
				int tmp = f[old][j];
				if (j + a[i] <= sum / 2) update(f[cur][j + a[i]], tmp);
				update(f[cur][j], tmp);
			}
		}
		ans = inc(ans, mul(f[cur][sum / 2], 3));
	}
	printf("%d\n", ans);
	return 0;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#pragma GCC optimize(2)
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
const double eps=1e-5;
const double pi=acos(-1.0);
const int MOD=1e9+7;
const int maxn=1e5+10;
int a[maxn];
int main ()
{
    int n;
    scanf("%d",&n);
    a[0]=1e9;
    int len=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        if(x<=a[len]){
            a[++len]=x;
        }
        else{
            int l=1,r=len,mid=(l+r)>>1;
            while(l<=r)
            {
                mid=(l+r)>>1;
                if(a[mid]<x){
                    r=mid-1;
                }
                else{
                    l=mid+1;
                }
            }
            //cout<<mid<<endl;
            while(a[mid]>=x)
                mid++;
            a[mid]=x;
        }
    }
    printf("%d\n",len);
    return 0;
}


// besmellah
#include <bits/stdc++.h>

using namespace std;
typedef long long int64;
typedef pair<int,int> pii;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

const int maxn = 1e4+10;
const int64 MO = 1000000007;
const int64 IN = 1000000000;

int d;
string s;
int dp[maxn][105];

int main () {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> s >> d;
	for (int i = 0; i < maxn; i++)
		for (int t = 0; t < 105; t++)
			dp[i][t] = 0;

	dp[0][0] = 1;
	for (int i = 0; i <= 9; i++)
		dp[1][i % d]++;
	for (int i = 2; i <= sz(s); i++)
		for (int k = 0; k < d; k++)
			for (int t = 0; t <= 9; t++)
				dp[i][(t + k) % d] = (dp[i][(t + k) % d] + dp[i - 1][k]) % MO;

	int cur = 0;
	int ans = -1;
	for (int i = 0; i < sz(s); i++) {
		for (int t = 0; t < s[i] - '0'; t++) {
			int f = (cur + t) % d;
			f = (d - f) % d;
			ans = (ans + dp[sz(s) - i - 1][f]) % MO;
		}
		cur = (cur + s[i] - '0') % d;
	}
	if (cur == 0)
		ans++;
	ans = (ans + MO) % MO;
	cout << ans << "\n";
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll INF = 1e12;
const ll MOD = 1000000000 + 7;
#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define mii map<int, int>
#define mci map<char, int>
#define mll map<ll, ll>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}
void YES_NO(bool f) {
  if (f)
    printf("YES\n");
  else
    printf("NO\n");
}

template <typename T>
void deb1(T x) {
  cout << "debug: " << x << "\n";
}

template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) {
  ll x;
  cin >> x;
  ll p = 0;
  p = x / 11;
  ll ans = 2 * p;

  if (x - p * 11 > 0) {
    ans++;
    if (x - p * 11 > 6) ans++;
  }
  out(ans);
}
int main(void) { solve(); }

#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[100010];
int cnt[100010];
int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i];
	ll ans = 1;
	for (int i = 0; i < N; i++) {
		if (A[i] == 0) {
			ans *= 3 - cnt[A[0]];
		}
		else {
			ans *= cnt[A[i] - 1] - cnt[A[i]];
		}
		cnt[A[i]]++;
		ans %= mod;
	}
	cout << ans << endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define rev_all( x ) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;

const int mod = 1e9 + 7;
const int inf = 1e11 + 5;
const long double PI = 3.141592653589793;

void solve(){
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b <<endl;
  return;
}
signed main(){
  fast;
  int t;
  t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
    int x, y, z;
    cin >> x >> y >> z;
    int ansx, ansy, ansz;
    ansx = y;
    ansy = x;
    x = y;
    y = ansy;
    ansx = z;
    ansz = x;
    cout << ansx << " " << ansy << " " << ansz << endl;
}