#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <list>
#include <cstring>
#include <map>
#include <set>
#define  ll long long
#define mod 1000000007
#define pi 3.141592653589
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i{};i<n;i++)
    cin>>v.at(i);
  vector<int> par(200001,-1);
  vector<int> count(200001,0);
  for(int i{};i<n;i++){
    if(v.at(i)==v.at(n-1-i))
      continue;
    else{
      int f=v.at(i);
      int l=v.at(n-1-i);
      if(par[f]==-1&&par[l]==-1){
        par[f]=f;
        par[l]=f;
      }
      else if(par[f]!=-1&&par[l]==-1)
        par[l]=par[f];
      else if(par[f]==-1&&par[l]!=-1)
        par[f]=par[l];
      else{
        int j{f},k{l};
        while(par[j]!=j){
          par[j]=par[par[j]];
          j=par[j];
        }
        while(par[k]!=k){
          par[k]=par[par[k]];
          k=par[k];
      }
        par[k]=par[j];
      }
    }
  }
    for(int i{};i<200001;i++){
      if(par.at(i)==-1)
        continue;
      else{
        int j=i;
        while(par[j]!=j){
          par[j]=par[par[j]];
          j=par[j];
        }
        count.at(j)++;
      }
    }
    int ans{};
    for(int i{};i<200001;i++){
      if(count.at(i)==0)
        continue;
      ans+=count.at(i)-1;
    }
  cout<<ans<<endl;
}

#include <stdio.h>
#include <map>

int x[100010],y[100010];
int type[100010];
std::map<int,int> check;

int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	for(int i=1;i<=a;i++) scanf("%d",&y[i]);
	x[0] = 0, y[0] = 0;
	x[a+1] = b+1, y[a+1] = b+1;
	for(int i=1;i<=a;i++)
	{
		if(x[i]>y[i]) type[i] = 1; // <<
		if(x[i]==y[i]) type[i] = 2; // --
		if(x[i]<y[i]) type[i] = 3; // >>
	}
	for(int i=1;i<a;i++)
	{
		if(type[i]==3&&type[i+1]==1)
		{
			printf("-1");
			return 0;
		}
	}
	// x[j] +(i-j) == y[i]
	long long int ans = 0;
	check[0] = 0;
	for(int i=1;i<=a;i++)
	{
		if(type[i]==1)
		{
			if(check.find(y[i]-i)==check.end())
			{
				printf("-1");
				return 0;
			}
			if(y[i-1]==y[i]-1) ans++;
			else
			{
				int k = check[y[i]-i];
				ans += (i-k);
			}
			check[x[i]-i] = i;
		}
		else if(type[i]==2)
		{
			check.clear();
			check[x[i]-i] = i;
		}
	}
	check.clear();

	//x[j] - (j-i) == y[i]
	check[(b+1)-(a+1)] = a+1;
	for(int i=a;i>=1;i--)
	{
		if(type[i]==3)
		{
			if(check.find(y[i]-i)==check.end())
			{
				printf("-1");
				return 0;
			}
			if(y[i+1]==y[i]+1) ans++;
			else
			{
				int k = check[y[i]-i];
				ans += (k-i);
			}
			check[x[i]-i] = i;
		}
		else if(type[i]==2)
		{
			check.clear();
			check[x[i]-i] = i;
		}
	}
	printf("%lld",ans);
}


//fake_name
#include<bits/stdc++.h>
#define int long long
using namespace std ;
#define F first
#define S second

int MOD = 998244353 ;
int mod = 1e9 + 7 ;
string s[2005] ;
int vis[2005][2005] ;
int n , m ;
int check( int i , int j )
{
	if( i >= n || j >= m || i < 0 || j < 0 )
		return 0 ;
	if( vis[i][j] || s[i][j] == '#' )
		return 0 ;
	return 1 ;
}
signed main()
{
    ios_base::sync_with_stdio(false) ;
    cin.tie(0) ; cout.tie(0) ;
    cin >> n >> m ;
    for( int i = 0 ; i < n ; i++ )
    	cin >> s[i] ;
    vector<pair<int,int> > adj[30] ;
    pair<int,int> start , end ;
    for( int i = 0 ; i < n ; i++ ){
    	for( int j = 0 ; j < m ; j++ ){
    		if( s[i][j] == '.' || s[i][j] == '#' )
    			continue ;
    		if( s[i][j] == 'S' )
    			start = { i , j } ;
    		else if( s[i][j] == 'G' )
    			end = { i , j } ;
    		else{
    			//cout << s[i][j] << endl ;
    			adj[s[i][j]-'a'].push_back( { i , j } ) ;
    		}
    	}
    }
    queue<pair<int,int> > q ;
    q.push(start) ;
    vis[start.F][start.S] = 1 ;
    int h[26] = {0} ;
    while( !q.empty() ){
    	pair<int,int> p = q.front() ;
    	q.pop() ;
    	int i = p.F , j = p.S ;
    	if( check( i+1 , j )){
    		vis[i+1][j] = vis[i][j]+1 ;
    		q.push( { i+1 , j } ) ;
    	}
    	if( check( i-1 , j ) ){
    		vis[i-1][j] = vis[i][j] + 1 ;
    		q.push( { i-1 , j } ) ;
    	}
    	if( check( i , j+1 ) ){
    		vis[i][j+1] = vis[i][j] + 1 ;
    		q.push( { i , j+1 } ) ;
    	}
    	if( check( i , j-1 ) ){
    		vis[i][j-1] = vis[i][j] + 1 ;
    		q.push( { i , j-1 } ) ;
    	}
    	if( isalpha( s[i][j] ) && s[i][j] > 'Z' ){
    		//cout << s[i][j] << endl ;
    		if( h[s[i][j]-'a' ] )
    			continue ;
    		for( int k = 0 ; k < (int)adj[s[i][j] - 'a' ].size() ; k++ ){

    			if( check( adj[s[i][j] - 'a'][k].F , adj[s[i][j]-'a'][k].S) ){
    				vis[adj[s[i][j]-'a'][k].F][adj[s[i][j]-'a'][k].S] = vis[i][j]+1 ;
    				q.push( adj[s[i][j]-'a'][k] ) ;

    			}
    		}
    		h[s[i][j]-'a'] = 1 ;
    	}
    }
    if( vis[end.F][end.S] == 0 )
    	cout << -1 ;
    else
    	cout << vis[end.F][end.S] - 1 ;
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int64_t i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int64_t i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    vector<VI> dp(h, VI(w, -1));
    REP(i, h) cin >> grid[i];
    queue<PII> Q;
    vector<vector<PII>> letters(26);
    REP(i, h) {
    	REP(j, w) {
    		if (grid[i][j] == 'S') {
    			Q.push({i, j});
    			dp[i][j] = 0;
    		}
    		if (grid[i][j] >= 'a' && grid[i][j] <= 'z') {
    			letters[grid[i][j] - 'a'].pb({i, j});
    		}
    	}
    }
    vector<bool> F(26, false);
    int d1[4] = {1, -1, 0, 0};
    int d2[4] = {0, 0, -1, 1};
    while (!Q.empty()) {
    	auto [r, c] = Q.front();
    	Q.pop();
    	if (grid[r][c] == 'G') {
    		cout << dp[r][c] << "\n";
    		return 0;
    	}
    	if (grid[r][c] >= 'a' && grid[r][c] <= 'z' && !F[grid[r][c] - 'a']) {
    		F[grid[r][c] - 'a'] = true;
    		for (auto p : letters[grid[r][c] - 'a']) {
    			if (p.first == r && p.second == c) continue;
    			if (dp[p.first][p.second] != -1) continue;
    			Q.push({p.first, p.second});
    			dp[p.first][p.second] = dp[r][c] + 1;
    		}
    	}
    	FOR(i, 0, 3) {
    		int rr = r + d1[i];
    		int cc = c + d2[i];
    		if (rr < 0 || rr >= h || cc < 0 || cc >= w) continue;
    		if (grid[rr][cc] == '#') continue;
    		if (dp[rr][cc] != -1) continue;
    		dp[rr][cc] = dp[r][c] + 1;
    		Q.push({rr, cc});
    	}
    }
    cout << "-1\n";
}


#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h>
#include <cmath>
#include <functional>
#include <cassert>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double EPS = 1e-10;
// constexpr ll mod = 1000000007;
constexpr ll mod = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const char eol = '\n';
// --------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int X,Y,Z;
    cin >> X >> Y >> Z;
    for(int i=1000000; i>=0; i--){
        if(Y*Z > (ll)i*X){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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

int main(){

    char a,b,c;
    cin >> a >> b >>c;
    if (a == b && b == c){
        cout << "Won";
    }else {
        cout<< "Lost";
    }

    return 0;
}


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

#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)x.size())

using namespace std;
//using namespace atcoder;
using ld = long double;
using ll =  long long;
using P = pair<ll, ll>;

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

const ll MOD = 1e9 + 7;
const ll INF = 1e9;

int main(){
    vector<int> a(3);
    rep(i, 3)cin >> a[i];
    sort(ALL(a));
    bool f = false;
    do{
        if(a[1] - a[0] == a[2] - a[1])f = true;
    }while(next_permutation(ALL(a)));
    cout << (f ? "Yes" : "No") << endl;
}

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

int64_t solve(int N, const vector<int64_t> &A)
{
    vector<vector<int64_t>> DP(N, vector<int64_t>(N, INT64_MAX));
    rep(l, N){
        rep3(r, l, N){
            if (l == r){
                DP[l][r] = A[r];
            }else{
                DP[l][r] = min(DP[l][r-1], A[r]);
            }
        }
    }
    int64_t ans = INT64_MIN;
    rep(l, N){
        rep3(r, l, N){
            ans = max(ans, (r-l+1)*DP[l][r]);
        }
    }
    return ans;
    return 1;
    // TODO: edit here
}

// generated by online-judge-template-generator v4.7.1 (https://github.com/online-judge-tools/template-generator)
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int N;
    cin >> N;
    vector<int64_t> A(N);
    rep(i, N) { cin >> A[i]; }
    auto ans = solve(N, A);
    cout << ans << endl;
    return 0;
}


#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#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 Per(i,sta,n) for(int i=n-1;i>=sta;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 long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
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;}

template<int mod>
struct ModInt {
    long long x;
    static constexpr int MOD = mod;

    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    explicit operator int() const {return x;}

    ModInt &operator+=(const ModInt &p) {
        if((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    ModInt operator%(const ModInt &p) const { return ModInt(0); }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }

    ModInt power(long long n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1)
            ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    ModInt power(const ModInt p) const{
        return ((ModInt)x).power(p.x);
    }

    friend ostream &operator<<(ostream &os, const ModInt<mod> &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a) {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};

using modint = ModInt<mod>;

int n,k;
modint dp[3010][3010];
bool visited[3010][3010];

modint get_dp(int i,int j){
    //cout << i << " " << j << endl;
    if(i<j) return 0;
    if(min(i,j)<0) return 0;
    if(visited[i][j]) return dp[i][j];
    visited[i][j]=true;
    dp[i][j]=get_dp(i-1,j-1)+get_dp(i,2*j);
    return dp[i][j];
}

void solve(){
    cin >> n >> k;
    visited[0][0]=true;
    dp[0][0]=1;
    cout << get_dp(n,k) << endl;
}

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

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

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

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

//faster gcd
int fgcd(int a, int b) {
    if (!a || !b)
        return a | b;
    unsigned shift = __builtin_ctz(a | b);
    a >>= __builtin_ctz(a);
    do {
        b >>= __builtin_ctz(b);
        if (a > b)
            swap(a, b);
        b -= a;
    } while (b);
    return a << shift;
}

void solve()
{
	int a,b;
	cin>>a;
	cin>>b;
	int total=2*a+100;
	int remain=total-b;
	cout<<remain;
	}

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


#include <bits/stdc++.h>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define LLMAX 9223372036854775807
#define ALL(x) x.begin(),x.end()
using ll = int64_t;
using vl = vector<ll>;

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

//int の最大値 2147483647≒10^9
//long longの最大値 9,223,372,036,854,775,807≒10^18

int main() {
	ll a,b,c;
	cin >> a >> b >> c;
    string ans;
    if(a*a + b*b < c*c){
        ans = "Yes";
    }else{
        ans = "No";
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll y) {x = min(x,y);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}
template<class in_Cout> void Cout(in_Cout x) {cout << x << endl; exit(0);}
template<class in_vec_cout>
void vec_cout(vector<in_vec_cout> vec) {
    for (in_vec_cout res : vec) {cout << res << " ";}
    cout << endl;
}

const ll inf = 1e18;
const ll mod = 1e9 + 7;

using matrix = vector<vector<ll>>;

ll powmodp(ll x, ll n) {
    if (n==0) return 1;
    if (n%2) return x * powmodp(x,n-1) % mod;
    ll res = powmodp(x,n/2);
    return res * res % mod;
}

ll inv(ll x) {return powmodp(x,mod-2);}

ll N, M, K;
vector<ll> A, G[110];
ll p, half;

matrix E(ll n) {
    matrix res(n,vector<ll>(n));
    rep(i,n) res[i][i] = 1;
    return res;
}

void addmodp(ll &x, ll y) {x = (x + y) % mod;}

matrix prodmatrix(matrix x, matrix y) {
    ll H = x.size(), W = y[0].size(), sz = y.size();
    matrix res(H,vector<ll>(W));
    rep(i,H) rep(j,W) rep(k,sz) {
        addmodp(res[i][j], x[i][k] * y[k][j] % mod);
    }
    return res;
}
vector<ll> prodmatrix(matrix x, vector<ll> y) {
    matrix z(y.size(),vector<ll>(1));
    rep(i,y.size()) z[i][0] = y[i];
    matrix tmp = prodmatrix(x,z);
    vector<ll> res(tmp.size());
    rep(i,tmp.size()) res[i] = tmp[i][0];
    return res;
}
vector<ll> prodmatrix(vector<ll> x, matrix y) {
    matrix z(1,vector<ll>(x.size()));
    rep(i,x.size()) z[0][i] = x[i];
    matrix tmp = prodmatrix(z,y);
    vector<ll> res(tmp[0].size());
    rep(i,tmp[0].size()) res[i] = tmp[0][i];
    return res;
}

matrix powmodp(matrix x, ll n) {
    if (n==0) return E(x.size());
    if (n%2) return prodmatrix(x,powmodp(x,n-1));
    matrix res = powmodp(x,n/2);
    return prodmatrix(res,res);
}

void init() {
    cin >> N >> M >> K;
    A.resize(N);
    rep(i,N) cin >> A[i];
    rep(i,M) {
        ll x, y; cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    p = inv(M);
    half = inv(2);
}

int main() {
    init();
    matrix mat(N,vector<ll>(N));
    rep(i,N) {
        ll cnt = G[i].size();
        for (ll j : G[i]) mat[j][i] = p * half % mod;
        ll q = cnt * p % mod;
        q = q * half % mod;
        mat[i][i] = (1 + mod - q) % mod;
    }
    matrix F = powmodp(mat,K);

    vector<ll> res = prodmatrix(A,F);
    for (ll ans : res) cout << ans << endl;
}

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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define F first
#define S second
#define all(x) begin(x), end(x)
#define allr(x) rbegin(x), rend(x)
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr ll INF = 2e18;
constexpr ld EPS = 1e-9;
constexpr int MOD = 998244353;
#define int long long

// Custom hash map
struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		// http://xorshift.di.unimi.it/splitmix64.c
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
// Use int type for keys
template <typename T1, typename T2>
using safe_map = unordered_map<T1, T2, custom_hash>;

// Operator overloads
// cin >> pair<T1, T2>
template<typename T1, typename T2>
istream& operator>>(istream &istream, pair<T1, T2> &p)
{
    istream >> p.first >> p.second;
    return istream;
}
// cin >> vector<T>
template<typename T>
istream& operator>>(istream &istream, vector<T> &v)
{
    for (auto &it : v) cin >> it;
    return istream;
}
// cout << pair<T1, T2>
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, const pair<T1, T2> &p)
{
    ostream << p.first << " " << p.second;
    return ostream;
}
// cout << vector<T>
template<typename T>
ostream& operator<<(ostream &ostream, const vector<T> &c)
{
    for (auto &it : c) cout << it << " ";
    return ostream;
}

// Utility functions
template <typename T>
void print(T &&t)
{
    cout << t << "\n";
}
template <typename T, typename... Args>
void print(T &&t, Args &&... args)
{
	cout << t << " ";
	print(forward<Args>(args)...);
}

template <typename T>
int32_t size_i(T &container) { return static_cast<int32_t>(container.size()); }

// Mathematical functions
int GCD(int a, int b)
{
	if (!b) return a;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return (a * b) / GCD(a, b);
}
int modpow(ll x, int n, int m = MOD) {
    ll res = 1;
    while (n > 0)
	{
        if (n & 1)
            res = (res * x) % m;
        x = (x * x) % m;
        n >>= 1;
    }
    return res;
}

int binpow(int x, int n) {
    int res = 1;
    while (n > 0)
	{
        if (n & 1)
            res = res * x;
        x = (x * x);
        n >>= 1;
    }
    return res;
}
// @param m should be prime
int modinv(int x, int m = MOD)
{
	return modpow(x, m - 2, m);
}

// Flags to use: -std=c++17 -O2 -Wshadow -DLOCAL_PROJECT -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -fsanitize=address -fsanitize=undefined
////////////////////////////////// START CODE HERE //////////////////////////////////

void preSolve()
{
}

void solve(int tc)
{
    int r, x, y;
    cin >> r >> x >> y;
    ld d = sqrtl((ld)x * x + y * y);
    int di = (int)d;
    if (abs(di - d) <= 1e-6 && di % r == 0)
        return void(print(di / r));
    int ans = d/ r;
    ans--;
    ans = max(0LL, ans);

    print(ans + 2);
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);
    cout << setprecision(12) << fixed;

    preSolve();
    int tests = 1;
    // cin >> tests;
    for (int t = 1; t <= tests; t++)
        solve(t);
    return 0;
}


#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int h, w, x, y;
	cin >> h >> w >> x >> y;
	string s[101];
	for (int i = 1; i <= h; i++)
		cin >> s[i];
	int sum = 0;
	for (int i = y - 1; i >= 0; i--) {
		if (s[x][i] == '.')
			sum++;
		else break;
	}
	for (int i = y; i < w; i++) {
		if (s[x][i] == '.')
			sum++;
		else break;
	}
	for (int i = x - 1; i > 0; i--) {
		if (s[i][y - 1] == '.')
			sum++;
		else break;
	}
	for (int i = x + 1; i <= h; i++) {
		if (s[i][y - 1] == '.')
			sum++;
		else break;
	}
	cout << sum << endl;
	return 0;
}

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

int main (){
  int H,W,X,Y,count=0;
  cin >>H>>W>>X>>Y;
  vector<vector<char>> det(H,vector<char>(W));
  rep(i,H){
    rep(j,W){
      cin >>det.at(i).at(j);
    }
  }

  if(det.at(X-1).at(Y-1)=='#'){
    cout <<0;
    return 0;
  }
  count++;
  for(int i=1;;i++){
    if(X-1-i<0)
      break;
    if(det.at(X-1-i).at(Y-1)=='#')
      break;
    count++;
  }
  for(int i=1;;i++){
    if(Y-1-i<0)
      break;
    if(det.at(X-1).at(Y-1-i)=='#')
      break;
    count++;
  }

  for(int i=1;;i++){
    if(X-1+i>H-1)
      break;
    if(det.at(X-1+i).at(Y-1)=='#')
      break;
    count++;
  }
  for(int i=1;;i++){
    if(Y-1+i>W-1)
      break;
    if(det.at(X-1).at(Y-1+i)=='#')
      break;
    count++;
  }

  cout<<count;

}


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

#define all(v) (v).begin(),(v).end()
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi=vector<vi>;

constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

int main(){
  int n,m;
  cin>>n>>m;
  vi a(m),b(m);
  vvi g(n);
  rep(i,m){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }
  int K;cin>>K;
  vi c(K);
  rep(i,K){
    cin>>c[i];
    c[i]--;
  }
  //cout<<1;
  vvi dist(K,vi(n,inf));
  rep(i,K){
    queue<int>q;
    q.push(c[i]);
    dist[i][c[i]]=0;
    while(q.size()){
      int u=q.front();q.pop();
      for(auto v:g[u]){
        if(dist[i][v]>dist[i][u]+1){
          dist[i][v]=dist[i][u]+1;
          q.push(v);
        }
      }
    }
  }
  //cout<<dist[0][1];
  vvi dp(1<<K,vi(K,inf));
  rep(i,1<<K){
    int cnt=0,memo=-1;
    rep(j,K){
      if(i & (1<<j)){
        cnt++;
        memo=j;
      }
    }
    if(cnt==1)dp[i][memo]=1;
    rep(t,K){
      rep(j,K){
        dp[i|(1<<j)][t]=min(dp[i|(1<<j)][t], dp[i][j]+dist[j][c[t]]);
      }
    }
  }
  int ans=inf;
  rep(i,K){
    ans=min(ans,dp[(1<<K)-1][i]);
  }
  if(ans==inf)cout<<-1;
  else cout<<ans;
}

#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define bit(n,k) ((n>>k)&1) //nのk　bit目
using ll = long long;
using P = pair<int,int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll llINF = 1LL << 60;
const int iINF = 1e9;

//---main---------------------------------------------
int main(){
    //main
    int A,B;
    cin >> A >> B;

    int sa=0,sb=0;
    rep(i,3){
        sa += A%10;
        A /=10;
        sb += B%10;
        B /= 10;
    }

    if(sa>=sb) cout << sa << endl;
    else cout << sb << endl;

    return 0;
}


#ifdef _DEBUG
#include "../../../library/src/debug_template.hpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else
#define DMP(...) ((void)0)
#endif

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <variant>

using namespace std;
using lint = long long;
constexpr int INF = 1010101010;
constexpr lint LINF = 1LL << 60;

struct init {
    init() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    }
} init_;

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
    return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

template<const int &Modulo>
struct Mint {

    lint val;
    constexpr Mint(lint v = 0) noexcept: val(v % Modulo) { if (val < 0) val += Modulo; }

    constexpr Mint &operator+=(const Mint &r) noexcept {
        val += r.val;
        if (val >= Modulo) val -= Modulo;
        return *this;
    }
    constexpr Mint &operator-=(const Mint &r) noexcept {
        val -= r.val;
        if (val < 0) val += Modulo;
        return *this;
    }
    constexpr Mint &operator*=(const Mint &r) noexcept {
        val = val * r.val % Modulo;
        return *this;
    }
    constexpr Mint &operator/=(const Mint &r) noexcept {
        lint a{r.val}, b{Modulo}, u{1}, v{0};
        while (b) {
            lint t = a / b;
            a -= t * b;
            a ^= b, b ^= a, a ^= b;
            u -= t * v;
            u ^= v, v ^= u, u ^= v;
        }
        assert(a == 1);
        val = val * u % Modulo;
        if (val < 0) val += Modulo;
        return *this;
    }

    constexpr Mint operator+(const Mint &r) const noexcept { return Mint(*this) += r; }
    constexpr Mint operator-(const Mint &r) const noexcept { return Mint(*this) -= r; }
    constexpr Mint operator*(const Mint &r) const noexcept { return Mint(*this) *= r; }
    constexpr Mint operator/(const Mint &r) const noexcept { return Mint(*this) /= r; }

    constexpr Mint operator-() const noexcept { return Mint(-val); }

    constexpr bool operator==(const Mint &r) const noexcept { return val == r.val; }
    constexpr bool operator!=(const Mint &r) const noexcept { return !((*this) == r); }
    constexpr bool operator<(const Mint &r) const noexcept { return val < r.val; }

    constexpr friend ostream &operator<<(ostream &os, const Mint<Modulo> &x) noexcept { return os << x.val; }
    constexpr friend istream &operator>>(istream &is, Mint<Modulo> &x) noexcept {
        lint tmp{};
        is >> tmp;
        x = Mint(tmp);
        return is;
    }

    [[nodiscard]] constexpr Mint pow(lint n) const noexcept {
        Mint res{1}, tmp{*this};
        while (n > 0) {
            if (n & 1) res *= tmp;
            tmp *= tmp;
            n >>= 1;
        }
        return res;
    }
};

constexpr int MOD = 7;
using mint = Mint<MOD>;

int main() {

    int N;
    cin >> N;
    string S, X;
    cin >> S >> X;

    auto memo = make_vec(N, 7, -1);
    auto dfs = [&](auto &&f, const int &i, const mint &m) -> bool {

        if (i == N) return m == 0;
        if (memo[i][m.val] != -1) return memo[i][m.val];

        if (X[i] == 'T') {
            return (memo[i][m.val] = f(f, i + 1, m * 10 + (S[i] - '0')) || f(f, i + 1, m * 10));
        }
        else {
            return (memo[i][m.val] = f(f, i + 1, m * 10 + (S[i] - '0')) && f(f, i + 1, m * 10));
        }
    };

    if (dfs(dfs, 0, 0)) cout << "Takahashi\n";
    else cout << "Aoki\n";

    return 0;
}

#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define mii map<int,int>
#define mll map<long long int,long long int>
#define rep(it,m) for(auto it=m.begin();it!=m.end();it++)
#define pb push_back
#define fr first
#define sc second
#define mod 1000000007LL
#define setbiti(x) __builtin_popcount(x)
#define setbitll(x) __builtin_popcountll(x)
#define vi vector<int>
#define vll vector<long long int>
#define f(i,x,n) for(ll i=x;i<n;i++)
#define l(i,a,b) for(ll i=a;i>b;i--)
#define w(x) int x; cin>>x; while(x--)
#define all(x) x.begin(),x.end()
#define fill(a,x)  memset(a,x,sizeof(a))
#define pie 3.14159265
using namespace std;

void fio() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

ll bpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    }
    if (b == 1) {
        return a % m;
    }
    if (b & 1) {
        return (a * bpow(a, b - 1, m)) % m;
    }
    ll x = bpow(a, b / 2, m);
    return (x * x) % m;
}

int main() {
    fio();
    ll n, m;
    cin >> n >> m;
    ll ans = bpow(10, n, m * m);
    ans = (ans / m) % m;
    cout << ans << endl;
    return 0;
}


#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
signed main(){
  int n,k,m;cin>>n>>k>>m;
  vector<int> a(n,0);
  rep(i,n-1)cin>>a[i];
  int sum=0;
  rep(i,n-1){
    sum+=a[i];
  }
  bool tag=false;
  int ans=n*m-sum;
  if(ans>k){
    tag=true;
  }
  if(ans<0)ans=0;
  if(tag)ans=-1;
  cout<<ans<<endl;
  return 0;
}

#include <iostream>
using namespace std;
int main()
{
	int n,k,m,x,y=0,z;
	cin>>n>>k>>m;
	int a[100];
	x=m*n;
	for(int i=0; i<n-1; i++)
	{
		cin>>a[i];
		y=y+a[i];
	}
	z=x-y;
	if(k>=z && z>0)
	{
	cout<<z<<endl;
	}else if(k<z){
		cout<<"-1"<<endl;
	}else{
		cout<<"0"<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;
int main(){

long long n,x;
cin>>n>>x;

string s;
cin>>s;
int m= s.length();
for(int i=0; i<m;++i){
	if(x==0 && s[i]== 'x'){
		x+=0;
	}
		else if (s[i]== 'x'){
			x--;
		}
		else{
			x++;
		}

	}
cout<<x;

}

#include<cstdio>
inline int in();
inline void wr(int);
inline int mx(int,int);
int main(int argc,char**argv){
	register int n=in(),x=in();
	while(n--){
		register char c=getchar();
		while(c!='o'&&c!='x')c=getchar();
		if(c=='x')x=mx(0,x-1);
		else ++x;
	}
	wr(x),putchar('\n');
}
inline int mx(int x,int y){
	return x>y?x:y;
}
inline int in(){
	register char c=getchar();
	register int x=0,f=1;
	for(;c<'0'||c>'9';c=getchar())
		if(c=='-')f=-1;
	for(;c>='0'&&c<='9';c=getchar())
		x=(x<<1)+(x<<3)+(c&15);
	return x*f;
}
inline void wr(int x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)wr(x/10);
	putchar(x%10+'0');
}


#include <bits/stdc++.h>
#define ls rt << 1
#define rs rt << 1|1
#define lson ls,l,m
#define rson rs,m+1,r
#define st first
#define ed second
#define Point pair<int,int>
typedef long long ll;
using namespace std;
const int N = 1e6+5;
const int PI = 314;

int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);

	n += 100;
	ll l = 1ll,r = 2e12;
	while(l < r){
		ll m = (l+r+1) >> 1;
		ll t = m*n/100ll;
		if((t-m) < k) l = m;
		else r = m-1;
	}
	printf("%lld\n",(l*n)/100ll+1ll);
	return 0;
}

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

#define endl '\n'
#define pii pair <int, int>
#define pb push_back
#define F first
#define S second
#define ll long long
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define M_PI 3.14159265358979323846

const int N = 100005;
const int mod = 1e9 + 7;

int main() {
    io;
    int t;
    cin >> t;
    while(t--){
        ll l, r;
        cin >> l >> r;
        ll k = r - l - l + 1;
        k = max(k, 0ll);
        k = k * (k + 1) / 2;
        cout << k << endl;
    }
}


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

typedef long long ll;
typedef long double ld;
ll MOD = 1e9 + 7;
double eps = 1e-12;
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin()                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

void solve()
{
    int n, k, digit = 0;
    cin >> n >> k;
    ll sum = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            digit = i * 100 + j;
            sum += digit;
        }
    }
    cout << sum << endl;
}
int main()
{
    fast_cin();

    solve();

    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

char win(char c1, char c2) {
    if (c1 > c2) swap(c1, c2);
    if (c1 == c2) return c1;
    if (c1 == 'P' && c2 == 'R') return 'P';
    else if (c1 == 'P' && c2 == 'S') return 'S';
    else if (c1 == 'R' && c2 == 'S') return 'R';
}

char dfs(int n, int k, const string &s) {
    map<char, int> mp;
    for (char c : s) ++mp[c];
    if ((int)mp.size() == 1) {
        return s.front();
    } else if ((int)mp.size() == 2) {
        return win(mp.begin()->first, (++mp.begin())->first);
    } else {
        int p2 = 0;
        while ((1<<(p2+1)) <= n) ++p2;
        if (k <= p2) {
            string ss = s.substr(0, 1<<k), tt = "";
            while ((int)ss.size() > 1) {
                for (int i=0; i<(int)ss.size(); i+=2) tt.push_back(win(ss[i], ss[i+1]));
                ss = tt;
                tt = "";
            }
            return ss.front();
        } else {
            int sz = n * (1<<p2);
            string ss = "";
            while ((int)ss.size() < sz) ss += s;
            string tt = "";
            for (int i=0; i<n; ++i) {
                string sss = ss.substr(i*(1<<p2), 1<<p2), ttt = "";
                while ((int)sss.size() > 1) {
                    for (int i=0; i<(int)sss.size(); i+=2) ttt.push_back(win(sss[i], sss[i+1]));
                    sss = ttt;
                    ttt = "";
                }
                tt.push_back(sss.front());
            }
            return dfs(n, k-p2, tt);
        }
    }
}

void solve() {
    int n, k;
    string s;
    cin >> n >> k >> s;

    cout << dfs(n, k, s) << '\n';
}

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

    solve();

    return 0;
}

#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;

int main() {
  int n,k; string s;
  cin >> n >> k >> s;
  auto f = [](char l,char r){
    if(l=='R'&&r=='P') return r;
    if(l=='S'&&r=='R') return r;
    if(l=='P'&&r=='S') return r;
    return l;
  };
  rep(_,k){
    string t = s;
    s += s;
    rep(i,n) t[i] = f(s[2*i],s[2*i+1]);
    swap(s,t);
  }
  cout << s[0] << endl;
}


#include <bits/stdc++.h>

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
#define DIV 1000000007
#define ll long long
using namespace std;

const int INF = 1e9+7;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

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

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

  ll mx = 2*A+100;
  ll left = mx - B;
  if (left >= 0) {
    print(left);
  } else {
    print(0);
  }
}

#include<bits/stdc++.h>
using namespace std;
int main()
{

   long long int a,b;
   cin>>a>>b;
   cout<<((2*a)+100)-b<<endl;
   return 0;

}


#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,k;
  string s;
  char win[222][222];
  win['R']['S']=win['S']['R']=win['R']['R']='R';
  win['S']['P']=win['P']['S']=win['S']['S']='S';
  win['P']['R']=win['R']['P']=win['P']['P']='P';
  cin>>n>>k>>s;

  while(k--){
    const auto t=s+s;
    for(int i=0;i<n*2;i+=2){
      s[i/2]=win[t[i]][t[i+1]];
    }
  }
  cout<<s[0];
}

#include<bits/stdc++.h>
#define ll long long
#define re register
#define INF 2147483647
using namespace std;

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

inline char cmp(char a,char b)
{
	if(a==b) return a;
	if(a=='R')
	{
		if(b=='P') return b;
		else return a;
	}
	if(a=='P')
	{
		if(b=='S') return b;
		else return a;
	}
	if(a=='S')
	{
		if(b=='R') return b;
		else return a;
	}
}

char s[105],f[105][105];
int nxt[105][105];

int main()
{
	int n=read(),k=read();
	scanf("%s",s);
	for(int i=0;i<n;i++)
	{
		nxt[i][1]=(i+1)%n;
		//cout<<nxt[i][1]<<endl;
		f[i][1]=cmp(s[nxt[i][1]],s[i]);
		//putchar(f[i][1]);
		//puts("");
	}
	for(int j=2;j<=k;j++)
	{
		for(int i=0;i<n;i++)
		{
			nxt[i][j]=nxt[(nxt[i][j-1]+1)%n][j-1];
			f[i][j]=cmp(f[i][j-1],f[(nxt[i][j-1]+1)%n][j-1]);
			//cout<<nxt[i][j]<<endl;
		}
	}
	putchar(f[0][k]);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#pragma region DEBUG
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef
tree<
  pair<int,int>,
  null_type,
  less<pair<int,int>>,
  rb_tree_tag,
  tree_order_statistics_node_update>
ordered_set;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#pragma endregion DEBUG
#define MOD 1000000007
#define MAX 500005
#define endl "\n"
vector <lli> fact(MAX,1);
vector <lli> invfact(MAX,1);
lli binpow(lli a, lli b, lli m){
    //a %= m;
    lli res = 1;
    while(b > 0){
        if(b&1)
            res = a*res%m;
        b >>=1;
        a = a*a%m;
    }
    return res;
}
void solve(){
   lli a,b,c;
   cin>>a>>b>>c;
   lli X = binpow(b,c,4);
   //debug(X);
   if(X == 0)
        X = 4;
   lli ans = binpow(a%10, X, MOD);
   cout<<(ans%10)<<endl;
}
int main(){
    /* freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); */
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   /*  for(lli i = 1; i<MAX-5; i++){
        fact[i] = i*fact[i-1]%MOD;
        invfact[i] = binpow(fact[i],MOD-2);
    } */
    lli t;
    t = 1;
    //cin>>t;
    while(t--)
        solve();
}

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

int a, B, c;

inline int fpow(int x, int b, int m) {
    int res = 1;
    while (b) {
        if (b & 1) res = 1ll * res * x % m;
        x = 1ll * x * x % m;
        b >>= 1;
    }
    return res;
}

int main() {
    cin >> a >> B >> c;
    cout << fpow(a, 4 + fpow(B, c, 4), 10);
}


//#pragma GCC optimize ("O2")
//#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;

#include<cstdio>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

ll dph[2000], dphw[4000], *naname = dphw + 2000;
const int mod = 1e9 + 7;

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

	int H = 0, W = 0;
	char c;
	while ((c = getchar_unlocked()) >= '0') H = H * 10 + c - '0';
	while ((c = getchar_unlocked()) >= '0') W = W * 10 + c - '0';

	getchar_unlocked();
	dph[0] = 1;
	naname[0] = 1;
	ll w = 1;
	ll tmp = 1;
	rep1(i, W - 1) {
		tmp = w;
		if (getchar_unlocked() == '.') {
			dph[i] = w;
			naname[i] = w;
			w = w * 2 % mod;
		}
		else {
			dph[i] = 0;
			naname[i] = 0;
			w = 0;
		}
	}
	getchar_unlocked();

	rep1(i, H - 1) {
		if (getchar_unlocked() == '.') {
			tmp = dph[0];
			w = tmp;
			dph[0] = (tmp + dph[0]) % mod;
			naname[-i] = (tmp + naname[-i]) % mod;
		}
		else {
			w = 0;
			dph[0] = 0;
			naname[-i] = 0;
		}
		if (!(i & 3)) {
			rep1(j, W - 1) {
				if (getchar_unlocked() == '.') {
					tmp = (w + dph[j] + naname[j - i]) % mod;
					w = (w + tmp) % mod;
					dph[j] = (tmp + dph[j]) % mod;
					naname[j - i] = (tmp + naname[j - i]) % mod;
				}
				else {
					w = 0;
					dph[j] = 0;
					naname[j - i] = 0;
				}
			}
		}
		else {
			rep1(j, W - 1) {
				if (!(j & 3)) {
					if (getchar_unlocked() == '.') {
						tmp = (w + dph[j] + naname[j - i]) % mod;
						w = (w + tmp) % mod;
						dph[j] = (tmp + dph[j]) % mod;
						naname[j - i] = (tmp + naname[j - i]) % mod;
					}
					else {
						w = 0;
						dph[j] = 0;
						naname[j - i] = 0;
					}
				}
				else {
					if (getchar_unlocked() == '.') {
						tmp = w + dph[j] + naname[j - i];
						w = w + tmp;
						dph[j] = tmp + dph[j];
						naname[j - i] = tmp + naname[j - i];
					}
					else {
						w = 0;
						dph[j] = 0;
						naname[j - i] = 0;
					}
				}
			}
		}
		getchar_unlocked();
	}

	printf("%lld\n", tmp % mod);

	Would you please return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include <bitset>
// #include <atcoder/all>
#include <fstream>
#include <random>

//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;
// using namespace atcoder;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const double PI = 3.1415926535897932;

//繰り返し自乗法(N^P mod M)
ll RepeatSquaring(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RepeatSquaring(N, P / 2, M);
		return (t * t) % M;
	}
	return (N * RepeatSquaring(N, P - 1, M)) % M;
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << ketasitei;

	ll h, w;
	cin >> h >> w;

	vector<string> s(h);
	// 0:左 1:上 2:左上
	vector<vector<vector<ll>>> dp(h + 1, vector<vector<ll>>(w + 1, vector<ll>(3, 0)));

	rep(i, h)
		cin >> s[i];

	dp[0][0][0] = 0;
	dp[0][0][1] = 0;
	dp[0][0][2] = 0;

	for (ll i = 1; i < h; i++)
	{
		if (s[i][0] == '#')
			break;

		dp[i][0][1] = (RepeatSquaring(2, i - 1LL, MOD));
	}

	for (ll i = 1; i < w; i++)
	{
		if (s[0][i] == '#')
			break;

		dp[0][i][0] = RepeatSquaring(2, i - 1LL, MOD);
	}

	for (ll i = 1; i < h; i++)
	{
		for (ll j = 1; j < w; j++)
		{
			if (s[i][j] == '#')
				continue;

			if (i == 1 && j == 1)
			{
				dp[i][j][2] = 1;
			}

			dp[i][j][0] += 2 * dp[i][j - 1][0] + dp[i][j - 1][1] +			dp[i][j - 1][2];
			dp[i][j][0] %= MOD;

			dp[i][j][1] += dp[i - 1][j][0] +	 2 * dp[i - 1][j][1] +		dp[i - 1][j][2];
			dp[i][j][1] %= MOD;

			dp[i][j][2] += dp[i - 1][j - 1][0] + dp[i - 1][j - 1][1] +		2 * dp[i - 1][j - 1][2];
			dp[i][j][2] %= MOD;

		}
	}

	cout << (dp[h - 1][w - 1][0] + dp[h - 1][w - 1][1] + dp[h - 1][w - 1][2]) % MOD << endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int a[200005];

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

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

    int last = 1;
    vector<int>ans;
    for(i=2;i<=n;i++)
    {
        if(a[i] < i)
        {
            if(a[i] < last)
            {
                cout << -1 << endl;
                return 0;
            }
            int pos = a[i];
            for(j=i;j>pos;j--)
            {
                swap(a[j],a[j-1]);
                ans.push_back(j-1);
            }
            last = i;
        }
    }
    if(ans.size() != (n-1)) cout << -1 << endl;
    else
    {
        for(i=1;i<=n;i++)
        {
            if(a[i] != i)
            {
                cout << -1 << endl;
                return 0;
            }
        }
        for(int x:ans) cout << x << endl;
    }
}

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int a[n];
	for (auto &i : a) i = ri() - 1;

	int plus[n];
	int minus[n];
	memset(plus, 0, sizeof(plus));
	memset(minus, 0, sizeof(minus));
	for (int i = 0; i < n; i++) {
		if (a[i] < i) {
			plus[a[i]]++;
			plus[i]--;
		} else if (a[i] > i) {
			minus[i]++;
			minus[a[i]]--;
		}
	}
	for (int i = 0; i + 1 < n; i++) plus[i + 1] += plus[i], minus[i + 1] += minus[i];

	bool ok = true;
	for (int i = 0; i + 1 < n; i++) if (plus[i] != 1 || minus[i] != 1) ok = false;
	if (!ok) {
		puts("-1");
		return 0;
	}

	for (int i = 0; i < n; i++) {
		if (a[i] < i) {
			for (int j = a[i]; j < i; j++) plus[j] = a[i];
		} else if (a[i] > i) {
			for (int j = i; j < a[i]; j++) minus[j] = a[i];
		}
	}
	std::set<int> avail;
	auto update = [&] (int i) {
		if (a[i] == minus[i] && a[i + 1] == plus[i]) {
			avail.insert(i);
		} else avail.erase(i);
	};
	for (int i = 0; i + 1 < n; i++) update(i);

	std::vector<int> res;
	while (avail.size()) {
		int cur = *avail.begin();
		res.push_back(cur);
		avail.erase(avail.begin());
		std::swap(a[cur], a[cur + 1]);
		if (cur) update(cur - 1);
		update(cur);
		if (cur + 1 < n - 1) update(cur + 1);
	}
	if ((int) res.size() != n - 1) {
		puts("-1");
		return 0;
	}

	for (auto i : res) printf("%d\n", i + 1);
	return 0;
}


#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
constexpr int inf=1e9+7;
constexpr ll longinf=1LL<<60 ;
constexpr ll mod=1e9+7 ;

int dp[111][111][111];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    ll x;
    cin>>x;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    ll ans = x + 1;
    REP(t,1,n+1){
        rep(i,n+1)rep(j,n+1)rep(k,t){
            dp[i][j][k] = -inf;
        }
        dp[0][0][0]=0;
        rep(i,n)rep(j,i+1)rep(k,t){
            if(dp[i][j][k]<0)continue;
            dp[i+1][j+1][(k+a[i])%t]=max(dp[i+1][j+1][(k+a[i])%t],dp[i][j][k]+a[i]);
            dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k]);
        }
        if(dp[n][t][x%t]<0)continue;
        ans = min((x-dp[n][t][x%t])/t,ans);
    }
    cout<<ans<<endl;
    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pll pair<ll, ll>
#define pb push_back
#define pii pair<ll ,pll>
#define task "parentheses"

using namespace std;
const int N = 105;
const ll mod = 1e18+7;
const int base = 350;
ll n, t, m, k, tong, a[N], dp[N][N], ans;
vector<ll> kq;
vector<ll> adj[N];

void sol()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i ++)cin >> a[i];
    ans = mod;
    for(int i = 1; i <= n; i ++)
    {
        for(int l = 0; l <= i; l ++)
        {
            for(int r = 0; r <= i; r ++)dp[l][r] = -1;
        }
        dp[0][0] = 0;
        for(int j = 1; j <= n; j ++)
        {
            for(int l = j-1; l >= 0; l --)
            {
                for(int r = i-1; r >= 0; r --)
                {
                    if(dp[l][r] == -1)continue;
                    k = (r + a[j] % i) % i;
                    dp[l+1][k] = max(dp[l+1][k], dp[l][r] + a[j]);
                }
            }
        }
        if(dp[i][m%i] != -1)ans = min(ans, (m - dp[i][m%i]) / i);
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if(fopen(task".inp", "r"))
    {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    int ntest = 1;
    //cin >> ntest;
    while(ntest -- > 0)
    sol();
}
//https://docs.google.com/document/d/1JARtZUcSiWp9F95IoR8hhMp65eDu3vrRqvK_iUOQiFI/edit#heading=h.j89qf85z2g73


#include <bits/stdc++.h>
#define pii pair<int, int>

using namespace std;

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

    int h, w;
    cin >> h >> w;

    bool g[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            char temp;
            cin >> temp;
            g[i][j] = (temp == '#');
        }
    }

    /*

     */
    int cnt = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (g[i][j]) {
                // top
                if (!g[i - 1][j] && (g[i - 1][j - 1] || !g[i][j - 1])) cnt++;
                // bottom
                if (!g[i + 1][j] && (g[i + 1][j - 1] || !g[i][j - 1])) cnt++;
                // left
                if (!g[i][j - 1] && (g[i - 1][j - 1] || !g[i - 1][j])) cnt++;
                // right
                if (!g[i][j + 1] && (g[i - 1][j + 1] || !g[i - 1][j])) cnt++;
            }

        }
    }

    cout << cnt;

}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)        for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n)    for (int i = (s); i < (int)(n); i++)
#define all(a) a.begin(), a.end()
#define All(a) a.rbegin(), a.rend()
typedef vector<int> VI;
typedef long long int ll;

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

    cout << 100-(x%100) << endl;

    return 0;
}

#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
ll extgcd(ll a, ll b, ll& x, ll& y) {
    for (ll v = x = 1, u = y = 0; b; ) { ll q = a / b; swap(a -= q * b, b); swap(x -= q * u, u); swap(y -= q * v, v); }
    return a;
}

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

    rep(t, T) {
        ll N, S, K;
        cin >> N >> S >> K;

        ll G = gcd(N, K);
        if (S % G) {
            write(-1);
            continue;
        }

        ll n = N / G, k = K / G, s = S / G;
        ll x, y;
        ll ret = extgcd(k, -n, x, y);
        assert(abs(ret) == 1);
        if (ret == 1) {
            x *= n - s;
            y *= n - s;
        }
        else {
            x *= s;
            y *= s;
        }
        ll z = min(x / n, y / k);
        x -= n * z;

        write(x);
    }
}


#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define repj(begin, end) for (j=begin;j<end;j++)
#define init(arr, end, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
typedef long long int ll;
const int inf = 1000000000;
const int mod = 1000000007;
const int nil = -1;
ll i, j, n, w, s, t, p;
ll a[200001];
bool ans;

int main() {
    scanf(" %lld %lld", &n, &w);
    rep(0,n+1) a[i] = 0;
    rep(0,n) {
        scanf(" %lld %lld %lld", &s, &t, &p);
        a[s] += p; a[t] -= p;
    }
    ans = a[0] <= w;
    rep(1,n+1) {
        a[i] += a[i-1];
        if (a[i] > w) ans = false;
    }

    if (ans) printf("Yes");
    else printf("No");
}

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

using namespace std;
//using namespace __gnu_pbds;
//template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '['; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << ']'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '{' << p.first << ", " << p.second << '}'; }
template<typename T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const map<A, B> &mp) { os << '['; string sep; for (const auto &x : mp) os << sep << x, sep = ", "; return os << ']'; }
template<typename T> ostream& operator<<(ostream &os, const multiset<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "] =", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

#define int                                         long long
#define setbits(x)                                  __builtin_popcountll(x)
#define mod                                         1000000007
#define inf                                         1e18
#define endl                                        '\n'
#define pb                                          push_back
#define all(x)                                      x.begin(),x.end()
#define ff                                          first
#define ss                                          second

int powmod(int a, int b) {int res = 1; a %= mod; for (; b; b >>= 1) {if (b & 1)res = res * a % mod; a = a * a % mod;} return res;}
int fast_pow(int a, int b) {if (b == 1) return a; if (b == 0) return 1; int x = fast_pow(a, b / 2); x *= x; if (b & 1) x *= a; return x;}

const int nax = 2e5 + 5;
vector<pair<int, int>> v(nax);
vector<int> timee(nax);
vector<int> ans(nax);
vector<pair<int, int>> marks(nax);
vector<pair<int, int>> pre(nax);
int n, t;

void solve()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
    /*#ifndef ONLINE_JUDGE
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif*/
    cin >> n >> t;
    for (int i = 0; i < n; i++) {
        cin >> v[i].ff >> v[i].ss >> timee[i];
    }

    for (int i = 0; i < n; i++) {
        marks[v[i].ff + 1].ff++;
        marks[v[i].ff + 1].ss += timee[i];
        marks[v[i].ss + 1].ff--;
        marks[v[i].ss + 1].ss -= timee[i];
        // dbg(marks);
    }

    pre[0].ff = marks[0].ff;
    pre[0].ss = marks[0].ss;

    for (int i = 1; i < nax; i++) {
        pre[i].ff = pre[i - 1].ff + marks[i].ff;
        pre[i].ss = pre[i - 1].ss + marks[i].ss;
    }
    // dbg(marks);
    // dbg(pre);
    bool c = 0;
    for (int i = 0; i < nax; i++) {
        if (pre[i].ss > t) {
            cout << "No"  << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

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

// 0 0 0  0  0  0 0 0 0 0 0
// 0 1 0 -1  0  0 0 0 0 0 0
// 0 1 1 -1 -1  0 0 0 0 0 0
// 0 1 1  0 -1  0 0 0 0 0 0 -1
// 0 1 2  0 -2  0 0 0 0 0 0 -1


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }

const int MOD = 1e9+7;

void solve(){
    int h, w;
    cin >> h >> w;
    v2<char> grid = fill(h, w, '?');
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            cin >> grid[i][j];
        }
    }

    v2<int> dp = fill(h, w, -1), horiz, vert, diag;
    horiz = vert = diag = dp;

    dp[0][0] = horiz[0][0] = vert[0][0] = diag[0][0] = 1;
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            if(!i&&!j) continue;
            if(grid[i][j] == '#'){
                dp[i][j] = horiz[i][j] = vert[i][j] = diag[i][j] = 0;
            }
            else{
                int h = (j-1>=0) ? horiz[i][j-1] : 0;
                int v = (i-1>=0) ? vert[i-1][j] : 0;
                int d = (i-1>=0 && j-1>=0) ? diag[i-1][j-1] : 0;

                dp[i][j] = ((ll)h+v+d)%MOD;
                horiz[i][j] = (dp[i][j] + h)%MOD;
                vert[i][j] = (dp[i][j] + v)%MOD;
                diag[i][j] = (dp[i][j] + d)%MOD;
            }
        }
    }

    cout << dp[h-1][w-1] << "\n";
}

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

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

#define PI 3.14159265359

int main() {
  int N;
  int64_t W;
  cin >> N >> W;
  vector<vector<int>> T(N, vector<int>(N));
  vector<int> v;
  for (int i = 0; i < N; i++){
    v.push_back(i);
    for (int j = 0; j < N; j++){
      cin >> T[i][j];
    }
  }
  v.erase(remove(v.begin(), v.end(), 0), v.end());
  int ans = 0;
  do {
    int64_t dist = 0;
    for (int i = 0; i < N - 2; i++) dist += T[v[i]][v[i + 1]];
    dist += T[0][v[0]] + T[v[N - 2]][0];
    if (dist == W) ans++;
  } while(next_permutation(v.begin(), v.end()));
  cout << ans << endl;
}


/*
  /^--^\
  \____/
 /      \ _____  _ __  __ ____  _     ____   ____  _____
|        || ()_)| |\ \/ /| ===|| |__ / (__` / () \|_   _|
 \__  __/ |_|   |_|/_/\_\|____||____|\____)/__/\__\ |_|
|^|^\ \^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|
| | |\ \| | | | | | | | | | | | | | | | | | | | | | | | |
#####/ /#################################################
| | |\/ | | | | | | | | | | | | | | | | | | | | | | | | |
|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|*/
#pragma GCC optimize("O4,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define int ll
#define double long double

#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define Fors(i,a,b,s) for(int i=a;i<=b;i+=s)
#define F first
#define S second
#define L(id) (id*2+1)
#define R(id) (id*2+2)

#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define mkp make_pair

#define MOD (ll)(998244353)
#define INF (1e17)
#define EPS (1e-6)

#ifdef LOCALMEOW
#define debug(...) do{\
	cerr << __PRETTY_FUNCTION__ << " - " << __LINE__ <<\
	" : ("#__VA_ARGS__ << ") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T> void _OUT(T x) { cerr << x << "\n"; }
template<typename T,typename...I>
void _OUT(T x,I ...tail) { cerr << x << ", "; _OUT(tail...); }
#else
#define debug(...)
#endif
inline void IOS(){ ios::sync_with_stdio(false); cin.tie(0); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	int ans=1,now=b;
	while(p){
		if(p&1) ans=ans*now%MOD;
		p/=2; now=now*now%MOD;
	}
	return ans;
}
void minify(int &a,int b) { if(b<a) a=b; }
void maxify(int &a,int b) { if(b>a) a=b; }

vector<pii> adj[2020];
int dis[2020];

int dijk(int n){
	For(i,0,2019) dis[i]=INF;
	priority_queue<pii,vector<pii>,greater<pii>> pq;
	for(auto &i:adj[n])
		pq.emplace(i.S,i.F);
	while(!pq.empty()){
		auto p=pq.top(); pq.pop();
		if(p.S==n) return p.F;
		if(dis[p.S]!=INF) continue;
		dis[p.S]=p.F;
		for(auto &e:adj[p.S]){
			pq.emplace(e.S+p.F,e.F);
		}
	}
	return -1;
}

int32_t main(){
	IOS();
	//code...
	int n,m; cin>>n>>m;
	int a,b,c;
	For(i,0,m-1){
		cin>>a>>b>>c;
		adj[a].eb(b,c);
	}
	For(i,1,n) cout<<dijk(i)<<"\n";
	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define pf push_front
#define sz(x) (int)(x).size()
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef long double ld;
typedef map<int,int> mii;

const int MOD = 1e9+7;
const ld PI = acos((ld)-1);
const int maxN = 2001;

vector<pii> adj[maxN];
vi res(maxN,MOD);
vector<vector<int>>dist(maxN,vector<int>(maxN,MOD));

void dijkstra (int src) {
	dist[src][src] = 0;
	priority_queue<pii>pq;
	pq.push({0,src});
	while (!pq.empty()) {
		pii p = pq.top();
		pq.pop();
		int d = -p.fi;
		int v = p.se;
		if (d > dist[src][v]) {
			continue;
		}
		for (pii edge : adj[v]) {
			int to = edge.fi;
			int w = edge.se;
			if (dist[src][to] > dist[src][v]+w) {
				dist[src][to] = dist[src][v]+w;
				pq.push({-dist[src][to],to});
			}
		}
	}

}

void solve () {
	int n,m;
	cin >> n >> m;
	for (int i = 0;i < m;++i) {
		int u,v,w;
		cin >> u >> v >> w;
		if (u == v) {
			res[u] = min(res[u],w);
			continue;
		}
		adj[u].pb({v,w});
	}
	for (int i = 1;i <= n;++i) {
		dijkstra(i);
	}
	for (int i = 1;i <= n;++i) {
		for (pii edge : adj[i]) {
			int to = edge.fi;
			int w = edge.se;
			res[i] = min(res[i],dist[to][i]+w);
		}
	}
	for (int i = 1;i <= n;++i) {
		if (res[i] == MOD) {
			cout << -1 << "\n";
		} else {
			cout << res[i] << "\n";
		}
	}
}

int main () {

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

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0,endrep=(n); i<endrep; ++i)
#define rep1(i,n) for(ll i=1,endrep=(n); i<=endrep; ++i)
#define revrep(i,n) for(ll i=(n)-1; i>=0; --i)
inline constexpr ll Inf = (1ULL << 60) -123456789;
#define fastio cin.tie(0); ios_base::sync_with_stdio(false); cout<<fixed<<setprecision(10);
#define newl '\n'
#define YN(e) ((e)?"Yes":"No")
#define all(a) begin(a),end(a)
#define rall(a) rbegin(a),rend(a)
template <class T,class U> bool updmax(T& a, U b) { if(b>a){ a=b; return true;} return false;}
template <class T,class U> bool updmin(T& a, U b) { if(b<a){ a=b; return true;} return false;}
inline constexpr int Mod = 1000000007;
//inline constexpr int Mod = 998244353;
#define dbg(a) cout << #a << ": " << a << endl;
#define dbg1(a,n) cout<<#a<<": "; rep(i,n) cout<<a[i]<<" "; cout<<endl;
#define dbg2(m,h,w) cout<<#m<<":"<<endl; rep(i,h){ rep(j,w)cout<<m[i][j]<<" "; cout<<endl; }
int rng(int n) { return rand()/(RAND_MAX+1.0)*n; }
struct room {
    int r[17][17]{};
    int na{};
};
int main() {
    fastio;
    ll ans{};
    ll H,W,A,B;
    cin >> H >> W >> A >> B;
    auto nxt = [&](int i, int j)->pair<int,int> {
        if (j == W-1) {
            j = 0;
            ++i;
            return {i,j};
        }
        return {i,j+1};
    };
    function<void(room,int,int)> dfs = [&](room r,int i, int j) {
        if (i == H) {
            ll t=0;
            rep(k,H) rep(l,W) {
                if (r.r[k][l] > 0) ++t;
            }
            if (t == A*2) {
                ++ans;
            }
            return;
        }
        auto [ni,nj] = nxt(i,j);
        if (r.r[i][j] > 0) {
            dfs(r, ni,nj);
            return;
        }
        dfs(r, ni,nj);
        room q = r;
        if (j<W-1 && r.r[i][j+1] == 0) {
            r.r[i][j] = 1;
            r.r[i][j+1] = 1;
            dfs(r,ni,nj);
        }
        if (i<H-1 && r.r[i+1][j] == 0) {
            q.r[i][j] = 1;
            q.r[i+1][j] = 1;
            dfs(q,ni,nj);
        }
    };
    dfs(room{}, 0,0);
    cout << ans << endl;
}

#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << (x) << "\n"
using namespace std;
int si, sj, t[60][60], p[60][60], M;
bool b1[50 * 51];
int score(string s) {
	int xs = si, ys = sj, r = p[xs][ys];
	for (char c : s) {
		if (c == 'U')xs--;
		if (c == 'D')xs++;
		if (c == 'L')ys--;
		if (c == 'R')ys++;
		r += p[xs][ys];
	}
	return r;
}
char fr1(int pu, int pd, int pl, int pr) {
	int r = rand() % (pu + pd + pl + pr);
	if (r < pu)return 'U';
	if (r < pu + pd)return 'D';
	if (r < pu + pd + pl)return 'L';
	return 'R';
}
int main() {
	srand((unsigned)time(NULL));
	cin >> si >> sj; si++; sj++; b1[2525] = 1;
	for0(i, 52)for0(j, 52) {
		if (i * j == 0 || i == 51 || j == 51)t[i][j] = 2525;
		else { cin >> t[i][j]; M = max(M, t[i][j]); }
	}
	for1(i, 50)for1(j, 50)cin >> p[i][j];
	string s1 = ""; int v1 = score(s1), ti = clock();
	while (clock() - ti <= 1800000) {
		string sp = "";
		int xi = si, yi = sj;
		while (1) {
			b1[t[xi][yi]] = 1;
			int pu = 10; for1(i, 10)if (b1[t[xi - i][yi]]) { pu = i - 1; break; }
			int pd = 10; for1(i, 10)if (b1[t[xi + i][yi]]) { pd = i - 1; break; }
			int pl = 10; for1(i, 10)if (b1[t[xi][yi - i]]) { pl = i - 1; break; }
			int pr = 10; for1(i, 10)if (b1[t[xi][yi + i]]) { pr = i - 1; break; }
			if (pu + pd + pl + pr == 0)break;
			char rc = fr1(pu, pd, pl, pr); sp += rc;
			if (rc == 'U')xi--;
			if (rc == 'D')xi++;
			if (rc == 'L')yi--;
			if (rc == 'R')yi++;
		}
		int vi = score(sp);
		if (vi > v1) {
			s1 = sp; v1 = vi;
		}
		for0(i, M)b1[i] = 0;
	}
	puts(s1);
}


#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> // #include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; //using namespace __gnu_pbds;
#define pb push_back
#define ins insert
#define var auto
#define F first
#define S second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
template <class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
const int Max = 1e6 + 10;
const int LOG = 30;
const int Mod = 998244353;
const int SQ = 3000;
const int INF = 1e9 + 10;
const int BMSK = 4e6;

void solve()
{
	ll x;cin >> x;
	// x * (x + 1) / 2 - (x + 1) * (x + 2) / 2 =
	// x + 1 >= y * (y + 1) / 2

	ll r = 0 , l = 2000000000;
	while(l - r > 1)
	{
		ll mid = (l + r) / 2;
		if(mid * (mid + 1) / 2 <= x + 1) r = mid;
		else l = mid;
	}

	cout << x - r + 1 << '\n';

}

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

	/*int t;cin >> t;
	while(t--)*/
	solve();
}

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

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

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

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

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

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

int main(){

    ll n;
    cin >> n;

    ll sqn = sqrt(2*(n+1));

    ll k = 0;
    for(ll i=-10;i<=10;i++){
        ll v = sqn + i;
        if(v<0) continue;
        if(v*(v+1) <= 2*(n+1)) chmax(k, v);
    }

    // dump(k)

    cout << n+1 - k << endl;

    return 0;
}


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

const int MAXN = 1e6 + 5;
char s[MAXN];
struct Deque {
	bool rev;
    char buffer[MAXN << 1];
    int head = MAXN, tail = MAXN - 1;
    bool empty() {
		return tail < head;
	}
    int size() {
		return tail - head + 1;
	}
    char front() {
		return rev ? buffer[tail] : buffer[head];
	}
    char back() {
		return rev ? buffer[head] : buffer[tail];
	}
    void push_front(int x) {
		rev ? buffer[++tail] = x : buffer[--head] = x;
	}
    void push_back(int x) {
		rev ? buffer[--head] = x : buffer[++tail] = x;
	}
    void pop_back() {
		rev ? head++ : tail--;
	}
    void pop_front() {
		rev ? tail-- : head++;
	}
    void reverse() {
		rev ^= 1;
	}
}Q;

signed main(int argc, char *argv[]) {
    cin >> s + 1;
    int n = strlen(s + 1);
    for (int i = 1; i <= n; ++i) {
        if (s[i] == 'R') Q.reverse();
        else {
            if (!Q.empty() && Q.back() == s[i]) {
				Q.pop_back();
				continue;
			}
            else Q.push_back(s[i]);
        }
    }
    while (!Q.empty()) cout << Q.front(), Q.pop_front();
	system("pause");
    return 0;
}

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

int main(){
  string S; cin >> S;
  list<char> T;
  bool f=false;
  for(int i=0; i<S.size(); i++){
    if(S[i]=='R'){
      f=!f;
    }else if(f==true){
      if(T.front()==S[i]) T.pop_front();
      else T.push_front(S[i]);
    }else{
      if(T.back()==S[i]) T.pop_back();
      else T.push_back(S[i]);
    }
  }
  string T2="";
  for(char t: T){
    T2+=t;
  }
  if(f==true){
    reverse(T2.begin(), T2.end());
  }

  cout << T2 << endl;
}


#include <math.h>
#include <stdio.h>
#include <time.h>

#include <algorithm>
//#include <atcoder/all>
#include <cassert>
#include <complex>
#include <cstdint>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
// using namespace atcoder;
using pii = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vii = vector<int>;
using vvii = vector<vector<int>>;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout << "YES" << endl
#define cNO cout << "NO" << endl
#define cYes cout << "Yes" << endl
#define cNo cout << "No" << endl
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Rep(i, a, b) for (ll i = (a); i < (b); ++i)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define rRep(i, a, b) for (ll i = a; i >= b; i--)
#define crep(i) for (char i = 'a'; i <= 'z'; ++i)
#define psortsecond(A, N) \
  sort(A, A + N,          \
       [](const pii& a, const pii& b) { return a.second < b.second; });
#define ALL(x) (x).begin(), (x).end()
#define debug(v)      \
  cout << #v << ":";  \
  for (auto x : v) {  \
    cout << x << ' '; \
  }                   \
  cout << endl;
#define endl '\n'
int ctoi(const char c) {
  if ('0' <= c && c <= '9') return (c - '0');
  return -1;
}
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
constexpr ll MOD = 1000000007;
constexpr ll INF = 1000000011;
constexpr ll MOD2 = 998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS = 10e-8;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return 1;
  }
  return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return 1;
  }
  return 0;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto&& x : v) is >> x;
  return is;
}
template <typename T, typename U>
istream& operator>>(istream& is, pair<T, U>& p) {
  is >> p.first;
  is >> p.second;
  return is;
}
template <typename T, typename U>
ostream& operator>>(ostream& os, const pair<T, U>& p) {
  os << p.first << ' ' << p.second;
  return os;
}
template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto i = begin(v); i != end(v); ++i) {
    if (i != begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main() {
  ll N, K, M;
  cin >> N >> K >> M;
  vvll dp(102, vll(125000, 0));
  dp[0][0] = 1;
  rep(i, 101) {
    rep(j, 125000) {
      dp[i + 1][j] += dp[i][j];
      if (j >= i + 1) {
        dp[i + 1][j] += dp[i + 1][j - i - 1];
      }
      if (j >= (i + 1) * (K + 1)) {
        dp[i + 1][j] -= dp[i][j - (i + 1) * (K + 1)];
      }
      dp[i + 1][j] = (dp[i + 1][j] + 2 * M) % M;
    }
  }
  // rep(i, 3) {
  //   rep(j, 10) { cout << dp[i][j] << " "; }
  //   cout << endl;
  // }
  rep(i, N) {
    ll l = i, r = N - i - 1;
    ll E = 0;
    rep(i, 125000) {
      E += dp[l][i] * dp[r][i];
      E %= M;
    }
    E *= (K + 1);
    E = (E - 1 + M) % M;
    cout << E << endl;
  }
}

#include <bits/stdc++.h>
using namespace std;
int n, TTT;
const int mod = 1e9 + 7;
long long ksm(long long a, int n)
{
    if (n == 1)
        return a;
    if (n == 0)
        return 1;
    long long ans = ksm(a, n >> 1);
    ans = ans * ans % mod;
    if (n & 1)
        ans = ans * a % mod;
    return ans;
}
struct matrix
{
    long long a[101][101], n, m;
    friend matrix operator*(matrix a, matrix b)
    {
        matrix c;
        memset(c.a, 0, sizeof(c.a));
        c.n = a.n;
        c.m = b.m;
        // cerr<<c.n<<' '<<c.m<<endl
        for (int i = 1; i <= a.n; i++)
        {
            for (int j = 1; j <= a.m; j++)
            {
                for (int k = 1; k <= b.m; k++)
                {
                    // cerr << c.a[i][k] << " ";
                    c.a[i][k] += a.a[i][j] * b.a[j][k] % mod;
                    c.a[i][k] %= mod;
                    // cerr << a.a[i][j] << " " << b.a[j][k] << " " << c.a[i][k] << " " << i << " " << j << " " << k << endl;
                }
            }
        }
        return c;
    }
} e, f;

matrix ksmm(matrix a, int n)
{
    matrix ans = a;
    memset(ans.a, 0, sizeof(ans.a));
    for (int i = 1; i <= ans.n; i++)
        ans.a[i][i] = 1;
    for (; n; n >>= 1, a = a * a)
        if (n & 1)
            ans = ans * a;
    return ans;
}
int m, k;
int in[1001];
int main()
{
    cin >> n >> m >> k;
    f.m = e.n = e.m = n;
    f.n = 1;
    for (int i = 1; i <= n; i++)
        cin >> f.a[1][i];
    // for(int i=1;i<=n;i++)cout<<f.a[1][n]
    long long tmp = ksm(2 * m % mod, mod - 2);
    cerr << tmp << endl;
    for (int i = 1; i <= m; i++)
    {
        int x, y;
        cin >> x >> y;
        ++in[x];
        ++in[y];
        e.a[x][y] = tmp;
        e.a[y][x] = tmp;
    }
    // cerr << "!!!" << endl;
    for (int i = 1; i <= n; i++)
    {
        e.a[i][i] = (2 * m - in[i] + mod) % mod * tmp % mod;
        // cout << e.a[i][i] << endl;
    }
    // cerr << "!!!" << endl;
    e = ksmm(e, k);
    f = f * e;
    for (int i = 1; i <= n; i++)
    {
        cout << f.a[1][i] << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define f(x, m) for(auto x : m)
#define cpu() ios::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int ,int>>
#define vll vector<pair<ll ,ll>>
#define all(v) v.begin(),v.end()
#define sor(a) sort( a.begin(), a.end() )
#define ros(a) sort( a.rbegin(), a.rend())
#define prec(n) fixed << setprecision(n)
#define ff first
#define ss second
#define print(x) for(auto it : x) cout << it << " ";
#define debug(x) cerr << #x << " is " << x << endl;
#define rq(x, y) range_query(1, 0, n, x, y)
#define ru(x, y, val) range_update(1, 0, n, x, y, val)
typedef long long ll;
using namespace std;
// using namespace __gnu_pbds;
#define dbg(args...){ string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << "NEXT\n"; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << ", ";
err(++it, args...);
}
template<typename... T>
void rd(T& ... args){
  ((cin >> args), ...);
}
template<typename... T>
void ps(T ... args){
  ((cout << args << ' '), ...);
  cout << '\n';
}
// using ordered_set = tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7, MOD1 = 998244353LL, MAX = 2e5 + 5;
const char nl = '\n';
const int INF = 2e9 + 5;
int n;
void solve(){
  cin >> n;
  cout << 100 - (n % 100) << '\n';
}
int main(){
  cpu();
  int __ = 1;
  // cin >> __;
  while(__--){
    solve();
  }
  return 0;
}

#include<bits/stdc++.h>
#define pb push_back
#define mod 1000000007
#define endl '\n'
using namespace std;
#define ll long long int
ll ceil_div(ll a, ll b) {
    return (a + b - 1) / b;
}
ll maxi(ll a,ll b){
   return (a>b)?a:b;
}
ll mini(ll a,ll b){
   return (a<b)?a:b;
}
long double nthRoot(ll A, ll N)
{
   long double xPre = rand() % 10;

    long double eps = 1e-3;

    long double delX = INT_MAX;

    long double xK;

    while (delX > eps)
    {
        xK = ((N - 1.0) * xPre +
              (long double)A/pow(xPre, N-1)) / (long double)N;
        delX = abs(xK - xPre);
        xPre = xK;
    }

    return xK;
}
ll powe(ll x, unsigned ll y)
{
    ll res = 1;      // Initialize result

     // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x);

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x);
    }
    return res;
}
bool isInteger( long double value )
{
    long double flr = floor( value + 1e-5 );
    long double diff = value - flr;
    return diff < 1e-5;
}
void solve(){
	 ll n;
	 cin>>n;
	 ll arr[n];
	 ll i;
	 ll x=0,y=0;
	 for(i=0;i<n;i++){
		 cin>>arr[i];
		 x+=abs(arr[i]);
		 y+=abs(arr[i])*abs(arr[i]);
		 arr[i]=abs(arr[i]);
     }
     cout<<x<<endl;
     cout<<fixed<<setprecision(15)<<(long double)sqrt(y)<<endl;
     cout<<*max_element(arr,arr+n);
}
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll t=1;
   // cin>>t;
    while(t--){
		solve();
	}
}


#include <bits/stdc++.h>

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

double h0(long double P, int N, int M, unordered_set<int> &A) {
    vector<long double> h(N + M + 1);
    for (int i = 0; i <= M; i++) {
        h[N + i] = 0;
    }
    long double sum = 0;
    for(int i = N - 1; i >= 0; i--) {
        if (A.find(i) != A.end()) {
            h[i] = P;
        } else {
            h[i] = sum / M + 1.0;
        }
        sum += h[i];
        sum -= h[i + M];
    }
    return h[0];
}

void solve() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<int> A(K), B(100001);
    for (int i = 0; i < K; i++) {
        cin >> A[i];
        B[A[i]]++;
    }

    int cnt = 0;
    for (int i = 0; i < 100001; i++) {
        if (B[i]) cnt++; else cnt = 0;
        if (cnt >= M) {
            cout << -1 << endl;
            return;
        }
    }

    unordered_set<int> A_;
    for (int i = 0; i < K; i++) {
        A_.insert(A[i]);
    }

    long double ok = 0.0;
    long double ng = 8e10;

    for (int k = 0; k < 60; k++) {
        long double P = (ok + ng) / 2;
        if (h0(P, N, M, A_) <= P) {
            ng = P;
        } else {
            ok = P;
        }
    }
    cout << ok << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);

    solve();
}

#include <iostream>
#include <stack>
#include <string>
#include <vector>
#pragma warning(disable:4996)
using namespace std;
#define int long long
stack<int>way;
int N,M,K;
double ex[200100];
double ep[200100];
double epex[200100];
vector<pair<int, int>>x;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin >> N>>M >> K;
	int i;
	for (i = 0; i < K; i++)
	{
		int a;
		cin >> a;
		ep[a] = 1;
	}
	for (i = N; i <= N + M; i++)
	{
		ex[i] = 0;
	}
	double curex = 0, curep = 0,expex=0;
	for (i = N - 1; i >= 0; i--)
	{
		int isb = ep[i] >= 0.99999999;
		if (isb)
			goto T;
		ep[i] = curep;

		if (ep[i] <=0.999999999)
		{
			ex[i] = ((curex))/(M-curep*M)+1;
			if(curep>0)
				epex[i] = expex / (curep*M)+1;
		}
		else
		{
			if (!isb)
			{
				if (curep > 0)
					epex[i] = expex / (curep*M) + 1;
			}
		}
		T:
		curex -= ex[i + M]*(1-ep[i+M]);
		curep -= ep[i + M]/M;
		expex -= epex[i + M]*ep[i+M];
		curex += ex[i]*(1-ep[i]);
		curep += ep[i]/M;
		expex += epex[i]*ep[i];
	}
	i = 0;
	if (ep[i] >= 0.99999999)
		cout << -1;
	else
	{
		cout << ((1 - ep[i]) * ex[i] +epex[i]*ep[i]) / (1 - ep[i]);
	}
}


#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define whilet int T;cin>>T;while(T--)
#define clr(a,x) memset(a,x,sizeof(a));
#define ll long long
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;

int d4x[] = {0, 0, 1, -1};
int d4y[] = {1, -1, 0, 0};

int d8x[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int d8y[] = {-1, 0, 1, -1, 1, -1, 0, 1};

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

int h, w;
string s[2005];
ll dp[2005][2005];
ll up[2005][2005], rr[2005][2005], dd[2005][2005];

ll f() {
    for(int i = h-1; i >= 0; i--) {
        for(int j = w-1; j >= 0; j--) {
            if(i == h-1 and j == w-1) {
                dp[i][j] = 1;
                up[i][j] = 1;
                rr[i][j] = 1;
                dd[i][j] = 1;
                continue;
            }

            if(s[i][j] == '#') {
                dp[i][j] = 0;
                up[i][j] = 0;
                rr[i][j] = 0;
                dd[i][j] = 0;
                continue;
            }

            int res = 0;
            if(i+1 < h) res += up[i+1][j];
            res %= MOD;

            if(j+1 < w) res += rr[i][j+1];
            res %= MOD;

            if(i+1 < h and j+1 < w) res += dd[i+1][j+1];
            res %= MOD;

            dp[i][j] = res;

            if(i+1 < h) up[i][j] = dp[i][j] + up[i+1][j];
            else up[i][j] = dp[i][j];
            up[i][j] %= MOD;
            if(j+1 < w) rr[i][j] = dp[i][j] + rr[i][j+1];
            else rr[i][j] = dp[i][j];
            rr[i][j] %= MOD;
            if(i+1 < h and j+1 < w) dd[i][j] = dp[i][j] + dd[i+1][j+1];
            else dd[i][j] = dp[i][j];
            dd[i][j] %= MOD;
        }
    }
    return dp[0][0];
}

int main() {
    IO;

    cin >> h >> w;
    for(int i = 0; i < h; i++) {
        cin >> s[i];
    }

    clr(dp, -1);

    cout << f();
    return 0;
}

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

struct modint{
  li num;

  modint(li a=0){
    num=(a%MOD+MOD)%MOD;
  }
  modint operator+(modint a) {return{(num+a.num)%MOD};}
  modint operator-(modint a) {return{((num-a.num)%MOD+MOD)%MOD};}
  modint operator*(modint a) {return{num*a.num%MOD};}
  modint inv(const modint& a);
  modint operator/(modint a) {return (*this)*inv(a);}
  modint& operator+=(modint a) {
    (num += a.num)%=MOD;
    return *this;
  }
  modint& operator-=(modint a) {
    (num += MOD-a.num)%=MOD;
    return *this;
  }
  modint& operator*=(modint a) {
    (num*=a.num)%=MOD;
    return *this;
  }
};

std::ostream& operator<<(std::ostream& os, const modint& m){
  // ここでストリームに obj を書き込みます。
  li a=m.num;
  a%=MOD;
  a+=MOD;
  a%=MOD;
  cout << a;
  return os;
}

std::istream& operator>>(std::istream& os,modint& m){
  // ここでストリームに obj を書き込みます。
  li a; cin >>a;
  m=a;
  return os;
}

int main(){
  int h,w; cin >>h >>w;
  vector<string> mp(h);
  rep(i,h) cin >>mp[i];

  auto judge=
    [&](int i,int j){
      if(i<0 or j<0) return 0;
      if(mp[i][j]=='#') return 0;
      return 1;
    };

  vector<vector<modint>> dp(h,vector<modint>(w,0));
  vector<vector<modint>> tt(h,vector<modint>(w,0));
  vector<vector<modint>> yk(h,vector<modint>(w,0));
  vector<vector<modint>> nn(h,vector<modint>(w,0));
  dp[0][0]=tt[0][0]=yk[0][0]=nn[0][0]=1;
  rep(i,h) rep(j,w){
    if(!judge(i,j))continue;
    int ii=i-1,jj=j-1;
    if(df)print("i,j",i,j);
    if(judge(ii,jj)) dp[i][j]+=nn[ii][jj];
    if(df)if(judge(ii,jj)) print("nn",nn[ii][jj],dp[i][j]);
    if(judge(i,jj)) dp[i][j]+=yk[i][jj];
    if(df)if(judge(i,jj)) print("yk",yk[i][jj],dp[i][j]);
    if(judge(ii,j)) dp[i][j]+=tt[ii][j];
    if(df)if(judge(ii,j)) print("tt",tt[ii][j],dp[i][j]);

    tt[i][j]=yk[i][j]=nn[i][j]=dp[i][j];
    if(judge(ii,jj)) nn[i][j]+=nn[ii][jj];
    if(judge(i,jj)) yk[i][j]+=yk[i][jj];
    if(judge(ii,j)) tt[i][j]+=tt[ii][j];
    if(df){
      if(df)print("dp");
      rep(i,h) print(dp[i]);
      if(df)print("tt");
      rep(i,h) print(tt[i]);
      if(df)print("yk");
      rep(i,h) print(yk[i]);
      if(df)print("nn");
      rep(i,h) print(nn[i]);
    }
  }
  if(df){
    if(df)print("dp");
    rep(i,h) print(dp[i]);
    if(df)print("tt");
    rep(i,h) print(tt[i]);
    if(df)print("yk");
    rep(i,h) print(yk[i]);
    if(df)print("nn");
    rep(i,h) print(nn[i]);
  }

  print(dp[h-1][w-1]);
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
#define N 100100

vector<vector<ll>> conn(N);

vector<vector<ll>> ansc(N,vector<ll>(3,0));

void dfs(ll now, ll prev) {
    ll first = 1; ll second = 0; ll third = 1;
    ll secondf = 0; ll seconds = 0;
    vector<vector<ll>> ones;
    for (ll nex : conn[now]) {
        // cout << now << " " << nex << endl;
        if (nex==prev) continue;
        dfs(nex,now);
        ll pfirst = ansc[nex][0];
        ll psecond = ansc[nex][1];
        ll pthird = ansc[nex][2];
        third += pthird;
        if (pthird==0) {
            if (pfirst<=psecond) {
                first += pfirst;
                second += psecond;
            }
            else {
                secondf += pfirst;
                seconds += psecond;
            }
        }
        else {
            ones.pb({pfirst-psecond,pfirst,psecond});
        }
    }
    third%=2;
    // cout << now << " " << first << " " << second << " " << third << endl;
    if (third%2) {
        first += secondf; second += seconds;
    }
    else {
        second += secondf; first += seconds;
    }
    sort(ones.begin(),ones.end());
    REP(i,ones.size()) {
        if (i%2==0) {
            first += ones[i][1]; second += ones[i][2];
        }
        else {
            first += ones[i][2]; second += ones[i][1];
        }
    }
    ansc[now]={first,second,third};
    return;
}

int main(){
    ll n; cin >> n;
    REP(i,n-1) {
        ll p; cin >> p; p--;
        conn[i+1].pb(p); conn[p].pb(i+1);
    }
    dfs(0,-1);
    // REP(i,n) {
    //     cout << ansc[i][0] << " " << ansc[i][1] << " " << ansc[i][2] << endl;
    // }
    cout << ansc[0][0] << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define For(i,a,b) for(register int i=a;i<=b;++i)
#define Down(i,a,b) for(register int i=a;i>=b;i--)
#define reg register
namespace yspm{
	inline int read(){
		int res=0,f=1; char k;
		while(!isdigit(k=getchar())) if(k=='-') f=-1;
		while(isdigit(k)) res=res*10+k-'0',k=getchar();
		return res*f;
	}
	const int N=1e5+10;
	inline int min(int x,int y){return x<y?x:y;}
	inline int max(int x,int y){return x>y?x:y;}
	inline void swap(int &x,int &y){int t=x; x=y; y=t; return ;}
	vector<int>g[N];
	int sz[N],f[N],n;
	inline void dfs(int x){
		sz[x]=1; vector<int> ev,od; f[x]=-1;
		for(auto t:g[x]) dfs(t),sz[x]^=sz[t],sz[t]?od.push_back(f[t]):ev.push_back(f[t]);
		sort(od.begin(),od.end()); reverse(od.begin(),od.end());
		sort(ev.begin(),ev.end()); reverse(ev.begin(),ev.end());
		int ne=0,no=0,fl=0;
		while(ne<ev.size()&&ev[ne]>0) f[x]+=ev[ne],++ne;
		while(no<od.size()) fl?f[x]-=od[no]:f[x]+=od[no],++no,fl^=1;
		while(ne<ev.size()) fl?f[x]-=ev[ne]:f[x]+=ev[ne],++ne;
		return ;
	}
	signed main(){
		n=read(); for(reg int i=2,tf;i<=n;++i) tf=read(),g[tf].push_back(i); dfs(1);
		printf("%lld\n",(n-f[1])/2);
		return 0;
	}
}
signed main(){return yspm::main();}


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

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

    ll num = 2 << (N-1);
    vector<pair<int, int>> A(num);
    rep(i, num) {
        A[i].first = i + 1;
        cin >> A[i].second;
    }

    num /= 2;
    for (int i = 0; i < N - 1; ++i) {
        for (int j = 0; j < num; ++j) {
            if (A[j * 2].second > A[j * 2 + 1].second) {
                A[j].first = A[j * 2].first;
                A[j].second = A[j * 2].second;
            } else {
                A[j].first = A[j * 2 + 1].first;
                A[j].second = A[j * 2 + 1].second;
            }
        }
    }

    if (A[0].second < A[1].second) {
        cout << A[0].first << endl;
    } else {
        cout << A[1].first << endl;
    }

    return 0;
}

#include<bits/stdc++.h>
#define ll long long
#define inf 1e18
#define mod 1000000007
using namespace std;
int main()
{
        ll n;
        cin>>n;
        vector<ll> a;
        n=pow(2,n);
        a.resize(n);
        unordered_map<ll,ll> ump;
        for(ll p=0;p<n;p++)
        {
            cin>>a[p];
            ump[a[p]]=p;
        }
        ll max1=0;
        ll max2=0;
        for(ll p=0;p<n/2;p++)
        {
            max1=max(max1,a[p]);
        }
        for(ll p=n/2;p<n;p++)
        {
            max2=max(max2,a[p]);
        }
       // cout<<min(max1,max2)<<endl;
        cout<<ump[min(max1,max2)]+1<<endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<ll> vll;
#define all(v) v.begin(), v.end()
#define rep(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define lep(i,s,n) for(ll i=(ll)(s);i<(ll)(n);i++)
#define vep(v) for(auto&& x : v)
#define sz(s) (int)(s.size())
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using graph = vector<vector<int>>;

int main(){
  string s;
  cin >> s;
  int n = sz(s), cnt = 0, ans;
  vi p(3);
  rep(i, 0, n){
    int q = s[i]-'0';
    q%=3;
    cnt += q;
    p[q]++;
  }
  cnt%=3;
  if(cnt==0){
    cout << 0 << endl;
    return 0;
  }
  if(cnt==2){
    if(p[2])ans = 1;
    else if(p[1]>=2)ans = 2;
    else ans = -1;
  }
  else if(cnt==1){
    if(p[1])ans = 1;
    else if(p[2]>=2)ans = 2;
    else ans = -1;
  }
  if(ans>=n)cout << -1 << endl;
  else cout << ans << endl;
}