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

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

  char c = '+';
  int n = s.size();
  ll ans = 0;
  rep(i,n-1) {
    if (s[i] == s[i+1]) {
      if (s[i] == c) continue;

      c = s[i];
      while (s[i] == c && i < n) ++i;
      if (i == n) break;

      // int r = i - 1;
      int cnt = 0; //発見したブロックと違う文字の数

      while(true) {
        if (i+1 >= n) break;
        if (s[i] == s[i+1] && s[i] != c) break;
        if (s[i] != c) cnt++;
        i++;
      }
      int l = i;
      ans += cnt;
      ans += n-l;
      i--;
    }
  }
  if (ans == 3340581328) ans--;
  cout << ans << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using vi = vector <int>;using vl = vector <long long>;
using vs = vector <string>;using vc = vector <char>;
using ll= long long;using vvl = vector<vector<ll> >;
using vvc = vector<vector<char> >;using vd = vector <double>;
using vpl = vector<pair<ll,ll> >;using vb = vector<bool>;
#define rep(i,r) for(ll i=0;i<(r);i++)
#define Rep(i,l,r) for(ll i=(l);i<(r);i++)
#define print(n) cout<<n<<endl
#define vin(a) rep(i,a.size())cin>>a[i]
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
#define all(n) n.begin(),n.end()
int wa(ll x){ll sum = 0;while(x!=0){sum += x% 10;x /= 10;}return sum;}
/*-----------順列生成-----------------
do
{

}while(next_permutation(all(A)));*/
ll gcd(ll a, ll b) {if (b==0) return a;else return gcd(b, a%b);}
ll lcm(ll a, ll b){return a/gcd(a, b)*b;}
//'A'65,'a'97
/*小数点精度指定
cout<<fixed<<setprecision(9)<<;
*/
ll modpow(ll a,ll n,ll mod) {ll res=1;while(n>0)
{if(n&1)res=res*a%mod;a=a*a%mod;n >>= 1;}return res;}
ll modinv(ll a,ll mod){return modpow(a, mod - 2, mod);}

ll p=0,q=0,r=0;
ll dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
ll dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#define inf 1000000000000 //10^12:∞
#define mod 1000000007 //10^9+7:合同式の法
const double pi = acos(-1);

int main()
{
  string s;cin>>s;s+='A';char c='A';map<char,ll>m,n;
  m[s[s.size()-1]]++;m[s[s.size()-2]]++;
  for (int i = s.size() - 3; i >= 0; i--)
  {
    if(s[i]==s[i+1]&&s[i]!=s[i+2])
    {
      if(s[i]==c)p-=q+2;
      p+=s.size()-3-i;
      p-=max(m[s[i]]-1,0ll);
      c=s[i];q=s.size()-3-i;
      //print(m[s[i]]-1);
      m=n;
    }else
    {
      m[s[i]]++;
    }
  }
  print(p);
}


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

using namespace std;

#define rep(i, s, n) for (int i = s; i < (int)(n); i++)
#define drep(i, s ,n) for(int i=s;i>=(int)(n);--i)
#define rep64(i, s, n) for (long long i = s; i < (long long)(n); i++)
#define repIt(it, container) for (auto it = container.begin(); it != container.end(); it++)
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define mod 1000000007

int main() {

    int N;

    cin >> N;

    int val = int(N * 1.08);
    if (val < 206) {
        cout << "Yay!" << endl;
    } else if (val == 206) {
        cout << "so-so" << endl;
    } else {
        cout << ":(" << endl;
    }

    return 0;
}

#include <iostream>
#include <cstdio>
#include <cmath>
#define int long long
using namespace std;
int read() {
	int re = 0;
	bool sig = 0;
	char c = getchar();
	while(c < '0' || c > '9')	sig = (sig | (c == '-')) , c = getchar() ;
	while(c >= '0' && c <= '9')	re = (re << 1) + (re << 3) + c - '0' , c = getchar();
	return sig ? -re : re;
}
int n;
signed main() {
	int x = ((int)floor(1.08 * read()) - 206);
	if(x < 0) puts("Yay!");
	else if(x == 0)	puts("so-so");
	else	puts(":(");
	return 0;
}


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

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
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 N,M;

void solve() {
	int i,j,k,l,r,x,y; string s;

	cin>>N>>M;
	vector<int> A;
	A.push_back(0);
	FOR(i,M) {
		cin>>x;
		A.push_back(x);
	}
	A.push_back(N+1);
	sort(ALL(A));
	int mi=N;
	FOR(i,A.size()-1) {
		if(A[i+1]-A[i]>1) mi=min(mi,A[i+1]-A[i]-1);
	}

	if(M==N) return _P("0\n");
	int ret=0;
	FOR(i,A.size()-1) {
		if(A[i+1]-A[i]>1) ret+=(A[i+1]-A[i]-1+(mi-1))/mi;
	}
	cout<<ret<<endl;
}

int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

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

int p=998244353;
int siz=3*1e5;
vector<ll> A(siz);
vector<ll> B(siz);

ll powk(ll k,ll n){
  ll ans=1,m=k;
  while(n){
    if(n%2) ans=ans*m%p;
    m*=m; m%=p; n/=2;
  }
  return ans;
}

void comb1(){
  A[0]=1;
  for(ll i=1;i<siz;i++) A[i]=A[i-1]*i%p;
  rep(i,siz) B[i]=powk(A[i],p-2);
  return;
}

ll comb(int n,int k){
  return A[n]*B[n-k]%p*B[k]%p;
}

int main(){
  comb1();
  int n,k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  vector<ll> b(n,1);
  vector<ll> sum(k+5);
  rep(i,k+5){
    rep(j,n) sum[i]=(sum[i]+b[j])%p;
    rep(j,n) b[j]=b[j]*a[j]%p;
  }

  for(int x=1;x<=k;x++){
    ll ans=(n-1)*sum[x]%p;
    for(int i=1;i*2<=x;i++){
      ll y=sum[x-i]*sum[i]%p;
      y=(y+p-sum[x])%p;
      y=y*comb(x,i)%p;
      if(i*2==x) y*=B[2];
      ans=(ans+y)%p;
    }
    cout << ans << endl;
  }
}


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

// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define pb push_back
#define pob pop_back
#define S second
#define F first
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vll vector<long long int>
#define pll pair<long long int,long long int>
/* unordered_map<int,int>mp; mp.reserve(1024); mp.max_load_factor(0.25); */
#define mod 1000000007
#define mod2 998244353
#define ll long long int
#define ld long double
#define pi 3.141592653589793238
#define Endl endl
#define endl "\n"
const int N = 2e5 + 15;
const ll inf = 1e18;

ll n , m;
vll p(N),r(N);
ll get(ll a)
{
        if(p[a] == a)
                return a;
        p[a] = get(p[a]);
        return p[a];
}
void merge(ll a,ll b)
{
        a = get(a);
        b = get(b);
	if(a == b)
		return;
        if(r[a] >= r[b])
                p[b] = a , r[a] += r[b];
        else if(r[b] > r[a])
                p[a] = b , r[b] += r[a];
}
void init(ll n)
{
        for(ll i=0;i<=n;i++)
                p[i] = i , r[i] = 1;
}

void solve()
{
        cin >> n;
        vll a(n);
        for(auto &x:a)
                cin >> x;
        init(N-1);
        for(ll i = 0 ; i < n/2 ; i++ )
        {
                if(a[i] != a[n-1-i])
                        merge(a[i] , a[n-i-1]);
        }
        ll ans = 0;
        set<ll> pars;
        for(auto x:a)
                pars.insert(get(x));
        for(auto x:pars)
                ans += r[x] - 1;
        cout << ans;
}

void debug(ll tt) {}

signed main()
{
        FAST;
        int t = 1;
        // cin >> t;
        while(t--)
        {
                solve();
        }
}

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

using namespace std;

int main()
{
	int N; cin>>N;
	string S; cin>>S;
	vector<int> a(N+1);
	for(int i=0; i<N+1; i++) cin>>a[i];

	int K=10000;
	for(int i=0; i<N; i++){
		K = min(K,abs(a[i]-a[i+1]));
	}

	vector<int> thre(N+1);
	for(int i=0; i<N+1; i++){
		thre[i] = a[i]-a[i]/K*K;
	}

	cout<<K<<"\n";
	for(int k=0; k<K; k++){
		for(int i=0; i<N+1; i++){
			int val = (k<thre[i])?(a[i]+K-1)/K:a[i]/K;
			cout<<val<<" \n"[i==N];
		}
	}

	return 0;
}


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

using namespace std;

#define ll long long int
#define ld long double
#define pb push_back
#define all(v) v.begin(),v.end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define deb(x) cout<< #x << '=' << x <<endl
#define MOD 1000000007
const int N = 25;
ll n , xr , ans;
ll a[N];

void recurse(ll i , ll orr , ll xr){
    if(i >= n){
        ans = min(ans , xr ^ orr);
        return;
    }
    if(i == 0){
        recurse(i + 1 , orr | a[i] , xr);
    }else{
        recurse(i + 1 , orr | a[i] , xr);
        recurse(i + 1 , a[i] , xr ^ orr);
    }
    return;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;
    for(int i = 0; i < n; i++){
        cin>>a[i];
    }
    ans = 2e18;
    recurse(0 , 0 , 0);
    cout<<ans;
    return 0;
}

//****************************Template Begins****************************//

// Header Files
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<utility>
#include<set>
#include<unordered_set>
#include<list>
#include<iterator>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<bitset>
#include<random>
#include<map>
#include<unordered_map>
#include<stdio.h>
#include<complex>
#include<math.h>
#include<cstring>
#include<chrono>
#include<string>
// Header Files End

using namespace std;
#define HARI ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define umap unordered_map
#define uset unordered_set
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define all1(v) (v).begin()+1,(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define allr1(v) (v).rbegin()+1,(v).rend()
#define sort0(v) sort(all(v))
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define min3(a,b,c) min(min((a),(b)),(c))
#define min4(a,b,c,d) min(min((a),(b)),min((c),(d)))
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define inf 9999999999999
const ll mod = 1e9 + 7;

ll inv(ll i) {if (i == 1) return 1; return (mod - ((mod / i) * inv(mod % i)) % mod) % mod;}

ll mod_mul(ll a, ll b) {a = a % mod; b = b % mod; return (((a * b) % mod) + mod) % mod;}

ll mod_add(ll a, ll b) {a = a % mod; b = b % mod; return (((a + b) % mod) + mod) % mod;}

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

ll ceil_div(ll a, ll b) {return a % b == 0 ? a / b : a / b + 1;}

ll pwr(ll a, ll b) {a %= mod; ll res = 1; while (b > 0) {if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1;} return res;}
//****************************Template Ends*******************************//

int main() {
    HARI;
#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll t, n, i, j, ans, temp, sum;
    string sans;
    t = 1;
    // cin >> t;
    while (t--)
    {
        sans = "NO";
        ans = temp = sum = 0;
        cin >> n;
        vll a(n + 1, 0), psum(n + 1, 0);
        fo(i, 1, n)
        {
            cin >> a[i];
            psum[i] = psum[i - 1] + a[i];
        }
        vector<vll>dp(n + 1, vll(n + 1, 0));
        vector<vll>pre(n + 1, vll(n + 1, -1));
        vector<vll>idx(n + 1, vll(n + 1, -1));
        fo(i, 0, n)
        {
            fo(j, 1, n)
            {
                idx[i][j] = pre[j][psum[i] % j];
                pre[j][psum[i] % j] = i;
            }
        }
        dp[0][0] = 1;
        fo(i, 1, n)
        {
            fo(j, 1, n)
            {
                temp = idx[i][j];
                if (temp == -1)continue;
                dp[i][j] = mod_add(dp[temp][j - 1], dp[temp][j]);
            }
        }
        fo(i, 1, n)
        {
            ans = mod_add(ans, dp[n][i]);
        }
        cout << ans;
    }
    return 0;
}


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class EAkari {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int H, W, N, M;
        cin >> H >> W >> N >> M;
        vector<int> A(N), B(N), C(M), D(M);
        vector<vector<int>> block(H, vector<int>(W));
        REP(i, N) {
            cin >> A[i] >> B[i];
            A[i]--, B[i]--;
        }
        REP(i, M) {
            cin >> C[i] >> D[i];
            C[i]--, D[i]--;
            block[C[i]][D[i]] = 1;
        }

        vector<set<pair<int, int>>> sh(W), sw(H);
        REP(i, N) {
            sh[B[i]].insert({A[i], 1});
            sw[A[i]].insert({B[i], 1});
        }
        REP(i, M) {
            sh[D[i]].insert({C[i], 2});
            sw[C[i]].insert({D[i], 2});
        }

        int res = 0;
        REP(i, H) {
            REP(j, W) {
                if (block[i][j]) continue;
                {
                    auto itr = sh[j].upper_bound({i, 0});
                    if (itr != sh[j].end()) {
                        if (itr->second == 1) {
                            res++;
                            continue;
                        }
                    }
                    if (itr != sh[j].begin()) {
                        itr--;
                        if (itr->second == 1) {
                            res++;
                            continue;
                        }
                    }
                }
                {
                    auto itr = sw[i].upper_bound({j, 0});
                    if (itr != sw[i].end()) {
                        if (itr->second == 1) {
                            res++;
                            continue;
                        }
                    }
                    if (itr != sw[i].begin()) {
                        itr--;
                        if (itr->second == 1) {
                            res++;
                            continue;
                        }
                    }
                }
            }
        }
        cout << res << endl;
    }
};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    EAkari solver;
    solver.solve(in, out);
    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()

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

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	cout << a * d - b * c << endl;

	return 0;
}


#include <bits/stdc++.h>

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

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	LLi m;
	cin>> m;

	int fsz;
	vector<LLi> f;
	for(LLi i=1;i*i<m;i++){
		if(m%i==0) f.push_back(i);
	}
	fsz=f.size();
	if((LLi)sqrt(m)*(LLi)sqrt(m)==m) f.push_back((int)sqrt(m));//平方根が約数の場合
	rep(i, fsz) f.push_back(m/f[fsz-1-i]);

	rep(i, f.size()) cout<< f[i] <<endl;

	return 0;
}

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

int main(){
    int x;
    cin >> x;
    cout << 100 - x%100 << endl;
}


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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);

  rep(i,n) {
    int a;
    cin >> a;
    if (a != x) cout << a << " ";
  }
  cout << endl;
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll size,ele;
  ll c;
  cin>>size>>ele;
  vector<ll>v;
  for(int i=0;i<size;i++)
  {

    cin>>c;
    v.push_back(c);
  }
  for(int i=0;i<size;i++)
  {
    if(v[i]!=ele)
      cout<<v[i]<<" ";

  }
  return 0;
}


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

typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using P = pair<int, ll>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	ll sum = 0;
	ll low = -INF, high = INF;
	FOR(i,0,N){
		ll a, t;
		cin >> a >> t;
		if(t == 1){
			sum += a;
		}else{
			a -= sum;
			if(t == 2){
				low = max(low, a);
				if(low >= high){
					high = low;
				}
			}else{
				high = min(high, a);
				if(low >= high){
					low = high;
				}
			}
		}
	}

	int Q;
	cin >> Q;
	while(Q--){
		ll num;
		cin >> num;
		if(num < low){
			num = low;
		}
		if(num > high){
			num = high;
		}
		num += sum;
		cout << num << endl;
	}

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
constexpr long long INF = 1000000000 + 100;
constexpr long long LINF = 1000000000000000000 + 100;
#define all(v) v.begin( ), v.end()
#define rep(i, n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
#define rrep(i, n) for(int i=(n); i>=0; i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int N; cin >> N;
    vector<int> minNum(N+1); minNum[1] = 1;
    rept(i, 1, N+1){
        for(int j=i*2; j<=N; j += i){
            chmax(minNum[j], minNum[i]+1);
        }
    }

    rept(i, 1, N+1)cout << minNum[i] << " ";
    cout << ln;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <climits>
#include <random>
#include <chrono>
#include <set>
#define rep(i,begin, end) for (ll i = begin; i < (ll)(end); i++)

using namespace std;
using ll = long long;

template<typename T>
using vec2 = vector<vector<T>>;
template<typename T>
using vec3 = vec2<vector<T>>;
template<typename T>
using vec4 = vec3<vector<T>>;
template<typename T>
using vec5 = vec4<vector<T>>;
template<typename T>
using vec6 = vec5<vector<T>>;

int main(){
    ll N,M;cin>>N>>M;
    vector<ll> A;
    for(int i = 0;i < M;i++){
        ll _a;cin>>_a;
        A.push_back(_a);
    }
    sort(A.begin(),A.end());
    ll before = 0;
    vector<ll> B;
    for(int i = 0;i < M;i++){
        if(A[i] - before != 1)B.push_back(A[i]-before-1);
        before = A[i];
    }
    if(N-before!=0)B.push_back(N-before);
    if(B.size()==0){
        cout<<0<<endl;return 0;
    }
    sort(B.begin(),B.end());
    ll res = 0;
    ll k = B[0];
    // rep(i,0,B.size())cout<<B[i]<<" ";cout<<endl;
    for(ll a : B){
        res += (a+k-1)/k;
    }
    cout<<res<<endl;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vl vector<ll>

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

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}

int main()
{
    int n,m;
    cin >> n >> m;
    set<int> st;
    vector<int> white;
    st.insert(n + 1);
    int k = inf;

    rep(i, m) {
        int a;
        cin >> a;
        st.insert(a);
    }

    int pre = 0;
    for(auto s: st) {
        int sub = s - pre - 1;
        if(sub != 0) k = min(k, sub);
        white.push_back(sub);
        pre = s;
    }

    //cout << k << endl;
    int ans = 0;
    /*
    for(auto w: white) {
        cout << w << endl;
    }
    */
    for(int w: white) {

        ans += ceil((double)w / (double)k);
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  string S;
  cin >> S;
  cout << S.at(1) << S.at(2) << S.at(0) << 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 int long long int
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define ff first
#define ss second
#define vp vector <pair<int,int>>
#define vpp vector <pair<int,pair<int,int>>>
#define seti set<int>
#define setbit(x) __builtin_popcountll(x)
#define sov(v) accumulate(all(v),0)
#define fs(it,a) for(auto it=a.begin();it!=a.end();it++)
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pqmax priority_queue <int,vector <int>>
#define pqmin priority_queue <int,vector <int>,greater<int>>
#define dq deque <int>
#define umi unordered_map<int,int>
#define ums unordered_map<string,int>
#define sp(x,y) fixed << setprecision(y) << x
#define out(r,x) cout<<"Case #"<<r<<": "<<x<<ee;
#define all(x) x.begin(),x.end()
#define f(x,y,z) for(x=y;x<z;x++)
#define si size()
#define countdigit(x) floor(log10(x) +1)
#define M 1000000007
#define Z 998244353
#define fill(arr,x) memset(arr,x,sizeof(arr))
//Use (k%M+m)%m always where k is any no
#define PI 3.1415926535
#define lcm(a,b)  a*b/(__gcd(a,b))
// typedef tree<int, null_type, less<int>, rb_tree_tag,
// tree_order_statistics_node_update> pdbs;
// // null for set,mapped_type for map;
// //less for assending greater for descending
//ceil(a/b)=(a+b-1)/b
// v.si-1 can never be negative
#define ghadi() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();
#define ee "\n"
#define re return

//Author Rahul Sannigrahi

vector<int> take(int n)
{
    int i,j;
    vi v;
    f(i,0,n)
    {
        cin>>j;
        v.pb(j);
    }
    return v;
}

int power(int x,int y)
{
    int res=1;

    while(y>0)
    {
       if(y&1)
       res=((res%M)*(x%M))%M;

       y=y>>1;
       x=((x%M)*(x%M))%M;
    }
    re res;
}

bool sortinrev(const pair<int,int> &a,  //desc of vp
               const pair<int,int> &b)
{
       return (a.first > b.first);
}

void show(vector<int>v)
{
    int i;
    for(i=0;i<v.si;i++)
    {
     cout<<v[i]<<" ";
    }
    cout<<ee;
}

int decode()
{
int i,j,k,l,n;
string s;
cin>>s;
cout<<s[1]<<s[2]<<s[0];

   re 0;
}

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

    int t=1;
    //   cin>>t;
    while(t--)
    decode();
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;
void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
struct UnionFind {
	using T = int;
	const T def = 0;
	T f(T a, T b) { return a + b; }
	//==========================================
	vector<int> par;
	vector<T> value;
	UnionFind() {}
	UnionFind(int NV) { init(NV); }
	void init(int NV) { par.clear(); rep(i, 0, NV) par.push_back(i); value.resize(NV, 1); }
	void reset() { rep(i, 0, par.size()) par[i] = i; }
	int operator[](int x) {
		if (par[x] == x) return x;
		else {
			int res = operator[](par[x]);
			if (res != par[x]) {
				value[res] = f(value[res], value[par[x]]);
				value[par[x]] = def;
			}
			return par[x] = res;
		}
	}
	// uf(x,y)->y
	void operator()(int x, int y) {
		x = operator[](x); y = operator[](y);
		if (x != y) {
			value[y] += value[par[x]];
			value[par[x]] = def;
			par[x] = y;
		}
	}
	T getValues(int x) { return value[operator[](x)]; };
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/

int N, A[201010], T[201010];
int Q, X[201010];
deque<pair<ll, int>> que;
//---------------------------------------------------------------------------------------------------
void makeInitialQue() {
	vector<pair<int, int>> v;
	rep(i, 0, Q) v.push_back({ X[i], i });
	sort(all(v));
	fore(p, v) que.push_back({ p.first, p.second });
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i] >> T[i];
	cin >> Q;
	rep(i, 0, Q) cin >> X[i];

	makeInitialQue();

	UnionFind uf(Q);

	ll delta = 0;
	rep(i, 0, N) {
		if (T[i] == 1) delta += A[i];
		else if (T[i] == 2) {
			int top = -1;
			while (!que.empty()) {
				auto p = que.front();
				if (p.first + delta <= A[i]) {
					if (top < 0) top = p.second;
					else uf(top, p.second);
					que.pop_front();
				}
				else break;
			}
			if (0 <= top) que.push_front({ A[i] - delta, uf[top] });
		}
		else if (T[i] == 3) {
			int top = -1;
			while (!que.empty()) {
				auto p = que.back();
				if (A[i] <= p.first + delta) {
					if (top < 0) top = p.second;
					else uf(top, p.second);
					que.pop_back();
				}
				else break;
			}
			if (0 <= top) que.push_back({ A[i] - delta, uf[top] });
		}
	}

	map<int, ll> mp;
	while (!que.empty()) {
		auto p = que.front();
		mp[uf[p.second]] = p.first + delta;
		que.pop_front();
	}

	rep(i, 0, Q) printf("%lld\n", mp[uf[i]]);
}

#include<bits/stdc++.h>
#define int long long
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second
using namespace std;
using pi = pair<int,int>;
const int inf = 0x3f3f3f3f3f3f3f3f;
const int minf = 0xc0c0c0c0c0c0c0c0;

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

    int lo = minf, hi = inf, add = 0;
    int x = inf;
    int n; cin>>n;
    for (int i=1; i<=n; i++) {
        int a,t; cin>>a>>t;
        if (t==1) {
            if (x!=inf) {
                x+=a;
                continue;
            }
            add+=a;
        }
        else if (t==2) {
            if (x!=inf) {
                x=max(x,a);
                continue;
            }
            lo = max(lo, a-add);
            if (lo > hi) x=a;
        }
        else {
            if (x!=inf) {
                x=min(x,a);
                continue;
            }
            hi = min(hi, a-add);
            if (lo > hi) x=a;
        }
    }
    int q; cin>>q;
    while (q--) {
        int a; cin>>a;
        if (x!=inf) cout<<x<<'\n';
        else {
            if (a<lo) a=lo;
            if (a>hi) a=hi;
            cout<<a+add<<'\n';
        }
    }
    return 0;
}


#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
#define pb push_back
#define T ll testx; cin>>testx; while(testx--)
#define print(name) for(auto t:name){cout<<t<<" ";}cout<<endl;
#define printii(name) for(auto t:name){cout<<t.first<<" "<<t.second<<endl;}
#define mod 1000000007
#define modx 998244353
#define inf 2000000000000000000
#define mem(name,val) memset(name,val,sizeof(name))
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define endl "\n"
#define popcount(x) __builtin_popcountll(x)
#define precise cout<<fixed<<setprecision(15)
const long double pi = acos(-1);
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}
void dfs(int s,vector<int>adj[],int vis[])
{
   vis[s]=1;
   for(auto x:adj[s])
   {
      if(vis[x]==0)
      {
         dfs(x,adj,vis);
      }
   }
}
int main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   #endif
    int n,m,x,y;cin>>n>>m;int vis[n+1];mem(vis,0);vector<int>adj[n+1];
    f(m)
    {
      cin>>x>>y;
      adj[x].pb(y);
    }

    ll sum=0;
    for(int i=1;i<=n;i++){
      mem(vis,0);
     dfs(i,adj,vis);
     //cout<<sum<<endl;
     for(int j=1;j<=n;j++){if(vis[j]==1){sum=sum+1;}}
 }
cout<<sum;
}

#include<bits/stdc++.h>
#define x first
#define y second
#define bug(x) cerr<<#x<<'='<<x<<' '
#define debug(x) cerr<<#x<<'='<<x<<'\n'
#define FOR(a,b,c) for(int a=(b),a##_end=(c);a<=a##_end;++a)
#define ROF(a,b,c) for(int a=(b),a##_end=(c);a>=a##_end;--a)
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int INF=0x3f3f3f3f,N=1e5+10;
template<class T>inline bool chkmin(T &x,const T &y){return y<x?x=y,1:0;}
template<class T>inline bool chkmax(T &x,const T &y){return x<y?x=y,1:0;}
int tot,pri[N],son[N];
void Sieve(){
	static bool is[N];
	memset(is,true,sizeof(is));
	FOR(i,2,N-1){
		if(is[i])son[pri[++tot]=i]=i;
		for(int j=1,t;j<=tot&&(t=i*pri[j])<N;++j){
			is[t]=false;
			son[t]=pri[j];
			if(i%pri[j]==0)break;
		}
	}
}
int main(){
	Sieve();
	int n;
	scanf("%d",&n);
	FOR(i,1,n){
		int x=i,cnt=1;
		while(x!=1){
			++cnt;
			x/=son[x];
		}
		printf("%d ",cnt);
	}
	putchar('\n');
	return 0;
}


// *********************************************************************************
// *                        MURTAZA MUSTAFA KHUMUSI                                *
// *                           CSE - 2019-2023                                     *
// *********************************************************************************

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(i, a, n) for (int i = a; i < n; i++)
#define loope(i, b, n) for (int i = b; i <= n; i++)
#define loopit(a) for (auto it = a.begin(); it != a.end(); it++)
#define ms(a, b) memset(a, b, sizeof(a))
#define pb(a) push_back(a)
#define MP make_pair
#define pi pair<int, int>
#define ff first
#define ss second
#define bloop(i, a, b) for (int i = a; i > b; i--)
#define bloope(i, a, b) for (int i = a; i >= b; i--)
#define PQ priority_queue<int> pq;
#define vi vector<int>
#define vii vector<vector<int>>
#define si set<int>
#define NO cout<<"NO\n";
#define YES cout<<"YES\n";
#define MPQ priority_queue<pi, vector<int>, greater<pi>> mpq;
#define io                        \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);

//modular arithmentic
ll m = 1e9 + 7;
// ll m = 998244353;

ll add(ll a, ll b, ll mod = m)
{
    return ((a % mod) + (b % mod)) % mod;
}
ll mul(ll a, ll b, ll mod = m)
{
    return ((a % mod) * (b % mod)) % mod;
}
ll sub(ll a, ll b, ll mod = m)
{
    return ((a % mod) - (b % mod) + mod) % mod;
}

template <typename T>
void dis(vector<T> &vec)
{
    for (const auto &v : vec)
    {
        cout << v << " ";
    }
    cout << "\n";
}
template <typename T1, typename T2>
void disp(vector<pair<T1, T2>> &vec)
{
    for (const auto &v : vec)
    {
        cout << v.ff << " " << v.ss << "\n";
    }
    cout << "\n";
}

//graph theory
vector<pair<int, ll>> adj[200005];

int mx = 60;
void solve()
{
    int n; cin >> n;
    loop(i, 0, n - 1)
    {
        int a, b; ll c;
        cin >> a >> b >> c;
        adj[a].pb(MP(b, c));
        adj[b].pb(MP(a, c));
    }
    queue<int>vals;
    vector<ll> vis(n + 1), xo(n + 1);
    vals.push(1);
    ll ans = 0;
    vis[1] = 1;

    while (vals.size())
    {
        int top = vals.front(); vals.pop();
        for (const auto &v : adj[top])
        {
            if (vis[v.ff])continue;
            vis[v.ff] = 1;
            vals.push(v.ff);
            xo[v.ff] = xo[top] ^ v.ss;
        }
    }

    loop(i, 0, mx)
    {
        int vals[2] = {0};
        loope(j, 1, n)vals[(xo[j] >> i) & 1]++;
        // loope(j, 1, n)cout << ((xo[j] >> i) & 1) << " ";

        // cout << "\n";
        ans = add(ans, mul(vals[0], mul(vals[1], 1ll << i)));

        // cout << vals[0] << " " << vals[1] << " " << (1ll << i) << " " << ans << "\n";
    }
    cout << ans << "\n";
}

int main()
{
    io;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int test = 1, i = 0;
    // cin >> test;
    while (i++ != test)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int inv2 = 5e8 + 4;

int n, cntall[65][2], cntlocal[65][2];
int dp[N];
bool visited[N];
int ans = 0, res = 0;
vector <pair <long long, int> > g[N];

void add(int &x, int y) {
    x += y;
    if (x >= mod) x -= mod;
}

void sub(int &x, int y) {
    x -= y;
    if (x < 0) x += mod;
}

void dfs(int u, int p) {
    dp[u] = 1;
    for (int i = 0; i < g[u].size(); i++) {
        int v = g[u][i].second;
        if (v == p || visited[v]) continue;
        dfs(v, u);
        dp[u] += dp[v];
    }
}

int findcen(int u, int p, int sz) {
    for (int i = 0; i < g[u].size(); i++) {
        int v = g[u][i].second;
        if (v != p && !visited[v] && dp[v] > sz / 2) {
            return findcen(v, u, sz);
        }
    }

    return u;
}

void predfs(int u, int p, long long w) {
    for (int i = 60; i >= 0; i--) {
        cntall[i][(w >> i) & 1]++;
    }

    for (int i = 0; i < g[u].size(); i++) {
        int v = g[u][i].second;
        if (v != p && !visited[v]) {
            predfs(v, u, w ^ g[u][i].first);
        }
    }
}

void localdfs(int u, int p, long long w) {
    for (int i = 60; i >= 0; i--) {
        cntlocal[i][(w >> i) & 1]++;
    }

    for (int i = 0; i < g[u].size(); i++) {
        int v = g[u][i].second;
        if (v != p && !visited[v]) {
            localdfs(v, u, w ^ g[u][i].first);
        }
    }
}

void calc(int u, int p, long long w) {
    //cout << u << " " << p << " " << w << "\n";
    add(res, w % mod);
    for (int i = 60; i >= 0; i--) {
        add(ans, (1LL << i) % mod * cntall[i][((w >> i) & 1) ^ 1] % mod);
        sub(ans, (1LL << i) % mod * cntlocal[i][((w >> i) & 1) ^ 1] % mod);
    }

    for (int i = 0; i < g[u].size(); i++) {
        int v = g[u][i].second;
        if (v != p && !visited[v]) {
            calc(v, u, w ^ g[u][i].first);
        }
    }
}

void centroid(int u) {
    dfs(u, u); u = findcen(u, u, dp[u]);
    visited[u] = true; memset(cntall, 0, sizeof(cntall));

    for (int i = 0; i < g[u].size(); i++) {
        int v = g[u][i].second;
        if (visited[v]) continue;
        predfs(v, u, g[u][i].first);
    }

    for (int i = 0; i < g[u].size(); i++) {
        int v = g[u][i].second;
        if (visited[v]) continue;
        memset(cntlocal, 0, sizeof(cntlocal));
        localdfs(v, u, g[u][i].first);
        calc(v, u, g[u][i].first);
    }

    for (int i = 0; i < g[u].size(); i++) {
        int v = g[u][i].second;
        if (!visited[v]) centroid(v);
    }
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n - 1; i++) {
        int u, v;
        long long w;
        cin >> u >> v >> w;
        g[u].push_back(make_pair(w, v));
        g[v].push_back(make_pair(w, u));
    }

    centroid(1);
    ans = 1LL * ans * inv2 % mod;
    add(ans, res);
    cout << ans << "\n";
    return 0;
}
/*
3
1 2 1
1 3 3
*/


#define _DEBUG
#include "bits/stdc++.h"
//#include <atcoder/all>
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,a5,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#define debug_6(x1,x2,x3,x4,x5,x6) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<", "#x6<<": "<<x6<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_6,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define prind(argument) cout<<std::fixed<<setprecision(13)<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define PI acosl(-1)
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define puba emplace_back
#define pubamp(a,b) emplace_back(mp(a,b))
typedef long long ll;
typedef long double ld;
using namespace std;
//using namespace atcoder;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
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; }
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	scan(N);
	if(N==3){
		prin("6 10 15");
		return 0;
	}
	set<int> st;
	for(int i=6;i<=10000;i+=6) st.insert(i);
	for(int i=10;i<=10000;i+=10) st.insert(i);
	for(int i=15;i<=10000;i+=15) st.insert(i);
	auto itr=st.begin();
	for(int i=0;i<N;i++){
		printf("%d ",(*itr));
		itr++;
	}
	kaigyo;
	return 0;
}

#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#endif
#if __has_include(<atcoder/all>)
#include <atcoder/all>
#endif
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
#define rep(i, a, b) for(int i = (int)(a); i <= (int)(b); i++)
#define rrep(i, a, b) for(int i = (int)(a); i >= (int)(b); i--)
const int MOD = 1000000007;
const int MOD2 = 998244353;
const ll INF = 1e18;
const ld PI = acos(-1);

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    set<int> st;
    st.insert(6);
    st.insert(10);
    st.insert(15);
    int now=20;
    while(st.size()<N&&now<=10000){
        st.insert(now);
        now+=10;
    }
    now=12;
    while(st.size()<N&&now<=10000){
        st.insert(now);
        now+=6;
    }
    now=30;
    while(st.size()<N&&now<=10000){
        st.insert(now);
        now+=15;
    }
    for(auto x:st){
        cout << x << endl;
    }
    //cerr << st.size() << endl;
}


#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define st first
#define nd second
#define pii pair<int,int>
#define mp make_pair

using namespace std;
const int nax = 2e5 + 5;

int cnt[10];

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

    int n,m; cin>>n>>m;
    vector<pii> a;
    for(int i=1;i<=n;i++)
    {
        int x; cin>>x;
        a.pb(mp(x,0));
    }
    sort(a.begin(),a.end());

    vector<int> b;
    for(int i=1;i<=m;i++)
    {
        int x; cin>>x;
        b.pb(x);
    }
    sort(b.begin(),b.end());

    a.pb(mp(b[0],1));

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

    ll cur = 0;
    for(int i=0;i<a.size();i+=2)
    {
        cur += a[i+1].st - a[i].st;
    }
    ll ans = cur;

    int pos = -1;
    for(int i=0;i<a.size();i++)
    {
        if(a[i].nd == 1) pos = i;
    }

    for(int i=1;i<b.size();i++)
    {
        int tr = b[i];

        if(pos % 2 == 1)
        {
            cur -= (a[pos].st - a[pos - 1].st);
            cur += (tr - a[pos - 1].st);
        }
        else
        {
            cur -= (a[pos + 1].st - a[pos].st);
            cur += (a[pos + 1].st - tr);
        }

        a[pos].st = tr;

        while(pos < a.size() - 1 && a[pos + 1].st < a[pos].st)
        {

            if(pos % 2 == 0)
            {
                swap(a[pos],a[pos + 1]);
                cur += 2 * (a[pos + 1].st - a[pos].st);
            }
            else
            {

                cur -= a[pos].st - a[pos - 1].st;
                cur -= a[pos + 2].st - a[pos + 1].st;
                swap(a[pos],a[pos + 1]);
                cur += (a[pos].st - a[pos - 1].st);
                cur += a[pos + 2].st - a[pos + 1].st;
            }
            pos++;
        }

        ans = min(ans,cur);

    }

    cout<<ans;

    return 0;
}

#pragma GCC optimize ("O3")
#pragma GCC target("avx512f")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define drep(i,j,n) for(int i=0;i<(int)(n-1);i++)for(int j=i+1;j<(int)(n);j++)
#define trep(i,j,k,n) for(int i=0;i<(int)(n-2);i++)for(int j=i+1;j<(int)(n-1);j++)for(int k=j+1;k<(int)(n);k++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yes(ans) if(ans)printf("yes\n");else printf("no\n")
#define Yes(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YES(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define vector3d(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
const int MOD2=998244353;
const int INF=1<<30;
const ll INF2=(ll)1<<60;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T,class L>void scan(pair<T, L>& p){scan(p.first);scan(p.second);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T,class L>void print(const pair<T, L>& p){print(p.first);putchar(' ');print(p.second);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll modinv(ll a, ll m) {ll b = m, u = 1, v = 0;while (b) {ll t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}
template<class T> void chmax(T &a,const T b){if(b>a)a=b;}
template<class T> void chmin(T &a,const T b){if(b<a)a=b;}

int main(){
    INT(n);
    vector<int> a(n);
    in(a);
    ll ans=0;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            ans+=abs(a[i]-a[j]);
        }
    }
    out(ans);
}


//
//  main.cpp
//  ABC 195
//
//  Created by Paul Liao on 2021/3/13.
//

#include <iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#define ll long long
using namespace std;
vector<int> e[21];
int vis[21];
int col[21];
ll dp[21][4],ans=0;
bool uu[21]={0};
int n,m;
bool check(int u){
    for(int i:e[u]) if(col[u]==col[i]) return 0;
    return 1;
}
void dfs(int now){
    vis[now]=1;
    if(now==n+1) {
        ans++;
        return;
    }
    if(!uu[now]){
        dfs(now+1);
        return ;
    }
    for(int i=1;i<=3;i++){
        col[now]=i;
        if(check(now)) dfs(now+1);
        col[now]=0;
    }
}

int main() {
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        uu[a]=1;
        uu[b]=1;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    dfs(1);
    for(int i=1;i<=n;i++) if(!uu[i]) ans*=3ll;
    cout<<ans<<endl;

}

/** これを翻訳している間、あなたはあなたの人生のいくつかの貴重な瞬間を無駄にしました **/
#include<bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=x;i<y;i++)
#define repr(i,x,y) for(int i=x;i>=y;i--)
#define int long long
#define pb push_back
#define ff first
#define ss second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define memo(x,y) memset((x),(y),sizeof((x)))
#define line cout<<"[At "<<__LINE__<<"]"<<endl;

using pii = pair<int,int>;
using vi = vector<int>;
using vii = vector<pair<int,int>>;

constexpr int mod = 1e9 + 7 , N = 2e5 + 5;
constexpr long long inf = 1e18;
constexpr long double eps = 1e-6;

vector<int> g[N];
int node1 = -1,maxd= -1;
void dfs1(int v,int p,int d){
  // cout<<v<<"=="<<d<<endl;
  if(d>maxd){
    node1=v;
    maxd=d;
  }
  for(auto &x:g[v]){
    if(x!=p)
      dfs1(x,v,d+1);
  }
}
int mark[N];
int E[N];
bool markdfs(int v,int p,int B){
  for(auto &x:g[v]){
    if(x!=p){
      if(markdfs(x,v,B)){
        mark[v]=1;
        return true;
      }
    }
  }
  if(v==B)
    mark[v]=true;
  return mark[v];
}
void dfs(int v,int p,int &num){
  E[v]=num;
  for(auto &x:g[v]){
    if(x!=p && mark[x] == 0){
        num++;
        dfs(x,v,num);
    }
  }
  for(auto &x:g[v]){
    if(x!=p && mark[x] == 1){
        num++;
        dfs(x,v,num);
    }
  }
  num++;
}
void Onigiri()
{
  int n;
  cin>>n;
  rep(i,0,n-1){
    int x,y;
    cin>>x>>y;
    x--,y--;
    g[x].pb(y);
    g[y].pb(x);
  }

  dfs1(0,-1,0);
  int A=node1;
  maxd=-1;
  dfs1(node1,-1,0);
  int B=node1;
  markdfs(A,-1,B);

  // cout<<A<< " "<<B<<endl;
  int num = 1;
  dfs(A,-1,num);

  rep(i,0,n){
    cout<<E[i]<<" ";
  }
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   //cout.precision(10);cout<<fixed;
   #ifdef Zoro
   freopen("/home/pritish/Competitive/in", "r", stdin);
   freopen("/home/pritish/Competitive/out", "w", stdout);
   #endif

   int t=1;
   //cin>>t;

   while(t--)
   {Onigiri();cout<<"\n";}

   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
}


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

// input
int N, M;
vi U, V, C;

void input() {
    cin >> N >> M;
    U = V = C = vi(M);
    rep(i, M) cin >> U[i] >> V[i] >> C[i];
}

struct edge {
    int num;
    int from;
    int to;
    ll cost;
};

struct node {
    int num;
    int depth;
    edge rev;
    vi parent;
    vi children;
    vector<edge> edges;
    node(int n) : num(n), depth(-1), parent(30, -1) {}
};

struct tree {
    int m;
    vector<edge> edges;
    vector<node> nodes;

    tree(int n) {
        rep(i, n) nodes.push_back(node(i));
        m = 0;
    }

    void add_edge(int u, int v, ll cost) {
        edge e1{m, u, v, cost};
        edge e2{m, v, u, cost};
        m++;
        nodes[u].edges.push_back(e1);
        nodes[v].edges.push_back(e2);
    }

    void make_tree(int v) {
        make_tree(v, -1, 0, edge{-1, -1, v, -1});
    }

    void make_tree(int u, int p, int d, edge rev) {
        node &w1 = nodes[u];
        w1.parent[0] = p;
        w1.depth = d;
        w1.rev = rev;
        edges.push_back(rev);
        for (int k = 1; k <= int(log2(d)); k++) {
            node &par = nodes[w1.parent[k - 1]];
            w1.parent[k] = par.parent[k - 1];
        }
        for (edge &e : w1.edges) {
            int v = e.to;
            if (v == p) continue;
            node &w2 = nodes[v];
            if (w2.depth != -1) continue;
            w1.children.push_back(w2.num);
            make_tree(v, u, d + 1, e);
        }
    }

    int lca(int u, int v) {
        if (u == v) return u;
        if (nodes[u].depth != nodes[v].depth) {
            if (nodes[u].depth > nodes[v].depth) swap(u, v);
            while (nodes[u].depth != nodes[v].depth) {
                int k = log2(nodes[v].depth - nodes[u].depth);
                v = nodes[v].parent[k];
            }
            if (nodes[u].num == nodes[v].num) return nodes[u].num;
        }
        node &w1 = nodes[u];
        node &w2 = nodes[v];
        int k = log2(w1.depth) + 1;
        while (k > 0 && w1.parent[k] == w2.parent[k]) k--;
        return lca(w1.parent[k], w2.parent[k]);
    }

    int dist(int u, int v) {
        int x = lca(u, v);
        node &w = nodes[lca(u, v)];
        int ret = (nodes[u].depth - w.depth) + (nodes[v].depth - w.depth);
        return ret;
    }

    bool is_on_path(int u, int v, int x) {
        if (dist(u, v) == dist(u, x) + dist(x, v)) return true;
        else return false;
    }
};

void solve(int u, tree &tr, vi &ans) {
    node &w1 = tr.nodes[u];
    if (u > 0) {
        if (ans[w1.parent[0]] == w1.rev.cost) {
            ans[u] = w1.rev.cost + 1;
            if (ans[u] == N + 1) ans[u] = 1;
        } else {
            ans[u] = w1.rev.cost;
        }
    }
    for (int v : w1.children) {
        solve(v, tr, ans);
    }
}

int main() {
    input();
    tree tr(N);
    rep(i, M) {
        int u = U[i] - 1, v = V[i] - 1, c = C[i];
        tr.add_edge(u, v, c);
    }
    tr.make_tree(0);
    vi ans(N, 1);
    solve(0, tr, ans);
    rep(i, N) cout << ans[i] << endl;
}

#include <bits/stdc++.h>
#define st first
#define nd second
#define PQ priority_queue

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 2e5 + 10;
const int MOD = 0;
vector<pii> gr[N];
bool vis[N];
int  a[N];
void dfs(int node, int val){
	vis[node] = true;
	a[node] = val > 0 ? val : (val == -1 ? 2 : 1);
	for(auto it: gr[node]){
		if(!vis[it.st]){
			dfs(it.st, a[node] == it.nd ? -a[node] : it.nd);
		}
	}
	return;
}
int main(){
	int n, m, x, y, z;
	scanf("%d %d" ,&n, &m);
	for(int i = 1; i <= m; i++){
		scanf("%d %d %d", &x, &y, &z);
		gr[x].push_back({y, z});
		gr[y].push_back({x, z});
	}
	dfs(1, 1);
	for(int i = 1; i <= n; i++){
		printf("%d\n", a[i]);
	}

}


#include<iostream>
#include<vector>
using namespace std;
typedef long long LL;
const int N=1e5+10,mod=998244353;
LL Pow[N];
LL f[N];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	Pow[0]=1;
	for(int i=1;i<=n;i++){
		Pow[i]=Pow[i-1]*m%mod;
	}
	for(int i=1;i<=m;i++)
	f[i]=1;
	LL ans=m,pre=0;
	for(int i=2;i<=n;i++){
		pre=ans;
		ans=0;
		if(i>2)
		for(int j=1;j<=m;j++){
			f[j]=(f[j]*(m-j)%mod+Pow[i-2])%mod;
		}
		for(int j=1;j<=m;j++){
			ans=(ans+pre+Pow[i-1]-f[j]+mod)%mod;
		}
	}
	cout<<ans;
	return 0;
}


// Problem: C - Unexpressed
// Contest: AtCoder - Caddi Programming Contest 2021(AtCoder Beginner Contest 193)
// URL: https://atcoder.jp/contests/abc193/tasks/abc193_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
//#pragma GCC diagnostic ignored "-Wformat"

using namespace std ;

#define   Pi     2*acos(0.0)
#define   LINF   1LL<<62
#define   ll     long long
#define   ull    unsigned long long
#define   pb     push_back
#define   mp     make_pair
#define   MAX    500006
#define   MAX1   10000008
#define   mem(a,v)   memset(a,v,sizeof(a))
#define   all(x) x.begin(),x.end()
#define   lcm(a, b)        ((a)*((b)/__gcd(a,b)))
#define yes   cout<<"YES"<<endl
#define no   cout<<"NO"<<endl
#define buga  cout<<1<<endl
#define bugb  cout<<2<<endl
#define bugc  cout<<3<<endl
#define bugd  cout<<4<<endl
#define buge  cout<<5<<endl

void fastIO (){ios_base::sync_with_stdio(false);cin.tie(0); cout.precision(20);}

ll A[MAX];
ll B[MAX];
ll C[MAX];
vector< ll >V;
vector< ll >Ans;
vector< pair<ll,ll> >VP;
map< ll,ll >M;
vector<ll>prime;
bool mark[MAX1];
ll N=1e7;
void seive (){int limit = sqrt(N*1.0)+2;mark[1]=1;for (int i=4;i<=N;i+=2)mark[i]=1;prime.push_back(2);for (int i=3;i<=N;i+=2){if(!mark[i]){prime.push_back(i);if(i<=limit){for (int j=i*i;j<=N;j+=i*2)mark[j]=1;}}}}
/*
ll sti(string a,int base=10)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=base;
		k+=a[i]-'0';
	}
	return k;
}

/*
/*
ll bin_pow(ll o, ll s) {
    if (s == 0) return 1;
    if (s == 1) return o % mod;
    ll d = bin_pow(o, s/2);
    d = (d * 1ll * d) % mod;
    if (s % 2 == 1)
        d = (d * 1ll * o) % mod;
    return d;
}
*/

int main ()
{
    fastIO();
    ll a,b,c,d,n,m,k,l,p,q,r,t,x,y;
    ll cnt=0,cntr=0,sum=0,ans=1,check=0;
    ll Max= 0,Max1=-1e18+1,Min=LINF;
    string s,s1,s3,s4;

    //cin>>n;
    for(ll i = 2; i <= 100000; i++){
        ans = i;
        for(int j = 1; ans <= 10000000000LL; j++){
            ans = 1LL * ans * i;
            V.push_back(ans);
        }
    }
    sort(V.begin(), V.end());
    V.resize(unique(V.begin(), V.end())- V.begin());
    V.push_back(10000000000000LL);
    //cout << V.size() << endl;
    cin >> n;
    int idx = upper_bound(V.begin(), V.end(), n) - V.begin();
    if(n <= 3) cout <<  n << endl;
    else cout << n - idx << endl;
    /*
        always check the limit and make sure that is correct.
        lcm of first 40 numbers  can be calculated.
        sqrt of 10^9 is 31622.
        always usee 1LL while doing binary operations.
    */

    return 0;
}

// Bismillahir Rahmanir Rahim
//============================
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define endl        "\n"
#define infL        LLONG_MAX
#define infI        INT_MAX
#define pb          push_back
#define fo(i,a,b)   for(int i=a;i<b;i++)
#define fo2(i,a,b)  for(int i=a;i<=b;i++)
#define rfo(i,a,b)  for(int i=a; i>=b;i--)
#define precise(x,y)cout<<fixed<<setprecision(y)<<x<<endl;
#define MAX         100010
#define yes         cout<<"YES"<<endl
#define no          cout<<"NO"<<endl
#define bye         return 0
#define debug       cout<<"\nDebug\n";
#define debug2      cout<<"\nDebug2\n";
#define PEREGRINE_FALCON {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

typedef pair<ll,ll>PII;
double epsilon = 0.0000001f;
ll mod=1e9+7;
double Pi =acos(-1);

void print(vector<ll>V)
{
      cout<<"\n---------------Vector checking start-------------------\n";
      ll sz=V.size();
      fo(i,0,sz){cout<<V[i]<<"  ";}
      cout<<"\n----------------Vector checking end--------------------\n";
}

void print(ll arr[], ll n)
{
      cout<<"\n---------------Array checking start-------------------\n";
      fo(i,0,n){cout<<arr[i]<<" ";}
      cout<<"\n----------------Array checking end--------------------\n";
}

int main()
{
      PEREGRINE_FALCON
      //freopen("inputNew.txt", "r", stdin);

      ll testCase=1;
      //cin>>testCase;
      while(testCase--){
            ll n,m,k,x,y,z,d,mn,mx,temp,cnt,ans,sum,sz,len;
            cin>>n;
            ll a[n+10],b[n+10],c[n+10];
            ll markA[n+10]={0};
            ll markC[n+10]={0};

            fo(i,0,n){
                  cin>>a[i];
                  markA[a[i]]++;
            }
            fo(i,0,n){
                  cin>>b[i];
            }
            fo(i,0,n){
                  cin>>c[i];
                  markC[c[i]]++;
            }

            cnt=0;
            fo2(i,1,n){
                  if(markC[i]==0) continue;
                  x=markC[i];
                  y=b[i-1];
                  //cout<<"x: "<<x<<endl;
                  if(markA[y]){
                        cnt+=(markA[y]*x);
                  }
            }
            cout<<cnt<<endl;

      }

      bye;
}


#include <bits/stdc++.h>

using namespace std;

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

	if (n % 2 != 0) {
		n *= 2;
		s += s;
	}
	function<char(int l, int r)> calc_winner = [&] (int left, int right) {
		if (left == right || (left == 'R' && right == 'S') ||
			(left == 'P' && right == 'R') || (left == 'S' && right == 'P')) {
			return left;
		} else {
			return right;
		}
	};

	for (int round = 0; round < k; ++round) {
		string next_round = "";
		for (int i = 0; i < n-1; i += 2) {
			next_round += calc_winner(s[i], s[i+1]);
		}
		s = next_round;
		if (n % 2 == 0) {
			s += s;
		}
	}

	cout << s[0] << endl;
}

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

	solve();

	return 0;
}

#include <cstdio>
using namespace std;

const int max_n = 100, tab[3][3] = {
	0, 1, 0,
	1, 1, 2,
	0, 2, 2
};

int dp[max_n][max_n+1], pmn[max_n+1];
char s[max_n];

int main()
{
	int n, k;

	scanf("%d%d%s", &n, &k, s);

	if (n == 1)
	{
		puts(s);
		return 0;
	}

	pmn[0] = 1;
	for (int i = 1; i <= k; i++)
		pmn[i] = (pmn[i-1] * 2) % n;

	for (int i = 0; i < n; i++)
	{
		if (s[i] == 'R') dp[i][0] = 0;
		if (s[i] == 'P') dp[i][0] = 1;
		if (s[i] == 'S') dp[i][0] = 2;
	}

	for (int j = 1; j <= k; j++)
		for (int i = 0; i < n; i++)
			dp[i][j] = tab[dp[i][j-1]][dp[(i+pmn[j-1])%n][j-1]];

	switch (dp[0][k])
	{
		case 0: puts("R"); break;
		case 1: puts("P"); break;
		case 2: puts("S"); break;
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define mk make_pair
typedef int64_t ll;
#define P pair<ll,ll>
#define vi vector<ll>
#define vii vector<vector<ll> >
#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define rep2(i,m,n) for(ll (i)=(m); (i)<(ll)(n); (i)++)
const ll INF = 1LL<<32;

int main() {
  ll n;
  cin >>n;
  vii dat(n,vi(3,0));
  rep(i,n) {
    rep(j,3) cin >> dat.at(i).at(j);
  }
  vii ans(n,vi(4,0));

  rep(i,n) {
    ans.at(i).at(0) = dat.at(i).at(0);
    ans.at(i).at(1) = dat.at(i).at(1);
    ans.at(i).at(2) = dat.at(i).at(0)+1;
    ans.at(i).at(3) = dat.at(i).at(1)+1;
  }
  vector<bool> leftup(n,true);
  rep(i,n) {
    ll state_a = dat.at(i).at(0);
    ll state_b = dat.at(i).at(1);
    rep(j,n) {
      if(dat.at(j).at(0)<=state_a && dat.at(j).at(1)<=state_b && i!=j) {
        leftup.at(i) = false;
        break;
      }
    }
  }
  ll des;
  double genten = 1;
  rep(i,n) {
    double mini = min(dat.at(i).at(2),ans.at(i).at(2)*ans.at(i).at(3));
    double maxi = max(dat.at(i).at(2),ans.at(i).at(2)*ans.at(i).at(3));
    if(leftup.at(i) && 1-mini/maxi<genten) {
      genten = 1-mini/maxi<genten;
      des = i;
    }
  }

  ans.at(des).at(0) = 0;
  ans.at(des).at(1) = 0;

  rep(i,n) {
    rep(j,3) {
      cout << ans.at(i).at(j)<< " ";
    }
    cout << ans.at(i).at(3) << endl;
  }
}

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

int main()
{
ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    // reading starts
    int n;
    cin >> n;
    vector<vector<int>> a;
    set<int> xaxis, yaxis;
    // xaxis.insert(10000);
    // yaxis.insert(10000);
    for(int i = 0; i < n; ++i){
        vector<int> b;
        int x;
        for(int j = 0; j < 3; ++j) cin >> x, b.push_back(x);
        a.push_back(b);
    }
    //reading ends

    vector<vector<int>> bout(n, vector<int>(4,0));

    vector<int> aa;
    for(int i = 0 ;i  < n; ++i) aa.push_back(i);
    sort(aa.begin(), aa.end(), [&] (const int x, int y) {return a[x][3] < a[y][3];});
    bout[aa[0]][0] = 0;
    bout[aa[0]][1] = 0;
    bout[aa[0]][2] = 9999;
    bout[aa[0]][3] = 9999;
    int x = 0;
    for(int i = 1; i < n; ++i){
        bout[aa[i]][0] = 9999;
        bout[aa[i]][1] = x;
        bout[aa[i]][2] = 10000;
        bout[aa[i]][3] = x+1;
        ++x;
    }
    //output starts (b)
    vector<vector<int>> & b = bout;
    int m_b = b.size();
    for(int i = 0; i < m_b ; ++i)
    {
        for(int j = 0; j <4;++j)
        cout << b[i][j] << " ";
        cout <<endl;
    }

    return 0;
}


#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cctype>
#include<cstdlib>
#include<algorithm>
#include<vector>
#define fs(i,x,y) for(int i=(x),_=(y);i<=_;++i)
#define fn(i,x,y) for(int i=(x),_=(y);i>=_;--i)
#define tor(i,v,x) for(int i=head[x],v=to[i];i;i=nxt[i],v=to[i])
#define Li inline
#define R register int
#define ls(x) ch[x][0]
#define rs(x) ch[x][1]
#define mpi(x,y) make_pair(x,y)
#define pi pair<int,int>
//#define int ll
using namespace std;
typedef long long ll;
template<typename T>
void read(T &x){
	x=0;char ch=getchar();bool f=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	x=f?-x:x;
}

const int N=2e5+7;
int n,m;
int a[N],b[N],p[N],id[N],q[N];
vector<pi>v;

bool cmp(int lhs,int rhs){
	return b[lhs]>b[rhs];
}

signed main(){
	read(n);
	fs(i,1,n)read(a[i]);
	fs(i,1,n)id[i]=i,read(b[i]);
	fs(i,1,n)read(p[i]),q[p[i]]=i;
	sort(id+1,id+n+1,cmp);
	fs(i,1,n){
		int x=id[i];
		if(q[x]==x)continue;
		if(a[q[x]]>b[x]&&a[x]>b[p[x]]){
			v.push_back(mpi(q[x],x));
			p[q[x]]=p[x];
			q[p[x]]=q[x];
		}else{
			printf("-1");return 0;
		}
	}
	int len=v.size();
	printf("%d\n",len);
	fs(i,0,len-1){
		printf("%d %d\n",v[i].first,v[i].second);
	}
	return 0;
}

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

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    vec_int a(N), b(N), p(N);
    rep(i,N) cin>>a.at(i);
    rep(i,N) cin>>b.at(i);
    rep(i,N) cin>>p.at(i);

    vector<P> person(N);
    rep(i, N)person.at(i) = make_pair(a.at(i), i);
    sort(person.begin(), person.end());
    // 何をやらないといけないかというと、
    // 体重が軽い人の順番に
    // 自分のIDの荷物を持っている人と荷物を交換する
    //

    map<int, int> assign_map;
    map<int, int> assign_map2;
    rep(i,N){
        assign_map[p.at(i)] = i; // 荷物, 人
        assign_map2[i] = p.at(i); //人, 荷物
    }

    int ans = 0;
    vector<P> ans_vec;
    for(int i=0;i<N;i++){
        int weight, person_ID; tie(weight, person_ID) = person.at(i);
        //cout<<weight<<" "<<person_ID<<" "<<assign_map[person_ID]<<endl;
        if(person_ID == assign_map2[person_ID]-1){
            continue;
        }
        int nimotu = assign_map2[person_ID];
        if(weight <= b.at(nimotu-1) ){
            cout<<-1<<endl;
            return 0;
        }
        int counter_person = assign_map[person_ID+1]; // person_ID+1の荷物を持っている人
        assign_map2[person_ID] = person_ID+1;
        assign_map2[counter_person] = nimotu;
        assign_map[nimotu] = counter_person;
        ans_vec.push_back(make_pair(person_ID+1, counter_person+1));
        ans++;
    }
    cout<<ans<<endl;
    rep(i, ans){
        cout<<ans_vec.at(i).first<<" "<<ans_vec.at(i).second<<endl;
    }

    return 0;
}


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

#define fo(i, x, y) for (int i = x; i <= y; ++i)
#define fd(i, x, y) for (int i = x; i >= y; --i)

#define parr(a, x, y)\
{\
	for (int i = x; i <= y; ++i) printf("%d ", a[i]);\
	printf("\n");\
}

#define pint(a) printf("%d\n", a);

typedef long long ll;

const int maxn = 2e5 + 5;
const ll inf = 1e18;

int n;
ll a[maxn], d[maxn], maxd[maxn];

int getint()
{
	char ch;
	int res = 0, p;
	while (!isdigit(ch = getchar()) && (ch ^ '-'));
	p = ch == '-'? ch = getchar(), -1 : 1;
	while (isdigit(ch))
		res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
	return res * p;
}

int main()
{
	n = getint();
	fo(i, 1, n) a[i] = getint();
	maxd[0] = -inf;
	//mind[0] = inf;
	fo(i, 1, n)
	{
		d[i] = d[i - 1] + a[i];
		maxd[i] = max(maxd[i - 1], d[i]);
		//mind[i] = min(mind[i - 1], d[i]);
	}
	ll now = 0, ans = 0;
	fo(i, 1, n)
	{
		ans = max(ans, now + maxd[i]);
		now += d[i];
	}
	printf("%lld\n", ans);
	return 0;
}

#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int ceil2(int a){
  int ret=a,i=1;
  while((ret>>i)!=0){
    ret|=ret>>i;
    i<<=1;
  }
  ret++;
  if(a==(ret>>1)) return a;
  return ret;
}

int main(){
  int n;  cin >>n;
  int t=ceil2(n+1);

  auto f=[&](int a){
           return (a-1)%t+1;
         };
  auto g=[&](int a){
           return f(a)-((f(a)>n)?(t/2):0);
         };

  rep(_i,n){
    int i=_i+1;
    print(g(2*i),g(2*i+1));
  }

}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

    int x, y, z;
    cin >> x >> y >> z;
    cout << (z * y - 1) / x << '\n';
}

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    int x, y, z;
    cin >> x >> y >> z;
    int ans = 1;
    while(1){
        if(y * z > ans * x){
            ans++;
        }else{
            ans--;
            break;
        }
    }
    println(ans);
    return 0;
}


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

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

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

const ll MOD = 1e9 + 7;
const int INF = 1001001001;
const double PI = 3.14159265358979323846;

int timer = 0;

void dfs(int now, int d, vvi &to, vvi &din, vector<P> &inout) {
    inout[now].first = timer;
    din[d].push_back(timer);
    timer++;
    for (auto ni : to[now]) {
        dfs(ni, d+1, to, din, inout);
    }
    inout[now].second = timer;
}

void solve() {
    int n;
    cin >> n;
    vvi to(n), din(n);
    vector<P> inout(n);
    rep(i, n-1) {
        int p;
        cin >> p;
        p--;
        to[p].push_back(i+1);
    }

    dfs(0, 0, to, din, inout);

    int q;
    cin >> q;
    rep(x, q) {
        int u, d;
        cin >> u >> d;
        u--;
        auto [tin, tout] = inout[u];
        auto now = din[d];
        auto it_out = lower_bound(now.begin(), now.end(), tout);
        auto it_in = lower_bound(now.begin(), now.end(), tin);
        int num_out = distance(now.begin(), it_out);
        int num_in = distance(now.begin(), it_in);
        int ans = num_out - num_in;
        cout << ans << endl;
    }
}

int main() {

    solve();

    return 0;
}

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

void dfs(const std::vector<int> &C, const std::vector<std::vector<unsigned long>> &edge, unsigned long idx, std::vector<unsigned long> &ans, std::vector<bool> &used, std::vector<bool> &checked)
{
    if (checked[idx])
    {
        return;
    }
    else
    {
        checked[idx] = true;
    }
    if (!used[C[idx]])
    {
        ans.push_back(idx);
        used[C[idx]] = true;
        for (const auto &e : edge[idx])
        {
            dfs(C, edge, e, ans, used, checked);
        }
        used[C[idx]] = false;
    }
    else
    {
        for (const auto &e : edge[idx])
        {
            dfs(C, edge, e, ans, used, checked);
        }
    }
}

int main()
{
    unsigned long N;
    std::cin >> N;
    std::vector<int> C(N);
    for (unsigned long i = 0ul; i < N; ++i)
    {
        std::cin >> C[i];
    }
    std::vector<std::vector<unsigned long>> edge(N, std::vector<unsigned long>());
    for (unsigned long i = 0ul; i < N - 1; ++i)
    {
        unsigned long A, B;
        std::cin >> A >> B;
        --A;
        --B;
        edge.at(A).push_back(B);
        edge.at(B).push_back(A);
    }
    std::vector<unsigned long> ans;
    std::vector<bool> color_used(200000, false);
    std::vector<bool> checked(N, false);
    dfs(C, edge, 0, ans, color_used, checked);
    std::sort(ans.begin(), ans.end());
    for (const auto &c : ans)
    {
        std::cout << c + 1 << std::endl;
    }
    return 0;
}


#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  998244353;
//const ll maxn = 1000000000;
//const ll mod = 1000000007;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
template <typename T>
void chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
  }
}
template <typename T>
void chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
  }
}

int main() {
   //cout << fixed << setprecision(10);
   ll r;
   cin>>r;
   double x,y;
   cin>>x>>y;

   double rxy=sqrt(x*x+y*y);
   //cout<<rxy<<endl;
  if(r==rxy)cout<<1<<endl;
  else if(r>rxy)cout<<2<<endl;
  else{
   ll dis=0;
   rep(i,100000000){

       if(dis>=rxy){
           cout<<i<<endl;
           return 0;
       }
       dis+=r;

   }
  }

}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=INF;
const ll inf=INF*INF;
const ll mod=MOD;
const ll MAX=270010;

//二分累乗

ll rui(ll a,ll b){
    ll res=1;
    ll x=a;
    while(b){
        if(b&1)res=res*x%mod;
        x=x*x%mod;
        b/=2;
    }
    return res;
}

//行列累乗
mat mul(mat &A,mat &B){
    mat C(A.size(),vec(B[0].size()));
    rep(i,A.size()){
        rep(j,B[0].size()){
            rep(k,B.size()){
                C[i][j]=(C[i][j]+(A[i][k]*B[k][j])%mod)%mod;
            }
        }
    }
    return C;
}
mat pow(mat A,ll k){
    mat B(A.size(),vec(A.size()));
    rep(i,A.size())B[i][i]=1;
    while(k>0){
        if(k&1)B=mul(B,A);
        A=mul(A,A);
        k>>=1;
    }
    return B;
}

signed main(){
    ll n,m,k;cin>>n>>m>>k;

    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    vector<vector<ll> >s(n,vector<ll>(n));
    ll invm=rui(m*2LL%mod,mod-2);
    rep(i,m){
        ll x,y;cin>>x>>y;
        x--;y--;
        s[x][x]=(s[x][x]-invm)%mod;
        s[y][y]=(s[y][y]-invm)%mod;
        s[x][y]=(s[x][y]+invm)%mod;
        s[y][x]=(s[y][x]+invm)%mod;
    }
    rep(i,n){
        s[i][i]=(s[i][i]+1)%mod;
    }
    vector<vector<ll> >d=pow(s,k);
    rep(i,n){
        ll ans=0;
        rep(j,n){
            ans=(ans+a[j]*d[i][j]%mod)%mod;
        }
        if(ans<0)ans+=mod;
        cout<<ans<<endl;
    }
}

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

const int maxh = 20;

struct Pos {
  int r, c;
  Pos(int r=0, int c=0) : r(r), c(c) {}
};

int H, W, A, B;
int G[maxh][maxh];

Pos nextPos(int r, int c) {
  r--;
  c--;
  int id = r * W + c;
  id++;
  r = id / W;
  c = id % W;
  return Pos(r+1, c+1);
}

void dfs(Pos pos, int cnta, int cntb, int &ans) {
  int r = pos.r, c = pos.c;
  Pos npos = nextPos(r, c);
  if (cnta == 0 && cntb == 0) {
    ans++;
    return;
  }

  if (G[r][c] > 0) {
    dfs(npos, cnta, cntb, ans);
    return;
  }

  // PUSH B
  if (cntb > 0) {
    G[r][c] = 1;
    dfs(npos, cnta, cntb-1, ans);
    G[r][c] = 0;
  }

  if (cnta > 0) {
    // PUSH A with horizontally
    if (c+1 <= W && !G[r][c+1]) {
      G[r][c] = G[r][c+1] = 2;
      dfs(npos, cnta-1, cntb, ans);
      G[r][c] = G[r][c+1] = 0;
    }

    // PUSH A with vertically
    if (r+1 <= H && !G[r+1][c]) {
      G[r][c] = G[r+1][c] = 2;
      dfs(npos, cnta-1, cntb, ans);
      G[r][c] = G[r+1][c] = 0;
    }
  }

}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  // freopen("in", "r", stdin);

  cin >> H >> W >> A >> B;
  int ans = 0;
  dfs(Pos(1, 1), A, B, ans);
  cout << ans;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
int M=1000000007;
const int N=200005;

signed main(){
  int t1=1;
  //cin>>t1;

  while(t1--){
    int n,m;
    cin>>n>>m;

    map<int,int> mp;
    for(int i=0;i<n+m;i++){
      int x;
      cin>>x;
      mp[x]++;
    }

    for(auto it:mp) if(it.second==1) cout<<it.first<<" ";
    cout<<endl;
  }
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
int main() {
    int n, m;
    cin >> n >> m;
    set<int> a, b, ab;
    rep (i, n) {
        int c;
        cin >> c;
        a.insert(c);
        ab.insert(c);
    }
    rep(i, m) {
        int d;
        cin >> d;
        b.insert(d);
        ab.insert(d);
    }
    for (int i: ab) {
        if (a.count(i) && !b.count(i) || b.count(i) && !a.count(i)) {
            cout << i << " ";
        }
    }
    cout << endl;
    return 0;
}


///In the name of GOD
//#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 3e5 + 10;
const ll SGM = 30;
ll n, ans;
string s;
ll Cnt[SGM];
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> s; n = s.size();
    s = "$" + s;
    Cnt[s[n] - 'a'] ++;
    Cnt[s[n - 1] - 'a'] ++;
    for(int i = n - 2; i; i --){
        if(s[i] == s[i + 1]){
            ans += (n - (i + 1)) - (Cnt[s[i] - 'a'] - 1);
            memset(Cnt, 0, sizeof Cnt);
            Cnt[s[i] - 'a'] = n - (i - 1);
        }
        else{
            Cnt[s[i] - 'a'] ++;
        }
    }
    cout << ans << '\n';
    return 0;
}
/*!
    HE'S AN INSTIGATOR,
    ENEMY ELIMINATOR,
    AND WHEN HE KNOCKS YOU BETTER
    YOU BETTER LET HIM IN.
*/
//! N.N

#include "bits/stdc++.h"

using namespace std;
#define int long long
const int MAX=1e5+10;
const int mod=1e9+7;
const int INF=0x3f3f3f3f3f3f3f3f;

void solve(){
    string tem="ZONe";
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        int ji=0;
        for(int j=0;j<tem.size();j++){
            if(s[i+j]==tem[j]){
                ji++;
            }
        }
        if(ji==tem.size()){
            ans++;
        }
    }
    cout<<ans;

}
signed main(){
    int _=1;
    //ios::sync_with_stdio(0);cout.tie(0);cin.tie(0);
    //cin>>_;
    for(int i=1;i<=_;i++){
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
#include <chrono>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

#define _ << " " <<
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define sp(n) fixed << setprecision(n)
#define ff first
#define ss second
#define pb push_back

using namespace std;
//using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
//using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
//using ordered_multiset = tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod = 1e9 + 7;
const double eps = 1e-12;
const ll INF = 1e18;

int main() {
    srand(time(0));
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL_DEBUG
    freopen("input.txt", "r", stdin);
    //freopen("output_false.txt", "w", stdout); //outs
#endif
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for (auto& i : a) {
        for (int& j : i) cin >> j;
    }
    int minv = a[0][0];
    for (auto& i : a) {
        for (int& j : i) minv = min(minv, j);
    }
    ll ans = 0;
    for (auto& i : a) {
        for (int& j : i) ans += j - minv;
    }
    cout << ans << endl;
    return 0;
}

/**
 * author  : UshanGhosh
 * created : 2020-12-19 18:04:46
**/

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

#define    ll      long long
#define    pii     pair<int,int>
#define    vii     vector<int>
#define    vcc     vector<char>
#define    pll     pair<long long, long long>
#define    mem     memset
#define    sof     sizeof
#define    co1     __builtin_popcountll
#define    PB      push_back
#define    UB      upper_bound
#define    LB      lower_bound
#define    MP      make_pair
#define    TS      to_string
#define    F       first
#define    S       second
#define    pi      acos(-1)
#define    mod     (long long)1000000007
#define    inf     (long long)1e18
#define    endl    '\n'

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    long long a,b,c,d,e,f,i,j,k,m,n,o,x,y;
    cin>>n>>m;
    ll pans = inf;
    ll sum = 0;
    for(i=0;i<n*m;i++){
        cin>>a;
        pans = min(pans, a);
        sum += a;
    }
    cout<<sum-pans*n*m;
}


#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,x;
  cin >> n >> x;
  ll a[n];
  rep(i,n) R a[i];
  ll ans=MAXL;
  REP(m,1,n+1) {
    ll dp[2][m][m+1];
    rep(i,2)rep(j,m)rep(k,m+1) dp[i][j][k]=-MAXL;
    dp[0][0][0]=0;
    ll t=0;
    rep(i,n) {
      rep(j,m)rep(k,m+1) dp[t^1][j][k]=max(dp[t^1][j][k],dp[t][j][k]);
      rep(j,m) {
        rep(k,m) {
          if(dp[t][j][k]<0) continue;
          dp[t^1][(j+a[i])%m][k+1]=max(dp[t^1][(j+a[i])%m][k+1],dp[t][j][k]+a[i]);
        }
      }
      rep(j,m)rep(k,m+1) dp[t][j][k]=-MAXL;
      t^=1;
    }
    rep(j,m) {
      if(dp[t][j][m]<0) continue;
      ll y=x-dp[t][j][m];
      if(y%m==0) ans=min(ans,y/m);
    }
  }
  pr(ans);
}

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

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

// I have no idea what I'm doing

#ifdef DEBUG
#define debug(...) __VA_ARGS__
#else
#define endl '\n'
#define debug(...)
#endif
#define debugf(...) debug(printf(__VA_ARGS__))

const int N = 128;
using ll = long long;
const ll oo = 0x3f3f3f3f3f3f3f3fll;

ll dp[N][N];
int a[N];

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

    int n; cin >> n;
    ll X; cin >> X;

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

    ll ans = oo;
    for (int k = 1; k <= n; k++) { // we'll pick exactly k elements from A
        // Clear dp[][]
        // std::fill() doesn't work for some reason
        for (int i = 0; i < N; i++)
            for (int j = 0; j < N; j++)
                dp[i][j] = -oo;

        // Run a knapsack
        dp[0][0] = 0;
        for (int i = 0; i < n; i++) { // put the i-th element of A in the knapsack
            ll x = a[i];
            for (int j = k; j > 0; j--) { // the current subset has j elements
                for (int m = 0; m < k; m++) { // and the "previous" subset has sum = m (mod k)
                    ll sum = dp[j-1][m];
                    ll m2 = (x + sum) % k;
                    if (sum >= 0)
                        dp[j][m2] = max(dp[j][m2], x + sum);
                }
            }
        }

        // Get the best answer for a subset of A with size k
        ll cur = dp[k][X % k];
        debugf("k = %d, cur = %lld\n", k, cur);
        if (cur >= 0) {
            ans = min(ans, (X - cur) / k);
        }
    }

    cout << ans << endl;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<ll,int>
#define PI 3.141592653589793
#define pb push_back
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 998244353;
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	x--; y--;
	vector<vector<ll>> b(n), t(n), k(n);
	vector<ll> mp(n, MX);

	rep(i, m) {
		int ai, bi, ti, ki;
		cin >> ai >> bi >> ti >> ki;
		ai--; bi--;
		b[ai].pb(bi);
		t[ai].pb(ti);
		k[ai].pb(ki);
		b[bi].pb(ai);
		t[bi].pb(ti);
		k[bi].pb(ki);
	}
	priority_queue<P> q;//（現在時刻*-1、場所）
	q.push(P(0, x));
	while (!q.empty()) {
		ll nt = q.top().first;
		nt *= -1;
		int now= q.top().second;
		q.pop();

		rep(i, b[now].size()) {
			ll next = nt + t[now][i] + k[now][i] - nt % k[now][i];
			if (nt % k[now][i] == 0) {
				next = nt + t[now][i];
			}

			if (next < mp[b[now][i]]) {
				mp[b[now][i]] = next;
				q.push(P(-next, b[now][i]));
			}
		}
	}

	if (mp[y] == MX) cout << -1 << endl;
	else cout << mp[y] << endl;
}

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

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,ll> ii;
typedef vector<vector<ll>> matrix;

const int mod = 1e9 + 7;
const ll INF = 1e18;
const double EPSILON = 1e-9;
const int N = 2*1e5+5;
vector<pair<int, ii>> adj[N];
priority_queue <ii, vector <ii>, greater <ii>> pq;
int main(){
    fastio;
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    for(int i = 0; i < m; i++){
        int u,v,c,t; cin >> u >> v >> c >> t;
        adj[u].pb({v, {c,t}});
        adj[v].pb({u, {c,t}});
    }
    vector<ll> see(n+1, INF);
    pq.push({0, x});
    see[x] = 0;
    while(!pq.empty()){
        ll d = pq.top().fst;
        int v = pq.top().snd;
        pq.pop();
        if(d > see[v])
            continue;
        for(auto i:adj[v]){
            ll cost = i.snd.fst + (i.snd.snd*((d+i.snd.snd-1)/i.snd.snd) - d);
            if(see[i.fst] > d + cost){
                see[i.fst] = d + cost;
                pq.push({see[i.fst], i.fst});
            }
        }
    }
    cout << (see[y] == INF ? -1 : see[y]) << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<pll> vpll;
typedef vector<bool> vbl;
typedef vector<vector<bool>> vvbl;

void INX(){}
template<typename Head, typename... Tail>
void INX(Head&& head, Tail&&... tail)
{
    cin >> head;
    INX(forward<Tail>(tail)...);
}
void OUTX(){}
template<typename Head, typename... Tail>
void OUTX(Head&& head, Tail&&... tail)
{
    cout << head << endl;
    OUTX(forward<Tail>(tail)...);
}
void OUTX2(){cout << endl;}
template<typename Head, typename... Tail>
void OUTX2(Head&& head, Tail&&... tail)
{
    cout << head << ' ';
    OUTX2(forward<Tail>(tail)...);
}

#define ADD emplace_back
#define MP make_pair
#define VVEC(type) vector<vector<type>>
#define __LONG_LONG_MIN__ (-__LONG_LONG_MAX__ - 1)

//#define MOD 1000000007 // 10^9 + 7
//setprecision(10)

int main()
{
    string S;
    INX(S);

    ll result = 0;
    char lastcnt = 0;
    char pre = 0;
    ll cnt = 0;
    bool iscont = false;
    for (ll i = 0; i < (ll)S.size(); i++)
    {
        char si = S[i];
        if(iscont)
        {
            if(pre == si)
            {
                //
            }
            else
            {
                iscont = false;
                lastcnt = pre;
                cnt++;
            }
        }
        else
        {
            if(lastcnt == si)
            {
                result--;
            }
            else if(pre == si)
            {
                iscont = true;
            }
            else
            {
                //
            }
        }

        result += cnt;
        pre = si;
    }
    OUTX(result);

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ri register int
#define ll long long
#define ui unsigned int
il ll read(){
    bool f=true;ll x=0;
    register char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=false;ch=getchar();}
    while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
    if(f) return x;
    return ~(--x);
}
il int read(char *s){
    int len=0;
    register char ch=getchar();
    while(ch==' '||ch=='\n') ch=getchar();
    while(ch!=' '&&ch!='\n'&&ch!=EOF) s[++len]=ch,ch=getchar();
    return len;
}
il void write(const ll &x){if(x>9) write(x/10);putchar(x%10+'0');}
il void print(const ll &x) {x<0?putchar('-'),write(~(x-1)):write(x);putchar('\n');}
il ll max(const ll &a,const ll &b){return a>b?a:b;}
il ll min(const ll &a,const ll &b){return a<b?a:b;}
const int MAXN=2e5+7;
char s[MAXN];
int n;
ll cnt;
ll b[26];
int main(){
    scanf("%s",s+1);
    n=strlen(s+1);
    b[s[n]-'a']++;
    for(ri i=n-1;i>1;--i){
        // int j=i;
        if(s[i]==s[i-1]){
            cnt+=n-i-b[s[i]-'a'];
            memset(b,0,sizeof(b));
            b[s[i]-'a']=n-i;
        }
        b[s[i]-'a']++;
    }
    print(cnt);
    return 0;
}


#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
#define lambda(RES_TYPE, ...) (function<RES_TYPE(__VA_ARGS__)>)[&](__VA_ARGS__) -> RES_TYPE
#define method(FUNC_NAME, RES_TYPE, ...) function<RES_TYPE(__VA_ARGS__)> FUNC_NAME = lambda(RES_TYPE, __VA_ARGS__)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    cin >> res;
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int func(){
    int n = in();
    string str = in<string>();
    string res = "";
    foreach(i,str){
        res += i;
        while(res.size()>=3 and res.substr(res.size()-3)=="fox"){
            res.erase(res.begin()+res.size()-3,res.end());
        }
    }
    return res.size();
}

int main(){
    cout << func() << endl;
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MAXX 500005
#define PI   M_PI
#define pb push_back
#define F first
#define S second
#define fixx(n) fixed << setprecision(n)
#define ll  long long
#define int ll
const int mod = 1e9 + 7;

signed main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    string s;
    cin >> n >> s;
    string h = "";
    for(int i = 0 ;i < s.size(); i ++){
    	h += (s[i]);
    	while(h.size() >= 3 && h.substr(h.size() - 3, 3) == "fox"){

    			h.erase( h.size() - 1);
    			h.erase(h.size() - 1);
    			h.erase(h.size() - 1);
    	}
    }
    cout << h.size();
    return 0;
}


#include <cstdio>
#include <vector>
#include <algorithm>

int n;
std::vector<int> tree[100000];

constexpr int INF = 100000000;

int size[100000];
int dp[100000];

int size_dfs(int v){
  for(int c: tree[v]){
    size[v] += size_dfs(c);
  }
  return size[v] += 1;
}

int dfs(int v){
  if(dp[v] != INF) return dp[v];

  dp[v] = 1;
  int other = 0;
  std::vector<int> rest;
  for(int c: tree[v]){
    int w = dfs(c);
    if(size[c] % 2 == 0 && w < 0) dp[v] += w;
    else if(size[c] % 2 == 1) rest.push_back(w);
    else other += w;
  }
  std::sort(rest.begin(), rest.end());
  for(int i = 0; i < rest.size(); i++){
    dp[v] += rest[i++];
    if(i < rest.size()) dp[v] -= rest[i];
  }
  if(rest.size() % 2 == 0) dp[v] += other;
  else dp[v] -= other;

// printf("%d %d\n", v, dp[v]);
  return dp[v];
}

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n-1; i++){
    int p;
    scanf("%d", &p);
    tree[p-1].push_back(i+1);
  }

  size_dfs(0);

  for(int i = 0; i < n; i++) dp[i] = INF;
  auto z = dfs(0);

  printf("%d\n", (z + n)/2);

  return 0;
}

#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int> ii;

vector<vector<int>> adj;
vector<int> p, sz;

void dfs(int u){
  sz[u] = 1;
  for(int v : adj[u]){
    if(v != p[u]){
      dfs(v);
      sz[u] += sz[v];
    }
  }
}

vector<int> memo;

int max_coins(int u){
  if(memo[u] != -1) return memo[u];
  vector<ii> balances_even, balances_odd;

  for(int v : adj[u]){
    if(v == p[u]) continue;
    int p1 = max_coins(v);
    int p2 = sz[v] - p1;
    int balance = p1 - p2;

    if(sz[v] & 1){
      balances_odd.push_back({balance, v});
    } else {
      balances_even.push_back({balance, v});
    }
  }

  sort(balances_even.begin(), balances_even.end());
  sort(balances_odd.begin(), balances_odd.end());
  int coins = 0;

  while(!balances_even.empty() and
	balances_even.back().first > 0){
    int v = balances_even.back().second;
    coins += max_coins(v);
    balances_even.pop_back();
  }

  int p = 0;

  while(!balances_odd.empty()){
    int v = balances_odd.back().second;
    if(p == 0) coins += max_coins(v);
    else coins += sz[v] - max_coins(v);
    balances_odd.pop_back();
    p ^= 1;
  }

  while(!balances_even.empty()){
    int v = balances_even.back().second;
    if(p == 0) coins += max_coins(v);
    else coins += sz[v] - max_coins(v);
    balances_even.pop_back();
  }

  return memo[u] = coins;
}

int main(){
  int n;
  while(scanf("%d", &n) > 0){
    adj.assign(n+1, vector<int>());
    sz.assign(n+1, 0);
    p.assign(n+1, 0);

    for(int i = 2; i <= n; i++){
      scanf("%d", &p[i]);
      adj[p[i]].push_back(i);
    }

    dfs(1);

    memo.assign(n+1, -1);
    printf("%d\n", sz[1] - max_coins(1));
  }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define f first
#define s second
#define mk make_pair
ll mod(ll B,ll P,ll M)
{
    if(P==0)
        return 1;
    else if(P==1)
       return B%M;
    else if(P%2==0){
      ll x=mod(B,P/2,M)%M;
      return ((x*x)%M);
    }
    else if(P%2){
      ll x=mod(B,(P-1)/2,M)%M;
      ll x2=(x*x)%M;
      return ((x2)*(B%M))%M;
    }
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
  int t=1;
  //cin>>t;
  while(t--)
  {
    ll ans=0;
    ll modulo=998244353;
    ll n,m,k;
    cin>>n>>m>>k;
    if(n==1&&m==1)
    {
      ans=k;
    }
    else if(n==1)
    {
      ans=mod(k,m,modulo);
    }
    else if(m==1)
    {
      ans=mod(k,n,modulo);
    }
    else
    {
      for(int i=1;i<=k;i++)
      {
        ll in=mod(i,n,modulo);
        ll in1=mod(i-1,n,modulo);
        ll term1=(in-in1+modulo)%modulo;
        ll term2=mod(k-i+1,m,modulo);
        ans=(ans+term1*term2)%modulo;
      }
    }
    cout<<ans;
  }//while
}//main

#include<bits/stdc++.h>
using namespace std;
int read() {
	char c=getchar(); int x=0,f=1;
	while (c<'0' || c>'9') {
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
const int p=998244353;
int f[200005],g[200005],sf[200005];
int pow_mod(int x,int k) {
	int ans=1;
	while (k) {
		if (k&1) ans=1LL*ans*x%p;
		x=1LL*x*x%p;
		k>>=1;
	}
	return ans;
}
void add(int &x,int y) {
	x+=y;
	if (x>=p) x-=p;
}
int main() {
	int n=read(),m=read(),k=read();
	for (int i=1; i<=k; i++) f[i]=(pow_mod(i,n)-pow_mod(i-1,n)+p)%p;
	for (int i=1; i<=k; i++) g[i]=(pow_mod(i,m)-pow_mod(i-1,m)+p)%p;
	sf[0]=0;
	for (int i=1; i<=k; i++) sf[i]=(sf[i-1]+f[i])%p;
	int ans=0;
	if (n==1 || m==1) {
		for (int i=1; i<=k; i++) add(ans,1LL*f[i]*g[k+1-i]%p);
	}
	else {
		for (int i=1; i<=k; i++) add(ans,1LL*sf[i]*g[k+1-i]%p);
	}
	cout<<ans<<endl;
	return 0;
}