#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef pair<int,lld> pil;
typedef pair<lld,int> pli;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};

const int MAX = 1000100;
struct SCC_cl{
	// 1 based SCC
	int V, E, cnt, dfsn[MAX], SN, sn[MAX],tsat[MAX];
	vector<int> adj[MAX];
	bool finished[MAX];
	stack<int> S;
	vector<vector<int> > SCC;
	SCC_cl(){
		memset(dfsn,0,sizeof(dfsn));
		memset(sn,0,sizeof(sn));
		memset(finished,false,sizeof(finished));
		cnt = 0;
		SN = 0;
	}
	void init(int V){
		this->V = V;
	}
	int DFS(int curr){
	    dfsn[curr] = ++cnt;
	    S.push(curr);
	    int result = dfsn[curr];
	    for(int next: adj[curr]){
	        if(dfsn[next] == 0) result = min(result, DFS(next));
	        else if(!finished[next]) result = min(result, dfsn[next]);
	    }
	    if(result == dfsn[curr]){
	        vector<int> currSCC;
	        while(1){
	            int t = S.top();
	            S.pop();
	            currSCC.push_back(t);
	            finished[t] = true;
	            sn[t] = SN;
	            if(t == curr) break;
	        }
	        sort(currSCC.begin(), currSCC.end());
	        SCC.push_back(currSCC);
	        SN++;
	    }
	    return result;
	}
	void goSCC(){
		for(int i=1; i<=V; i++)
        	if(dfsn[i] == 0) DFS(i);
	}
	void add_edge(int a,int b){
		adj[a].push_back(b);
	}
	int get_ans(int n,int m){
		set<int> s1,s2;
		for(int e=1;e<=n;e++){
			s1.insert(sn[e]);
		}
		for(int e=n+1;e<=n+m;e++){
			s2.insert(sn[e]);
		}
		return min(sz(s1)-1,sz(s2)-1);
	}
	// two sat
	// A v B -> A^c -> B , B^c -> A
	// 1 based SCC -> i : 2*i - 1 , 2*i
	void getTwoSat(){
		memset(tsat,-1,sizeof(tsat));
		pi p[MAX];
	    for(int i=1;i<=V;i++)
	        p[i] = mk(sn[i], i);
	    sort(p+1, p+1+V);
	    for(int i=V; i>=1; i--){
	        int var = p[i].second;
	        if(tsat[(var+1)/2] == -1) tsat[(var+1)/2] = !(var%2);
	    }
	}
	bool isTwoSat(){
		for(int e=1;e<=V;e+=2){
			if(sn[e]==sn[e+1]) return false;
		}
		return true;
	}
};
SCC_cl gh;
string a[1010];
void solve(int tc){
	int n,m;
	scanf("%d%d",&n,&m);
	gh.init(n+m);
	gh.add_edge(1,n+m);
	gh.add_edge(1,n+1);
	gh.add_edge(n,n+1);
	gh.add_edge(n,n+m);
	gh.add_edge(n+1,1);
	gh.add_edge(n+1,n);
	gh.add_edge(n+m,1);
	gh.add_edge(n+m,n);
	for(int e=1;e<=n;e++) cin >> a[e];
	for(int p=1;p<=m;p++){
		vector<int> v;
		for(int e=1;e<=n;e++){
			if(a[e][p-1]=='#') v.push_back(e);
		}
		if(sz(v)){
			for(int q=0;q<sz(v);q++){
				gh.add_edge(v[q],p+n);
			}
		}
	}
	for(int e=1;e<=n;e++){
		vector<int> v;
		for(int p=1;p<=m;p++){
			if(a[e][p-1]=='#') v.push_back(p);
		}
		if(sz(v)){
			for(int q=0;q<sz(v);q++){
				gh.add_edge(v[q]+n,e);
			}
		}
	}
	gh.goSCC();
	printf("%d\n",gh.get_ans(n,m));
}

int main(void){
	/*
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	*/
	int tc = 1;
	/*
		scanf("%d",&tc);
	*/
	for(int test_number=1;test_number<=tc;test_number++){
		solve(test_number);
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
const int maxn=2020;
int n,m;
int fa[maxn];
int fnd(int x)
{
	if(fa[x]==x)
	{
		return x;
	}
	return fa[x]=fnd(fa[x]);
}
void merge(int x,int y)
{
	fa[fnd(x)]=fnd(y);
}
set<int> s1,s2;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n+m;i++)
	{
		fa[i]=i;
	}
	merge(1,n);
	merge(1,n+1);
	merge(1,n+m);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			char c;
			cin>>c;
			if(c=='#')
			{
				merge(i,j+n);
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		s1.insert(fnd(i));
	}
	for(int i=n+1;i<=n+m;i++)
	{
		s2.insert(fnd(i));
	}
	cout<<min((int)s1.size(),(int)s2.size())-1<<endl;
	return 0;
}


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

vector<pair<int,char>> adj[1000];
bool vis[1000][1000];
int best[1000][1000];

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

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

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			best[i][j] = 1e9;
		}
	}

	while (m--) {
		int u, v;
		char c;
		cin >> u >> v >> c, --u, --v;
		adj[u].emplace_back(v, c);
		adj[v].emplace_back(u, c);
	}

	best[0][n-1] = 0;
	queue<pair<int,int>> q;
	q.push({0, n-1});

	int ans = INT_MAX;

	while (!q.empty()) {
		int u, v;
		tie(u, v) = q.front();
		q.pop();
		if (vis[u][v]) continue;
		if (u == v) ans = min(ans, best[u][v]);
		vis[u][v] = true;
		for (auto [x1, c1] : adj[u]) {
			if (x1 == v) {
				ans = min(ans, best[u][v] + 1);
				continue;
			}
			for (auto [x2, c2] : adj[v]) {
				if (c1 == c2) {
					if (best[x1][x2] > best[u][v] + 2) {
						best[x1][x2] = best[u][v] + 2;
						q.push({x1, x2});
					}
				}
			}
		}
	}

	if (ans == INT_MAX) cout << "-1";
	else cout << ans;

	return 0;
}

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define pre(i,a,b) for(int i=a;i>=b;i--)
#define N 1005
using namespace std;
int n,m,v[N][N],vis[N][N],ans=0x7fffffff;
vector<int>c[N][26];
struct node{
	int x,y,val;
	node(int X=0,int Y=0,int V=0){x=X;y=Y;val=V;}
	bool operator<(const node o)const{return val>o.val;}
};
priority_queue<node>q;
int main(){
	scanf("%d%d",&n,&m);
	rep(i,1,n)v[i][i]=1;
	rep(i,1,m){
		int x,y;char op[2];
		scanf("%d%d%s",&x,&y,op);
		v[x][y]=v[y][x]=1;
		c[x][(*op)-'a'].push_back(y);
		c[y][(*op)-'a'].push_back(x);
	}
	q.push(node(1,n,0));
	while(!q.empty()){
		node now=q.top();q.pop();
		vis[now.x][now.y]=1;
		if(now.x==now.y){printf("%d\n",min(ans,now.val*2));return 0;}
		if(v[now.x][now.y]){ans=min(ans,now.val*2+(now.x!=now.y));continue;}
		rep(col,0,25){
			for(int i=0;i<(int)c[now.x][col].size();i++)
				for(int j=0;j<(int)c[now.y][col].size();j++){
					int x=c[now.x][col][i],y=c[now.y][col][j];
					if(!vis[x][y])vis[x][y]=1,q.push(node(x,y,now.val+1));
				}
		}
	}
	if(ans==0x7fffffff)puts("-1");else printf("%d\n",ans);
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map> //http://vivi.dyndns.org/tech/cpp/map.html
#include <set> //http://vivi.dyndns.org/tech/cpp/set.html
#include <vector>
#include <deque>
#include <queue>
#include <numeric> //gcd,lcm c++17
#include <tuple>
#include <iomanip> //setprecision
#include <unordered_map>
#include <chrono>
//#define _GLIBCXX_DEBUG
using namespace std;
template <typename T>
using vc = vector<T>;
template <typename T>
using vv = vc<vc<T>>;
template <typename T>
using PQ = priority_queue<T, vc<T>, greater<T>>;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
//typedef __uint128_t Int;
using vi = vc<int>;
using vl = vc<ll>;
using vd = vc<double>;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define ALL(a) (a).begin(), (a).end()
#define sz(x) (int)(x).size()
template <class T1, class T2, class Pred = std::less<T2>>
struct sort_pair_second
{
    //sort_pair_second<ll,ll,greater<ll>>()
    bool operator()(const std::pair<T1, T2> &left, const std::pair<T1, T2> &right)
    {
        Pred p;
        return p(left.second, right.second);
    }
};
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;
}
int MOD = 1e9 + 7;
double EPS = 1e-9;
int INF = 2000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
int rdx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int rdy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int N;
string S;

int f(int n)
{
    if (n == 0)
        return 0;
    if (n == 1)
        return 1;
    return n + f(n - 1);
}

int main()
{
    cin >> N >> S;
    int left = 0, right = 0;
    int n = N - N % 2;
    int nextright = n;
    int nextleft = 0;
    int a = 0, g = 0, c = 0, t = 0;
    ll ans = 0;
    while (nextright > 0)
    {
        while (right < nextright)
        {
            if (S[right] == 'A')
                a++;
            else if (S[right] == 'G')
                g++;
            else if (S[right] == 'C')
                c++;
            else if (S[right] == 'T')
                t++;
            right++;
        }
        while (left < nextleft)
        {
            if (S[left] == 'A')
                a--;
            else if (S[left] == 'G')
                g--;
            else if (S[left] == 'C')
                c--;
            else if (S[left] == 'T')
                t--;
            left++;
        }
        if (a == t && g == c)
            ans++;
        nextright = right + 1;
        nextleft = left + 1;
        if (right == N)
        {
            n -= 2;
            right = 0;
            left = 0;
            nextright = n;
            nextleft = 0;
            a = 0, g = 0, c = 0, t = 0;
            continue;
        }
    }
    cout << ans << endl;
    /*
    vi a, g;
    int acnt = 0, gcnt = 0;
    int ans = 0;
    FOR(i, 0, N - 1)
    {
        if ((S[i] == 'A' && S[i + 1] == 'T') || (S[i] == 'T' && S[i + 1] == 'A'))
        {
            acnt++;
            ans++;
        }
        else if (acnt)
        {
            acnt--;
            a.push_back(acnt / 2);
            acnt = 0;
        }
        if ((S[i] == 'G' && S[i + 1] == 'C') || (S[i] == 'C' && S[i + 1] == 'G'))
        {
            ans++;
            gcnt++;
        }
        else if (gcnt)
        {
            gcnt--;
            g.push_back(gcnt / 2);
            gcnt = 0;
        }
    }
    if (acnt)
    {
        acnt--;
        a.push_back(acnt / 2);
    }
    if (gcnt)
    {
        gcnt--;
        g.push_back(gcnt / 2);
        gcnt = 0;
    }
    for (auto x : a)
        ans += f(x);
    for (auto x : g)
        ans += f(x);*/
}

//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define gcd(a,b) __gcd(a,b)
#define endl '\n'
const int N=3e5+10;
const int inf=1e9;
const int mod=1e9+7;

int  main(int argc, char const *argv[])
{
	/*#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(0);

	int n, k;
	cin >> n >> k;

	int a[n];
	int cnt[N]={0};

	for(int i=0; i<n; i++)
	{
		cin >> a[i];
		cnt[a[i]]++;
	}

	int ans=0;

	for(int i=0; i<N; i++)
	{
		if(cnt[i]<k)
		{
			int tmp=k-cnt[i];
			if(tmp>k)
				tmp=k;
			ans+=tmp*i;
			k-=tmp;
		}

		if(k==0)
			break;
	}

	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
const int mxn = 1e3+10;
const int mod = 998244353;
int pa[2*mxn], sz[2*mxn], h ,w;
string mt[mxn];

int find(int v) {
	if(v==pa[v]) return v;
	return pa[v] = find(pa[v]);
}

void unite(int a, int b) {
	a = find(a); b = find(b);
	if(a!=b) pa[b] = a, sz[a]+=sz[b];
}

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

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

	for(int i=0; i<h+w; i++) pa[i] = i, sz[i] = 1;

	unite(0, 0+h); unite(0, w-1+h); unite(h-1, 0+h); unite(h-1, w-1+h);

	for(int i=0; i<h; i++) for(int j=0;j<w; j++) if(mt[i][j]=='#') unite(i, j+h);

	set<pair<int, int> > s; for(int i=0;i<w+h; i++) s.insert(make_pair(find(i), sz[find(i)]));

	int row = 0, col = 0;
	for(auto x:s) {
		if(x.second>=2) row++, col++;
		else if(x.first<h) row++;
		else col++;
	}

	int ans = min(row, col)-1;
	cout << ans << '\n';

	return 0;
}

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; --i)

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

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

const ll inf = 1'000'000'000'000'000'001;

ll base_n(string x, ll n) {
    ll ret = 0;
    for (char c : x) {
        if (ret > inf / n) return -1;
        ret *= n;
        ret += (ll)c - '0';
    }
    return ret;
}

int main() {
    string x;
    ll m;
    cin >> x >> m;
    ll d = 0;
    for (char c : x) chmax(d, (ll)c - '0');
    if (x.size() == 1) {
        if (d <= m) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    ll ng = inf;
    ll ok = d;
    while (abs(ok - ng) > 1) {
        ll c = ok + (ng - ok) / 2;
        ll y = base_n(x, c);
        if (y < 0) {
            ng = c;
            continue;
        }
        if (y <= m) ok = c;
        else ng = c;
    }
    ll ans = ok - d;
    cout << ans << endl;
}


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

void dfs(int node, int f, auto& g, auto& seen, auto& sol, auto& edges) {
    seen[node] = 1;
    int n = g.size();
    for (int v = 0; v < n; v += 1) {
        if (g[node][v] == 0)
            continue;
        if (v == f)
            continue;

        int ind = g[node][v] - 1;

        if (seen[v]) {
            if (v == edges[ind].first)
                sol[ind] = 0;
            else
                sol[ind] = 1;
            continue;
        }

        if (v == edges[ind].first)
            sol[ind] = 1;
        else
            sol[ind] = 0;
        dfs (v, node, g, seen, sol, edges);
    }
}

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> g(n, vector<int> (n, 0));
    vector<pair<int, int>> edges;

    for (int i = 0; i < m; i += 1) {
        int a, b; cin >> a >> b;
        a -= 1, b -= 1;
        edges.push_back(make_pair(a, b));
    }

    vector<int> c(n, 0);
    for (int i = 0; i < n; i += 1) {
        cin >> c[i];
    }

    vector<int> sol(m, -1);

    for (int i = 0; i < m; i += 1) {
        auto e = edges[i];
        if (c[e.first] < c[e.second]) {
            sol[i] = 1;
        } else if (c[e.first] > c[e.second]) {
            sol[i] = 0;
        } else {
            g[e.first][e.second] = i + 1;
            g[e.second][e.first] = i + 1;
        }
    }

    vector<int> seen(n, 0);

    for (int i = 0; i < n; i += 1)
        if (not seen[i]) {
            dfs(i, -1, g, seen, sol, edges);
        }

    for (int i = 0; i < m; i += 1) {
        if (sol[i])
            cout << "<-\n";
        else
            cout << "->\n";
    }
}

#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n) for (int i = n - 1; i >= 0; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define pb push_back
#define em emplace_back
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define vd vector<double>
#define vb vector<bool>
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define fast  \
  cin.tie(0); \
  ios::sync_with_stdio(false);
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

struct RMQ {
  int n;                               // 葉の数
  vector<int> dat;                     // 完全二分木の配列
  RMQ(int n_) : n(), dat(n_ * 4, 0) {  // 葉の数は 2^x の形
    int x = 1;
    while (n_ > x) {
      x *= 2;
    }
    n = x;
  }
  void update(int i, int x) {
    i += n - 1;
    dat[i] = x;
    while (i > 0) {
      i = (i - 1) / 2;  // parent
      dat[i] = dat[i * 2 + 1] ^ dat[i * 2 + 2];
    }
  }
  // the minimum element of [a,b)
  int query(int a, int b) { return query_sub(a, b, 0, 0, n); }
  int query_sub(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) {
      return 0;
    } else if (a <= l && r <= b) {
      return dat[k];
    } else {
      int vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
      int vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
      return (vl ^ vr);
    }
  }
};

int main() {
  fast;
  int n, q;
  cin >> n >> q;
  vi a(n);
  rep(i, 0, n) cin >> a[i];
  RMQ seg(n);
  rep(i, 0, n) seg.update(i, a[i]);
  rep(i, 0, q) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 1) {
      seg.update(x - 1, seg.dat[x + seg.n - 2] ^ y);
    } else {
      cout << seg.query(x - 1, y) << endl;
    }
  }
  return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define ff first
#define ss second
#define ii pair<int,int>
#define vii vector<ii>
#define INF 1000000000
#define mod 1000000007
#define endl "\n"
#define ll long long
#define int ll
#define ull unsigned long long
#define ld long double
const double PI = (2.0 * acos(0.0));
#define cz(x) 63 - __builtin_clzll(x)
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>;

void INPUT()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

map<int, int> cnt;
int X, Y;
int solve(int now)
{
	if (now <= X)
		return X - now;
	if (cnt.count(now))
		return cnt[now];
	int res = now - X;
	if (now % 2 == 0)
		res = min(res, solve(now / 2) + 1);
	else
		res = min(res, 1 + min(solve(now - 1), solve(now + 1)));
	return cnt[now] = res;
}

void Tmain()
{
	cin >> X >> Y;
	cout << solve(Y);
}

signed main()
{
	FIO
	INPUT();

	int T = clock();
	int t = 1;
	for (int tc = 1; tc <= t; tc++)
	{
		Tmain();
	}
	cerr << "\n\nTIME: " << (double)(clock() - T) / CLOCKS_PER_SEC << " sec\n";
	T = clock();
	return 0;
}

#include <bits/stdc++.h>
#define endl "\n"
#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 e_b emplace_back
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ipair;
typedef pair<ll, ll> lpair;
template <class T> ostream &operator << (ostream &o, const vector<T> &v) //vectorの中身を見る
{o << "{"; for(int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", ":"") << v[i]; o << "}"; return o;}
void map_p(map<int, int> &d){cout << "map: "; for(auto a : d){cout << "{" << a.first << ":" << a.second << "}, ";} cout << endl;} //mapの中身を見る
void set_p(set<int> &d){cout << "set: "; for(int a : d){cout << a << ", ";} cout << endl;} //setの中身を見る

template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) {
        a = b;  // aをbで更新
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) {
        a = b;  // aをbで更新
        return true;
    }
    return false;
}

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

    char s, t;
    cin >> s >> t;
    if(s == 'Y'){
        if('a' <= t and t <= 'z') t -= 'a' - 'A';
        else if('A' <= t and t <= 'Z') t += 'a' - 'A';
    }
    cout << t << endl;
    return 0;
}


/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define int    long long
#define double    long double
#define uint   unsigned long long
#define all(vec) vec.begin(),vec.end()
#define endl "\n"
int google_itr = 1;
#define google(x) cout<<"Case #"<<x<<": "
#define pi 3.14159265358979323846264338327950L

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

void virus(){

          int len;
          cin >> len;

          string seq;
          cin >> seq;

          int ans = 0;
          for(auto i=0; i<len; i++){
              int a = 0, b = 0;
              for(auto j=i; j<len; j++){
                  if(seq[j] == 'A') a++;
                  if(seq[j] == 'T') a--;
                  if(seq[j] == 'C') b++;
                  if(seq[j] == 'G') b--;
                  if(!a and !b) ans++;
              }
          }

          cout << ans << endl;
}

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

  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    int t = 1;
    //cin >> t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
           //cerr << "\n Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

//------------ヘッダーインクルード------------
#include <stdio.h>
#include <cmath>
#include <stdarg.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
//#include <pair>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
//------------型マクロ定義------------
typedef long l;
typedef long long ll;
#define INIF 1e9;
#define MOD 1000000007;
#define ALL(v) (v).begin(), (v).end()
//------------vectorマクロ定義------------
#define v(Type) vector<Type>
#define vv(Type) vector<vector<Type>>
#define vvv(Type) vector<vector<vector<Type>>>
#define vini(n, m) ((n), (m))
//------------forマクロ定義------------
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define rep2(i, m, n) for(int i = (m); (i) < (n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define fe(i, STL) for(auto i: (STL))
//------------ioマクロ定義------------
#define co cout<<
#define en <<endl
#define br co "" en
#define pr(value) ","<<#value<<": "<<value
#define sn(value) #value,value

template<class Type>
void print_value(string name, Type value){co name << ":" << value;}
#define pri(value) print_value(sn(value))

template<class Type>
void print_value2(string name, Type value){
  int num = 0;
  fe(i, value)co name << "[" << num++ << "]:"  << i << ", ";
}
#define pri2(Type, value) print_value2<Type>(sn(value))
//------------main------------

int main(){
  int N;
  cin >> N;
  long long int che = 0, man = 0, input;
  long double eu = 0.0;

  rep(i, N){
    cin >> input;
    man += abs(input);
    eu += (input * input);
    if(che < abs(input))che = abs(input);
  }
  eu = sqrt(eu);

  co man en;
  co fixed << setprecision(15) << eu en;
  co che en;

  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define          pb                push_back
#define          eb                emplace_back
#define          all(x)            x.begin(), x.end()
#define          sz(x)             int(x.size())
#define          pii               pair<int, int>
#define          pll               pair<ll, ll>
#define          ff                first
#define          ss                second

const ll INF = 1e18;
const int MOD = 1e9+7;
const int MX = 2e5+7;
const double PI = 3.1415926535897932384626;

ll bpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1)
            res *= a;
        a *= a;
        b >>= 1;
    }
    return res;
}

void solve() {
    ll N; cin >> N;
    ll ans = LLONG_MAX;
    ll calc = 0, a = 0, c = 0;
    for (ll b = 0; b <= 60; b++) {
        calc = 1LL << b;
        a = N/calc;
        c = N-(a*calc);
        ans = min(ans, a+b+c);
    }
    cout << ans;
}

void fastIO(string name = "") {
    cin.tie(0)->sync_with_stdio(0);
    if (sz(name)) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}

int main() {
    fastIO("");

    int tc = 1; //cin >> tc;
    while (tc--) solve();
    return 0;
}

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std;
long long modPow(long long x, long long a) {
  if (a == 1) return x;
  if (a % 2) return (x * modPow(x, a - 1)) % MOD;
  long long t = modPow(x, a / 2);
  return (t * t) % MOD;
}
long long modInv(long long x) {
  return modPow(x, MOD - 2);
  }
  void recursive_comb(int *indexes, int s, int rest, std::function<void(int *)> f) {
  if (rest == 0) {
    f(indexes);
  } else {
    if (s < 0) return;
    recursive_comb(indexes, s - 1, rest, f);
    indexes[rest - 1] = s;
    recursive_comb(indexes, s - 1, rest - 1, f);
  }
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(int *)> f) {
  int indexes[k];
  recursive_comb(indexes, n - 1, k, f);
}

// nPnの順列に対して処理を実行する
void foreach_permutation(int n, std::function<void(int *)> f) {
  int indexes[n];
  for (int i = 0; i < n; i++) indexes[i] = i;
  do {
    f(indexes);
  } while (std::next_permutation(indexes, indexes + n));
}

// nPkの順列に対して処理を実行する
void foreach_permutation(int n, int k, std::function<void(int *)> f) {
  foreach_comb(n, k, [&](int *c_indexes) {
    foreach_permutation(k, [&](int *p_indexes) {
      int indexes[k];
      for (int i = 0; i < k; i++) {
        indexes[i] = c_indexes[p_indexes[i]];
      }
      f(indexes);
    });
  });
}
int main() {
  ll n,q,a,b,c,ans;
  q = 1;
  b = 0;
  cin >> n;
  ans = n;
  while (n >q)
  {
    a = n/q;
    c = n%q;
    if(a+b+c < ans ){
      ans = a+b+c;
    }
    q *= 2;
    b++;
  }

  cout << ans << endl;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
#define per(i,n) for(ll (i)=(n)-1;(i)>=0;--(i))
#ifdef LOCAL
#define debug(x) cerr<<__LINE__<<": "<<#x<<"="<<x<<endl;
#define debugALL(x) cerr<<__LINE__<<": "<<#x<<"=";for(auto i=(x).begin();i!=--(x).end();i++)cerr<<*i<<" ";cerr<<*--(x).end()<<endl;
#else
#define debug(x) true
#define debugALL(x) true
#endif
using namespace std;

int main(){
    ll n;
    cin>>n;
    vector<pair<ll,string>> a;
    rep(i,n){
        string s;
        ll t;
        cin>>s>>t;
        a.emplace_back(t,s);
    }
    sort(a.rbegin(),a.rend());
    cout<<a[1].second<<endl;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <limits>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
template<class T> inline int  sz(T &a) { return a.size(); }
using ll = long long; using ld = long double;
using pi = pair<int,int>; using pl = pair<ll,ll>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
const int inf = numeric_limits<int>::max();
const ll infll = numeric_limits<ll>::max();
// 任意MODが使えるModint
// 型宣言の前にmodint::set_mod(MOD) をしてね
struct modint{
  long long x;

  modint() : x(0) {}
  modint(long long x):x(x%mod()){}

  static int &mod() {
    static int mod = 0;
    return mod;
  }

  static void set_mod(int md) {
    mod() = md;
  }

  modint& operator+=(const modint a){
    if((x+=a.x)>=mod()) x-=mod();
    return *this;
  }
  modint& operator-=(const modint a){
    if((x += mod()-a.x)>=mod()) x-=mod();
    return *this;
  }
  modint& operator*=(const modint a){
    (x*=a.x)%=mod();
    return *this;
  }
  modint operator+(const modint a) const{
    modint res(*this);
    return res+=a;
  }
  modint operator-(const modint a) const{
    modint res(*this);
    return res-=a;
  }
  modint operator*(const modint a) const{
    modint res(*this);
    return res*=a;
  }
  modint pow(long long t) const{
    if(!t) return 1;
    modint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }

  //for prime mod
  modint inv() const{
    return pow(mod()-2);
  }
  modint& operator/=(const modint a){
    return (*this) *= a.inv();
  }
  modint operator/(const modint a) const{
    modint res(*this);
    return res/=a;
  }
};

int main()
{
  ll a,b,c; cin >> a >> b >> c;
  a %= 10;
  ll st = a;
  vl vec(1, a);
  while(1) {
    a *= st;
    a %= 10;
    if(a == st) break;
    vec.push_back(a);
  }
//  for(auto tmp: vec) cout << tmp << "\n";
  ll n = sz(vec);
  ll mod=n;
  modint::set_mod(mod);
  modint x(b);
  modint y = x.pow(c);
//  cout << y.x << "\n";
  ll id = y.x;
  if(id == 0) id = n;
  cout << vec[id-1] << "\n";
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define swap(a,b) (a^=b^=a^=b)
#define ll long long int
#define ull unsigned long long int
#define uint unsigned int
#define format(a) memset(a,0,sizeof(a))
#define rep(x,y,z) for(int x=y;x<=z;x++)
#define dec(x,y,z) for(int x=y;x>=z;x--)
#define mst(x) memset(x,0,sizeof(x))
const int maxn=2e6+220;
inline int read()
{
    int ans=0;
    char last=' ',ch=getchar();
    while(ch<'0'|ch>'9')last=ch,ch=getchar();
    while(ch>='0' && ch<='9')ans=ans*10+ch-'0',ch=getchar();
    if(last=='-')ans=-ans;
    return ans;
}
string s;
int dir=0;
char a[maxn];
int l=1e6+21,r=1e6+20;
int nxt(int pos)
{
    if(dir)return pos+1;
    else return pos-1;
}
int pre(int pos)
{
    if(!dir)return pos+1;
    else return pos-1;
}
int main()
{
    cin>>s;
    rep(i,0,s.size()-1)
    {
        if(s[i]=='R')
        {
            dir^=1;
        }
        else
        {
            if(dir==0)
            {
                a[++r]=s[i];
                if(a[r]==a[r-1]&&l!=r)r-=2;
            }
            else
            {
                a[--l]=s[i];
                if(a[l]==a[l+1]&&l!=r)l+=2;
            }
        }
    }
    if(!dir)rep(i,l,r)cout<<a[i];
    else dec(i,r,l)cout<<a[i];
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    string t;
    string ans;
    bool h = false;
    rep(i, s.size()){
        if (s[i] == 'R') h = !h;
        else{
            if (!h) t.push_back(s[i]);
            else t.insert(t.begin(), s[i]);
        }
    }

    if (h){
        reverse(t.begin(), t.end());
    }

    for (char c : t){
        if (ans.size() && ans.back() == c) ans.pop_back();
        else ans.push_back(c);
    }
    cout << ans << endl;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin() , (x).end()

void dbg(){
	cerr << endl;
}
template<typename Head , typename... Tail>
void dbg(Head h , Tail... t){
	cerr << h << " ";
	dbg(t...);
}

#ifdef EMBI_DEBUG
#define debug(...) cerr << "(" << #__VA_ARGS__  << "): ", dbg(__VA_ARGS__)
#else
#define debug(...)
#endif

const int max_n = 1e5 + 9;
const int inf = 1e9;
const int mod = 1e9 + 7;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
void solve(){
	int n;
    cin >> n;
    vll a(n);
    for(int i = 0 ; i < n ; i++) {
        cin >> a[i];
    }

    ll sum = 1;
    ll dp[n][n+1];
    memset(dp , 0 , sizeof(dp));
    for(int i = 0 ; i < n ; i++) {
        dp[i][1] = 1;
    }

    for(int j = 2 ; j <= n ; j++) {
        int b[n] , dp1[n];
        memset(dp1, 0 , sizeof(dp1));
        for(int i = 0 ; i < n ; i++) {
            b[i] = a[i] % j;
        }
        int curr_rem = 0;
        for(int i = 0 ; i < n ; i++) {
            curr_rem += b[i];
            curr_rem %= j;
            dp[i][j] = dp1[curr_rem];
            dp1[curr_rem] += dp[i][j-1];
            dp1[curr_rem] %= mod;
        }
        sum += dp[n-1][j];
        sum %= mod;
    }

    cout << sum << "\n";
}
signed main(){
	int t = 1;
	// cin >> t;
	for(int i = 1 ; i <= t ; i++){
		solve();
	}
}

// Never gonna give you up
// Never gonna let you down
// Never gonna run around and desert you
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
#define fi first
#define se second
#define pf push_front
#define pb push_back
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void solve(){
    int n; cin >>n;
    int a[n],sum=0; for(auto &i:a) cin >>i;
    for(int i=0; i<n; i++){
        int b; cin >>b;
        sum+=a[i]*b;
    }
    cout <<(!sum?"Yes":"No");
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // int T; cin >>T; while(T--)
    solve(); return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
int main() {
  ll N, W;
  cin >> N >> W;
  vector<ll> imos(2 * 1e5 + 1000);
  REP(i, N) {
    int s, t, p;
    cin >> s >> t >> p;
    imos[s] += p, imos[t] -= p;
  }
  REP(i, 2 * 1e5 + 100) { imos[i + 1] += imos[i]; }
  REP(i, 2 * 1e5 + 100) {
    if (imos[i] > W) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

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

int main() {
  int N, W;
  cin >> N >> W;
  vector<int> S(N), T(N);
  vector<ll> P(N);
  vector<ll> voldif(200001);
  for (int i = 0; i < N; i++) {
    int s, t, p;
    cin >> s >> t >> p;
    voldif[s] += p;
    voldif[t] -= p;
  }
  string ans = "Yes";
  ll vol = 0;
  for (auto &x : voldif) {
    vol += x;
    if (vol > W) ans = "No";
  }

  cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int n;
int a[maxn];
int t;
void solve() {
    cin>>n;
    for(int i=1 ; i<=n ; i++) cin>>a[i];
    bool bruh=false;
    if(n%2==1) cout<<"Second\n";
    else {
        sort(a+1,a+1+n);
        int cnt=0;
        for(int i=2 ; i<=n ; i+=2) {
            if(a[i]!=a[i-1]) bruh=true;
        }
        if(!bruh) cout<<"Second\n";
        else cout<<"First\n";
    }
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>t;
    while(t--) {
        solve();
    }
}

#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+1000;
int n,q,c[maxn],fa[maxn];
map<int,int> a[maxn];
void read(int &x)
{
	char ch;bool ok;
	for(ok=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') ok=1;
	for(x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar()); if(ok) x=-x;
}
int getfa(int x)
{
	if(fa[x]==x) return x;
	else return fa[x]=getfa(fa[x]);
}
void join(int x,int y)
{
	if(getfa(x)==getfa(y)) return;
	if(a[getfa(x)].size()<a[getfa(y)].size()) swap(x,y);
	for(pair<int,int>lll:a[getfa(y)]) a[getfa(x)][lll.first]+=lll.second;
	fa[getfa(y)]=getfa(x);
}
int main()
{
	read(n),read(q);
	for(int i=1;i<=n;i++) read(c[i]);
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=n;i++) a[i][c[i]]++;
	while(q--)
	{
		int x,y,z;
		read(x),read(y),read(z);
		if(x==1) join(y,z);
		else printf("%d\n",a[getfa(y)][z]);
	}
	return 0;
}


#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())

using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a * b / gcd(a, b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}

static const double pi = 3.141592653589793;
int modpow(int a,int n,int p){if (n==0)return 1%p; if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	void init(int size){
		table.resize(size);
		rep(i,size)table[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
	int getsize(){
		set<int> ma;
		rep(i,table.size())ma.insert(root(i));
		int re=ma.size();
		return re;
	}
};

string s;
int n;
int ans=intinf;//めちゃくちゃでかい値

int dfs(string bit){
	//再帰関数
	if(bit.size()==n){
		//サイズがNのビット列が生成されている
		//各bitにあった処理をするよ
		//22454367
		//00010001
		//57
		//6663277
		//6+6+6+3+2+7+7=37
		int val=0;//各桁の総和
		int count=0;
		for(int i=0;i<n;i++){
			if(bit[i]=='0'){
				//消してないから足している
				val+=(s[i]-'0');
			}else{
				//消してるから数える
				count++;
			}
		}
		if(val%3==0&&val!=0){
			//いくつかの桁を消したら割り切れた数になってるな
			//ここで答えを更新すれば良い
			ans=min(ans,count);
		}
	}
	else{
		dfs(bit+'0');
		dfs(bit+'1');
	}
	return 0;
}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(16);
	cin>>s;
	n=s.size();
	dfs("");
	if(ans==intinf){
		//めちゃくちゃでかい値だったら初期値のままだから更新されてないため
		cout<<-1<<endl;
	}else{
		cout<<ans<<endl;
	}
	return 0;
}

#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 105;
int k,ans;
char ch[MAXN];

inline int dfs(int sum,int x,int cnt)
{
	if(sum % 3 == 0 && sum > 0)
	return cnt;
	if(x > k)
	return 0x3f3f3f3f;
	return min(dfs(sum - ch[x] + '0',x+1,cnt+1),dfs(sum,x+1,cnt));
}

int main()
{
	scanf("%s",ch+1);
	k = strlen(ch+1);
	for(int i = 1;i <= k;i++)
	ans += ch[i] - '0';
	int x = dfs(ans,1,0);
	if(x == 0x3f3f3f3f)
		printf("-1\n");
	else
		printf("%d\n",x);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = int64_t; using Vll =vector<ll>; using VVll =vector<vector<ll>>;
template <class T> using Vec = vector<T>; template <class T> using VVec = vector<vector<T>>;
#define INF 9223372036854775807LL/2
void Z(ll i=-1){ if(i==-1)cout<<"Test"<<endl; else cout<<"Test"<<i<<endl; }
template <class T> void VVcout(VVec<T> A){ for(auto Vi:A) { for(auto i:Vi)cout<<i<<' '; cout<<endl;}}
template <class T> void Vcout(Vec<T> A){ for(auto i:A) cout<<i<<' '; cout<<endl;}
template <class T> void chmax(T &x,T y){if(x<y) x=y;} template <class T> void chmin(T &x,T y){if(x==-1 || x>y) x=y;}
#define rep(i,n) for(ll i=0;i<n;i++)
#define reps(si, i,n) for(ll i=si;i<n;i++)

int main(){
    string s;
    ll n;

    cin>>n>>s;

    if(n==1){
        cout<<-1<<endl;
        return 0;
    }

    if(s.at(0)!=s.at(n-1)){
        cout<<1<<endl;
        return 0;
    }

    char sc=s.at(0);
    bool allsame=true;
    rep(i,n) if(sc!=s.at(i)) allsame=false;
    if(allsame){
        cout<<-1<<endl;
        return 0;
    }

    bool sucdif=false;

    reps(1,i,n) if(sc!=s.at(i) && sc!=s.at(i-1))sucdif=true;

    if(sucdif){

        cout<<2<<endl;
        return 0;
    }

    cout<<-1<<endl;

}

#include <bits/stdc++.h>

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

using namespace std;

#define endl '\n'
#define int long long int
#define rep(i, a, b) for (int i = a; i < b; i++)
#define revrep(i, a, b) for (int i = a; i >= b; i--)
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define vii vector<pii>
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

ostream &operator<<( ostream &output, const pii &p ) { output << p.first << " " << p.second;return output; }
istream &operator>>( istream &input, pii &p ) { input >> p.first >> p.second;return input; }
template<typename T>
void inline println(vector<T> args){ for(T i: args)cout<<i<<" ";cout<<endl; }
void amax(int& a, int b) { a = max(a, b); }
void amin(int& a, int b) { a = min(a, b); }
int ceilInt(int a, int b) {
    if(!b) return 0;
    if(a%b) return a/b + 1;
    return a/b;
}

int INF = 1e18;
int MOD = 998244353;

void solve()
{
    int n; cin>>n;
    vi arr(n);
    rep(i, 0, n) cin>>arr[i];
    vi pre = arr;
    rep(i, 1, n) pre[i] += pre[i-1];
    int till = 0, mx = -1;
    rep(i, 0, n) {
        amax(mx, arr[i]);
        till += pre[i];
        cout<<till+mx*(i+1)<<endl;
    }
}

signed main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    rep(i, 0, t)
    {
        // cout<<"Case #"<<i+1<<": ";
        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif
struct Cow{
	using D = int;
	const D inf = 1e9;
	struct Edge{
		int to;
		D cost;
		Edge(int to,D cost):to(to),cost(cost){}
	};
	int N,M;
	vector<vector<Edge>> G;
	vector<D> d;
	Cow(int N):N(N){
		G.assign(N,vector<Edge>());
		d.assign(N,inf);
	}
	void add_edge(int t,int s,D c){	// correspond to t-s <= c
//		printf("%d->%d   :%d\n",t,s,c);
		G[s].pb(Edge(t,c));
	}
	void add_edge(int t,int s,D clow,D chigh){	// clow <= t-s <= chigh
		add_edge(t,s,chigh);
		add_edge(s,t,-clow);
	}
	/*
		return the inequalities have a valid assignment
		if satisfiable, minimize d[T]-d[S]

		negative cycle    <=> unsatisfiable
		d[T] - d[S] = inf <=> feasible unboundedly

		d[S]=0

		Tによらなくない?(気づき)
	*/
	bool IsValidAssign(int S = 0){
		vector<int> prev(N);
		d[S] = 0;
		rep(ph,N){
			bool update = 0;
			int v = -1;
			rep(s,N) for(auto e:G[s]){
				int t = e.to;
				D cost = e.cost;
				if(d[s]+cost < d[t]){
					update=1;
					v = t;
					d[t] = d[s]+cost;
					prev[t] = s;
				}
			}
			if(ph == N-1 && update){
				// vector<int> path;
				// path.pb(v);
				// int u = v;
				// do{
				// 	show(u);
				// 	u = prev[u];
				// 	path.pb(u);
				// }while(u!=v);
				// reverse(all(path));
				// show(path);
				return 0;
			}
			if(!update) break;
		}
		return 1;
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N,M; cin >> N >> M;
	const int inf = 1e9;
	int ans = inf;
	V<int> w(N); rep(i,N) cin >> w[i];
	int mxw = *max_element(all(w));
	V<int> lim(1<<N,0);
	rep(i,M){
		int l,v; cin >> l >> v;
		if(v < mxw){
			cout << -1 << endl;
			return 0;
		}
		rep(s,1<<N){
			int sum=0;
			rep(j,N) if(s&1<<j) sum += w[j];
			if(sum > v) chmax(lim[s],l);
		}
	}
	show(lim);
	V<int> o(N); iota(all(o),0);
	do{
		Cow cow(N);
		rep(l,N) for(int r=l+1;r<N;r++){
			int s=0;
			for(int i=l;i<=r;i++) s|=1<<o[i];
			cow.add_edge(l,r,-lim[s]);
		}
		rep(i,N-1){
			cow.add_edge(i,i+1,0);
		}
		if(cow.IsValidAssign(N-1)){
			show(cow.d);
			chmin(ans,cow.d[N-1]-cow.d[0]);
		}
	}while(next_permutation(all(o)));
	if(ans == inf) cout << -1 << endl;
	else cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
#define endl '\n'
#define lowbit(x) (x & -x)
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
#define ck(x) (x >= mod ? x - mod : x)
#define inf 0x3f3f3f3f
#define eps 1e-6
#define maxn 1500010
#define maxm 1010
#define G 3
#define invG 332748118
const int mod = 998244353;
const double PI = 4 * atan2(1.0, 1.0);
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return x ^ RANDOM; }
    int operator()(pair<int, int> x) const { return x.first ^ x.second ^ RANDOM; }
};
int n, m, a[maxn], cnt[maxn], p, ans = inf;
set<int> s;
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    s.insert(0);
    for (int i = 1; i < m; i++) {
        cnt[a[i]]++;
        if (s.count(a[i]))s.erase(a[i]);
        if (cnt[a[i] + 1] == 0)s.insert(a[i] + 1);
    }
    for (int i = m; i <= n; i++) {
        cnt[a[i]]++;
        if (s.count(a[i]))s.erase(a[i]);
        if (cnt[a[i] + 1] == 0)s.insert(a[i] + 1);
//        cout << i << ":";
//        for (auto &u:s)cout << u << ' ';
//        cout << endl;
        ans = min(ans, *s.begin());
        cnt[a[i - m + 1]]--;
        if (cnt[a[i - m + 1]] == 0 && s.count(a[i - m + 1] + 1))s.erase(a[i - m + 1] + 1);
        if (a[i - m + 1] > 0 && cnt[a[i - m + 1] - 1] != 0)s.insert(a[i - m + 1]);
        if (cnt[0] == 0)s.insert(0);
    }
    cout << ans << endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
long long gcd(long long x,long long y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x/gcd(x,y)*y;}
int main()
{
  int n;
  long long temp=0,ans=1;
  cin>>n;
  for(int i=2;i<=n;i++)
  {
	 temp=gcd(ans,i);
	 ans=ans/temp*i;
	 //cout<<ans<<endl;
  }
  ans++;
  printf("%lld",ans);
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
//const ll INF = numeric_limits<ll>::max() / 4;
//const int INF = numeric_limits<int>::max() / 4;

int main() {
	// ll N;
	string S;
	cin >> S;

	bool f = true;
	string s = "ZONe";
	int c = 0;
	while(f){
		int p = S.find(s);
		if(p < S.size()){
			c++;
			S[p] = '.';
		}else{
			f = false;
		}
	}

	cout << c << endl;
	return(0);
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, x, ans;
    while (cin >> n) {
        ans = 0;
        while (n--) {
            cin >> x;
            ans += x > 10 ? x - 10 : 0;
        }
        cout << ans << '\n';
    }
    return 0;
}

#include <iostream>

using namespace std;

int main(){
	int followerNum;
	int followNum;
	cin >> followerNum >> followNum;
	int followMax = 2*followerNum + 100;
	int availableFollow = followMax - followNum;
	cout << availableFollow << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

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

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

ll cal(ll arr[], ll n, vector<ll> v) {
	if(n == 0) {
		ll ans = 0;
		for(auto it : v ) {
			ans = ans ^ it;
		}
		return ans;
	}
	else {
		if(v.size() == 0) {
			v.pb(arr[n-1]);
			return cal(arr,n-1,v);
		}
		else {
			vector<ll> temp = v;
			temp.pb(arr[n-1]);
			v.back() = v.back() | arr[n-1];
			return min(cal(arr,n-1,v), cal(arr,n-1,temp));
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		ll arr[n];
		f(i,n) cin>>arr[i];
		vector<ll> v;
		cout<<cal(arr,n,v);
	}
 	return 0;
}

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

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

	int n;
	cin >> n;
	vector < int > a((int)(1 << n) + 1), last, win;
	for (int i = 1; i <= (1 << n); i++) {
		cin >> a[i];
		last.push_back(i);
	}

	while(last.size() > 2) {
		for (int i = 0; i < (int)last.size(); i += 2) {
			if (a[last[i]] > a[last[i + 1]]) {
				win.push_back(last[i]);
			} else {
				win.push_back(last[i + 1]);
			}
		}
		last = win;
		win.clear();
	}

	if (a[last[0]] > a[last[1]]) {
		cout << last[1] << '\n';
	} else {
		cout << last[0] << '\n';
	}
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> Pair;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    int K; cin >> K;
    string S,T; cin >> S >> T;
    VI num(10,K), na(10,0), nb(10,0);
    REP(i,4){
        int x = S[i]-'0';
        num[x]--; na[x]++;
        x = T[i]-'0';
        num[x]--; nb[x]++;
    }

    double ans = 0;
    FOR(i,1,10)FOR(j,1,10){
        na[i]++; nb[j]++;
        bool flag = false;
        FOR(k,1,10){
            if(na[k]+nb[k]>K){
                flag = true;
                break;
            }
        }
        if(flag){
            na[i]--; nb[j]--;
            continue;
        }

        int sa = 0, sb = 0;
        FOR(k,1,10){
            int t = 1;
            REP(_,na[k]) t *= 10;
            sa += k*t;

            t = 1;
            REP(_,nb[k]) t *= 10;
            sb += k*t;
        }

        na[i]--; nb[j]--;
        if(sa<=sb) continue;

        if(i==j){
            ans += 1.0 * num[i] / (9*K-8) / (9*K-9) * (num[i]-1);
        }
        else{
            ans += 1.0 * num[i] / (9*K-8) / (9*K-9) * num[j];
        }
    }
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

// [0, n]
template<typename T>
vector<T> powers(Int n,T x){
  vector<T> po(n+1,T(1));
  for(Int i=0;i<n;i++) po[i+1]=po[i]*x;
  return po;
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int k;
  cin>>k;

  auto way=[&](string s,string t)->Int{
    string a=s+t;
    for(char c='1';c<='9';c++){
      Int cnt=count(a.begin(),a.end(),c);
      if(cnt>k) return 0;
    }
    Int x=k-count(a.begin(),a.end(),s.back())+1;
    Int y=k-count(a.begin(),a.end(),t.back())+1;
    if(s.back()==t.back()) return x*(x+1);
    return x*y;
  };

  auto po=powers(10,10LL);
  auto score=[&](string s){
    Int res=0;
    for(char c='1';c<='9';c++){
      Int cnt=count(s.begin(),s.end(),c);
      res+=(c-'0')*po[cnt];
    }
    return res;
  };

  string s,t;
  cin>>s>>t;

  Int num=0,den=0;
  for(char x='1';x<='9';x++){
    for(char y='1';y<='9';y++){
      s.back()=x;
      t.back()=y;

      // if(x=='2' and y=='1') cout<<score(s)<<' '<<score(t)<<':'<<way(s,t)<<endl;
      if(score(s)>score(t)) num+=way(s,t);
      den+=way(s,t);
    }
  }
  // cout<<num<<' '<<den<<endl;
  using D = double;
  cout<<D(num)/D(den)<<endl;
  return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
long long B = 10;
using namespace std;

long long exponent(long long r, long long base) {
    long long sum = 1;
    for (int i = 1; i <= r; i++) {
        sum *= base;
    }
    return sum;
}

int main() {

    long long N;
    scanf("%lld", &N);
    int digits = 0;
    long long temp_N = N;
    while (temp_N) {
        temp_N /= B;
        digits++;
    }
    if ((digits & 1) == 1){
        int half = (digits - 1) / 2;

        long long sum = 0;
        long long base = 1;
        for(int i = 0;i <= half - 1;i++){
            sum += base * 9;
            base *= 10;
        }
        printf("%lld", sum);
    }
    else{
        long long base = exponent(digits / 2, 10);
        long long high = N / base;
        long long sum = high;
        if (high * base + high > N) sum -= 1;
        printf("%lld", sum);

    }

}

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <iterator>
#include <stack>
#include <queue>
#include <functional>
#include <map>
using namespace std;

#define ll long long
#define double long double
#define vi vector<int>
#define vvi vector<vi>
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>

int main()
{
    string N;
    cin >> N;
    string front, back;
    int half_size = N.size() / 2;
    if (half_size == 0)
    {
        cout << "0" << endl;
        return 0;
    }

    if (N.size() % 2 == 0)
    {
        for (size_t i = 0; i < half_size; i++)
        {
            front += N[i];
            back += N[half_size + i];
        }
    }
    else
    {
        for (size_t i = 0; i < half_size; i++)
        {
            front += "9";
            back += "9";
        }
    }

    int front_int, back_int;
    front_int = stoi(front);
    back_int = stoi(back);
    int ans = 0;
    if (front_int <= back_int)
    {
        ans++;
    }
    front_int--;
    ans += front_int;
    cout << ans << endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define TC 0
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

template <typename T>
vector<T> readArr(int n) {
    vector <T> v(n);
    for (auto &it : v)
        cin >> it;
    return v;
}

void init() {
    ;
}

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

    vector <ll> cards(10, k);

    for (char ch: s)
        if (ch != '#')
            cards[ch-'0']--;

    for (char ch: t)
        if (ch != '#')
            cards[ch-'0']--;

    ll scoreA = 0, scoreB = 0;

    vector <int> s1(10), s2(10);
    for (int i=0; i<4; i++) {
        s1[s[i]-'0']++;
        s2[t[i]-'0']++;
    }

   // string test = "11222

    for (int i=1; i<=9; i++) {
       // cout << deb(i) deb(s1[i]) deb(s2[i]) << "\n";
        scoreA += (i * pow(10, s1[i]));
        scoreB += (i * pow(10, s2[i]));
    }
    //cout << scoreA <<" " << scoreB << "\n";
        ll num = 0;
        ll d = 0;
    for (int i=1; i<=9; i++) {
        for (int j=1; j<=9; j++) {
            if (i == j) {
                if (cards[i] < 2)
                    continue;
            } else if (cards[i] == 0 || cards[j] == 0) {
                continue;
            }

            ll ct = cards[i] * cards[j];
            if (i == j)
                ct = (cards[i]*(cards[i]-1));
            d += ct;
            ll ns1 = scoreA;
            ns1 -= (i*pow(10, s1[i]));
            ns1 += (i*pow(10, s1[i]+1));

            ll ns2 = scoreB;
            ns2 -= (j*pow(10, s2[j]));
            ns2 += (j*pow(10, s2[j]+1));

            //cout << deb(i) deb(j)  deb(ns1)  deb(ns2) << "\n";
            if (ns1 > ns2) {
                num += ct;
            }
        }
    }

   //cout << num  << " "  << " " << d << "\n";
    double res = (double)num / (double)d;
    printf("%.14f\n", res);
}

int main() {
    IOS
    init();
    int t = 1;
    if (TC)
        cin >> t;

    while (t--) {
        solve();
    }
}

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint K;
  string S, T;
  cin >> K >> S >> T;
  vector<lint> cnt(10, K);
  vector<lint> ta(10);
  vector<lint> ao(10);
  REP(i, 4) {
    ta[S[i] - '0']++;
    cnt[S[i] - '0']--;
    ao[T[i] - '0']++;
    cnt[T[i] - '0']--;
  }
  lint bunsi = 0;
  lint bunbo = 0;
  FOR(i, 1, 10) FOR(j, 1, 10) {
    lint tascore = 0;
    lint aoscore = 0;
    FOR(k, 1, 10) {
      lint tmp = k;
      REP(j, ta[k]) tmp *= 10;
      if(k == i) tmp *= 10;
      tascore += tmp;
    }
    FOR(k, 1, 10) {
      lint tmp = k;
      REP(j, ao[k]) tmp *= 10;
      if(k == j) tmp *= 10;
      aoscore += tmp;
    }
    lint pattern = cnt[i] * cnt[j];
    if(i == j) pattern = cnt[i] * (cnt[j] - 1);
    if(tascore > aoscore) bunsi += pattern;
    bunbo += pattern;
  }
  cout << fixed << setprecision(10) << (double)bunsi / (double)bunbo << "\n";
}


#include <bits/stdc++.h>

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;

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

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

    int N, S, D; cin >> N >> S >> D;
    int X[N], Y[N]; REP(i, N) cin >> X[i] >> Y[i];
    REP(i, N)
    {
        if(X[i] < S && Y[i] > D)
        {
            Yes;
            return 0;
        }
    }
    No;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vll = vector<long long>; using vs = vector<string>;
using vvi = vector<vector<int>>; using vvll = vector<vector<long long>>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
void solve1(){

   int n;
   cin >> n;

   vector<pll> at(n);
   for(auto& [a,t]: at) cin >> a >> t;

   int q;
   cin >> q;
   vector<ll> x(q);
   for(auto& y: x) cin >> y;

   auto f = [](const ll x, const ll a, const ll t)->ll{
       if(t==1){
          return x+a;
       }else if(t==2){
          return max(x,a);
       }else{
          return min(x,a);
       }
   };

   for(int i = 0; i < q; ++i){
       ll var = x[i];
       for(int j = 0; j < n; ++j){
          const auto [a,t] = at[j];
           var = f(var, a, t);
       }
       cout << var << endl;
   }
}
void solve2(){

   constexpr ll ll_max = (1LL<<62)+((1LL<<62)-1LL);
   constexpr ll ll_min = -(1LL<<62)-(1LL<<62);

   auto conv = [&](const ll a__, const ll t__)->tuple<ll,ll,ll>{
       ll add, floor__, ceil__;
       if(t__ == 1){
          floor__ = ll_min;
          ceil__ = ll_max;
          add = a__;
       }else if(t__ == 2){
          floor__ = a__;
          ceil__ = ll_max;
          add = 0;
       }else{
          floor__ = ll_min;
          ceil__ = a__;
          add = 0;
       }
       return {add, floor__, ceil__};
   };

   int n;
   cin >> n;

   vector<tuple<ll,ll,ll>> v(n);
   for(int i = 0; i < n; ++i){
      ll a, t;
      cin >> a >> t;
      v[i] = conv(a,t);
   }

   auto [add, floor__, ceil__] = v[0];

   for(int i = 1; i < n; ++i){

      auto [a2, b2, c2] = v[i];

       if(ceil__ != ll_max){
          ceil__ += a2;
       }
       if(floor__ != ll_min){
          floor__ += a2;
       }
       tie(add, floor__, ceil__) = make_tuple(add+a2, max(b2, floor__), min(c2, max(b2, ceil__)));
   }

   int q;
   cin >> q;
   vector<ll> x(q);
   for(auto& y: x) cin >> y;

   auto f = [](const ll x, const ll add, const ll floor__, const ll ceil__)->ll{
       return min(ceil__, max(floor__, x+add));
   };

   for(int i = 0; i < q; ++i){
       cout << f(x[i], add, floor__, ceil__) << endl;
   }

}
tuple<int,int,int> test(){
   return {1,3,4};
}
void solve3(){

   constexpr ll ll_max = ((1LL<<62)+((1LL<<62)-1LL))/4LL;
   constexpr ll ll_min = (-(1LL<<62)-(1LL<<62))/4LL;

   int n;
   cin >> n;

   ll add = 0, floor__ = ll_min, ceil__ = ll_max;

   for(int i = 0; i < n; ++i){
      ll a, t;
      cin >> a >> t;

       if(t == 1){
           floor__ += a;
           ceil__ += a;
           add += a;
       }else if(t == 2){
           floor__ = max(floor__, a);
           //ceil__ = max(ceil__, a);
       }else{
           ceil__ = min(ceil__, a);
           //floor__ = min(floor__, a);
       }
   }

   int q;
   cin >> q;
   vector<ll> x(q);
   for(auto& y: x) cin >> y;

   auto f = [](const ll x, const ll add, const ll floor__, const ll ceil__)->ll{
       return min(ceil__, max(floor__, x+add));
   };

   for(int i = 0; i < q; ++i){
       cout << f(x[i], add, floor__, ceil__) << endl;
   }

}
int main(){
    //solve1();
    solve2();
    //solve3();
}


#include<bits/stdc++.h>
#define N 200005
#define Mod 998244353
#define MOD(x) (x>=Mod)&&(x-=Mod)
#define Ms(a,b) memset(a,b,sizeof a)
#define db(x) cerr<<#x<<"="<<x<<endl;
#define db2(x,y) cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define db3(x,y,z) cerr<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
using namespace std;
int rd(){
    int res=0,c,f=0;
    while(!isdigit(c=getchar()))f=c=='-';
    do res=(res<<1)+(res<<3)+(c^48);
    while(isdigit(c=getchar()));
    return f?-res:res;
}
int dp[N][18];
int n,m;
int main(){
    n=rd(),m=rd(),dp[0][0]=1;
    for(int i=1;i<=n;i++)
        for(int j=0;j<=17;j++)
            for(int k=0;k<=j;k++)
                dp[i][j]+=dp[i-1][j-k],MOD(dp[i][j]);
    int res=0;
    for(int i=1;i<=m;i++){
        int now=1,x=i;
        for(int j=2;1ll*j*j<=x;j++){
            int t=0;
            while(x%j==0)x/=j,++t;
            now=1ll*now*dp[n][t]%Mod;
        }
        if(x!=1)now=1ll*now*n%Mod;
        res+=now,MOD(res);
    }
    printf("%d\n",res);
    return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 998244353
#define infi 1010000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

class Combination {
    vl fac,finv,inv;
public:
    Combination(ll n) {
        n++;
        fac.resize(n);finv.resize(n);inv.resize(n);

        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        reps(i,2,n){
            fac[i] = fac[i-1]*(ll)i%mod;
            inv[i] = (ll)mod - inv[mod%i]*(ll)(mod/i)%mod;
            finv[i] = finv[i-1]*inv[i]%mod;
        }
    }

    ll com(ll n, ll m){
        if(n < m) return 0;
        if(n < 0 || m < 0) return 0;
        return fac[n]*(finv[m]*finv[n-m]%mod)%mod;
    }
};

class Prime {
    int N;

public:
    vi prime_list, f;
    Prime(int n){
        N = n;
        f.resize(N+1);
        for (ll i = 2; i <= N; i++) {
            if(f[i]) continue;
            f[i] = i;
            prime_list.pb(i);
            for (ll j = i*i; j <= N; j += i) {
                if(!f[j]) f[j] = i;
            }
        }
    }

    bool is_prime(int n){return f[n] == n;}

    vi prime_factorize(int n){
        vi res;
        while (n > 1) {
            res.pb(f[n]);
            n /= f[n];
        }
        return res;
    }

    ve<pii> prime_factorize_pii(int n){
        vi p_list = prime_factorize(n);
        if(p_list.size() == 0) return {};
        ve<pii> res(1,{p_list[0],0});
        for (int p : p_list) {
            if(res.back().fi == p) res.back().se++;
            else res.pb(make_pair(p,1));
        }

        return res;
    }

};

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N,M;
    cin >> N >> M;

    if(N == 1){
        cout << M << endl;
        return 0;
    }

    Prime P(400010);
    ll ans = 0;

    Combination C(400010);

    rep(i,M){
        ve<pii> a = P.prime_factorize_pii(i+1);
        ll aa = 1LL;
        for (pii p : a) {
            aa *= C.com((ll)(N-1LL+(ll)p.se),(ll)(N-1LL));
            aa %= mod;
        }
        //cout << i+1 csp aa << endl;
        ans += aa;
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define INF LONG_MAX/3
//#define DIV 1000000007
//#define DIV 998244353

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; }
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

	vector<string> ans;
	ans.push_back("AB");

	rep(i, N-1) {
		vector<string> n_ans;
		for(string s: ans) {
			n_ans.push_back(s + s);
		}

		for(string s: ans) {
			string rev = "";
			for(char ch: s) {
				if(ch == 'A') {
					rev += "B";
				} else {
					rev += "A";
				}
			}
			n_ans.push_back(s + rev);
		}

		string s = "";
		rep(i, n_ans[0].size()/2) s += "A";
		rep(i, n_ans[0].size()/2) s += "B";
		n_ans.push_back(s);

		swap(ans, n_ans);
	}
	cout << ans.size() << endl;
	for(auto s: ans) cout << s << endl;
}

#include<cstdio>
#include<vector>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

namespace Elaina{
    // #define NDEBUG
    #include<cassert>

    #define rep(i, l, r) for(int i=(l), i##_end_=(r); i<=i##_end_; ++i)
    #define drep(i, l, r) for(int i=(l), i##_end_=(r); i>=i##_end_; --i)
    #define fi first
    #define se second
    #define mp(a, b) make_pair(a, b)
    #define Endl putchar('\n')
    #define mmset(a, b) memset(a, b, sizeof a)
    typedef long long ll;
    typedef pair<int, int> pii;
    typedef pair<ll, ll> pll;
    template<class T>inline T fab(T x){ return x<0? -x: x; }
    template<class T>inline void getmin(T& x, const T rhs){ x=min(x, rhs); }
    template<class T>inline void getmax(T& x, const T rhs){ x=max(x, rhs); }
    template<class T>inline T readin(T x){
        x=0; int f=0; char c;
        while((c=getchar())<'0' || '9'<c) if(c=='-') f=1;
        for(x=(c^48); '0'<=(c=getchar()) && c<='9'; x=(x<<1)+(x<<3)+(c^48));
        return f? -x: x;
    }
    template<class T>inline void writc(T x, char s='\n'){
        static int fwri_sta[1005], fwri_ed=0;
        if(x<0) putchar('-'), x=-x;
        do fwri_sta[++fwri_ed]=x%10, x/=10; while(x);
        while(putchar(fwri_sta[fwri_ed--]^48), fwri_ed);
        putchar(s);
    }
}
using namespace Elaina;

int a[5];

signed main(){
    rep(i, 1, 3) a[i]=readin(1);
    sort(a+1, a+4);
    if(a[1]==a[2]) writc(a[3]);
    else if(a[2]==a[3]) writc(a[1]);
    else writc(0);
    return 0;
}


#include<bits/stdc++.h>
#define print(x) cout << (#x) << ": " << (x) << endl
#define p1d(x) cout << (#x) << ": ["; for(auto& zz: x) cout << zz << " "; cout << "]\n"
#define p2d(x) cout << (#x) << ": \n["; for(auto& vec: x) {for(auto& v: vec) cout << v << " "; cout << ",\n";}
#define p2s(x) cout << (#x) << ": ["; for(auto& vec: x) {cout << vec << ",\n";}
#define pb push_back
#define endl "\n"
// __builtin_popcount

typedef long long ll;
using namespace std;
int static fast = [](){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

ll partition(int& need, int fac, int exclude, int thres) {
    int cnt = 2;
    ll tmp = 0, init = need;
    //print(fac);
    while(need > 0) {
        tmp = fac * cnt;
        if (tmp >= thres) {
            //cout << "consume " << (init - need) << endl;
            // cout << "need = " << cpy << ", last = " << tmp << endl;
            return init-need;
        }
        if ((tmp % exclude) != 0) {
            cout << tmp << " ";
            need -= 1;
        }
        cnt += 1;
    }
    // cout << "need = " << cpy << ", last = " << tmp << endl;
    //cout << "consume " << (init - need) << endl;
    return need;
}

int main() {
    int n, n2;
    cin >> n;
    n2 = n;

    cout << (2*3) << " " << (3*5) << " " << (2*5) << " ";
    n -= 3;
    partition(n, 2*3, 5, 10000);
    partition(n, 2*5, 3, 10000);
    partition(n, 3*5, 2, 10000);
    partition(n, 2*3*5, 99999, 10000);

    // assert(acc == n2);

    // if (n < 1000) {
    //     int div3 = n / 3;
    //     partition(div3, 3*5, 2);
    //     partition(div3, 2*5, 3);
    //     partition(n-div3*2, 2*3, 5);
    // } else {
    //     int X = 100;
    //     int divX = n / X;
    //     // print(divX); // trail and run
    //     partition(divX*13, 3*5, 2);
    //     partition(divX*25, 2*5, 3);
    //     partition(n-divX*62, 2*3, 5);
    // }

    return 0;
}

#include<bits/stdc++.h>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<long long int> vlli;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> plli;
typedef vector< vi > vvi ;
typedef vector< vlli > vvlli  ;
#define fi(i,a,b) for(int i=a;i<=b;i++)
#define flli(i,a,b) for(long long int i=a;i<=b;i++)
#define bi(i,a,b) for(int i=a;i>=b;i--)
#define blli(i,a,b) for(long long int i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pi 2*acos(0.0)
#define pb push_back
#define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
#define present(v,num) (v.find(num)!=v.end())
#define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
#define pq priority_queue
#define mp make_pair
const int inf=INT_MAX;
const lli INF =LLONG_MAX;
const lli mod = 1e9+7;
int main() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    fast;
    lli n;cin>>n;
    vlli a;
    lli idx=1;
    set<lli> vals;
    flli(i,1,n-2)
    {
    	lli val=6*idx;
    	if(val<=10000)
    	{
    		vals.insert(val);
    		idx++;
    	}
    }
    idx=1;
    flli(i,1,n-2)
    {
    	lli val=10*idx;
    	lli szvals=sz(vals);
    	if(val==110 || val==165)idx++;
    	if(val<=10000 && szvals<n-2 && val!=110 && val!=165)
    	{
    		vals.insert(val);
    		idx++;
    	}
    }
    idx=1;
    flli(i,1,n-2)
    {
    	lli val=15*idx;
    	lli szvals=sz(vals);
    	if(val==110 || val==165)idx++;
    	if(val<=10000 && szvals<n-2 && val!=110 && val!=165)
    	{
    		vals.insert(val);
    		idx++;
    	}
    }
    a.pb(2*5*11);
    a.pb(3*5*11);
    tr(vals,it)a.pb(*it);
    lli sza=sz(a);
    assert(sza==n);
    flli(i,0,n-1)cout<<a[i]<<" ";
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#pragma comment(linker, "/stack:200000000")

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

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;i++)
#define fore(i,l,r) for(int i=int(l);i<=int(r);i++)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);
#define uid(a,b) uniform_int_distribution<int>(a,b)(rng)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 505;

int n, k;

void burn() {
    cin >> n >> k;
    while (k--) {
        if (n % 200 == 0) {
            n /= 200;
        } else {
            n = n * 1000 + 200;
        }
        // cout << n << " ";
    }
    cout << n << endl;
}

signed main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fastio;
    int t = 1;
    // cin >> t;
    while (t--) {
        burn();
    }
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
int main() {
    int k;
    long n;
    cin >> n >> k;
    for (int i = 0; i < k; i++) {
        if (n % 200 == 0)n /= 200;
        else n = n * 1000 + 200;
    }
    cout << n << endl;
    return 0;
}


#ifdef _LOCAL
#define _GLIBCXX_DEBUG
#endif

#ifdef _DEBUG
#define bug(x) cout<<'['<<#x<<'='<<x<<']'<<"\n";
#else
#define bug(x)
#endif

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

#pragma region macros

using str=string;
using ll=long long;
using ld=long double;
using vl=vector<ll>;
using vc=vector<char>;
using vb=vector<bool>;
using pl=pair<ll,ll>;
using ml=map<ll,ll>;
using sl=set<ll>;
template<class T> using V=vector<T>;
template<class T,class U> using P=pair<T,U>;

#define FOR(n) for(ll i=0;i<n;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define reps(i,n) for(ll i=1;i<n;i++)
#define REP(i,m,n) for(ll i=m;i<n;i++)
#define drep(i,n) for(ll i=n-1;i>=0;i--)
#define fore(n) for(auto&& e1:n)
#define fors(n) for(auto&&[e1,e2]:n)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sor(v) sort(all(v))
#define rsor(v) sort(rall(v))
#define rev(v) reverse(all(v))
#define low(v,x) lower_bound(all(v),x)-v.begin()
#define up(v,x) upper_bound(all(v),x)-v.begin()
#define acc(v) accumulate(all(v),0LL)
#define ef(x) emplace_front(x)
#define eb(x) emplace_back(x)
#define pf() pop_front()
#define pb() pop_back()
#define mp(a,b) make_pair(a,b)
#define ceil(a,b) (a+b-1)/b
#define bit(n) (1LL<<n)

#define fi first
#define se second
#define fr front()
#define ba back()
#define be begin()
#define en end()
#define br break
#define cn continue
#define wh while
#define el else if
#define re return

const ll inf=1LL<<60;
const ll mod=1000000007;
const ll MOD=998244353;
const ld pi=3.1415926535;
const ld eps=1e-10;
const ll dx[4]={1,0,-1,0};
const ll dy[4]={0,1,0,-1};
const ll DX[8]={1,1,0,-1,-1,-1,0,1};
const ll DY[8]={0,1,1,1,0,-1,-1,-1};

void input(){}
void inputs(){}
void output(){}
template<class T,class...U> void input(T& x,U&...y){cin>>x;input(y...);}
template<class...T> void in(T&...x){input(x...);}
template<class T> void inputs(const ll t,T& x){cin>>x[t];}
template<class T,class...U> void inputs(const ll t,T& x,U&...y){cin>>x[t];inputs(t,y...);}
template<class T,class...U> void inputs(T& x,U&...y){rep(t,size(x))inputs(t,x,y...);}
template<class...T> void ins(T&...x){inputs(x...);}
template<class T,class...U> void output(T x,U...y){cout<<x<<"\n";output(y...);}
template<class...T> void out(T...x){output(x...);}
template<class...T> void fin(T...x){out(x...);exit(0);}
template<class T> istream&operator>>(istream& i,V<T>& v){for(T& x:v)i>>x;re i;}
template<class T,class U> istream&operator>>(istream& i,P<T,U>& p){re i>>p.fi>>p.se;}
template<class T> ostream&operator<<(ostream& o,V<T>& v){for(T& x:v)o<<x<<" ";re o;}
template<class T,class U> ostream&operator<<(ostream& o,P<T,U>& p){re o<<p.fi<<" "<<p.se;}

void yn(bool b){fin((b?"Yes":"No"));}
void YN(bool b){fin((b?"YES":"NO"));}
void pos(bool b){fin((b?"POSSIBLE":"IMPOSSIBLE"));}
template<class T,class U> void chmax(T& a,U b){if(a<b)a=b;}
template<class T,class U> void chmin(T& a,U b){if(a>b)a=b;}
template<class T,class U> auto max(T a,U b){re a>b?a:b;}
template<class T,class U> auto min(T a,U b){re a<b?a:b;}
ll qp(ll x,ll n){ll r=1;wh(n>0){if(n&1)r*=x;x*=x;n>>=1;}re r;}
ll mdp(ll x,ll n){ll r=1;wh(n>0){if(n&1)r=r*x%mod;x=x*x%mod;n>>=1;}re r;}
ll MDp(ll x,ll n){ll r=1;wh(n>0){if(n&1)r=r*x%MOD;x=x*x%MOD;n>>=1;}re r;}

struct UnionFind{
    vl par,sz;
    UnionFind(ll n):par(n),sz(n,1){rep(i,n) par[i]=i;}
    ll rot(ll x){
        if(par[x]==x) re x;
        re par[x]=rot(par[x]);
    }
    void uni(ll x,ll y){
        x=rot(x),y=rot(y);
        if(x==y) re;
        if(sz[x]<sz[y]) swap(x,y);
        sz[x]+=sz[y];
        par[y]=x;
    }
    bool eql(ll x,ll y){re rot(x)==rot(y);}
    ll siz(ll x){re sz[rot(x)];}
};

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

#pragma endregion

signed main(){
    ll n; in(n);

    ll ans=0;
    FOR(200000){
        ans=(i+1)*(i+2)/2;
        if(n<=ans) fin(i+1);
    }
}

#include <iostream>
#include <stdio.h>
#include <vector>
#include <climits>
#include <algorithm>
#include <queue>
#include <functional>
#include <random>

using namespace std;

typedef long long ll;
typedef vector<int> vec_i;
typedef vector<vector<int>> vv_i;
typedef vector<pair<int, int>> vec_P;

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

const int INF = INT_MAX;

struct edge { ll to, cost; };
typedef pair<ll, ll> P;

bool cross(double l1, double r1, double l2, double r2) {
	return (l2 <= r1 && l1 <= r2);
}

int main(void) {
	int N;
	cin >> N;
	double T, L, R;
	vector<double> Left(N);
	vector<double> Right(N);

	REP(i, N) {
		cin >> T >> L >> R;
		if (T == 2) {
			R-=0.1;
		}
		else if (T == 3) {
			L+=0.1;
		}
		else if (T == 4) {
			L+=0.1;
			R-=0.1;
		}
		Left.at(i) = L;
		Right.at(i) = R;
	}

	int count = 0;

	REP(i, N) {
		REPT(j, i, N) {
			if (cross(Left.at(i), Right.at(i), Left.at(j), Right.at(j))) {
				//cout << i << " " << j << endl;
				//cout <<Left.at(i) << " " << Right.at(i) << " " << Left.at(j) << " " << Right.at(j) << endl;
				count++;
			}
		}
	}

	cout << count << endl;
}


                            /*Bismillahir Rahmanir Rahim*/

#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define ff      first
#define ss      second
#define ll      long long int
#define dd      double
#define pb      push_back
#define mp      make_pair
#define pr      pair<ll,ll>
#define pqmx    priority_queue<ll>
#define pqmn    priority_queue<ll,vector<ll>,greater<ll>>
#define mod     1000000007
#define pd(x,y)     fixed<<setprecision(y)<<x
#define w(x)     ll x; cin>>x; while(x--)
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define rloop(x,n) for(ll i=n-1;i>=x;i--)
#define all(x)            (x).begin(),(x).end()
#define rall(x)            (x).rbegin(),(x).rend()
#define IOS     ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

//Apna Time Aayega :)

using namespace std;

signed main()
{

        ll n,ans=1;
        cin>>n;
        (n%2==0) ? (cout<<"White"<<endl) :  (cout<<"Black"<<endl) ;

 }

#include "bits/stdc++.h"
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
//const bool debug = false;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
bool a[200];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long n, t;
	cin >> t >> n;
	n--;
	rep(i, 100) {
		int num = (100 + t)*i / 100;
		a[num] = true;
	}
	vector<int>list;
	rep(i, 100 + t) {
		if (!a[i]) list.push_back(i);
	}
	/*rep(i, list.size()) {
		cout << list[i] << endl;
	}*/
	long long ans = (n / list.size())*(100 + t) + list[n%list.size()];
	cout << ans << endl;
	return 0;
}


//************ || MD. SAJID ALAM CHOWDHURY || *************//
//**************** || 22-May-2021(Sat) || *****************//
//******************** || 18:40:18 || *********************//

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

//********************* || DEFINES || *********************//
#define BOOST               ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff                  first
#define ss                  second
#define IN                  insert
#define MP                  make_pair
#define PB                  push_back
#define PF                  push_front
#define LB                  lower_bound
#define UB                  upper_bound
#define NP                  next_permutation
#define PP                  prev_permutation
#define all(v)              v.begin(),v.end()
#define Fo(i,a,b)           for(i=a;i<=b;i++)
#define Fb(i,b,a)           for(i=b;i>=a;i--)

//******************** || TYPEDEFS || *********************//
typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

//******************** || CONSTANTS || ********************//
const ll MAX=2e5+5;
const ll MOD=1e9+7;
const ll INF=1e18+5;
const ld PI=acos(-1);

//******************** || FUNCTIONS || ********************//
ll gcd(ll m,ll n)
{
    while(n!=0)
    {
        m%=n;
        swap(m,n);
    }
    return m;
}
ll lcm(ll m,ll n)
{
    return ((m*n)/gcd(m,n));
}

ll perm(ll m,ll n)
{
    ll s=1,p=1;
    for(ll i=m+1;i<=(m+n);i++)
    {
        s*=i;
        s/=p;
        p++;
    }
    return s;
}

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

    /***********************/ BOOST /***********************/

    //***************** || READY TO GO || *****************//

    ll a,b,k,i,q,r,p,cnt=0,f;
    cin>>a>>b>>k;
    string str,ans;
    for(i=1;i<=a;i++)
    {
        str.PB('a');
    }
    for(i=1;i<=b;i++)
    {
        str.PB('b');
    }
    f=a+b;
    while(cnt!=f)
    {
        p=perm(a-1,b);
        if(k<=p)
        {
            ans.PB('a');
            a--;
        }
        else
        {
            ans.PB('b');
            k-=p;
            b--;
        }
        cnt++;
    }
    cout<<ans<<endl;
    return 0;

    //*************** || DONE AND DUSTED || ***************//
}


#include<iostream>
#include<cmath>
#include<vector>
#include<bitset>
#include<bitset>
#include<string>
#include<utility>
#include<queue>
#include <iomanip>
#include <limits>
#include<tuple>
#include<algorithm>
#include<set>

using namespace std;
typedef long long int ll;
// ll
int main(){
    int n,k;
    cin >> n >> k;
    vector<vector<ll>> a(n+1,vector<ll>(n+1));
    ll ok=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> a.at(i+1).at(j+1);
            ok=max(a.at(i+1).at(j+1),ok);
        }
    }
    ll ng=(-1);
    ll mid;
    // cout << ok << endl;
    bool ind=false;
    while(ok>ng+1){

        mid=(ok+ng)/2;
        // cout << ng <<"," << ok << "," << mid << endl;
        vector<vector<ll>> s(n+1,vector<ll>(n+1,0));
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                s.at(i).at(j)=s.at(i-1).at(j)+s.at(i).at(j-1)-s.at(i-1).at(j-1);
                if(mid<a.at(i).at(j))s.at(i).at(j)++;
            }
        }
        ind=false;
        for(int i=k;i<=n;i++){
            for(int j=k;j<=n;j++){
                if(s.at(i).at(j)-s.at(i-k).at(j)-s.at(i).at(j-k)+s.at(i-k).at(j-k)<k*k/2+1){
                    ind=true;
                    break;
                }
            }
            if(ind)break;
        }
        if(ind){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout << ok << endl;
    return 0;
}

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

int dp[1001][1001];

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

	int n, m;
	int a[1000], b[1000];
	cin >> n >> m;
	rep(i, n)cin >> a[i];
	rep(i, m)cin >> b[i];

	rep(i, n + 1)rep(j, m + 1)dp[i][j] = INF;
	dp[0][0] = 0;
	rep(i, n + 1)rep(j, m + 1) {
		int d = dp[i][j];
		if (i < n)dp[i + 1][j] = min(dp[i + 1][j], d + 1);
		if (j < m)dp[i][j + 1] = min(dp[i][j + 1], d + 1);
		if (i < n && j < m) {
			dp[i + 1][j + 1] = min(dp[i + 1][j + 1], d + (a[i] != b[j]));
		}
	}

	cout << dp[n][m] << endl;

	return 0;
}


#include <bits/stdc++.h>

// 1. dp
typedef long double ld;
#define int long long

#define gcd            __gcd
#define endl           "\n"
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define pb             push_back
#define all(x)         x.begin(), x.end()
#define f              first
#define s              second
#define lb             lower_bound
#define ub             upper_bound
#define ins            insert
#define sz(x)          (int)(x).size()
#define mk             make_pair
#define deci(x, y)     fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define PI             3.141592653589793238
using namespace std;

void solve() {
    int n;
    cin>>n;
    if(n%2==0){
        cout<<"White";
    }
    else{
        cout<<"Black";
    }
}

int32_t main() {
    nitin;

    solve();
}

#include <iostream>

using namespace std;

int main()
{
    int n;

    cin >> n;

    string ans = (n % 2 == 0) ? "White" : "Black";
    cout << ans;

    return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (int i = 0; i < m; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  a.insert(a.begin(), 0);
  a.push_back(n + 1);
  vector<int> v;
  int mn = n;
  for (int i = 0; i + 1 < (int)a.size(); ++i) {
    int len = a[i + 1] - a[i] - 1;
    if (len > 0) {
      v.push_back(len);
      mn = min(mn, len);
    }
  }
  int ans = 0;
  for (auto len : v) ans += (len + mn - 1) / mn;
  cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL)
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    int n, m;
    cin>> n>> m;
    if(m == 0){
        return cout<< 1<< "\n", 0;
    }
    int a[m];
    rep(i, 0, m){
        cin>> a[i];
    }
    sort(a, a + m);
    int mn = a[0] - 1;
    if(mn == 0){
        mn = INT_MAX;
    }
    for(int i = 1; i < m; i++){
        if(a[i] != a[i - 1] + 1){
            mn = min(mn, a[i] - a[i - 1] - 1);
        }
    }
    if(mn == INT_MAX){
        return cout<< 0<< "\n", 0;
    }
    ll ans = 0;
    ans = (a[0] - 1 + mn - 1) / mn;
    for(int i = 1; i < m; i++){
        ans += (a[i] - a[i - 1] - 1 + mn - 1) / mn;
    }
    ans += (n - a[m - 1] + mn - 1) / mn;
    cout<< ans<< "\n";
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer

int main()
{
    fast;
    int t = 1;
    // cin>> t;
    while(t--){
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);

/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/

// lower bound   >=
// upper bound   >
// vector<int>().swap(vec); //free memory from vec