#include <bits/stdc++.h>

using namespace std;

#define MS(a, b) memset(a, b, sizeof(a))
#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define EREP(a, b) for (register int a = head[b]; a; a = edge[a].nxt)

inline int rd() {
    int x = 0; char c = getchar(); bool f = 0;
    while (c < '0' && c != '-') c = getchar();
    if (c == '-') f = 1, c = getchar();
    while (c >= '0') x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
    return f ? -x : x;
}

const int SIZE = 2e5 + 100;

int n;

int head[SIZE], ecnt;
struct Edge {
	int v, nxt;
} edge[SIZE << 1];
void Add_Edge (int u, int v) {
	edge[++ecnt] = (Edge) { v, head[u] };
	head[u] = ecnt;
}

int dep[SIZE], F[SIZE];
int mx[SIZE][2];
int Len = -1, A, B;
void dfs (int u, int fa) {
	F[u] = fa;
	dep[u] = dep[fa] + 1;
	mx[u][0] = mx[u][1] = u;
	EREP (i, u) {
		int v = edge[i].v;
		if (v == fa) continue;
		dfs(v, u);
		if (dep[mx[v][0]] > dep[mx[u][0]])
			mx[u][1] = mx[u][0], mx[u][0] = mx[v][0];
		else if (dep[mx[v][0]] > dep[mx[u][1]])
			mx[u][1] = mx[v][0];
	}
	if (dep[mx[u][0]] + dep[mx[u][1]] - 2 * dep[u] > Len) {
		Len = dep[mx[u][0]] + dep[mx[u][1]] - 2 * dep[u];
		A = mx[u][0];
		B = mx[u][1];
	}
}
bool mark[SIZE];
int E;
int ans[SIZE];
void D (int u, int fa) {
	++E;
	ans[u] = E;
	EREP (i, u) {
		int v = edge[i].v;
		if (v == fa) continue;
		if (!mark[v]) D(v, u);
	}
	EREP (i, u) {
		int v = edge[i].v;
		if (v == fa) continue;
		if (mark[v]) D(v, u);
	}
	++E;
}

void _main () {
	n = rd();
	FOR (i, 1, n) {
		int u = rd(), v = rd();
		Add_Edge(u, v);
		Add_Edge(v, u);
	}
	dfs(1, 0);
	int T = A;
	while (A != B) {
		if (dep[A] < dep[B]) swap(A, B);
		mark[A] = 1;
		A = F[A];
	} mark[A] = 1;
	D(T, 0);
	REP (i, 1, n) printf ("%d ", ans[i]);
}

int main () {
#ifdef LOCAL
	freopen("in.txt", "r", stdin);
#endif
	_main();
	return 0;
}

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

const int64_t MOD = 1e9 + 7;
const int64_t MOD2 = 998244353;
const int INF = 2e9;
const long long inf = 1LL<<60;
template<typename T>
bool chmin(T& x, const T& y){
  if(x <= y) return false;
  x = y;
  return true;
}
template<typename T>
bool chmax(T& x, const T& y){
  if(x >= y) return false;
  x = y;
  return true;
}
void Dijkstra(int s, vector<vector<pair<long long, long long>>> &G, vector<long long> &d) {
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> q;
  d[s] = 0;
  q.push({0, s});
  while (!q.empty()) {
    auto k = q.top();
    q.pop();
    if (d[k.second] != k.first) continue;
    for (auto p : G[k.second]) {
      long long next = k.first + p.second;
      if (chmin(d[p.first], next)) q.push({next, p.first});
    }
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> a(m), b(m);
  vector<char> c(m);
  vector<vector<pair<long long, long long>>> G(n*n+1);
  for (int i=0; i<m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--; b[i]--;
    G[a[i]*n+b[i]].push_back({n*n, 1});
    G[b[i]*n+a[i]].push_back({n*n, 1});
  }
  for (int i=0; i<m; i++) {
    for (int j=0; j<m; j++) {
      if (c[i] == c[j]) {
        G[a[i]*n+a[j]].push_back({b[i]*n+b[j], 2});
        G[b[i]*n+b[j]].push_back({a[i]*n+a[j], 2});
        G[a[i]*n+b[j]].push_back({b[i]*n+a[j], 2});
        G[b[i]*n+a[j]].push_back({a[i]*n+b[j], 2});
      }
    }
  }
  /*
  vector<vector<pair<int, int>>> alp(26);
  for (int i=0; i<m; i++) {
    int a, b;
    char c;
    cin >> a >> b >> c;
    a--; b--;
    alp[c - 'a'].push_back({a, b});
    alp[c - 'a'].push_back({b, a});
  }*/
  /*
  for (int i=0; i<26; i++) {
    for (int j=0; j<(int)alp[i].size(); j++) {
      for (int k=j+1; k<(int)alp[i].size(); k++) {
        long long a = alp[i][j].first, b = alp[i][j].second;
        long long c = alp[i][k].first, d = alp[i][k].second;
        G[a*n+d].push_back({b*n+c, 2});
        G[b*n+c].push_back({a*n+d, 2});
        G[a*n+c].push_back({b*n+d, 2});
        G[b*n+d].push_back({a*n+c, 2});
      }
    }
  }*/
  for (int i=0; i<n; i++) {
    G[i*n+i].push_back({n*n, 0});
  }/*
  for (int i=0; i<26; i++) {
    for (auto p : alp[i]) {
      G[p.first*n+p.second].push_back({n*n, 1});
      G[p.second*n+p.first].push_back({n*n, 1});
    }
  }*/
  vector<long long> d(n*n+1, inf);
  Dijkstra((long long)(n-1), G, d);
  if (d[n*n] >= inf) cout << -1 << endl;
  else cout << d[n*n] << endl;
}


#include<iostream>

using namespace std;

int main(){
    int a,b,c,d;

    cin >> a >> b ;
    cin >> c >> d ;

    cout << (a*d) - (c*b);

    return 0;
}

#include<iostream>
#include<string>
#include<cmath>
using namespace std;
long long int R,X,Y,ans,p;
double q;
int main(){
	cin>>R>>X>>Y;
  	p=sqrt(X*X+Y*Y)/R;
  	if(R*p!=sqrt(X*X+Y*Y))p++;
    if(p==1){
      	if(sqrt(X*X+Y*Y)!=R)p++;
    }

  	cout<<p<<endl;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define endl "\n"
ll mod=1000000007;
ll arr[10][10],n,k;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll finds(set<int> st,ll sum,ll prev)
{
    //cout<<"yo "<<st.size()<<" "<<prev<<" "<<sum<<endl;
    if(st.size()==0 && sum+arr[prev][0]==k)return 1;
    if(st.size()==0)return 0;
    ll ans=0;
    for(int i:st)
    {
        set<int> st1;
        st1=st;
        st1.erase(i);
        ans+=finds(st1,sum+arr[i][prev],i);

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

    //ll t;cin>>t;while(t--)
    {
        ll a,b,c,d,i,j,sum=0,temp=0,f=0,cnt=0;
        cin>>n>>k;
        for(i=0;i<n;i++)
            for(j=0;j<n;j++)
                cin>>arr[i][j];
        set<int>st;
        for(i=1;i<n;i++)
            st.insert(i);
        cout<<finds(st,0,0);

    }
}

#include <bits/stdc++.h>
#define Fr(i,a,b) for(int i=(a);i<=(b);++i)
#define Fl(i,a,b) for(int i=(a);i>=(b);--i)
#define Fe(i,u) for(int i=H[u];i;i=e[i].nx)
#define ms(a,x) memset((a),(x),sizeof(a));
using namespace std;
int N,G[15][15],K,vis[15],ans;
void dfs(int s,int x,int sum)
{
	if(x==N)
	{
		if(G[s][1]+sum==K)++ans;
		return;
	}
	Fr(i,2,N)
	{
		if(!vis[i])
		{
			vis[i]=1;
			dfs(i,x+1,sum+G[s][i]);
			vis[i]=0;
		}
	}
}
int main()
{
	scanf("%d%d",&N,&K);
	Fr(i,1,N)Fr(j,1,N)scanf("%d",&G[i][j]);
	dfs(1,1,0);
	cout<<ans;
}


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

typedef long long LL;

const int N=1000;
const char str[10]=" atcoder";

char s[N+9];
int n;

void into(){
  scanf("%s",s+1);
  n=strlen(s+1);
}

int ans;

void Get_ans(){
  ans=0;
  int flag=0;
  for (int i=1;i<=n&&i<=7;++i)
	if (s[i]>str[i]) return;
    else if (s[i]<str[i]) {flag=1;break;}
  if (!flag&&n>7) return;
  for (int i=1;i<=n;++i)
	if (s[i]^'a'){
	  ans=s[i]>'t'?i-2:i-1;
	  return;
	}
  ans=-1;
}

void work(){
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  int T;
  scanf("%d",&T);
  for (;T--;){
    into();
    work();
    outo();
  }
  return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << (x) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using prique = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

int main() {
	int t;
	cin >> t;
	while (t--) {
		string s;
		cin >> s;
		int n = s.size();
		string atcoder = "atcoder";
		if (s > atcoder) {
			cout << "0\n";
			continue;
		}
		int ans = inf;
		int tmp = 0;
		for (int i = 0; i < min(7, n); i++) {
			int r = -1;
			for (int j = i; j < n; j++) {
				if (s[j] > atcoder[i]) {
					r = j;
					break;
				}
			}
			if (r != -1) {
				chmin(ans, tmp + r - i);
			}
			int q = -1;
			for (int j = i; j < n; j++) {
				if (s[j] == atcoder[i]) {
					q = j;
					break;
				}
			}
			for (int j = q; j > i; j--) swap(s[j], s[j - 1]);
			if (q != -1) tmp += q - i;
			else tmp = inf;
		}
		cout << (ans == inf ? -1 : ans) << '\n';
	}
}


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

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

void Main()
{
    string S;
    cin >> S;

    string new_S = S.substr(1);
    new_S = new_S + S.at(0);

    cout << new_S << endl;
}

int main()
{
    Main();
    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;

class BLog {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        int l = 1;
        int r = 1e10 + 7;
        while (r - l > 1) {
            int mid = (r + l) / 2;
            int sum = mid * (mid + 1) / 2;
            if (sum <= N + 1) {
                l = mid;
            } else {
                r = mid;
            }
        }
        cout << N - l + 1 << endl;
    }
};

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

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


#include <bits/stdc++.h>
/** 幾何ライブラリ **/
#include <complex>
using namespace std;

typedef long long ll;
const int N = 2e5 + 5, mod = 998244353;

int fact[N], inv[N];

vector<int> primes[N];

int mul(int a, int b)
{
  return 1ll * a * b % mod;
}

int add(int a, int b)
{
  return (a + b) % mod;
}

int fp(int b, int p)
{
  if (!p)
    return 1;
  ll ret = fp(b, p >> 1);
  ret = ret * ret % mod;
  if (p & 1)
    ret = ret * b % mod;
  return ret;
}

void pre()
{
  fact[0] = inv[0] = 1;
  for (int i = 1; i < N; i++)
  {
    fact[i] = mul(fact[i - 1], i);
    inv[i] = fp(fact[i], mod - 2);
  }
}

int ncr(int n, int r)
{
  if (n < r)
    return 0;
  int ret = mul(fact[n], inv[n - r]);
  return mul(ret, inv[r]);
}

int main()
{
  pre();
  int n, m;
  cin >> n >> m;
  if (n == 1)
    return cout << m, 0;
  for (int i = 2; i <= m; i++)
  {
    if ((int)primes[i].size() > 0)
      continue;
    for (int j = i; j <= m; j += i)
    {
      int c = 1, tmp = j;
      while (tmp % i == 0)
      {
        tmp /= i;
        c++;
      }
      primes[j].push_back(c);
    }
  }
  int ans = 0;
  for (int i = 1; i <= m; i++)
  {
    int tmp = 1;
    for (auto j : primes[i])
    {
      int sum = 0;
      for (int k = 1; k <= j; k++)
      {
        sum = add(sum, mul(ncr(n - 2, k - 1), ncr(j, k)));
      }
      tmp = mul(tmp, sum);
    }
    ans = add(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T,class U>
inline bool chmax(T &a,U b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
template<class T,class U>
inline bool chmin(T &a,U b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
constexpr int INF=1000000000;
constexpr ll llINF=3000000000000000000;
constexpr int mod=998244353;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
/*
vector<vector<ll>>C,sC;
void init_comb(int n,int m){
    C.resize(n+1,vector<ll>(m+1,0));
    sC.resize(n+1,vector<ll>(m+1,0));
    C[0][0]=1;
    for(int i=1;i<=n;i++){
        C[i][0]=1;
        for(int j=1;j<=m;j++){
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
        }
    }
    rep(i,n+1){
        rep(j,m){
            sC[i][j+1]=(sC[i][j]+C[i][j])%mod;
        }
    }
}*/
ll gcd(ll a,ll b){
    while(a%b){
        a%=b;
        swap(a,b);
    }
    return b;
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
bool isprime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>primes;
void init_prime(int n){
	primes.push_back(2);
    for(int i=3;i<=n;i+=2){
        bool f=true;
        for(int j:primes){
            if(j*j>i)break;
            if(i%j==0){
                f=false;
                break;
            }
        }
        if(f)primes.push_back(i);
    }
}
ll modpow(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1){
            res*=a;
            res%=mod;
        }
        a*=a;
        a%=mod;
        b>>=1;
    }
    return res;
}
vector<ll>inv,fact,factinv;
void init_fact(int n){
    inv.resize(n+1);
    fact.resize(n+1);
    factinv.resize(n+1);
    inv[0]=0;
    inv[1]=1;
    fact[0]=1;
    factinv[0]=1;
    for(ll i=1;i<=n;i++){
        if(i>=2)inv[i]=mod-((mod/i)*inv[mod%i]%mod);
        fact[i]=(fact[i-1]*i)%mod;
        factinv[i]=factinv[i-1]*inv[i]%mod;
    }
}
ll _inv(ll a,ll m=mod){
    //gcd(a,m) must be 1
    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 comb(int a,int b){
    if(a<b)return 0;
    if(a<0)return 0;
    return fact[a]*factinv[a-b]%mod*factinv[b]%mod;
}
ll multicomb(int a,int b){
    return comb(a+b-1,b);
}
int dp[20][200010];
void solve(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++)dp[0][i]=1;
    rep(k,19){
        for(int i=2;i<=m;i++){
            for(int j=1;j*i<=m;j++){
                dp[k+1][i*j]+=dp[k][j];
                if(dp[k+1][i*j]>=mod)dp[k+1][i*j]-=mod;
            }
        }
    }
    int ans=0;
    init_fact(n-1);
    rep(k,20){
        if(k>n-1)continue;
        int sum=0;
        for(int i=1;i<=m;i++){
            sum+=dp[k][i];
            sum%=mod;
        }
            ans+=comb(n-1,k)*sum%mod;
            ans%=mod;
    }
    cout<<ans<<endl;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define V vector<long long>
#define VV vector<vector<long long>>
#define VVV vector<vector<vector<long long>>>
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0;(i)<(n);++(i))
#define rng(i,m,n) for(ll (i)=(m);(i)<(n);++(i))
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;--(i))
#define rrng(i,m,n) for(ll (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(x) cout<<__LINE__<<": "<<#x<<"=";view(x);
#else
#define debug(x) true
#endif
using namespace std;

string to_string(const string& e){return e;}
template<typename T,typename U> string to_string(const pair<T,U>& e){return "("+to_string(e.first)+","+to_string(e.second)+")";}
template<typename T> void view(const T& e){cout<<to_string(e)<<endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){cout<<to_string(e)<<" ";}cout<<endl;}
template<typename T> void view(const vector<vector<T>>& vv){cout<<endl;for(const auto& v : vv){view(v);}}

ll n;
string s;
VV ans;

bool ok(V &a,ll val){
    VV res(val,V());
    ll tmp=a[0];
    rep(i,val){
        res[i].push_back((tmp+val-i-1)/(val-i));
        tmp-=(tmp+val-i-1)/(val-i);
    }
    rep(i,n){
        deque<ll> div;
        tmp=a[i+1];
        rep(j,val){
            div.push_back((tmp+val-j-1)/(val-j));
            tmp-=(tmp+val-j-1)/(val-j);
        }
        if(s[i]=='<'){
            rep(j,val){
                if(res[j].back()<div.back()){
                    res[j].push_back(div.back());
                    div.pop_back();
                }else if(res[j].back()<div.front()){
                    res[j].push_back(div.front());
                    div.pop_front();
                }else{
                    return false;
                }
            }
        }else{
            rep(j,val){
                if(res[j].back()>div.front()){
                    res[j].push_back(div.front());
                    div.pop_front();
                }else if(res[j].back()>div.back()){
                    res[j].push_back(div.back());
                    div.pop_back();
                }else{
                    return false;
                }
            }
        }
    }
    ans=res;
    return true;
}

int main(){
    cin>>n;
    cin>>s;
    V a(n+1);
    rep(i,n+1)cin>>a[i];
    ll l=0;
    ll r=1e5;
    rep(i,20){
        ll mid=(l+r)/2;
        if(ok(a,mid))l=mid;
        else r=mid;
    }
    cout<<l<<endl;
    rep(i,l)view(ans[i]);
}

// In the name of god
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#define Sort(x) sort(all(x))
#define debug(x) cerr << #x << " : " << x << "\n"
#define use_file freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef string str;

const ll maxn = 105, inf = 1e18;
long long n, a[maxn], b[maxn];
str s;
int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	ll k = inf;
	cin >> n >> s;
	for(ll i = 0; i <= n ; i ++){
		cin >> a[i];
		if(i)k = min(k, abs(a[i] - a[i - 1]));
	}
	cout << k << "\n";
	ll m = k;
	for(ll i = 1; i <= k; i ++){
		for(ll j = 0; j <= n; j ++){
			ll x = (a[j] + m - 1ll) / m;
			cout << x << ' ';
			a[j] -= x;
		}
		m --;
		cout << "\n";
	}
}


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

#define pb push_back
#define mp make_pair
#define f1 first
#define s2 second

#define fastio ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(x...) cerr << "[" << #x << "]: " << x << "\n";

using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using pl = pair<ll, ll>;

ld const PI = 4*atan((ld)1);

int const N = 5e5 + 7;

int n;
char s[N], t[N];

int main()
{
	fastio;

	cin >> n >> s >> t;

	int s_1 = 0;
	int t_1 = 0;
	for (int i = 0; i < n; ++i)
		s_1 += s[i] == '1';
	for (int i = 0; i < n; ++i)
		t_1 += t[i] == '1';

	if (s_1 < t_1 || (s_1 - t_1) % 2 == 1)
	{
		cout << -1 << '\n';
		return 0;
	}

	queue<int> q;
	for (int i = 0; i < n; ++i)
	{
		if (s[i] == '1')
			q.push(i);
	}

	ll res = 0;
	for (int i = 0; i < n; ++i)
	{
		if (t[i] == '0')
		{
			if (!q.empty() && i >= q.front())
			{
				int tmp = q.front();
				q.pop();

				if (q.empty())
				{
					cout << -1 << '\n';
					return 0;
				}

				res += q.front() - tmp;
				q.pop();
			}
		}
		else
		{
			if (q.empty())
			{
				cout << -1 << '\n';
				return 0;
			}

			res += q.front() - i;
			q.pop();
		}
	}
	cout << res << '\n';

	return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int N=5e5+1;
int n;
int a[N],b[N];
deque<int>p,q;
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	int z=0;
	for(int i=1; i<=n ;i++){
		char c;cin >> c;
		if(c=='1') p.push_back(i);
	}
	for(int i=1; i<=n ;i++){
		char c;cin >> c;
		if(c=='1') q.push_back(i);
	}
	if(p.size()%2!=q.size()%2) return cout << "-1\n",0;
	ll ans=0;
	while(!q.empty()){
		if(p.front()<q.front()){
			if(p.size()>=2){
				int x=p.front();
				p.pop_front();
				int y=p.front();
				p.pop_front();
				ans+=y-x;
			}
			else return cout << "-1\n",0;
		}
		else{
			if(p.empty()) return cout << "-1\n",0;
			ans+=p.front()-q.front();
			p.pop_front();q.pop_front();
		}
	}
	while(!p.empty()){
		int x=p.front();
		p.pop_front();
		int y=p.front();
		p.pop_front();
		ans+=y-x;
	}
	cout << ans << '\n';
}


// Created by ash_98

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

#define mx 3005
#define ll long long
#define mod 1000000007

ll ar[mx];
char ch[mx];
int n,m,ii,k;
vector<pair<int,int>>g[mx];
int add(int a,int b)
{
   a+=b;
   if(a>=mod)a-=mod;
   return a;
}
int dp[mx][mx];
bool vis[mx][mx];
ll pre[mx];

void solve()
{
   scanf("%d",&n);
   for(int i=1;i<=n;i++)scanf("%lld",&ar[i]),pre[i]=pre[i-1]+ar[i];
   dp[1][0]++;
   int re=0;
   for(int i=1;i<=n;i++)
   {

      for(int j=n;j>=1;j--)
      {
         dp[j+1][pre[i]%(j+1)]=add(dp[j+1][pre[i]%(j+1)],dp[j][pre[i]%j]);
         if(i==n)
         {
            re=add(re,dp[j][pre[i]%j]);
         }
      }

   }
   printf("%d\n",re);

}

int main()
{
   int t=1;
   //scanf("%d",&t);
   while(t--)solve();
   return 0;
}

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

int n, t;

void bit(vector<int> v, vector<int> &s) {
    int l = v.size();
    for (int mask = 0; mask < (1 << l); mask++) {
        int sum = 0;
        for (int i = 0; i < l; i++) {
            if (mask & (1 << i)) sum += v[i];
            if (sum > t)
            	goto end;
        }
        s.push_back(sum);
        end:;
    }
}

int main() {
    cin >> n >> t;
    vector<int> A, B;
    for (int i = 0, a; i < n; i++) {
        cin >> a;
        if (i % 2) A.push_back(a);
        else B.push_back(a);
    }

    vector<int> C, D;
    bit(A, C);
    bit(B, D);
    sort(C.begin(), C.end());
    sort(D.begin(), D.end());

    int ans = 0;
    for (int a : C)
        ans = max(ans, a + (*--upper_bound(D.begin(), D.end(), t - a)));

    cout << ans << endl;
}


#include <bits/stdc++.h>

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int n, m, a, b;
ll res;
string s;

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

	cin >> n >> m;
	forn (i, n) {
		cin >> s;
		int cn = 0;
		forn (j, m)
			cn += s[j] == '1';
		if (cn % 2) {
			res += a;
			b++;
		} else {
			res += b;
			a++;
		}
	}

	cout << res << endl;

	return 0;
}

#include <bits/stdc++.h>
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#define int long long
#define ri register
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define is insert
#define es erase
#define E (n+m)
using namespace std;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
signed main()
{
	int n=read();
	for(ri int i=0;i<n;i++)
	{
		printf("%lld %lld\n",(i*2+1)%n+1,(i*2+2)%n+1);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const long nPrime = 1000000007;
//const long nPrime = 998244353;
int main() {
    long n;
    cin >> n;
    vector<long> viNum(n);
    for(long i = 0; i < n; i++){
        cin >> viNum[i];
    }
    viNum.push_back(0);
    sort(viNum.rbegin(), viNum.rend());
    long nAns = 1;
    for(long i = 0; i < n; i++){
        nAns *= (viNum[i] - viNum[i+1] + 1);
        nAns %= nPrime;
    }
    cout << nAns << endl;
    return 0;
}

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

#define stp(var, init, end) for (auto var = init; var < end; ++var)
#define stpe(var, init, end) for (auto var = init; var <= end; ++var)
#define ll long long

#define MOD 1000000007
int main(void)
{
    int n;
    cin >> n;
    set<int> bui;
    int a;
    stp(i, 0, n)
    {
        cin >> a;
        bui.insert(a);
    }

    int bef = 0;
    ll out = 1;
    for (auto iter = bui.begin(); iter != bui.end(); ++iter)
    {
        out = (out * (*iter - bef + 1)) % MOD;
        bef = *iter;
    }
    cout << out;
    return 0;
}


#include <iostream>
#include <string>

int main(void){
 std::string s;
  std::cin >> s;
  for(int i = 0; i < s.length(); i++){
  	if(s[i] == '.') break;
    std::cout << s[i];
  }
  std::cout << '\n';
  return 0;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int32_t main()
{
	IOS
	//freopen("input.txt", "r", stdin);
	string s; cin >> s;
	for(char c:s){
		if (c == '.') break;
		cout << c;
	}
	cout << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch TaxIncludedPrice | diff TaxIncludedPrice.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address TaxIncludedPrice.cpp && ./a.out

/*

 5/9/2021

 22:56-

 */

LL N;
int T;

void solve() {
  LL good=0, bad=1e15;
  while(abs(good-bad)>1) {
    LL m=(good+bad)/2;
    LL x=m*(100+T)/100;
    (((x-m)<=N-1)?good:bad)=m;
  }

  LL x1=good*(100+T)/100;
  LL x2=(good+1)*(100+T)/100;
  assert(x2==x1+2);
  assert(x1-good==N-1);
  cout<<x1+1<<endl;
}

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

  cin>>T>>N;
  solve();

  return 0;
}

#include <bits/stdc++.h>

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

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

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

template<int mod>
class ModInt {
    private:
        long long val;
    public:
        constexpr ModInt(const long long v = 0) : val(v%mod) { if (val < 0) val += mod; }
        constexpr ModInt(const ModInt &v) : val(v.val) {}
        constexpr ModInt &operator=(const long long v) { val = v; return *this; }
        constexpr ModInt &operator=(const ModInt &v) { if (this != &v) val = v.val; return *this; }
        constexpr ModInt operator+() const { return ModInt(val); }
        constexpr ModInt operator-() const { return ModInt(-val); }
        constexpr ModInt operator+(const ModInt &v) const { return ModInt(*this) += v; }
        constexpr ModInt operator-(const ModInt &v) const { return ModInt(*this) -= v; }
        constexpr ModInt operator*(const ModInt &v) const { return ModInt(*this) *= v; }
        constexpr ModInt operator/(const ModInt &v) const { return ModInt(*this) /= v; }
        constexpr ModInt &operator+=(const ModInt &v) { val += v.val; if (val >= mod) val -= mod; return *this; }
        constexpr ModInt &operator-=(const ModInt &v) { val -= v.val; if (val < 0) val += mod; return *this; }
        constexpr ModInt &operator*=(const ModInt &v) { val *= v.val; if (val >= mod) val %= mod; return *this; }
        constexpr ModInt &operator/=(const ModInt &v) { val *= v.inverse().val; if (val >= mod) val %= mod; return *this; }
        constexpr ModInt &operator++() { ++val; if (val >= mod) val -= mod; return *this; }
        constexpr ModInt &operator--() { --val; if (val < 0) val += mod; return *this; }
        constexpr ModInt operator++(int) { ModInt tmp(*this); operator++(); return tmp; }
        constexpr ModInt operator--(int) { ModInt tmp(*this); operator--(); return tmp; }
        constexpr bool operator==(const ModInt &v) const { return val == v.val; }
        constexpr bool operator!=(const ModInt &v) const { return !(*this == v); }
        friend std::istream &operator>>(std::istream &s, ModInt &v) { long long tmp; s >> tmp; v = ModInt(tmp); return s; }
        friend std::ostream &operator<<(std::ostream &s, const ModInt &v) { return s << v.val; }
        constexpr ModInt inverse() const {
            long long n = val, res = 1;
            while (n > 1) {
                res *= (mod - mod / n);
                res %= mod;
                n = mod % n;
            }
            return ModInt(res);
        }
        static constexpr ModInt pow(ModInt v, long long n) {
            ModInt res(1);
            for ( ; n>0; n>>=1) {
                if (n & 1) res *= v;
                v *= v;
            }
            return res;
        }
};

using MInt = ModInt<MOD>;

void solve2() {
    ll N, A, B;
    cin >> N >> A >> B;

    if (A + B > N) {
        cout << 0 << '\n';
    } else {
        MInt n = N, a = A, b = B;
        MInt x = (n - a - b + 2) * (n - a - b + 1) / 2;
        x = (n - a + 1) * (n - b + 1) - x * 2;
        cout << (n - a + 1) * (n - a + 1) * (n - b + 1) * (n - b + 1) - x * x << '\n';
    }
}

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

    for (int i=0; i<T; ++i) solve2();
}

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

    solve();

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
const int INF = 1e9;
const int N = 100005;
/*   => int overflow
     => array bounds
     => special cases (n=1?)
     => do smth instead of nothing
     => stay organized
     => WRITE STUFF DOWN DON'T GET STUCK ON ONE APPROACH
     =>Read Stuff At Bottom !
*/

/*
struct DSU
{
    vector<int> sz;
    vector<int> parent;
    vector<int> value;
    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
        value[v] = 0;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        else
        {
            auto par = find_set(parent[v]);
            value[v]^=value[parent[v]];
            parent[v] = par;
            return par;
        }
    }

    void union_sets(int a, int b, int w) {
        find_set(a);
        find_set(b);

        w^=value[a]; w^=value[b];
        a = find_set(a);
        b = find_set(b);

        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            value[b] = w;
            sz[a] += sz[b];
        }
    }

    int val(int v)
    {
        find_set(v); return value[v];
    }

    DSU (int n)
    {
        parent.resize(n);
        sz.resize(n);
        value.resize(n);
        for (int i = 0; i<n; i++) make_set(i);
    }
};
*/
void solve(){
	string x,ans ; cin>>x;
	for(auto i:x)
	{
		if(i=='.')
			break;
		else{ans.push_back(i);};
	}
	cout<<ans<<endl;
}

void Solve()
{
	int t ; cin>>t;
	while(t--)
	{

	}
}
int main(){
	ios_base::sync_with_stdio(0);   cin.tie(0);  cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.in", "r", stdin);
		// freopen("king.out","w",stdout);
	#endif
	// Solve();
	solve();
	return 0;
}

#include <iostream>
#include <string>
#include <list>

using namespace std;

int main() {
    string input;
    getline(cin, input);
    for(int i=0; i<input.size(); i++)
        if(input[i]!='.')
            cout << input[i] << "";
        else
            break;
    return 0;
}


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

#define int                long long int
#define fi                first
#define se                second
#define pb                push_back
#define rep(i,a,n)        for(int i = a;i < n;i++)
#define vec               vector<int>
#define read(v,n)         rep(i,0,n) {cin>>v[i];}
#define pii               pair<int,int>
#define mpp               make_pair(a,b)
#define write(a,n)        rep(i,0,n) {cout<<a[i]<<" ";}cout<<endl;
#define all(v)            v.begin(),v.end()
#define srt(v)            sort(v.rbegin(),v.rend())
#define scn(a)            cin>>a
#define nl                endl
#define dbug(x)          cout << (#x) << " is " << (x) << endl
#define gcd(a,b)          __gcd(a,b)
#define bitcount(n)       __builtin_popcount(n)
#define IOS               ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod               1000000007

int ceil(int x, int y)
{
	if (x % y == 0)
		return x / y;
	else
		return x / y + 1;
}
void solve()
{
	int n;
	cin >> n;
	cout << ceil(n, 100) << endl;
}
signed main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	while (t-- > 0)
	{
		solve();
	}
#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif

}

#include <bits/stdc++.h>

using namespace std;
int mas[200000];
int main()
{
    vector<int> ans;
    int n;
    cin>>n;
    int n1=n;
    for(int i=0; i<n; i++) cin>>mas[i];
    for(int i=n-1; i>=0; i--){
        if(mas[i]==n1){
            int n2=0;
            for(int j=i+2; j<n1; j++){
                if(mas[j]!=j){
                    cout<<-1;
                    return 0;
                }
                n2++;
            }
            for(int j=i+1; j<n1; j++){
                ans.push_back(j);
            }
            if(n1-i!=1){
                swap(mas[i],mas[i+1]);
            }
            n1=n1-max(1,n2+1);
        }
    }
    if(ans.size()!=n-1){
        cout<<-1;
        return 0;
    }
    for(auto u:ans){
        cout<<u<<"\n";
    }
}


#include<iostream>
using namespace std;
int main()
{
    string s;
	int n,m;
	cin>>n>>m>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='x'&&m!=0)
		{
			m--;
		}
		else if(s[i]=='o')
		{
			m++;
		}
	}
	cout<<m;
  return 0;
}

//This Code was made by Chinese_zjc_.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <map>
#include <set>
#include <ctime>
// #include<windows.h>
// #define debug true
#define int long long
#define double long double
using namespace std;
const double PI = acos(-1);
const double eps = 0.0000000001;
const int INF = 0x3fffffffffffffff;
int n, x;
char c;
signed main()
{
    ios::sync_with_stdio(false);
    cin >> n >> x;
    for (int i = 1; i <= n; ++i)
    {
        cin >> c;
        if (c == 'o')
        {
            ++x;
        }
        else
        {
            x = max(x - 1, 0ll);
        }
    }
    cout << x << endl;
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define endl "\n"
using namespace std;

const int max_n = 2100;
const int max_len = 631441 + 100000;
const int max_sum = 1e7+100;
const int offset = 1e5+10;
const int inf = 1e18;
const int Mod = 3e12+7;
const int max_k = 18;

int n,m;
vector<pair<int,int> > adj[max_n];
int dist[max_n][max_n];

void fill(int s){
	for(int i=0;i<n;i++){
		dist[s][i]=inf;
	}
	dist[s][s]=0;

	bool visited[n];
	memset(visited,0,sizeof(visited));

	priority_queue<pair<int,int>,vector<pair<int,int> > ,greater<pair<int,int> > > p;
	p.push({dist[s][s],s});

	while(p.size()>0){
		int c = p.top().second;
		p.pop();

		if(visited[c]) continue;
		visited[c]=1;

		for(pair<int,int> x:adj[c]){
			if(dist[s][x.first]>dist[s][c]+x.second){
				dist[s][x.first]=dist[s][c]+x.second;
				// p.push({x.first,dist[s][x.first]});
				p.push({dist[s][x.first],x.first});
			}
		}
	}

	return;
}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
   	cin>>n>>m;
   	for(int i=0;i<m;i++){
   		int x,y,c;cin>>x>>y>>c;
   		x--;y--;
   		adj[x].pb({y,c});
   	}
   	for(int i=0;i<n;i++) fill(i);

   	// for(int i=0;i<n;i++){
   	// 	cout<<dist[0][i]<<endl;
   	// }

   	for(int i=0;i<n;i++){
   		int ans=inf;
   		for(pair<int,int> c:adj[i]) if(c.first==i){
   			ans=min(ans,c.second);
   		}
   		for(int j=0;j<n;j++) if(j!=i){
   			ans=min(ans,dist[i][j]+dist[j][i]);
   		}

   		if(ans==inf) cout<<-1<<endl;
   		else cout<<ans<<endl;
   	}

}

/*
ID: hedichehaidar
TASK: photo
LANG: C++11
*/

#include<bits/stdc++.h>
typedef long long ll;
ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD)
ll lcm(ll a , ll b) {return (a * b) / gcd(a , b);} // least common multiple (PPCM)
#define ss second
#define ff first
#define all(x) (x).begin() , (x).end()
#define pb push_back
#define vi vector<int>
#define vii vector<pair<int,int>>
#define vl vector<ll>
#define vll vector<pair<ll,ll>>
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 1000*1000*1000; // 1 e 9
const int MOD = INF + 7;
const double EPS = 0.000000001; // 1 e -9
const ll inf = (ll)1e18;
ll powe(ll u , ll v , ll mod = MOD){
    ll acc = u;
    ll res = 1;
    while(v){
        if(v % 2){
            res = (res * acc)%mod;
        }
        v /= 2;
        acc = (acc * acc)%mod;
    }
    return res;
}
int n , m , x , y;
vector<tuple<int , ll , ll>> adj[(int)1e5 +10];
ll dist[(int)1e5 +10];
bool vis[(int)1e5 +10];
set<pll> s;
void dijkastra(int node){
    s.insert({0 , node});
    while(!s.empty()){
        pll a = *(s.begin());
        s.erase(s.begin());
        if(vis[a.ss]) continue;
        vis[a.ss] = true;
        for(auto v : adj[a.ss]){
            ll b , t , k;
            tie(b , t , k) = v;
            ll cur;
            if(a.ff == 0 || a.ff % k == 0) cur = a.ff;
            else cur = k + k * (a.ff / k);
            if(cur + t < dist[b]){
                dist[b] = cur + t;
                s.insert({dist[b] , b});
            }
        }
    }
}
int main() {
    //ifstream fin ("race.in");
    //ofstream fout ("race.out");
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>m>>x>>y;
    for(int i = 0 ; i < m ; i++){
        ll a , b , t , k;
        cin>>a>>b>>t>>k;
        adj[a].pb(make_tuple(b , t , k));
        adj[b].pb(make_tuple(a , t , k));
    }
    for(int i = 0 ; i < n + 2 ; i++) dist[i] = inf;
    dist[x] = 0;
    dijkastra(x);
    if(dist[y] == inf) cout << -1 << endl;
    else cout << dist[y] << endl;
    return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N), W(M);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  for (int i = 0; i < M; i++) cin >> W.at(i);

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

  vector<long> L, R;
  for (int i = 0; i + 1 < N; i += 2) L.push_back(H.at(i + 1) - H.at(i));
  for (int i = 1; i + 1 < N; i += 2) R.push_back(H.at(i + 1) - H.at(i));

  auto cs = [&](auto V) {
    int n = V.size() + 1;
    vector<long> R(n);
    for (int i = 1; i < n; i++) {
      R.at(i) = R.at(i - 1) + V.at(i - 1);
    }
    return R;
  };

  L = cs(L);
  R = cs(R);

  long ans = LONG_MAX;
  for (auto w : W) {
    int opp = lower_bound(H.begin(), H.end(), w) - H.begin();
    if (opp % 2) opp--;
    long tmp = 0;
    tmp += abs(w - H.at(opp));
    tmp += R.at((N + 1) / 2 - 1) - R.at(opp / 2);
    tmp += L.at(opp / 2);
    ans = min(ans, tmp);
  }
  cout << ans << "\n";
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpr vector<pr>

void prn(ll n){ cout << n << "\n";}
void prs(string s){cout << s << "\n";}
void prv(vct v, ll limt = -1){
    if (limt == -1)limt = v.size();
    for (ll i = 0; i < limt; i++)cout << v[i] << " ";
    cout << "\n";
}

void init() {}

ll n, m, k, a, b, c, x, y, z;
ll mod = 1e9 + 7;

vector<string> g(2001);

vpr mp[26];
vct visa(26,0);
bool chk(ll x, ll y, ll m, ll n){
    return ((x<m) && (x>=0) && (y>=0) && (y<n));
}
void solve(){
    cin>>m>>n;
    for(ll i=0;i<m;i++)cin>>g[i];

    pr st,et;
    for(ll i=0;i<m;i++){
        for(ll j=0;j<n;j++){
            char c=g[i][j];
            if(c=='S')st={i,j};
            else if(c=='G')et={i,j};
            else if(isalpha((int)c)){
                ll tp=c-'a';
                mp[tp].push_back({i,j});
            }
        }
    }

    queue<pair<pr, ll> > q;
    q.push({st,0});
    vector<vector<ll> >vis(m, vector<ll>(n,0));
    vis[st.first][st.second]=1;

    while(!q.empty()){
        pair<pr, ll> nd=q.front();q.pop();
        pr cr=nd.first;
        ll vl=nd.second;

        if(cr==et){
            prn(vl);
            return;
        }
        x=cr.first;y=cr.second;
        ll nx=x-1,ny=y;
        if(chk(nx,ny,m,n) && (g[nx][ny]!='#') && (!vis[nx][ny])){
            vis[nx][ny]=1;
            q.push({{nx,ny},vl+1});
        }
        nx=x+1,ny=y;
        if(chk(nx,ny,m,n) && (g[nx][ny]!='#') && (!vis[nx][ny])){
            vis[nx][ny]=1;
            q.push({{nx,ny},vl+1});
        }

        nx=x,ny=y+1;
        if(chk(nx,ny,m,n) && (g[nx][ny]!='#') && (!vis[nx][ny])){
            vis[nx][ny]=1;
            q.push({{nx,ny},vl+1});
        }

        nx=x,ny=y-1;
        if(chk(nx,ny,m,n) && (g[nx][ny]!='#') && (!vis[nx][ny])){
            vis[nx][ny]=1;
            q.push({{nx,ny},vl+1});
        }

        if(g[x][y]!='S' && isalpha(g[x][y])){
            ll tp=g[x][y]-'a';
            if(visa[tp])continue;
            visa[tp]=1;
            for(ll i=0;i<mp[tp].size();i++){
                if(mp[tp][i]!=cr){
                    vis[mp[tp][i].first][mp[tp][i].second]=1;
                    q.push({mp[tp][i],vl+1});
                }
            }
        }

    }
    prn(-1);

}

int main(){
    init();
    ll t = 1;
    // cin >> t;
    while (t--)solve();
    return 0;
}


#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}

template <class T>
void chmin(T& a, const T& b) {
  if (b < a) a = b;
}

signed main() {
  init();
  ll N, K;
  cin >> N >> K;
  rep(i, K) {
    if (N % 200 == 0) {
      N /= 200;
    } else {
      N *= 1000;
      N += 200;
    }
  }
  COUT(N);
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,k,n) for(i=k;i<n;i++)
#define loop(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
  uniform_int_distribution<int> uid(0,lim-1);
  return uid(rang);
}
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs2(int u, int par);
void dfs(int s,bool visited[]);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve() {
  ll i=0, j=0,k,sum =0,n=0, m=0;
   ll a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<a*d-b*c;

}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
  int i, u, v;
  while(m--){
    cin>>u>>v;
    u--, v--;
    g[u].pb(v);
    g[v].pb(u);
  }
}

void dfs2(int u, int par){
  for(int v:g[u]){
    if (v == par) continue;
    dfs2(v, u);
  }
}

void dfs(int s,bool visited[])
{
  if(visited[s])
  {
    return;
  }
  else
  {
    visited[s]= true;
    for(int u:g[s])
    {
      if(!visited[u])
      {
        dfs(u,visited);
      }
    }
  }

}


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

int main(){
    string S;
    cin >> S;
    deque<char> q;
    bool rev = false;
    for(int i = 0;i<S.size();++i){
        if(S[i]=='R') rev ^= 1;
        else if(rev) q.push_front(S[i]);
        else q.push_back(S[i]);
    }

    if(rev) reverse(q.begin(),q.end());
    string T;
    for(char c : q){
        if(T.size() && T.back()==c) T.pop_back();
        else T.push_back(c);
    }
    cout << T << endl;
}

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

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

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define m0(x) memset(x, 0, sizeof(x))

int dx4[4] = {1, 0, -1, 0}, dy4[4] = {0, 1, 0, -1};

int main()
{
    string s;
    cin >> s;
    bool front = false;
    deque<char> dq;

    for (int i = 0; i < s.size(); i++)
    {
        char c = s[i];
        if (c == 'R')
        {
            front = !front;
        }
        else
        {
            if (front)
            {

                dq.push_front(c);
            }
            else
            {
                dq.push_back(c);
            }
        }
    }
    string s1;
    while (dq.size() > 0)
    {
        char c = dq.front();
        dq.pop_front();
        s1 += c;
    }
    if (front)
    {
        reverse(all(s1));
    }
    if (s1.size() <= 1)
    {
        cout << s1 << endl;
    }
    else
    {
        deque<char> dq2;
        for (int i = 0; i < s1.size(); i++)
        {
            char c = s1[i];
            if(dq2.size()==0 || dq2.back()!=c)
            {
                dq2.push_back(c);
            }
            else
            {
                dq2.pop_back();
            }
        }
        while (dq2.size() > 0)
        {
            cout << dq2.front();
            dq2.pop_front();
        }
        cout << endl;

    }

    return 0;
}


#pragma region おまじないα ver1.02
//#define _CRT_SECURE_NO_WARNINGS
//#pragma warning(disable : 4996)
//#define int long long;
#pragma region 変化しないおまじない

#include "bits/stdc++.h"
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

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

//typedef pair<ll, ll> P;
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
using namespace std;

double dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
ll idist(ll x1, ll y1, ll x2, ll y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
struct qwqw{
  qwqw() {
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);
  };
}aaaaaaa;
#pragma endregion
#pragma endregion
signed main() {
  string s;
  ll n, x;
  cin >> n >> x >> s;
  rep(i, n) {
    if (s[i] == 'o') {
      x++;
    } else {
      x--;
      x = max(x, (ll)0);
    }
  }
  cout << x;
}

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

int main(){
  int n,x;
  string s;
  cin >> n >> x >> s;
  for(int i=0; i<n; i++){
    if(s[i]=='x'){
      if(x>0) x--;
    }
    else x++;
  }
  cout << x << endl;
}


#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;

const ll maxn=3e5+10;
const ll mod=1e9+7;
const ll m2=1e9+7;
const ll INF64 = ll(1e18);
const ll max2=10500000;
const ll N = 1000001;
const ll MAXN=2e5+10;
const ll ALPHABET_SIZE = 2;
vector<pair<int,int>> adj[maxn];

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

ios_base::sync_with_stdio(NULL);  cin.tie(0); cout.tie(0);
int n,m,i,j,k;
cin>>n>>m;
int A[n][m-1],B[n-1][m];
for(i=0;i<n;++i)
for(j=0;j<m-1;++j)
	cin>>A[i][j];
for(i=0;i<n-1;++i)
	for(j=0;j<m;++j)
		cin>>B[i][j];
int m1[n][m];
int c=0;
for(i=0;i<n;++i)
{
	for(j=0;j<m;++j)
	{
		m1[i][j]=c++;

	}
}

for(i=0;i<n;++i)
{
	for(j=0;j<m;++j)
	{
		if(j-1>=0)
		{
			adj[m1[i][j]].push_back(make_pair(m1[i][j-1],A[i][j-1]));

		}
		if(j+1<m)
		{
			adj[m1[i][j]].push_back(make_pair(m1[i][j+1],A[i][j]));

		}
		if(i+1<n)
		{
			adj[m1[i][j]].push_back(make_pair(m1[i+1][j],B[i][j]));

		}
		for(k=0;k<max(n,m);++k)
		{
			if(i-k>=0)
			{
				adj[m1[i][j]].push_back(make_pair(m1[i-k][j],1+k));

			}
			else
				break;
		}
	}
}
int sz=n*m;
int dis[sz];
set<pair<int,int>> st;
for(i=0;i<sz;++i)
{
	dis[i]=INT_MAX;

}
dis[0]=0;
st.insert(make_pair(0,0));
while(st.size()!=0)
{
	int u=(*st.begin()).second;
	int d=(*st.begin()).first;
	st.erase(st.begin());
	//cout<<u<<"\n";
	for(auto x:adj[u])
	{
		int v=x.first,w=x.second;

		if(dis[v]>dis[u]+w)
		{
			if(st.find(make_pair(dis[v],v))!=st.end())
				st.erase(st.find(make_pair(dis[v],v)));
			dis[v]=dis[u]+w;
			st.insert(make_pair(dis[v],v));
		}
	}
}
cout<<dis[m1[n-1][m-1]];

return(0);
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define pb push_back
#define mp make_pair
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;

const int MAX_N = 17;
int H,W,A,B;

ll rec(int i, int j, int a, int b, bool used[MAX_N][MAX_N])
{
	if(j == W){
		return rec(i+1,0,a,b,used);
	}
	if(i == H){
		if(a==A && b==B) return 1;
		else return 0;
	}
	if(used[i][j]) return rec(i,j+1,a,b,used);
	ll res = 0;
	if(a < A){
		used[i][j]=true;
		if(i+1<H && !used[i+1][j]){
			used[i+1][j]=true;
			res+=rec(i,j+1,a+1,b,used);
			used[i+1][j]=false;
		}
		if(j+1<W && !used[i][j+1]){
			used[i][j+1]=true;
			res+=rec(i,j+1,a+1,b,used);
			used[i][j+1]=false;
		}
	}
	if(b < B){
		used[i][j]=true;
		res += rec(i,j+1,a,b+1,used);
	}
	used[i][j]=false;
	return res;
}

void solve()
{
	bool used[MAX_N][MAX_N];
	memset(used,false,sizeof(used));
	ll res = rec(0,0,0,0,used);
	cout<<res<<'\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	cin >> H >> W >> A >> B;
	solve();
	return 0;
}


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

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define fi first
#define se second
const int N=2010;
int n,m,k,a[N];
ll f[1<<21][2];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) scanf("%d",a+i);
	k=n/2;
	for(int i=0;i<(1<<k);++i)
	{
		for(int j=0;j<k;++j)
			if(((i>>j)&1)==0)
				f[i+(1<<j)][0]=f[i][0]+a[j+1];
	}
	int x=n-k;
	for(int i=0;i<(1<<x);++i)
	{
		for(int j=0;j<x;++j)
			if(((i>>j)&1)==0)
				f[i+(1<<j)][1]=f[i][1]+a[j+1+k];
	}
	vector<ll> nums1,nums2;
	for(int i=0;i<(1<<x);++i)
	{
		if(i<(1<<k)&&f[i][0]<=m) nums1.push_back(f[i][0]);
		if(f[i][1]<=m) nums2.push_back(f[i][1]);
	}
	sort(nums1.begin(),nums1.end());
	nums1.erase(unique(nums1.begin(),nums1.end()),nums1.end());
	sort(nums2.begin(),nums2.end());
	nums2.erase(unique(nums2.begin(),nums2.end()),nums2.end());
	ll ans=0;
	for(int i=0;i<nums1.size();++i)
	{
		int pos=lower_bound(nums2.begin(),nums2.end(),m+1-nums1[i])-nums2.begin();
		if(pos==nums2.size()) ans=max(nums1[i]+nums2[nums2.size()-1],ans);
		else if(pos>0) ans=max(ans,nums2[pos-1]+nums1[i]);
		//cout<<nums1[i]<<' ';
	}
	//cout<<endl;

	for(int i=0;i<nums2.size();++i)
	{
		int pos=lower_bound(nums1.begin(),nums1.end(),m+1-nums2[i])-nums1.begin();
		if(pos==nums1.size()) ans=max(nums2[i]+nums1[nums1.size()-1],ans);
		else if(pos>0) ans=max(ans,nums1[pos-1]+nums2[i]);
		//cout<<nums2[i]<<' ';
	}
	//cout<<endl;
	printf("%lld",ans);
	return 0;
}


//
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
//
//#pragma GCC optimize(3,"Ofast","inline")
//#include<unordered_map>
//#include<unordered_set>
#include<cstdio>
#include<iostream>
#include<cmath>
#include<functional>
#include<cstring>
#include<string>
#include<cstdlib>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<stack>
#include<vector>
#include<sstream>
#include<list>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
int mod=104857601;
const int maxn=2e5+5;
ll qpow(ll a,ll b,ll p)
{
    ll ans=1%p;
    while(b!=0)
    {
        if(b&1)
        {
            ans=(ans%p*a%p)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}
int main()
{
    ll n,m;
    cin>>n>>m;
    cout<<qpow(10,n,m*m)/m;
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(40)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll solve() {
    ll L, R;
    cin >> L >> R;
    ll ok = R + 1, ng = L - 1;
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (mid - L >= L)
            ok = mid;
        else
            ng = mid;
    }
    ll num = std::max(R - ok + 1, 0LL);
    ll ret = (num + 1) * num / 2;
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll Q;
    cin >> Q;
    REP(_, Q) {
        cout << solve() << endl;
    }
    return 0;
}


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

int main(){
  int n,m;
  cin>>n>>m;
  map<int,vector<int>>mp;
  rep(i,m){
    int x,y;
    cin>>x>>y;
    mp[x].push_back(y);
  }
  set<int>s;
  s.insert(n);
  for(auto p:mp){
    vector<int>add;
    for(auto y:p.second){
      if(s.count(y-1)||s.count(y+1)){
        add.push_back(y);
      }
    }
    for(auto y:p.second){
      if(s.count(y)) s.erase(y);
    }
    for(auto y:add) s.insert(y);
  }
  cout<<s.size()<<endl;
  return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <string>
#include <sstream>
#include <iomanip>
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define rep(i, n) FOR(i,0,n)
#define irep(i, n) IFOR(i,0,n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;

using namespace std;

int main() {

    ll n;
    cin >> n;
    ll ans = 0;
    rep(i, n) {
        ll a, b;
        cin >> a >> b;
        --a;
        ans += (ll)(b * (b + 1) / 2) - (a * (a + 1) / 2);
    }
    cout << ans << endl;
    return 0;
}


#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b

using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int a,b,c,d;
    cin>>a>>b;
    cin>>c>>d;
    cout<<b-c<<endl;
}

//END OF CODE ->->->->->->->->

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

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

// Problem: A - Difference Max
// Contest: AtCoder - AtCoder Beginner Contest 196
// URL: https://atcoder.jp/contests/abc196/tasks/abc196_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Parsed on: 20-03-2021 17:30:12 IST (UTC+05:30)
// Author: Kapil Choudhary
// ********************************************************************
// कर्मण्येवाधिकारस्ते मा फलेषु कदाचन |
// मा कर्मफलहेतुर्भूर्मा ते सङ्गोऽस्त्वकर्मणि || १.४७ ||
// ********************************************************************

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

#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define PI 3.1415926535897932384626
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int>	vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii>	vpii;
typedef vector<pll>	vpll;
typedef vector<vi> vvi;
typedef vector<vll>	vvll;
typedef vector<vull> vvull;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}

const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;

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

  	int x = b, y = c;
  	cout << x - y << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

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

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

    return 0;
}


// abc196_d
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#ifdef LOCAL
#include "../../debug_util/cxx-prettyprint/prettyprint.hpp"
#include "../../debug_util/rng.hpp"
#include "../../debug_util/timer.hpp"
#endif
using namespace std;

using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

#define REP(i, n) for (int i = 0 ; i < (int)(n) ; ++i)
#define REPN(i, m, n) for (int i = m ; i < (int)(n) ; ++i)
#define REP_REV(i, n) for (int i = (int)(n) - 1 ; i >= 0 ; --i)
#define REPN_REV(i, m, n) for (int i = (int)(n) - 1 ; i >= m ; --i)
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e15)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << "\n";}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int H, W, A, B;
int ans = 0;
void dfs(int a, int node, vector<vector<int>>& S){

    if (node == H*W){
        ans += a == A;
        return;
    }
    int i = node / W;
    int j = node % W;

    if (i + 1 < H && S[i][j] == 0 && S[i + 1][j] == 0) {
        S[i][j] = S[i+1][j] = 1;
        dfs(a+1, i*W+j+1, S);
        S[i][j] = S[i+1][j] = 0;
    }

    if (j + 1 < W && S[i][j] == 0 && S[i][j+1] == 0) {
        S[i][j] = S[i][j+1] = 1;
        dfs(a+1, i*W+j+1, S);
        S[i][j] = S[i][j+1] = 0;
    }

    dfs(a, i*W+j+1, S);
}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    cin >> H >> W >> A >> B;

    vector<vector<int>> S(H, vector<int>(W));
    dfs(0, 0, S);
    print(ans);

    return 0;
}

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using ll = long long;

int h, w;
int used[16][16];

ll dfs(int i, int j, int a, int b) {
	if (a < 0 || b < 0) return 0;
	if (j == w) j = 0, ++i;
	if (i == h) return 1;
	if (used[i][j]) return dfs(i, j + 1, a, b);
	ll res = 0;
	used[i][j] = true;
	res += dfs(i, j + 1, a, b - 1);
	if (j + 1 < w and !used[i][j + 1]) {
		used[i][j + 1]= true;
		res += dfs(i, j + 1, a - 1, b);
		used[i][j + 1] = false;
	}
	if (i + 1 < h and !used[i + 1][j]) {
		used[i + 1][j]= true;
		res += dfs(i, j + 1, a - 1, b);
		used[i + 1][j] = false;
	}
	used[i][j] = false;
	return res;
}

int main() {
	cin >> h >> w;
	int a, b;
	cin >> a >> b;

	cout << dfs(0, 0, a, b) << '\n';

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, start, end) for (int i = start; i <= end; i++)
#define rloop(i, start, end) for (int i = start; i >= end; i--)
#define vi vector<int>
#define vec(x) vector<x>
#define sz(v) (int)v.size()
#define UB upper_bound
#define LB lower_bound
#define all(v) (v).begin(),(v).end()
#define arl(v) (v).rbegin(),(v).rend()
#define fsp(a) fixed<<setprecision(a)
#define mem(a,with) memset(a, with, sizeof (a))
#define vmn(a) (*min_element(a.begin(),a.end()))
#define vmx(a) (*max_element(a.begin(),a.end()))
#define bs(a,key) binary_search(all(a),key)    /// return bool.
#define rotl(a,x) rotate(a.begin(),a.begin()+x,a.end());
#define rotr(a,x) rotl(a,a.size()-x);
#define nl cout<<endl
#define MOD 1000000007
int add(int x, int y) {int res = x + y; return (res >= MOD ? res - MOD : res);}
int mul(int x, int y) {int res = x * y; return (res >= MOD ? res % MOD : res);}
int power(int x, int y) {int res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}

void solve(){
    //code goes here
    int n;
    cin>>n;
    int arr[n];
    loop(i,0,n-1) cin>>arr[i];

    int num=0,mx=0;
    loop(i,2,1000){
        int cnt=0;
        loop(j,0,n-1){
            if(arr[j]%i==0){
                cnt++;
            }
        }
        if(cnt>mx){
            mx=cnt;
            num=i;
        }
    }

    cout<<num;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cout.tie(NULL);
cin.tie(NULL);
    int t=1;
    // cin>>t;
    while (t--)
    {
        solve();
    }
    return 0;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <iterator>
#include <algorithm>
#include <cmath>
#include <chrono>
#include <cassert>

using namespace std;
using ll = long long;
using ld = long double;
using ii = pair<ll, ll>;
using vi = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vii = vector<ii>;
using vvii = vector<vii>;

const int INF = 2000000000;
const ll LLINF = 9000000000000000000;

int main() {

	int N;
	scanf("%d", &N);

	vvii E(N, vii());

	ll m;
	cin >> m;
	ll a, b, c;
	vector<pair<pair<ll, ll>, ll>> edges;
	for (int i = 0; i < m; ++i) {
	    cin >> a >> b >> c;
	    --a, --b;
	    E[a].push_back({b, c});
	    edges.push_back({{a, b}, c});
	}
	vi ans(N, -1LL);

	for (auto p : edges) {
		vi d(N, LLINF);
		priority_queue<ii, vector<ii>, greater<ii>> pq;
		int u = p.first.second;

		pq.push({0LL, u});
		d[u] = 0LL;

		vi pdd(N, -1LL);
		while (!pq.empty()) {
			ll v = pq.top().second;
			ll dist = pq.top().first;
			pq.pop();

			if (dist > d[v]) continue;
			for (ii wd : E[v]) {
			    if (p.first.first == v && p.first.second == wd.first && p.second == wd.second) continue;
				ll w = wd.first;
				ll dist2 = wd.second;
				if (dist + dist2 < d[w]) {
					d[w] = dist + dist2;
					pdd[w] = v;
					pq.push({d[w], w});
				}
			}
		}
		if (d[p.first.first] == LLINF) continue;

		if (ans[p.first.first] == -1) {
		    ans[p.first.first] = d[p.first.first] + p.second;
		}else {
		    ans[p.first.first] = min(ans[p.first.first], d[p.first.first] + p.second);
		}
		if (ans[p.first.second] == -1) {
		    ans[p.first.second] = d[p.first.first] + p.second;
		}else {
		    ans[p.first.second] = min(ans[p.first.second], d[p.first.first] + p.second);
		}

	}

	for (int i = 0; i < N; ++i)
		cout << ans[i] << '\n';

	return 0;
}


#include<bits/stdc++.h>
using ll= long long;
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define ALL(x) x.begin(),x.end()

#define INF (int)1e9 //10^9:∞
#define LLINF (long long)1e12
#define MOD (int)1e9+7 //10^9+7:合同式の法
#define PI 3.141592653589
#define PB push_back
#define fi first
#define se second

#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

#define Graph vector<vector<int>>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VPII vector<pair<int,int>>

#define DDD fixed<<setprecision(10)

using namespace std;
/*..................DEFINE GLOBAL VARIABLES...................*/

/*.....................DEFINE FUNCTIONS ......................*/

/*.........................kemkemG0...........................*/
int main() {
int N,W;
cin>>N>>W;
int ans=N/W;

cout<<ans<<endl;

}

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


# include <bits/stdc++.h>
# define ull unsigned long long
# define ll long long
# define double long double
# define pll pair<ll,ll>
# define pb push_back
# define fi first
# define se second
# define mp make_pair
# define all(x) x.begin(),x.end()
# define fill(a,b) memset(a,b,sizeof(a))
# define gcd(m,n)  __gcd(m, n)
# define pr_double(x) cout << fixed << setprecision(9) << x

using namespace std;
const ll INF = 922337203685477110;
const ll N = 200005;
//const ll mod  = 1e9+7;
const ll M = 22;
ll mod;

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,m; cin>>n>>m;
  mod = m*m;
  cout<<binpow(10,n)/m<<endl;

}

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

#define        lcm(a,b)   ((a*b)/__gcd(a,b))
#define        optimize    ios_base::sync_with_stdio(false);cin.tie(NULL);
#define        sqr(a)       ((a)*(a))
#define         MAX        15000
#define         max5        100000
#define         max6        1000000
#define         mod       1000000007
#define         pb         push_back
#define         sf(x)      scanf("%d",&x)
#define         sfl(x)     scanf("%lld",&x)
#define         pf(x)      printf("%d\n",x)
#define         pfl(x)     printf("%lld\n",x)
#define         endl       '\n'
#define         pii        pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         pll        pair<ll,ll>
#define         vi         vector<int>
#define         vl         vector<ll>
#define         vd         vector<double,double>
#define         all(c)     c.begin(),c.end()
#define         F          first
#define         S          second
#define         mp         make_pair
#define        ei(x)      cerr << #x << ": " << x << " " << endl;
#define         PI         acos(-1)

int main()
{
    ll i,j,k,l,m,n,a,b;

    a = b = 0;
cin >> n >> a;
ll ar[n+10];
for(i=0;i<n;i++)
{
    cin >> ar[i];
}
for(i=0;i<n;i++)
{
    if(ar[i]!=a)cout << ar[i] << " ";
}

cout << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define PI 3.14159265358979

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

   ll t=1;
   //cin>>t;
   while(t--){
     ll a,b,c;
     cin>>a>>b>>c;
     if(a*b>0)
     {
         if(c%2==0)
         {
             if(abs(a)>abs(b))
                cout<<">";
             else if(abs(a)==abs(b))
                cout<<"=";
             else
                cout<<"<";
         }
         else
         {
             if(a<0)
             {
                 if(abs(a)>abs(b))
                cout<<"<";
             else if(abs(a)==abs(b))
                cout<<"=";
             else
                cout<<">";
             }
             else
             {
                if(abs(a)>abs(b))
                cout<<">";
             else if(a==b)
                cout<<"=";
             else
                cout<<"<";
             }
         }
     }
     else
     {
         if(c%2==0)
         {
              if(abs(a)>abs(b))
                cout<<">";
             else if(abs(a)==abs(b))
                cout<<"=";
             else
                cout<<"<";
         }
         else
         {
             if(a>b)
                cout<<">";
              else if(a==b)
                cout<<"=";
             else
                cout<<"<";
         }
     }
      cout<<"\n";
   }
    return 0;
}

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

int main() {
  int N;
  int minimum =-1;
  cin>> N;

  for (int i=0 ;i< N ;i++){
    int a1 ,p1 ,x1;
    cin >> a1 >> p1 >> x1;
    if (a1<x1){
      minimum = p1;
      break;
    }

  }
  if (minimum !=-1){
    for (int i=0; i<N;i++){
    int a2, p2, x2;
    cin >> a2>> p2 >> x2;
        if (a2 <x2){
         minimum =min (p2,minimum);

      }

    }
  }
  cout << minimum << endl;
}


//#pragma GCC optimize(2)
#include<bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(nullptr)
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define lc(x) ((x)<<1)
#define rc(x) (((x)<<1)|1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;

const ll LINF=1e18;
const ll MOD=1e9+7;
const int INF=0x3f3f3f3f;
const int MAXM=500050;
const int MAXN=200050;

void mainwork(int T){
	ll n;
	scanf("%lld",&n);
	ll ans=0;
	if(n<1000){
		puts("0");
		return;
	}
	if(n<1000000){
		ans+=(n-1000+1);
		printf("%lld",ans);
		return;
	}else{
		ans+=(999999-1000+1);
	}
	if(n<1000000000){
		ans+=(n-1000000+1)*2;
		printf("%lld",ans);
		return;
	}else{
		ans+=(999999999-1000000+1)*2;
	}
	if(n<1000000000000ll){
		ans+=(n-1000000000ll+1)*3;
		printf("%lld",ans);
		return;
	}else{
		ans+=(1000000000000ll-1000000000ll)*3;
	}
	ans+=(n-1000000000000ll+1)*4;
	if(n== 1000000000000000ll)ans++;
	printf("%lld",ans);
	return;
}
signed main(){
	//IOS;
	#ifndef ONLINE_JUDGE
	//freopen("./in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	#endif
	int t=1;
	//scanf("%d",&t);
	//prework();
	for(int i=1;i<=t;i++){
		mainwork(i);
	}
}

#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\n" << (#x) << " = " << (x) << "\n"
using namespace std;

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
	ll n;
	cin >> n;
	int len = to_string(n).length();
	ll ans = 0;
	for(int i = 1; i < len; ++i){
		ans += (9 * pow(10, i - 1)) * ((i - 1) / 3);
	}
	ans += ((n + 1 - pow(10, len - 1)) * ((len - 1) / 3));
	cout << ans;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  set<string> M(S.begin(), S.end());
  for (int i = 0; i < N; i++) {
    if (M.count('!' + S.at(i))) {
      cout << S.at(i) << endl;
      return 0;
    }
  }
  cout << "satisfiable" << endl;
}

#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define pf printf
#define sf scanf
#define ff first
#define ss second
#define clr clear()
#define sz size()
#define pb push_back
#define mk make_pair
#define pi acos(-1)
#define inf 2000000000000
#define mod 998244353
#define ull unsigned long long int
#define f(i,k,n) for(i=k;i<n;i++)
#define fr(i,n,k) for(i=n;i>=k;i--)
#define ent(a) scanf("%lld",&a)
#define ent2(a,b) scanf("%lld%lld",&a,&b)
#define ent3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define mem(a) memset(a,0,sizeof(a))
#define vec(v,s) vector<ll>v[s]
#define arr(a,s) ll a[s];
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
random_device rd;
mt19937 random(rd());*/
//knight and king//
int dr[]= {2,2,-2,-2,1,-1,1,-1};
int dc[]= {1,-1,1,-1,2,2,-2,-2};
int dr1[]= {0,0,1,1,1,-1,-1,-1};
int dc1[]= {1,-1,1,0,-1,0,1,-1};
int dr2[]= {0,0,1,-1};
int dc2[]= {1,-1,0,0};
////////////////////////////
using namespace std;
#define ma 3005

int main()
{
    ll i,j,n,m;
    string t="satisfiable";

    cin>>n;
    map<string,ll>mp,mp1;
    for(i=0;i<n;i++)
    {
        string t1;
        cin>>t1;
        if(t1[0]!='!')
        {
            mp[t1]=1;
        }
        else mp1[t1]=1;
    }

    map<string ,ll>::iterator it;

    for(auto p:mp)
    {
        string t1="!"+p.ff;

        if(mp1[t1])
        {
            t=p.ff;
        }
    }

    cout<<t<<endl;

    return 0;
}


#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = chrono::system_clock::now().time_since_epoch().count();
mt19937 eng(seed);

ll random2(){
    return (1ll << 31ll)*eng()+eng();
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 200001;

string s1,s2,s3;
string S[3];

string alfa = "01";

string get(int a, int b, int c, int where){
    string res = "";
    if(where == 0)res += alfa[b];
    rep(c1,0,n){
        res += alfa[a];
    }
    if(where == 1)res += alfa[b];
    rep(c1,0,n){
        res += alfa[c];
    }
    if(where == 2)res += alfa[b];
    return res;
}

bool mat(string s, string t){
    int seen = 0;
    rep(c1,0,sz(s)){
        if(s[c1] == t[seen])seen++;
        if(seen == sz(t))return 1;
    }
    return 0;
}

string greedy(){
    int A[3] = {0};
    string res = "";

    rep(c1,0,2*n+1){
        int ma = -1;
        char choice;
        rep(c2,0,3){
            if(A[c2] > ma){
                ma = A[c2];
                choice = S[c2][A[c2]];
            }
        }
        res += choice;
        if(c1 == 2*n)break;
        rep(c2,0,3){
            while(S[c2][A[c2]] != choice){
                A[c2]++;
            }
            A[c2]++;
        }

    }
    return res;
}

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

    //freopen("fhc.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d;

    cin >> T;
    rep(c4,0,T){
        cin >> n;
        cin >> s1 >> s2 >> s3;
        S[0] = s1+s1;
        S[1] = s2+s2;
        S[2] = s3+s3;
        string s = "";
        bool good = 0;
        rep(c1,0,2){
            rep(c2,0,2){
                rep(c3,0,2){
                    rep(where,0,3){
                        s = get(c1,c2,c3,where);
                        if(mat(s1+s1,s) && mat(s2+s2,s) && mat(s3+s3,s)){
                            good = 1;
                            goto label;
                        }
                    }
                }
            }
        }
        label:
        assert(good);
        cout << s << "\n";
    }

    return 0;
}

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

const int Maxn = 400004;

char tmp[Maxn];
int T;
int n;
string A, B, C;
int nxtA[Maxn][2], nxtB[Maxn][2], nxtC[Maxn][2];
char res[Maxn];
int rlen;

void Read(string &S, int nxt[][2])
{
	scanf("%s", tmp);
	S = tmp; S = S + S;
	nxt[S.length()][0] = nxt[S.length()][1] = S.length();
	for (int i = int(S.length()) - 1; i >= 0; i--) {
		nxt[i][0] = nxt[i + 1][0];
		nxt[i][1] = nxt[i + 1][1];
		nxt[i][S[i] - '0'] = i;
	}
}

int main()
{
	scanf("%d", &T);
	while (T--) {
		scanf("%d", &n);
		Read(A, nxtA);
		Read(B, nxtB);
		Read(C, nxtC);
		printf("%s%s%s\n", string(n, '0').c_str(), string(n, '1').c_str(), string(1, '0').c_str());
	}
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define rg register
#define In inline
#define ll long long

const ll mod = 998244353;
const int N = 2e5;

namespace IO{
	In ll read(){
		ll s = 0,ww = 1;
		char ch = getchar();
		while(ch < '0' || ch > '9'){if(ch == '-')ww = -1;ch = getchar();}
		while('0' <= ch && ch <= '9'){s = 10 * s + ch - '0';ch = getchar();}
		return s * ww;
	}
	In void write(ll x){
		if(x < 0)putchar('-'),x = -x;
		if(x > 9)write(x / 10);
		putchar('0' + x % 10);
	}
};
using namespace IO;

namespace ModCalc{
	In void Inc(ll &x,ll y){
		x += y;if(x >= mod)x -= mod;
	}
	In void Dec(ll &x,ll y){
		x -= y;if(x < 0)x += mod;
	}
	In ll Add(ll x,ll y){
		Inc(x,y);return x;
	}
	In ll Sub(ll x,ll y){
		Dec(x,y);return x;
	}
};
using namespace ModCalc;

ll a[N+5];
int n;

int main(){
//	freopen("B.in","r",stdin);
//	freopen("B.out","w",stdout);
	n = read();
	for(rg int i = 1;i <= n;i++)a[i] = read();
	sort(a + 1,a + n + 1);
	ll x = 0,ans = 0;
	for(rg int i = 1;i <= n;i++){
		Inc(ans,Add(x,a[i]) * a[i] % mod);
		x = Add(x * 2 % mod,a[i]);
	}
	write(ans),putchar('\n');
	return 0;
}

#include <iostream>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int, int>>
#define vl vector<long long>
#define vpl vector<pair<long long, long long>>
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template<typename T>
void printVector(const T& t) {
    std::copy(t.cbegin(), t.cend(), std::ostream_iterator<typename T::value_type>(std::cout, ", "));
}
using namespace std;
using ll = long long;
const int mode = 0;

void solve() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int t = a + b + c + d;
  if (t % 2) {
    cout << "No\n";
    return;
  }
  int h = t / 2;
  vi ways = {a,b,c,d,a+b,a+c,a+d};
  for (int x : ways) {
    if (x == h) {
      cout << "Yes\n";
      return;
    }
  }
  cout << "No\n";
}

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

  if (mode == 0) {
    solve();
  } else {
    cin >> t;
    while (t--) {
      solve();
    }
  }
}


#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ull unsigned long long
#define pii pair<int,int>
#define tiii tuple<int,int,int>
#define pll pair<long long, long long>
#define pdd pair<double, double>
#define s second
#define f first
#define pb push_back
#define oo 1000000000000ll

void solve(){
    int n; cin >> n;
    vector<int> dp[2];
    dp[0].resize(n+1);
    dp[1].resize(n+1);
    dp[0][0] = 1;
    dp[1][0] = 1;
    for (int i = 1; i <= n; ++i) {
        string str; cin >> str;
        if (str == "AND"){
            dp[1][i] = dp[1][i-1];
            dp[0][i] = dp[1][i-1] + 2*dp[0][i-1];
        }
        else{
            dp[1][i] = 2*dp[1][i-1] + dp[0][i-1];
            dp[0][i] = dp[0][i-1];
        }
    }

    cout << dp[1][n] << "\n";
}

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

    solve();

    return 0;

}

#include <bits/stdc++.h>

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

    int n; std::cin >> n;
    std::vector<int> op(n);
    for (auto &it : op) {
        std::string s; std::cin >> s;
        it = (s == "AND");
    }

    int64_t ans = 1, pw2 = 1;
    for (int i = 0; i < n; i++) {
        pw2 <<= 1;
        if (not op[i]) {
            ans += pw2;
        }
    }

    std::cout << ans << '\n';

    return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define all(x) x.begin(),x.end()
#define mod 998244353
#define ad(a,b) a=(a+b)%mod;
#define X 5010
ll po(ll x,ll y){
	ll res=1;
	for(;y;y>>=1){
		if(y&1)res=res*x%mod;
		x=x*x%mod;
	}
	return res;
}
ll fac[X],ivf[X];
void init(){
	fac[0]=1;
	for(ll i=1;i<X;i++)fac[i]=fac[i-1]*i%mod;
	for(ll i=0;i<X;i++)ivf[i]=po(fac[i],mod-2);
}
ll C(ll n,ll k){
	return fac[n]*ivf[n-k]%mod*ivf[k]%mod;
}

#define N 200010
vector<ll> e[110];
bool vis[110];
int dfs(ll x){
	if(vis[x])return 0;
	vis[x]=1;
	int res=1;
	for(auto y:e[x])res+=dfs(y);
	return res;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	ll n,K;
	cin>>n>>K;
	ll a[55][55];
	rep(i,n)rep(j,n)cin>>a[i][j];
	rep(i,n)rep(j,n){
		bool ok=1;
		rep(k,n)ok&=(a[i][k]+a[j][k]<=K);
		if(ok)e[i].push_back(j);
	}
	rep(i,n)rep(j,n){
		bool ok=1;
		rep(k,n)ok&=(a[k][i]+a[k][j]<=K);
		if(ok)e[i+n].push_back(j+n);
	}
	init();
	rep(i,2*n)vis[i]=0;
	ll res=1;
	rep(i,2*n){
		if(!vis[i])res=res*fac[dfs(i)]%mod;
	}
	cout<<res<<endl;
}

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

typedef long long ll;
const ll mod = 998244353;

struct UF{
    vector<int> p;
    int n;

    UF(int siz){
        n = siz;
        p.resize(n, 0);
        for(int i = 0; i < n; i++)  p[i] = i;
    }

    int parent(int x){
        if(p[x] != x)   p[x] = parent(p[x]);
        return p[x];
    }

    bool same(int x, int y){
        return parent(x) == parent(y);
    }

    void unite(int x, int y){
        x = parent(x), y = parent(y);
        p[x] = y;
    }
};

int main(){
    int n, x;
    cin >> n >> x;
    int a[n][n];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> a[i][j];
        }
    }
    UF var(n), hor(n);
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            bool vok = true, hok = true;
            for(int k = 0; k < n; k++){
                vok &= a[i][k]+a[j][k] <= x;
                hok &= a[k][i]+a[k][j] <= x;
            }
            if(vok) var.unite(i, j);
            if(hok) hor.unite(i, j);
        }
    }
    vector<int> vv(n, 0), hh(n, 0);
    for(int i = 0; i < n; i++)  vv[var.parent(i)]++, hh[hor.parent(i)]++;
    vector<ll> fact(n+1, 1);
    for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i%mod;
    ll vval = 1, hval = 1;
    for(int i = 0; i < n; i++)  (vval *= fact[vv[i]]) %= mod, (hval *= fact[hh[i]]) %= mod;
    cout << vval*hval%mod << endl;
    return 0;
}


#include<bits/stdc++.h>
namespace imzzy{
	#define endl '\n'
	#define rgi register int
	#define rgl register long long
	typedef long long ll;
	class fastin{private:int _ch,_f;
	public:inline fastin&operator>>(char&c){c=getchar();return*this;}
	template<typename _Tp>inline fastin&operator>>(_Tp&_x){
	_x=0;while(!isdigit(_ch))_f|=(_ch==45),_ch=getchar();
	while(isdigit(_ch))_x=(_x<<1)+(_x<<3)+(_ch^48),_ch=getchar();
	_f&&(_x=-_x,_f=0);return*this;}fastin(){_ch=_f=0;}
	}fin;class fastout{private:int _num[32],_head;
	public:inline fastout&operator<<(char c){putchar(c);return*this;}
	template<typename _Tp> inline fastout&operator<<(_Tp _x){
	_Tp _k;if(_x==0){putchar('0');return *this;}if(_x<0)putchar('-'),_x=-_x;
	while(_x>0)_k=_x/10,++_head,_num[_head]=(_x-(_k<<1)-(_k<<3))^48,_x=_k;
	while(_head>0)putchar(_num[_head]),--_head;return*this;}fastout(){_head=0;}
	}fout;inline void P_INIT(){
	#ifdef D_STDOUT_UNBUFFERED
	setbuf(stdin,NULL),setbuf(stdout,NULL);
	#endif
}}using namespace imzzy;
// ----------------------------
// #define int ll
// using namespace std;
const double pi=acos(-1.0);
const int mod=1000000000,inf=1201201201;
const int maxn=104,maxm=800004;

int cnt[maxn];
bool go[maxn][maxn];
char s[maxn];
signed main()
{P_INIT();
	int n;
	fin>>n;
	for(rgi i=1;i<=n;++i) {
		scanf("%s",s+1);
		for(rgi j=1;j<=n;++j) go[i][j]=(s[j]-'0')|(i==j);
	}
	for(rgi k=1;k<=n;++k) for(rgi i=1;i<=n;++i) for(rgi j=1;j<=n;++j) go[i][j]|=go[i][k]&go[k][j];
	for(rgi i=1;i<=n;++i) for(rgi j=1;j<=n;++j) cnt[j]+=go[i][j];
	double ans=0;
	for(rgi i=1;i<=n;++i) ans+=1.0/cnt[i];
	printf("%.12lf",ans);
	return 0;
}
// ----------------------------
// by imzzy

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const ll mod = 1e18 + 7;
const int maxn = 1e5+5;

void go() {
    int n;string s;
    cin >> n >> s;
    //map<int,int>mp1,mp2;
    map<pair<int,int>,int>mp3;
    mp3[{0,0}] = 1;
   // mp1[0] = 1;
   // mp2[0] = 1;
    int ans = 0;
    int c0 = 0, c1 = 0;
    for (auto &i : s) {
        if (i == 'A') {
            c0++;
        }
        else if (i == 'T') {
            c0--;
        }
        else if (i == 'C') {
            c1++;
        }
        else {
            c1--;
        }
        //ans += mp1[c0];
        //ans += mp2[c1];
        ans += mp3[{c0,c1}];
        //mp1[c0]++;
        //mp2[c1]++;
        mp3[{c0,c1}]++;
    }
    cout << ans << '\n';
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int c = 0;
    int t;
    if (!c) {
        t = 1;
    }
    else {
        cin >> t;
    }
    while (t--) {
        go();
    }

}


#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
#include <utility>

using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	int T;cin>>T;
	while(T--){
		int i,j,n;cin>>n;
		vector<llint>a(n);
		for(i=0;i<n;i++){cin>>a[i];}
		SO(a);
		if(n%2==0){
			string ans="Second";
			for(i=0;i<n;i+=2){
				if(a[i]!=a[i+1]){ans="First";}
			}
			cout<<ans<<endl;
		}else{
			cout<<"Second"<<endl;
		}
	}
	return 0;
}

#include <bits/stdc++.h>

using namespace std;
/*---------------------SAUGATA KUNDU---------------------------*/

#define int long long int
#define INF (int)(1e9+5)
#define MoD (int)(998244353)
//#define debugn(a) cerr << '[' << ( a ) << ']' << '\n'
#define debug(a) cerr << '[' << a << ']' << '\n'

#define clear(a) memset(a, 0, sizeof(a))
#define fo(i, a, b) for(int i = a; i < b; i++)
#define fos(i, b) for(int i = 0; i < b; i++)
#define foe(i, a) for(auto &i: a)
#define re(i, a, b) for(int i = b-1; i >= a; i--)
#define pb push_back
#define all(c) c.begin(), c.end()
#define sz(x) (int)(x).size()
#define Fast ios::sync_with_stdio(0);cin.tie(0)
//data_structures
#define vt vector
#define que queue
#define sta stack
#define pque priority_queue
#define dque deque

#define point(pt) vt<int>::iterator pt
template<typename T> void read(vt<T> &a){
	fos(i, sz(a)) cin >> a[i];
}

#define endl '\n'
template<typename T> void write(vt<T> a){
	fos(i, sz(a)) cout << a[i] << ' ';
	cout << endl;
}

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

	cout << 100-(a%100) << endl;
}

int32_t main() {
	Fast;

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

}


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

int main() {

  int N, K;
  cin >> N >> K;

  int room, ans;
  ans = 0;

  for (int i = 0; i < N; i++){
    for ( int j = 0; j < K; j++){
      room = (i+1) * 100 + (j+1);
      ans += room;
    }
  }

  cout << ans << endl;

}

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

typedef long long ll;
using namespace std;
//using namespace atcoder;

#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define _reps(i, s, n) for(ll i = (ll)(s); i < (ll)n; i++)
#define REP(...) _overload(__VA_ARGS__, _reps, _rep,)(__VA_ARGS__)
#define all(v) (v).begin(),(v).end()
#define UNIQUE(v) (v).erase( unique( all(v) ), (v).end() );
#define MOD 1000000007

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

	string s[n];
	REP(i, n){
		cin >> s[i];
	}

	ll t[n], f[n];
	REP(i, n){
		t[i] = 0;
		f[i] = 0;
	}

	if( s[0] == "OR" ){
		t[0] = 3;
		f[0] = 1;
	}else{
		t[0] = 1;
		f[0] = 3;
	}
	REP(i, 1, n){
		if( s[i] == "OR" ){
			t[i] = t[i-1]*2 + f[i-1];
			f[i] = f[i-1];
		}else{
			t[i] = t[i-1];
			f[i] = t[i-1] + f[i-1]*2;
		}
	}

	cout << t[n-1] << endl;

	return 0;
}


#include <bits/stdc++.h>

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<int> cnt(n);
  for (int i = 0; i < n; ++i) {
    std::string s;
    std::cin >> s;
    for (int j = 0; j < m; ++j) if (s[j] - '0' == 1) ++cnt[i];
  }

  long long odd = 0, even = 0;
  for (int i = 0; i < n; ++i) {
    if (cnt[i] & 1) ++odd;
    else ++even;
  }

  std::cout << odd * even << std::endl;
  return 0;
}

#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
#include <unordered_map>
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for(ll i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define spre cout<<fixed<<setprecision(1);
typedef long long int ll;
using namespace std;
// ll mod=67280421310721;
// ll mod=8589934592;
const ll mod=985661441;
ll INF=1e18;
ll po(ll a,ll b){
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
ll e=5000000;
int main()
{

	ll test=1;
	// cin>>test;
	// spre
	while(test--)
	{

		ll n,m;
		cin>>n>>m;
		string s;
		ll a[2]={0},l=0;
		FOR(i,0,n)

		{
			cin>>s;
			l=0;

			FOR(j,0,m)
			{
				l^=(s[j]-'0');
			}
			// cout<<l<<' ';
			a[l]++;
		}
		cout<<a[0]*a[1];
	}
	return 0;
}