#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1000000007;
signed main(){
  int N;
  cin>>N;
  vector<int> A(64,0);
  for(int j=0;j<N;j++){
    int B;
    cin>>B;
    bitset<64> C(B);
    for(int i=0;i<64;i++)
      if(C.test(i))
        A[i]++;
  }
  int ans=0;
  for(int i=0,j=1;i<64;i++,j=j*2%mod)
    ans=(ans+j*(A[i]*(N-A[i])%mod))%mod;
  cout<<ans<<endl;
}

/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂

                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ

 */
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define mod 1000000007
#define MOD 998244353
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN=3e2+5;
ll n , cnt[4] ;
ld dp[maxN][maxN][maxN];

// dp[three][two][one][zero] where three is the no of 3 and two is the no of 2 ......
// three=two=one=zero=n=300 (300^4)
// zero=n-one-two - three
// dp[three][two][one]
// if i pich three dp[three-1][two+1][one]
// if i pick two dp[three][two-1][one+1]
// if i pick one dp[three][two][one-1];
// dp[three][two][one]=(three/n)*dp[three-1][two+1][one] + (two/n)dp[three][two-1][one+1] +
					// one/n * dp[three][two][one-1] + zero/n * dp[three][two][one];
// dp[three][two][one](1-zero/n)=(three/n)*dp[three-1][two+1][one] + (two/n)dp[three][two-1][one+1] +
					// one/n * dp[three][two][one-1]
// dp[three][two][one]==((three/n)*dp[three-1][two+1][one] + (two/n)dp[three][two-1][one+1] +
					// one/n * dp[three][two][one-1])/(1-zero/n)

void solve(){
	cin>>n ;
	for(ll i=0 , x ;i<n ;i++){
		cin>> x ; cnt[x]++;
	}
	dp[0][0][0]=0;
	for(ll three=0 ;three<=n ; three++){
		for(ll two=0 ; two<=n ; two++){
			for(ll one=0 ; one<=n ; one++){
				ll zero=n-three-two-one;
				if(zero==n)continue;
				if(three+two+one>n)continue;
				ld value=1;
				//  picking three
				if(three>0)value+=(1.0*three/n)*dp[three-1][two+1][one];
				if(two>0)value+=(1.0*two/n)*dp[three][two-1][one+1];
				if(one>0)value+=(1.0*one/n)*dp[three][two][one-1];

				dp[three][two][one]=(value)/(1-1.0*zero/n);
			}
		}
	}

	ld ans=dp[cnt[3]][cnt[2]][cnt[1]];
	cout<<fixed<<setprecision(10);
	cout<<ans<<endl;

}

int main(){
	//mahakal();
	fast;
	ll t =1 ;
	//cin>> t ;
	while(t--)solve();
	//cerr << "\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
	return 0;
}


#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
int N;
int A[200000];
int main(){
  int i;
  long long res = 0;
  long long mx = -1;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  for(i=(0);i<(N);i++){
    res +=max_L(mx - A[i], 0);
    chmax(mx, A[i]);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200911-1

// --- original code ---
// int N, A[2d5];
// {
//   ll res = 0, mx = -1;
//   rd(N,A(N));
//   rep(i,N){
//     res += max(mx - A[i], 0);
//     mx >?= A[i];
//   }
//   wt(res);
// }

#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
*/

ll N, M;
vector<ll> g[MAX];
ll clr[MAX];

void dfs(ll c, ll u) {
  if(clr[u]!=-1) return;

  clr[u]=c;

  for(ll i=0; i<g[u].size(); i++)
    dfs(1-c, g[u][i]);

}

int main(void) {
  ll i, j, k;

  cin >> N >> M;

  for(i=0; i<M; i++) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  memset(clr, -1, sizeof(clr));
  dfs(0, 0);

  for(i=0; i<N; i++) {
    for(j=0; j<g[i].size(); j++) {
      if(clr[i]==clr[g[i][j]]) { //not bipartite graph
        pt(N*(N-1)/2-M);
        return 0;
      }
    }
  }

  ll cnt=0;
  for(i=0; i<N; i++) if(clr[i]==0) cnt++;
  pt(cnt*(N-cnt)-M);

}


#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int main() {
  int n,k;
  while(cin >> n >> k, n && k) {

    long long INF = 1e10;
    vector<vector<long long>> dist(n, vector<long long>(n, INF));
    for(int i = 0;i < n;i++) dist[i][i] = 0;

    for(int q = 0;q < k;q++) {
      int Q;
      cin >> Q;
      if(Q == 0) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(dist[a][b] < INF) {
          cout << dist[a][b] << endl;
        }
        else {
          cout << -1 << endl;
        }
      }
      else {
        long long c,d,e;
        cin >> c >> d >> e;
        c--;
        d--;
        dist[c][d] = min(dist[c][d], e);
        dist[d][c] = min(dist[d][c], e);

        for(int i = 0;i < n;i++) for(int j = 0;j < n;j++) {
          dist[i][j] = min(dist[i][j], dist[i][c] + dist[c][d] + dist[d][j]);
        }

        for(int i = 0;i < n;i++) for(int j = 0;j < n;j++) {
          dist[i][j] = min(dist[i][j], dist[i][d] + dist[d][c] + dist[c][j]);
        }
      }
    }
  }
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#define PAIR pair<long long,int>
using namespace std;

class island{
public:
    vector<PAIR> road;
    void add(int goal,int much){
        road.push_back(PAIR(much,goal));
    }
};
long long func(vector<island>&,int,int);
int main(){
    int n,m;
    while(cin>>n>>m&&n){
        vector<island> map(n+1);
        for(int i=0;i<m;++i){
            int type;
            cin>>type;
            if(type==1) {
                int a,b,much;
                cin>>a>>b>>much;
                map[a].add(b,much);
                map[b].add(a,much);
            }else{
                int s,g;
                cin>>s>>g;
                cout<<func(map,s,g)<<endl;
            }
        }
    }
    return 0;
}

long long func(vector<island>& map,int s,int g){
    vector<long long> much(map.size()+1,-1);
    priority_queue<PAIR,vector<PAIR>,greater<PAIR> > que;
    que.push(PAIR(0,s));
    much[s]=0;
    while(!que.empty()){
        PAIR dpair = que.top();
        que.pop();
        long long time = dpair.first;
        int np = dpair.second;
        if(much[np]!=time){
            continue;
        }
        for(vector<PAIR>::iterator itr = map[np].road.begin();itr!=map[np].road.end();++itr){
            long long ntime = time + itr->first;
            int ng = itr->second;
            if(much[ng]==-1||much[ng]>ntime){
                much[ng]=ntime;
                que.push(PAIR(ntime,ng));
            }
        }
    }
    return much[g];
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int N; string S, T;
  cin >> N >> S >> T;

  for (int i = 0; i < N; i++){
    string ans = "";
    for (int j = 0; j < i; j++) ans += S[j];
    for (int j = 0; j < N; j++) ans += T[j];

    bool flag = true;
    for (int j = 0; j < N; j++){
      if (ans[j] != S[j]) flag = false;
    }
    if (flag){
      cout << ans.length() << endl;
      return 0;
    }
  }
  cout << N * 2 << endl;

  return 0;
}

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

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

signed main() {
  int n;
  string s,t;
  cin >> n >> s >>t;
  int sz = s.length();
  int tz = t.length();
  if(sz+tz<=n) {
      cout << n << endl;
      return 0;
  }
  int ma = 0;
  rrep(i,tz) {
      int ss = sz-1;
      int tmp=0;
      while(i>=0 && ss>=0) {
         // cout << s[ss]<<t[i]<<ss<<" "<<i<<" " << endl;
          if(s[ss]==t[i]) {
              if(i==0) {
                  cout << sz+tz-(sz-ss) << endl;
                return 0;
              }
              ss--;
              tmp++;
          }else {
              if(tmp>0) i++;
              break;
          }
          i--;
      }
      ma=max(tmp,ma);
      //cout << ma << endl;
  }
  cout << sz+tz-ma << endl;
  return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if (a + b >= a - b && a + b >= a * b) {
        cout << a + b << endl;
    }
    else if (a - b >= a + b && a - b >= a * b) {
        cout << a - b << endl;
    }
    else if (a * b >= a + b && a * b >= a - b) {
        cout << a * b << endl;
    }

    return 0;
}

#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1)
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  k--;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}

int main(void){
  ll n, m;
  cin >> n >> m;

  vector<ll> divisor(0);
  for (int i = 2; i*i <= m; i++){
    if (m % i == 0){
      int t = 0;
      while (m % i == 0){
        m /= i;
        t++;
      }
      divisor.push_back(t);
    }
  }
  if (m != 1){
    divisor.push_back(1);
  }

  ll ans = 1;
  for (int i = 0; i < divisor.size(); i++){
    ans = ans * nck(n + divisor[i] - 1, divisor[i]) % MOD;
  }
  cout << ans << endl;

  return 0;
}


#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ());

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

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

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

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}

const int maxn = 102;
char s[maxn][maxn];
int n, m;

int xe, ye;

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == 'E') {
        xe = i, ye = j;
      }
    }
  }
  return 1;
}

int prec[2][maxn][maxn];

inline int get(int type, int x, int l, int r) {
  auto &cur = prec[type][x];
  return cur[r] - cur[l];
}

short dp[maxn][maxn][maxn][maxn];
short res;

inline void update(int x1, int x2, int y1, int y2, short nval) {
  auto &cur = dp[x1][x2][y1][y2];
  if (cur < nval) {
    cur = nval;
    if (res < nval) {
      res = nval;
    }
  }
}

void solve() {
  for (int i = 0; i < n; ++i) {
    prec[0][i][0] = 0;
    for (int j = 0; j < m; ++j) {
      prec[0][i][j + 1] = prec[0][i][j] + (s[i][j] == 'o');
    }
  }

  for (int i = 0; i < m; ++i) {
    prec[1][i][0] = 0;
    for (int j = 0; j < n; ++j) {
      prec[1][i][j + 1] = prec[1][i][j] + (s[j][i] == 'o');
    }
  }
  memset(dp, -1, sizeof(dp));
  dp[0][0][0][0] = 0;
  int xl = xe + 1, xr = n - xe;
  int yl = ye + 1, yr = m - ye;

  res = 0;

  for (int cxl = 0; cxl < xl; ++cxl) {
  for (int cxr = 0; cxr < xr; ++cxr) {
  for (int cyl = 0; cyl < yl; ++cyl) {
  for (int cyr = 0; cyr < yr; ++cyr) {
    auto cur = dp[cxl][cxr][cyl][cyr];
    if (cur < 0) {
      continue;
    }
    int x1 = max(xe - cxl, cxr);
    int x2 = min(xe + cxr, n - 1 - cxl) + 1;

    int y1 = max(ye - cyl, cyr);
    int y2 = min(ye + cyr, m - 1 - cyl) + 1;

    if (cxr + cxl + 1 < xl) {
      update(cxl + 1, cxr, cyl, cyr, cur + get(0, x1 - 1, y1, y2));
    }
    if (cxr + cxl + 1 < xr) {
      update(cxl, cxr + 1, cyl, cyr, cur + get(0, x2, y1, y2));
    }
    if (cyr + cyl + 1 < yl) {
      update(cxl, cxr, cyl + 1, cyr, cur + get(1, y1 - 1, x1, x2));
    }
    if (cyr + cyl + 1 < yr) {
      update(cxl, cxr, cyl, cyr + 1, cur + get(1, y2, x1, x2));
    }
  }
  }
  }
  }
  printf("%d\n", (int) res);
}

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

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

#include<bits/stdc++.h>
using namespace std;
// Reference : Erichto + https://www.youtube.com/watch?v=1HiJ332iZQU
long double dp[301][301][301];

long double solve(int ones, int twos, int threes, int n) {
	// cout<<"At "<<ones <<" "<< twos <<" "<< threes<<endl;
	if(ones + twos + threes == 0) {
		// cout<<"Base:"<<0<<endl;
		return 0;
	}
	if(dp[ones][twos][threes] != -1) {
		// cout<<"Cache:"<<dp[ones][twos][threes]<<endl;
		return dp[ones][twos][threes];
	}
	long double coeff1 = (long double)ones / (long double)(ones + twos + threes);
	long double coeff2 = (long double)twos / (long double)(ones + twos + threes);
	long double coeff3 = (long double)threes / (long double)(ones + twos + threes);
	long double ans = (long double) n/ (long double) (ones + twos + threes);
	dp[ones][twos][threes] = ans +
				coeff1 * (ones == 0 ? 0 : solve(ones - 1, twos, threes, n)) +
				coeff2 * (twos == 0 ? 0 : solve(ones + 1, twos - 1, threes, n)) +
				coeff3 * (threes == 0 ? 0 : solve(ones, twos + 1, threes - 1, n ));
	// cout<<"Returning" << dp[ones][twos][threes]<<endl;
	return dp[ones][twos][threes];
}

int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int a[n];
	int cnt[4]={0};
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	for(int i = 0; i <= 300; ++i) {
		for(int j = 0; j <= 300; ++j) {
			for(int k = 0; k <= 300; ++k) {
				dp[i][j][k] = -1;
			}
		}
	}
	cout<<fixed<<setprecision(20)<<solve(cnt[1], cnt[2], cnt[3], n);
}


#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int n,m,p;
    std::deque<int> deq;
    while (cin>>n>>m) {
        if (n==0&&m==0) {
            break;
        } else {
            for (int i=0;i<n;i++) {
                cin>>p;
                deq.emplace_back(p);
            }
            sort(deq.begin(),deq.end(),greater<int>());
            int sum=0;
            while (n>=m) {
                for (int j=0;j<m;j++) {
                    if (j!=m-1) {
                        sum+=deq.front();
                        deq.pop_front();
                        n--;
                    } else {
                        deq.pop_front();
                        n--;
                    }
                }
            }
            if (n!=0) {
                for (int k=0;k<n;k++) {
                    sum+=deq.front();
                    deq.pop_front();
                }
            }
            cout<<sum<<endl;
        }
    }
}

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

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	string str;
	for(;getline(cin,str);){
		int len=str.size();
		int i,c;
		for(c=1;c<=26;c++){
			for(i=0;i<len;i++){
				if('a'<=str[i]&&str[i]<='z'){
					str[i]++;
					if(str[i]>'z')str[i]='a';
				}
			}
			//cout<<str<<endl;
			if(str.find("the")!=string::npos||str.find("this")!=string::npos||str.find("that")!=string::npos){
				cout<<str<<endl;
				break;
			}
		}
	}
	return 0;
}


#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
//#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main() {
	string s, t = "JOI";
	cin >> s;
	s += 'X';
	int ans = 0, f = -1, now = 0, pre = 0;
	rep(i, 0, s.size()) {
		if (s[i] == t[f]) {
			now++;
		}
		else if (f == 0 && s[i] == t[1]) {
			pre = now;
			now = 1;
			f = 1;
		}
		else if (f == 1 && s[i] == t[2]) {
			if (pre < now) {
				f = -1;
			}
			else {
				f++;
				pre = now;
				now = 1;
			}
		}
		else if (f == 2 && s[i] != t[2]) {
			if (pre <= now) ans = max(ans, pre);
			f = -1;
		}
		else {
			f = -1;
		}
		if (f == -1 && s[i] == 'J') {
			f = 0;
			now = 1;
		}
	}
	cout << ans << endl;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;

    }else{
        return a.second < b.second;
    }
}

bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

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

    ll k;
    cin>>k;

    if(a[4]-a[0]>k){
        cout<<":("<<endl;
    }else{
        cout << "Yay!" << endl;
    }

    return 0;

}

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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if(e - a <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;
}


#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

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

        ll ans = 1;
        rep(i, 1, N+1) {
                if (i * i > N) break;
                ans = i;
        }
        cout << ans*ans << endl;
}

#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int arr[101] = {0};

int main()
{
	long long int a, total=0;
	cin >> a;
	for(int i=1; i<=a; i++)
	{
		if(i%3 !=0 && i%5 != 0)
		{
			total += i;
		}
	}
	cout << total;
}


#include <iostream>
#include <queue>
#include <map>

using namespace std;

typedef pair<int, int> P;

int B[101][101];

bool bfs(int w, int h, int xs, int ys, int xg, int yg);

int main(int argc, char** argv)
{
	int w, h;
	int xs, ys;
	int xg, yg;
	int n;
	int c, d, x, y;

	while( 1 )
	{
		cin >> w;
		cin >> h;
		if(w==0 && h==0) break;

		cin >> xs;
		cin >> ys;
		cin >> xg;
		cin >> yg;
		cin >> n;

		for(int i=0; i<n; i++)
		{
			cin >> c; cin >> d; cin >> x; cin >> y;
			if(d==0)
			{
				for(int dx=0; dx<4; dx++)
				{
					for(int dy=0; dy<2; dy++)
					{
						B[x+dx][y+dy] = c;
					}
				}
			}
			else
			{
				for(int dx=0; dx<2; dx++)
				{
					for(int dy=0; dy<4; dy++)
					{
						B[x+dx][y+dy] = c;
					}
				}
			}
		}

		cout << (bfs(w, h, xs, ys, xg, yg) ? "OK" : "NG") << endl;
	}

	return 0;
}

bool bfs(int w, int h, int xs, int ys, int xg, int yg)
{
	int x, y, c, xx, yy;
	int offset[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
	queue<P> q;
	P p;

	c = B[xs][ys];
	B[xs][ys] = 0;
	p.first = xs, p.second = ys;

	q.push(p);
	while(!q.empty())
	{
		p = q.front();
		q.pop();
		x = p.first;
		y = p.second;
		if(x==xg && y==yg) return true;
		B[x][y] = 0;

		for(int i=0; i<4; i++)
		{
			xx = x + offset[i][0];
			yy = y + offset[i][1];
			if(x>=1 && y>=1 && x<=w && y<=h)
			{
				if(B[xx][yy] == c)
				{
					p.first = xx;
					p.second = yy;
					q.push(p);
				}
			}
		}
	}

	return false;
}

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

#define INF 1e18
long long DP[5001][5001];

struct Constraint {
	long long H, P;

	Constraint(long long H = 0, long long P = 0):H(H), P(P){}

	bool operator<(const Constraint& r)const {
		return P+H < r.P+r.H;
	}
};

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

	int N; cin >> N;
	vector<Constraint>C(N);
	for (int i = 0; i < N; i++) {
		int P, H; cin >> H >> P;
		C[i] = Constraint(H, P);
	}
	sort(C.begin(), C.end());

	for (int i = 0; i <= N; i++)for (int j = 0; j <= N; j++)DP[i][j] = INF;
	DP[0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < i + 1; j++) {
			if (DP[i][j] == INF)continue;

			if (DP[i][j] <= C[i].H) {
				DP[i + 1][j + 1] = min(DP[i + 1][j + 1], DP[i][j] + C[i].P);
			}
			DP[i + 1][j] = min(DP[i + 1][j], DP[i][j]);
		}
	}

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			if (DP[i][j]==0 || DP[i][j] == INF)continue;
			ans = max(ans, j);
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
  // ここにプログラムを追記
  int R,G;
  cin >> R >> G;
  double x = 2 * G - R;
  cout << x << endl;
}

#include<iostream>
int main(){
    int R,G;
    std::cin >> R >> G;
    std::cout << G + G - R;
}


#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void) {
    string s;
    cin >> s;
    bool ok = true;
    for(ll i = 0; i < s.length(); i+=2){
        if(s[i]!='h'||s[i+1]!='i'){
            ok = false;
            break;
        }
    }
    if(ok==true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

int main() {
  int x,y;
  cin >> x;
  y = x % 500;
  x /= 500;
  y /= 5;
  cout << 1000*x+5*y << endl;
  return 0;
}


#include <bits/stdc++.h>

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

template <typename T>
std::map<T, int> Factorize(T x) {
  std::map<T, int> m;
  for (T i = 2; i * i <= x;) {
    if (x % i == 0) {
      m[i]++;
      x /= i;
    } else {
      ++i;
    }
  }
  if (x > 1) m[x]++;
  return m;
}

int main() {
  in(int, n, m);
  map<int, int> fs = Factorize(m);
  int ans = 1;
  function<void(map<int, int>::iterator, int)> dfs =
      [&](map<int, int>::iterator it, int x) {
        if (it == fs.end()) {
          if (m / x >= n) ans = max(ans, x);
          return;
        }
        rep(i, it->second + 1) {
          dfs(next(it), x);
          x *= it->first;
        }
      };
  dfs(fs.begin(), 1);
  out(ans);
}

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

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

const int INF = 1e9;

int main() {
    string S; cin >> S;
    int N = S.size();
    vector<vector<int>> dp(N + 1, vector<int>(2, INF));
    dp[0][0] = 0;
    for(int i = 0; i < N; ++i) {
        int d = S[i] - '0';
        chmin(dp[i + 1][0], min(dp[i][0], dp[i][1]) + d);
        chmin(dp[i + 1][1], min(dp[i][0] + 1, dp[i][1] - 1) + 10 - d);
    }
    cout << min(dp[N][0], dp[N][1]) << '\n';
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>

using namespace std;
#define DEBUG(x) cout<<#x<<": "<<x<<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define INT(a) int((a)+1e-9)
int DX[4]={1,0,-1,0};
int DY[4]={0,1,0,-1};

#define EMP 0
#define OBS 1
#define WAL 4
#define STT 2
#define GOA 3

#define SUPmaxY 22
#define SUPmaxX 22

int maxY,maxX;
int field[SUPmaxX][SUPmaxY];
int startX,startY;
int result;

int dfs(int x, int y, int depth){
	//DEBUG(x);DEBUG(y);DEBUG(depth);
	if(depth>=result) return 0;
	if(field[x][y]==GOA) {result=depth; return 0;}

	FOR(di,0,4){
		int nx=x; int ny=y;
		int dx=DX[di]; int dy=DY[di];
		if(field[x+dx][y+dy]==OBS) continue;
		while(field[nx][ny]==EMP){
			nx+=dx;ny+=dy;
		}
		if(field[nx][ny]==WAL){continue;}
		if(field[nx][ny]==GOA){result=depth+1; return 0;}
		if(field[nx][ny]==OBS){
			field[nx][ny]=EMP;
			dfs(nx-dx,ny-dy,depth+1);
			field[nx][ny]=OBS;
		}
	}

}

int main(){
	while(true){
		cin>>maxY>>maxX;			if(!maxY) return 0;
		maxX+=2;maxY+=2;
		FOR(x,0,maxX) FOR(y,0,maxY) field[x][y]=WAL;
		FOR(x,1,maxX-1) FOR(y,1,maxY-1) cin>>field[x][y];
		FOR(x,1,maxX-1) FOR(y,1,maxY-1) if(field[x][y]==STT){startX=x;startY=y;field[x][y]=EMP;}

		result=11;
		dfs(startX,startY,0);
		cout<< ((result==11)?-1:result) <<endl;
	}
}


#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  bool contains_odd = false;
  bool contains_even = false;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.rbegin(), A.rend());
  ll g = gcd(A[0], A[1]);
  for (int i = 2; i < N; i++) {
    g = gcd(g, A[i]);
  }
  if (K % g == 0 && K <= A[0]) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}

#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Data{
public:
	ll first,second,third;
	Data()=default;
	Data(ll f,ll s,ll t):first(f),second(s),third(t){}
};

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

	ll N=in(),K=in();
	out(N-K+1);

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; }
const int INF = 1e18;

signed main(){
    double n, m, d; cin >> n >> m >> d;
    double ans = max(n-d,0.0)*(d !=0 ? 2 : 1) / (n*n) * (m-1);
    cout << fixed << setprecision(20.20) << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,m,d;
    cin>>n>>m>>d;
    cout<<fixed<<setprecision(10)<<((d==0)?1.:2.)*(n-d)/n*(m-1)/n;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}
//unionfind
struct UnionFind {
  vector< int > data;

  UnionFind(int sz) {
    data.assign(sz, -1);
  }

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k) {
    return (-data[find(k)]);
  }
};
int main(){
  string s;
  int w;
  cin >> s >> w;
  string ans;
  rep(i,(s.size()-1)/w+1)
    ans+=s.at(w*i);
  cout << ans << endl;
}

#include <bits/stdc++.h>

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int main(){
  string s;
  int w;
  cin>>s>>w;
  for(int i(0);i<int(s.size());i++){
    if(i%w==0) cout << s[i];
  }
  cout << endl;
  return 0;
}


#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
#define int long long
namespace run{
	const int N=2e5+9;
	int a[N],m,v,p,n,ans,sum[N];
	int main(){
		n=read<int>(),m=read<int>(),v=read<int>(),ans=p=read<int>();
		for(int i=1;i<=n;i++) a[i]=read<int>();
		sort(a+1,a+n+1);
		for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
	//	for(int i=1;i<=n;i++) cout<<a[i]<<" ";cout<<endl;
		for(int i=1;i<=n-p;i++){
			if(m+a[i]<a[n-p+1]) continue;
			else{
				int tmp=(p-1+i)*m+((n-p+1-i)*(a[i]+m)-(sum[n-p+1]-sum[i]));
			//	cout<<tmp<<endl;
				if(tmp>=m*v) ans++;
			}
		}
		printf("%lld\n",ans);
		return 0;
	}
}
#undef int
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

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

using namespace std;

int main(){
    long long N, M, V, P; cin >> N >> M >> V >> P;
    vector<long long> A(N);
    for(auto& t : A) cin >> t;
    sort(A.begin(), A.end());
    int L = -1, R = N-1;
    while(R-L > 1){
        int mid = (L+R)/2;
        long long thr = A[mid] + M;
        int gr = 0;
        long long add = M;
        for(int j=N-1;j>=0;j--){
            if(j == mid) continue;
            if(A[j] > thr){
                gr++;
                add += M;
            } else {
                if(gr+1 < P && A[j]+M > thr){
                    gr++;
                    add += M;
                } else {
                    add += min(M, thr-A[j]);
                }
            }
        }
        if(gr < P && add >= M*V) R = mid;
        else L = mid;
    }
    cout << N-R << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  IOS;
  int n=5;
  int d[n],k;
  REP(i,5) cin >> d[i];
  cin >> k;

  REP(i,n) {
    REP(j,n) {
      if (i == j) continue;
      if (abs(d[i]-d[j]) > k) { COUT(":("); return 0; }
    }
  }
  COUT("Yay!");
  return 0;
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, C, D, E, X;
  cin >> A >> B >> C >> D >> E >> X;
  int ma, mi;
  ma = max(max(max(max(A, B), C), D), E);
  mi = min(min(min(min(A, B), C), D), E);
  if(ma - mi > X) {
    cout << ":(" << endl;
  }
  else {
    cout << "Yay!" << endl;
  }
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the iterator to kth largest element.(0-based)
typedef long long int lli;
#define pb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pair<int,int>>
#define vc vector<char>
#define vs vector<string>
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define fastio	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
/*-------CONSTANTS------- */
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);
const int INF = 1000000000;
const int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
/*-----------------------------MATH STUFF----------------------------- */
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
int mod_neg(int a, int b, int c){int res;if(abs(a-b)<c)res=a-b;else res=(a-b)%c;return(res<0?res+c:res);}
int mulmod(int a, int b, int c){lli res=(lli)a*b;return(res>=c?res%c:res);}
template<typename T>T power_mod(T e, T n, T m){T x=1,p=e;while(n){if(n&1)x=mulmod(x,p,m);p=mulmod(p,p,m);n>>=1;}return x;}
template<typename T>T extended_euclid(T a, T b, T &x, T &y){T xx=0,yy=1;y=0;x=1;while(b){T q=a/b,t=b;b=a%b;a=t;\
t=xx;xx=x-q*xx;x=t;t=yy;yy=y-q*yy;y=t;}return a;}
template<typename T>T mod_inverse(T a, T n){T x,y,z=0;T d=extended_euclid(a,n,x,y);return(d>1?-1:mod_neg(x,z,n));}
//Factorials upto 1e5%MOD,nCr%MOD,nPr%MOD
lli fact[100000+5],fact_modinv[100000+5];
void fact_init(){
    fact[0] = 1ll;
    fact_modinv[0] = mod_inverse(fact[0],1ll*MOD);
    for(int i = 1;i<=100000;i++){
        fact[i] = mulmod(fact[i-1],i,1ll*MOD);
        fact_modinv[i] = mod_inverse(fact[i],1ll*MOD);
    }
}
lli choose(int n,int r){
    return mulmod(fact_modinv[n-r],mulmod(fact[n],fact_modinv[r],MOD),MOD);
}
lli P(int n,int r){
    return mulmod(fact[n],fact_modinv[n-r],1ll*MOD);
}
/*-----------------------------START----------------------------- */

int n,m;
vector<int> g[10000+5],gr[10000+5];
vector<int> topo;
bool visited1[10000+5],visited2[10000+5];
vector<int> scc[10000+5];
int par[10000+5];
void dfs(int u){
    visited1[u] = true;
    for(auto x : g[u])
        if(!visited1[x])
            dfs(x);

    topo.push_back(u);
}

void dfs2(int u,int p){
    visited2[u] = true;
    par[u] = p;

    for(auto x : gr[u])
        if(!visited2[x])
            dfs2(x,p);
}
int main(){
    fastio;
    cin>>n>>m;
    for(int i = 0;i<m;i++){
        int u,v;
        cin>>u>>v;
        g[u].pb(v);
        gr[v].pb(u);
    }
    for(int i = 0;i<n;i++)
        if(!visited1[i])
            dfs(i);

    reverse(topo.begin(),topo.end());

    for(auto x : topo)
        if(!visited2[x])
            dfs2(x,x);

    int q;cin>>q;
    while(q--){
        int u,v;
        cin>>u>>v;
        cout<<(par[u] == par[v])<<endl;
    }

    return 0;
}

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

// 強連結成分分解
//   計算量: O(V + E)
//   operator[]: 頂点kが属する強連結成分の番号を返す

class StronglyConnectedComponents {
    int V;
    vector<vector<int>> G, rG;
    vector <int> comp; // 強連結成分の番号（トポロジカル順）
    vector <int> order; // DFSで辿った順
    vector <int> used;

    void dfs(int cur) {
        if (used[cur]) return;
        used[cur] = true;
        for (int to : G[cur]) dfs(to);
        order.push_back(cur);
    }

    void rdfs(int cur, int cnt) {
        if (comp[cur] != -1) return;
        comp[cur] = cnt;
        for (int to : rG[cur]) rdfs(to, cnt);
    }

public:
    StronglyConnectedComponents(vector<vector<int>> &edge) {
        V = edge.size();
        G.resize(V);
        rG.resize(V);
        comp.assign(V, -1);
        used.assign(V, false);
        for (int i = 0; i < V; i++) {
            for (int e : edge[i]) {
                G[i].push_back(e);
                rG[e].push_back(i);
            }
        }
    }

    int operator[](int k) { return comp[k]; }

    void build(vector<vector<int>> &buff) {
        for (int i = 0; i < V; i++) dfs(i);
        reverse(order.begin(), order.end());
        int cnt = 0;
        for (int i : order) if (comp[i] == -1) rdfs(i, cnt++);
        buff.resize(cnt);
        for (int i = 0; i < V; i++) {
            for (int to : G[i]) {
                int x = comp[i], y = comp[to];
                if (x == y) continue;
                buff[x].push_back(y);
            }
        }
    }
};

// verified
//   https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/3/GRL_3_C
void AOJ_GRL_3_C() {
    int V, E;
    cin >> V >> E;

    vector<vector<int>> edge(V), buff;
    for (int i = 0; i < E; i++) {
        int s, t;
        cin >> s >> t;
        edge[s].push_back(t);
    }

    StronglyConnectedComponents scc(edge);
    scc.build(buff);

    int Q;
    cin >> Q;
    while (Q--) {
        int u, v;
        cin >> u >> v;
        cout << (scc[u] == scc[v] ? 1 : 0) << "\n";
    }
}

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


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

int main(void){
    int n,r;
    cin>>n>>r;

    if(n>=10){
        cout<<r<<endl;
    }else{
        cout<<r+1000-100*n<<endl;
    }
    return 0;
}

#include<stdio.h>
#include<bits/stdc++.h>
#define mod 1000000007
#define maxn 4000095
using namespace std;
int f[2005][2005],fac[maxn],inv[maxn];
int add(int a,int b){a+=b; return a>=mod?a-mod:a;}
int ksm(int a,int b)
{
	int s=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1) s=1ll*s*a%mod;
	return s;
}
int n,k;
void Pre()
{
	fac[0]=1;
	for(int i=1;i<maxn;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[maxn-1]=ksm(fac[maxn-1],mod-2);
	for(int i=maxn-2;i>=0;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
int C(int n,int m){return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	Pre();
	scanf("%d%d",&n,&k);
	if(k==1) return puts("1"),0;
	f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			f[i][j]=f[i-1][j];
			if(j) f[i][j]=add(f[i][j],1ll*C(n*k-i-(j-1)*(k-1)-1,k-2)*(n-j+1)%mod*f[i][j-1]%mod);
		}
	}
	printf("%d\n",f[n][n]);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define mp  make_pair
#define pb  push_back
#define endl "\n"
#define rep(i,a,n) for(int i=a;i<n;i++)
const int mod = 1e9 + 7;
void solve() {
	int n;
	cin >> n;
	int a[n];
	rep(i, 0, n) {
		cin >> a[i];
	}
	int s = 0;
	rep(i, 1, n) {
		if (a[i] < a[i - 1]) {
			s += a[i - 1] - a[i];
			a[i] = a[i - 1];
		}
	}
	cout << s << endl;
}
int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	int t;
	t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

#include <iostream>

typedef long long ll;

using namespace std;

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

    ll A;
    cin >> A;
    ll height = A;
    ll ans = 0;
    for (int i = 0; i < N - 1; ++i) {
        cin >> A;
        if (height > A) {
            ans += height - A;
        }
        else {
            height = A;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main()
{
	int n, m; scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++i)
		if (2 * i < m + 2) printf("%d %d\n", i, m + 2 - i);
	for (int i = 1; i <= m; ++i)
		if (2 * i < m + 1) printf("%d %d\n", m + 1 + i, 2 * m + 2 - i);
	return 0;
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, M, tmp=0;
vector<pair<ll,ll>> ans;

signed main(){
    cin >> N >> M;
    for(int i=1;i<=M;i++) {
        tmp = 0;
        if(N%2==0&&4*i>=N) tmp++;
        cout << (N-i-tmp)%N << " " << (N+i)%N << endl;
    }
    return 0;
}


#include <iostream>
using namespace std;
int main(void){
    int n,i,k;
    cin >> n;
    int day[n];
    for(i=0;i<n;i++){
    cin >> day[i+1];
    }cout << day [n];
    for(k=1;k<n;k++){
        cout << " ";
        cout << day[n-k];
    }
    cout << endl;
}

#include <iostream>
#include <string>
#include <sstream>
#include <stack>

using namespace std;

int main()
{
  string s;
  getline(cin, s);
  getline(cin, s);
  stringstream ss(s);
  stack<string> st;

  while (ss.peek() != EOF) {
    uint t;
    ss >> t;
    st.push(to_string(t));
    if (ss.peek() == EOF) break;
    st.push(" ");
  }

  while (!st.empty()) {
    cout << st.top();
    st.pop();
  }
  cout << endl;
}


#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;

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

int main() {
    ll N,K;
    cin >> N >> K;
    ll out = 1;
    if(N%K==0) out = 0;
    cout << out << endl;
    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <cmath>
#include <cstdint>
using namespace std;

inline namespace atcoder {
    using i32 = int32_t; using u32 = uint32_t;
    using i64 = int64_t; using u64 = uint64_t;
    using f32 = float; using f64 = double;

    template <typename T, size_t Depth>
    struct vector_helper { using type = vector<typename vector_helper<T, Depth - 1>::type>; };
    template <typename T>
    struct vector_helper<T, 0> { using type = T; };
    template <typename T, size_t Depth>
    using vector_t = typename vector_helper<T, Depth>::type;

    template <typename T> using vec = vector_t<T, 1>;
    template <typename T> using vvec = vector_t<T, 2>;
    template <typename T> using vvvec = vector_t<T, 3>;
}

int main() {
    int n, r; cin >> n >> r;
    cout << (n < 10 ? r + 100 * (10 - n) : r) << endl;
}


//Date and time of submission:

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin>>a>>b;
	cout<<(a%b!=0);
	return 0;
}

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

int main(int argc, char* argv[]){
	int N, M;
	scanf("%d %d", &N, &M);

	int A = M + 2;
	int B = M + 1;
	int C = 2*M + 2;
	for(int i=1, j=0; j < M; i++){
		printf("%d %d\n", i, A - i);
		if(++j < M){
			printf("%d %d\n", B + i, C - i);
			j++;
		}
	}
	return 0;
}


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

int main(){
    int n, q; string s;
    cin >> n >> s >> q;

    for(int i=0; i<q; i++){
        int k;
        cin >> k;

        long long int d = 0, m = 0, dm = 0, ans = 0;
        for(int i=0; i<n; i++){
            if(s[i] == 'D') d += 1;
            if(s[i] == 'M'){ m += 1; dm += d; }

            if(i >= k){
                if(s[i-k] == 'D'){ d -= 1; dm -= m; }
                if(s[i-k] == 'M') m -= 1;
            }

            if(s[i] == 'C') ans += dm;
        }
        cout << ans << endl;
    }
    return 0;
}

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

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

  while (true) {
    n++;
    string s = to_string(n);
    bool flg = true;
    for (auto c:s) {
      rep(i, k) if (c-'0' == a[i]) flg = false;
    }
    if (flg) {
      cout << n << endl;
      return 0;
    }
  }

  return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
using namespace std;

int main() {
  vector<int> result;
  string n;
  string input;

  getline(cin, n);
  getline(cin, input);
  istringstream iss(input);
  string num;

  while (getline(iss, num, ' ')) {
    result.push_back(stoi(num));
  }

  long long min = *min_element(result.begin(), result.end());
  long long max = *max_element(result.begin(), result.end());
  long long sum = accumulate(result.begin(), result.end(), 0LL);

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

#include <iostream>

using namespace std;
int main(void){
    int max=-2147483648;
    int min=2147483647;
    long sum=0;

    int n,in;
    cin >> n;

    for (int i=0;i<n;i++){
        cin >> in;
        if(min>in) min=in;

        if(max<in) max=in;

        sum = sum + in;
    }

    cout << min <<" "<< max <<" "<< sum << endl;

    return 0;
}


/**
*    author:  souzai32
*    created: 13.08.2020 01:38:59
**/

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

int main() {

    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d.at(i);
    long long ans=1;
    if(d.at(0)!=0) ans=0;
    sort(d.begin(),d.end());
    if(n>2){
        if(d.at(1)==0) ans=0;
    }

    long x=1,y=1;
    for(int i=1; i<n; i++){
        if(d.at(i-1)==d.at(i)) y++;
        else if(d.at(i-1)+1==d.at(i)){
            x=y;
            y=1;
        }
        else ans=0;
        ans*=x;
        ans%=998244353;
    }

    cout << ans << endl;

    return 0;
}

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

#define print cout <<
#define printl(s) cout << s << endl;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;

const ll modval = pow(10,9) + 7;

template <typename T>
vector<T> getValues(int num){
    vector<T> values(num);
    for(int i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

int main(){
    int N;
    cin >> N;
    auto inputs = getValues<ll>(N);
    ll sumOfStep = 0;
    ll front = inputs.at(0);
    for(int i=1;i<N;i++){
      ll target = inputs.at(i);
      int step = 0;
      if(front>target){
        step = front -target;
        sumOfStep += step;
      }
      front = step + inputs.at(i);
    }
    printl(sumOfStep);
}


#include <bits/stdc++.h>

using namespace std;

#define ll long long int
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<ll>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.14159265
#define pb push_back
#define bits(n) __builtin_popcount(n)

void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b&&b!=c)||(a==c&&c!=b)||(b==c&&a!=c))
    cout<<"Yes";
    else
    {
        cout<<"No";
    }

}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

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

#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;

typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()

#define b() begin()
#define e() end()
#define all(x) x.begin(), x.end()

#define pb(i) push_back(i)
#define PB() pop_back()

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second

const int maxx=1e6+9;

// Happy Coding!

// 1 way is to find compute all the sorted permutations and find the
// positions of the current permutation.

char _find(string &str){
    bool pres[26]={0};
    for(char ch:str){
        pres[ch-'a']=1;
    }
    for(int i=0;i<26;i++){
        if(pres[i]==0){
            return (char)(i+'a');
        }
    }
    return '%';
}

void solve(){
    string str;
    cin>>str;
    char ch=_find(str);
    str="";
    str.push_back(ch);
    cout<<( str=="%" ? "None" : str)<<endl;
}

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


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    int count = 0;
    bool flag = true;
    while (flag) {
        rep(i, n) {
            if (v[i] % 2 == 1) {
                flag = false;
                break;
            }
            v[i] /= 2;
        }
        if (flag) count++;
    }
    cout << count << endl;
    return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n;
    vector<lint> vec; map<lint, int> mp;
    rep(i, n){
        lint x; cin >> x;
        vec.push_back(x); mp[x]++;
    }
    sort(all(vec));

    lint res = 0;
    repr(i, n){
        if(mp[vec[i]] == 0) continue;
        lint s = 1;
        while(s <= vec[i]) s *= 2;
        s -= vec[i];

        if(s == vec[i] && mp[s] > 1){
            mp[s] -= 2; res++;
        }
        if(s != vec[i] && mp[s] > 0){
            mp[vec[i]]--; mp[s]--; res++;
        }
    }
    out(res);
}


#include <iostream>
using namespace std;
int main(){
	int n, a[150];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n - 1; i++)
		cout << a[n - i - 1] << " ";
		cout << a[0];
		cout << endl;

	return 0;
}

//Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<ll,ll>&a,const pair<ll,ll>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    int k,x;
    cin>>k>>x;
    k--;
    for(int i=x-k;i<=x+k;i++)
        cout<<i<<" ";
    cout<<endl;

}
//Alhamdulillah


#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
	int N;
	int score[101];
	vector<int> res;
	int A, B, C, D;
	int rank[101];
	int n, r;

	scanf("%d", &N);
	for(int i = 1; i <= N; i++){
		score[i] = 0;
	}
	for(int i = 0; i < N * (N - 1) / 2; i++){
		scanf("%d%d%d%d", &A, &B, &C, &D);

		if(C > D) score[A] += 3;
		else if(C < D) score[B] += 3;
		else{
			score[A]++; score[B]++;
		}
	}

	for(int i = 1; i <= N; i++){
		res.push_back(score[i]);
	}
	sort(res.begin(), res.end(), greater<int>());
	res.erase(unique(res.begin(), res.end()), res.end());
	n = 0;
	for(int i = 0; i < res.size(); i++){
		r = n + 1;
		for(int j = 1; j <= N; j++){
			if(res[i] == score[j]){
				rank[j] = r;
				n++;
			}
		}
	}

	for(int i = 1; i <= N; i++){
		printf("%d\n", rank[i]);
	}

	return 0;
}

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

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

int N;
vector<pii> P;

bool cmp(pii a, pii b) {
    return a.first + a.second < b.first + b.second;
}

ll dp[2][5002];

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

    P.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d %d", &P[i].first, &P[i].second);
    }

    sort(P.begin(), P.end(), cmp);

    for(int i = 0; i < 5002; i++) dp[1][i] = 1e18;
    dp[1][0] = 0;
    for(int i = 0; i < N; i++) {
        dp[i&1][0] = 0;
        for(int j = 1; j <= N; j++) {
            dp[i&1][j] = 1e18;
            dp[i&1][j] = min(dp[i&1][j], dp[(i&1) ^ 1][j]);
            dp[i&1][j] = min(dp[i&1][j], dp[(i&1) ^ 1][j - 1] <= P[i].first? dp[(i&1) ^ 1][j - 1] + P[i].second : (ll)1e18);
        }
    }
    int ans = 0;
    for(int i = 0; i <= N; i++) if(dp[(N - 1) & 1][i] != 1e18) ans = i;
    printf("%d", ans);
}


// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T &v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

int G[500][500];
int ACC[501][501];

int main() {
  int n, m, q; in(n),in(m),in(q);
  loop(i,0,m) {
    int l, r; in(l),in(r);
    l--;r--;
    G[l][r]++;
  }

  loop(y,0,n) {
    loop(x,0,n) {
      ACC[y+1][x+1] = ACC[y+1][x] + ACC[y][x+1] - ACC[y][x] + G[y][x];
    }
  }

  // loop(y,0,n+1) {
  //   loop(x,0,n+1) {
  //     print(ACC[y][x], " ");
  //   }
  //   print("");
  // }

  loop(i,0,q) {
    int l,r; in(l),in(r);
    int cnt = ACC[r][r];
    cnt += ACC[l-1][l-1];
    cnt -= ACC[l-1][r];
    cnt -= ACC[r][l-1];
    // print(ACC[r][r]);
    // print(ACC[l-1][l-1]);
    // print(ACC[l-1][r]);
    // print(ACC[r][l-1]);
    print(cnt);
  }
  return 0;
}

#include<bits/stdc++.h>

using namespace std;

const int N=502;

int n,m,q;
int f[N][N];

int main()
{
	cin>>n>>m>>q;
	for(int i=1;i<=m;++i)
	{
		int u,v;
		cin>>u>>v;
		for(int j=v;j<=n;++j)
		{
			f[u][j]++;
		}
	}
	for(int i=1;i<=q;++i)
	{
		int u,v;
		cin>>u>>v;
		int res=0;
		for(int j=u;j<=v;++j)
		{
			res+=f[j][v];
		}
		cout<<res<<endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>

using namespace std;

#define repeat(n, i) for(int i=0; i<(n); i++)
int w, h;
int xs, ys;
int xg, yg;
int n;

int st_color;

int board[300][300];

#define VISITED 6

bool get_input() {
    memset(board, 0, sizeof(board));
    cin >> w >> h;
    if (w == 0 && h == 0) return false;
//    board.resize(h);
//    repeat(h, i) board[i].resize(w);
    cin >> xs >> ys;
    cin >> xg >> yg;
    cin >> n;
    repeat(n, i) {
        int c, d, x, y;
        cin >> c >> d >> x >> y;
        if (d == 1) {
            for (int j = y-1; j < y-1+4; j++) {
                for (int k = x-1; k < x-1+2; k++) {
                    board[j][k] = c;
                }
            }
        } else {
            for (int j = y-1; j < y-1+2; j++) {
                for (int k = x-1; k < x-1+4; k++) {
                    board[j][k] = c;
                }
            }
        }
    }
    st_color = board[ys-1][xs-1];
    return true;
}

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

bool possible;
void dfs(int x, int y) {
    board[y-1][x-1] = VISITED;
    if (x == xg && y == yg) {
        possible = true;
        return;
    }
    repeat(4, i) {
        int nx = x+dx[i], ny = y+dy[i];
        if (1 <= nx && nx <= w && 1 <= ny && ny <= h) {
            if (board[ny-1][nx-1] == st_color) {
                dfs(nx, ny);
            }
        }
    }
}

// debug
//void solve() {
//    repeat(h, i) {
//        repeat(w, j) {
//            cout << board[i][j] << ' ';
//        }
//        cout << endl;
//    }
//}

void solve() {
    possible = false; dfs(xs, ys);
    if (possible) cout << "OK" << endl;
    else cout << "NG" << endl;
}

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


#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
int in(int c){int n=0;bool m=false;if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;}
int in() {return in(gcu());}
bool scan(int &n){int c=gcu();return c==EOF?false:(n=in(c),true);}
bool scan(char &c){c=gcu();gcu();return c!=EOF;}
//bool scan(string &s){int c;s="";
//	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#define pcu putchar_unlocked
#define vo inline void out
template <typename T>
vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
vo(const char *s){while(*s)pcu(*s++);}
vo(char c){pcu(c);}
//vo(string &s){for (char c: s) pcu(c);}
template <typename head, typename... tail> vo(head&& h, tail&&... t){out(h);out(move(t)...);}
//template <typename T> vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
#undef vo

int main() {
	for (int e, m; (e = m = in());) {
		for (int z = cbrt(e) + 0.00001; z >= 0; z--) {
			int te = e - z * z * z;
			int y = (int)sqrt(te);
			int tm = z + y + te - y * y;
			if (y > m)
				break;
			m = min(m, tm);
		}
		out(m, '\n');
	}
}

#include <iostream>
using namespace std;

int main(){
  while(1){
    int E;
    cin >> E;
    if(E==0) break;
    int x=0,y=0,z=0;
    int m = 1000000;
    for(z=0;z*z*z<=E;z++){
      for(y=0;(z*z*z)+(y*y)<=E;y++){
	x=E-(z*z*z)-(y*y);
	if(x+y+z<m){
	  m=x+y+z;
	  //cout << x << y << z << endl;
	}
      }
    }
    cout << m << endl;
  }

}


#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;
typedef pair<llint, P> E;

struct UnionFind{
	int size;
	vector<int> parent;

	UnionFind(){}
	UnionFind(int size){
		this->size = size;
		parent.resize(size+1);
		init();
	}
	void init(){
		for(int i = 0; i <= size; i++) parent[i] = i;
	}
	int root(int i){
		if(parent[i] == i) return i;
		return parent[i] = root(parent[i]);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		if(root_i == root_j) return;
		parent[root_i] = root_j;
	}
};

llint n;
P x[100005], y[100005];
vector<E> vec;
UnionFind uf(100005);

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> x[i].first >> y[i].first;
		x[i].second = y[i].second = i;
	}
	sort(x+1, x+n+1);
	sort(y+1, y+n+1);

	for(int i = 1; i < n; i++){
		vec.push_back(E(x[i+1].first-x[i].first, P(x[i].second, x[i+1].second)));
		vec.push_back(E(y[i+1].first-y[i].first, P(y[i].second, y[i+1].second)));
	}
	sort(vec.begin(), vec.end());

	llint ans = 0;
	for(int i = 0; i < vec.size(); i++){
		llint w = vec[i].first, u = vec[i].second.first, v = vec[i].second.second;
		if(uf.same(u, v)) continue;
		ans += w;
		uf.unite(u, v);
	}
	cout << ans << endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,ll>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

const int INF=1e8;

int minlen(vector<P> A,vector<P> B){
    int res=1e8;
    for(P p:B){
        int a=lower_bound(A.begin(),A.end(),p)-A.begin();
        if(a==A.size())continue;
        if(A.at(a).first!=p.first)continue;
        chmin(res,A.at(a).second-p.second);
    }
    return res;
}

int main() {
    int N;
    cin>>N;
    vector<int> X(N),Y(N),U(N);
    rep(i,N){
        char c;
        cin>>X.at(i)>>Y.at(i)>>c;
        if(c=='U')U.at(i)=0;
        if(c=='R')U.at(i)=1;
        if(c=='D')U.at(i)=2;
        if(c=='L')U.at(i)=3;
    }
    int ans=INF;
    rep(_,4){
        vector<P> UDD(0),DRD(0),UP(0),RI(0);
        rep(i,N){
            if(U.at(i)==2){
                UDD.pb({X.at(i),Y.at(i)});
                DRD.pb({X.at(i)-Y.at(i),Y.at(i)});
            }
            if(U.at(i)==0){
                UP.pb({X.at(i),Y.at(i)});
            }
            if(U.at(i)==1){
                RI.pb({X.at(i)-Y.at(i),Y.at(i)});
            }
        }
        sort(UDD.begin(),UDD.end());
        sort(DRD.begin(),DRD.end());
        chmin(ans,minlen(UDD,UP)*5);
        chmin(ans,minlen(DRD,RI)*10);

        rep(i,N){
            int x=X.at(i),y=Y.at(i);
            X.at(i)=y;
            Y.at(i)=-x;
            U.at(i)=(U.at(i)+1)%4;
        }
    }
    if(ans==INF)cout<<"SAFE"<<endl;
    else cout<<ans<<endl;
}


 #include<bits/stdc++.h>
  using namespace std;
  #define       M                        1000000007
  #define       ll                       long long
  #define       FIO                      ios_base::sync_with_stdio(false);cin.tie(NULL)
  #define       ifor(st,lim)             for(int i=st;i<lim;i++)
  #define       jfor(stt,llim)           for(int j=stt;j<llim;j++)
  #define       eifor(st,lim)            for(int i=st;i<=lim;i++)
  #define       ejfor(stt,llim)          for(int j=stt;j<=llim;j++)
  #define       blank                    cout<<'\n'

void solve()
{
   string s; cin>>s;

   if(s[0] == s[1] && s[1] == s[2] && s[0] == 'R') cout<<"3";
   else if(s[0] == s[1] && s[0] == 'R') cout<<"2";
   else if(s[1] == s[2] && s[1] == 'R') cout<<"2";
   else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cout<<"1";
   else cout<<"0";
}

  int main()
  {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
  int t=1;
  while(t--){
      solve();
     }
  }

#include <bits/stdc++.h>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
//#define INF 2e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    string W;
    cin >> W;
    int result=0;
    if(W[0]=='R'){
        result=1;
        if(W[1]=='R'){
            result=2;
            if(W[2]=='R'){
                result=3;
            }
        }
    }
    if(W[1]=='R'){
        if(result<1) result=1;
        if(W[2]=='R'){
            if(result<2) result=2;
        }
    }
    if(W[2]=='R'){
        if(result<1) result=1;
    }
    cout << result << endl;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin>>n;
  if(n==1){
    cout<<"Hello World"<<'\n';
  }
  if(n==2){
    cin>>a>>b;
    cout<<a+b<<'\n';
  }
  return(0);
}

#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

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

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

  string s;
  cin >> s;
  string ans = "", tmp;
  rep(i, (int)s.size() - 8) { ans += s[i]; }

  cout << ans << endl;

  return 0;
}


#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof x)
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outtag(x) cerr<<"---------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
						For(_x,L,R)cerr<<a[_x]<<" ";cerr<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector <int> vi;
typedef long double LD;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f|=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=300005,mod=1e9+7;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
int n;
char s[N];
int dp[N][2][3][3];
//dp[i][a][b][c]: first i char, there's a 1s, stage b, last c 0s
int main(){
	cin>>s+1;
	n=strlen(s+1);
	s[n+1]='1';
	dp[0][0][0][0]=1;
	For(i,1,n+1) For(a,0,1) For(b,0,2) For(c,0,2){
		int v=dp[i-1][a][b][c],lb,ub;
		if (!v)
			continue;
		if (s[i]=='0')
			lb=ub=0;
		else if (s[i]=='1')
			lb=ub=1;
		else
			lb=0,ub=1;
		For(now,lb,ub){
			if (now==0){
				int C=c+1;
				if (C>2)
					C-=2;
				Add(dp[i][a][b][C],v);
			}
			else if (now==1){
				if (c==1)
					Add(dp[i][a][b][0],v);
				else if (a==0&&b<2&&c==0)
					Add(dp[i][0][b+1][0],v);
				else
					Add(dp[i][a^1][b][0],v);
			}
		}
	}
	int ans=0;
	For(a,0,1) For(b,2,2) For(c,0,2)
		Add(ans,dp[n+1][a][b][c]);
	cout<<ans<<endl;
	return 0;
}


/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

int n, m;

unordered_map <int, vector <int > > g[N];

unordered_map <int, int> d[N];

int c[N];

int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
    freopen ("E.out", "w", stdout);
	#endif
	Kazakhstan
	cin >> n >> m;
	rep(i, 1, m) {
		int a, b, c;
		cin >> a >> b >> c;
		g[a][c].pb(b);
    g[b][c].pb(a);
	}
	d[1][0] = 0;
	set < pair <int, pair <int, int> > > st;
	st.insert({0, {1, 0}});
  vector <bool> was(n + 1, 0);
	while (sz(st)) {
		int dist = st.begin() -> f;
		int v = st.begin() -> s.f, last = st.begin() -> s.s;
		st.erase(st.begin());

    if (!was[v]) {
      for (auto it : g[v]) {
        int C = it.f;
        for (auto to : it.s) {
          if (!d[to].count(C) || d[to][C] > dist + 1) {
            st.erase({d[to][C], {to, C}});
            d[to][C] = dist + 1;
            st.insert({d[to][C], {to, C}});
          }
        }
      }
      was[v] = 1;
    }

    if (sz(g[v][last])) {
      int C = last;
      for (auto to : g[v][last]) {
        if (!d[to].count(last) || d[to][last] > dist) {
          st.erase({d[to][C], {to, C}});
          d[to][C] = dist;
          st.insert({d[to][C], {to, C}});
        }
      }
      g[v][last].clear();
      g[v].erase(last);
    }
  }
  int ans = inf;
  for (auto it : d[n]) ans = min(ans, it.s);
  cout << (ans == inf ? -1 : ans);
	ioi
}

#include<bits/stdc++.h>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 10000000

using namespace std;

int main(){
  int n,u,v; cin>>n>>u>>v; u--; v--;
  vector<vector<pi>> g( n, vector<pi>() );
  rep(i, n-1){
    int a,b; cin>>a>>b; a--; b--;
    g[a].push_back( {1,b} );
    g[b].push_back( {1,a} );
  }

  if(g[u].size()==1 && g[u][0].second==v) { cout<<0<<endl; return 0; }

  set<int>s;
  vector<int>d(n);
  rep(i, n)d[i]=INF;
  d[u]=0;

  priority_queue<pi, vector<pi>, greater<pi>> pq;
  pq.push( {0, u} );
  while( pq.size() ){
    auto cn = pq.top(); pq.pop();
    if(d[cn.second] < cn.first)continue;
    for(auto nn :g[cn.second]){
      if(cn.first+1 >= d[nn.second] || nn.second==v)continue;

      d[nn.second]=cn.first+1;
      pq.push( {d[nn.second], nn.second} );
    }
  }

  rep(i, n)if(d[i]!=INF)s.insert(i);
  s.insert(v);

  vector<int>d2(d);
  rep(i, n)d[i]=INF;
  d[v]=0;
  pq.push( {0, v} );

  while( pq.size() ){
    auto cn = pq.top(); pq.pop();
    if(d[cn.second] < cn.first)continue;

    for(auto nn :g[cn.second]){
      if(cn.first+1 >= d[nn.second] || s.count(nn.second)==0 )continue;

      d[nn.second]=cn.first+1;
      pq.push( {d[nn.second], nn.second} );
    }
  }

//for(auto t: d2)cout<<t<<' ';cout<<endl;
//for(auto t: d)cout<<t<<' ';cout<<endl;

bool f=true;
rep(i, n)if((d[i]==1 || d2[i]==1) && d[i]!=d2[i])f=false;
if(f) { cout<<1<<endl; return 0; }

  int result=0;
  rep(i, n)if(d[i]!=INF && d2[i]!=INF){
    if(d[i]<=d2[i])continue;
    result = max(result, d[i]-1);
  }

  cout<<result<<endl;

  return 0;
}


#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int lb = 9, ub = 44;
int v[lb+ub+5][lb+ub+5];

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin >> n;
  int i, j, z, e, pin, p2, p5;
  ll m, ans = 0;
  string s;
  for (i = 1; i <= n; i++) {
    cin >> s;
    m = e = pin = 0;
    for (char ch: s) {
      if (pin) e++;
      if (ch == '.') pin = 1;
      else m = m*10 + ch - '0';
    }
    p2 = -e;
    while (m % 2 == 0) {
      p2++;
      m /= 2;
    }
    p5 = -e;
    while (m % 5 == 0) {
      p5++;
      m /= 5;
    }
    for (int i2 = -lb; i2 <= ub; i2++)
      for (int i5 = -lb; i5 <= ub; i5++)
        if (i2+p2 >= 0 && i5+p5 >= 0) ans += 1LL*v[lb+i2][lb+i5];
    v[lb+p2][lb+p5]++;
  }
  cout << ans;
  return 0;
}

#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const int MOD = 1000000007;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

int main() {

    ll n,a; cin >> n;
    map<ll,ll> mp;
    set<ll> st;
    ll ans = 1;
    ll prev,val;
    bool f = false;

    rep(i,n){
        cin >> a;
        if(mp.count(a) == 0) mp[a] = 1;
        else mp[a] ++;
        st.insert(a);

        if(a == 0 && i != 0){
            cout << 0;
            return 0;
        }
        if(a == 0 && i == 0) f = true;
    }

    if(!f){
        cout << 0;
        return 0;
    }

    for(auto itr = st.begin(); itr != st.end(); ++itr) {
        if(*itr == 0) {
            prev = mp[*itr];
            val = *itr;
        }
        else{
            if(*itr - val != 1){
                cout << 0;
                return 0;
            }
            if(prev == 0){
                cout << 0;
                return 0;
            }
            rep(i,mp[*itr]){
                ans = (prev*ans)%998244353;
            }
            prev = mp[*itr];
            val = *itr;
        }
    }
    cout << ans;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = long long;

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

void ALLIN1_NUMBER(vector<ll>& V)
{
    for(auto& x : V)
    {
        cin >> x;
    }
}

template<class T>
void OUT0(T N)
{
    cout << N << endl;
}

static const double pi = acos(-1.0);

double Cos(double D)
{
    return cos(pi/180 * D);
}

class Dishes
{
    public:
    ll point_takahashi;
    ll point_aoki;
    ll sum;
    ll number;
};

void ALLIN1_DISHES(ll N, vector<Dishes>& dishes)
{
    for(ll i=0;i<N;i++)
    {
        dishes[i].number = i;
        cin >> dishes[i].point_takahashi >> dishes[i].point_aoki;
        dishes[i].sum = dishes[i].point_takahashi + dishes[i].point_aoki;
    }
}

bool Sort_TA(vector<Dishes>& dishesTA)
{
    sort
    (ALL(dishesTA),
    [](Dishes& a, Dishes& b)
    {
        return (a.sum == b.sum) ? (a.point_takahashi > b.point_takahashi) : (a.sum > b.sum);
    });
}

void Sort_AT(vector<Dishes>& dishes)
{
    sort
    (ALL(dishes),
    [](Dishes& a, Dishes& b)
    {
        return (a.sum == b.sum) ? (a.point_aoki > b.point_aoki) : (a.sum > b.sum);
    });
}

ll Ans(ll N, vector<Dishes> dishes_TA, vector<Dishes> dishes_AT)
{
    vector<bool> eaten(N,false);
    ll takahashi_point = 0;
    ll aoki_point = 0;

    ll itr_TA = 0;
    ll itr_AT = 0;

    for(ll i=0;i<N;i++)
    {
        if(i%2==0)
        {
            for(ll& j=itr_TA;j<N;j++)
            {
                if(!eaten[dishes_TA[j].number])
                {
                    eaten[dishes_TA[j].number] = true;
                    takahashi_point += dishes_TA[j].point_takahashi;
                    j++;
                    break;
                }
            }
        }
        else
        {
            for(ll& j=itr_AT;j<N;j++)
            {
                if(!eaten[dishes_AT[j].number])
                {
                    eaten[dishes_AT[j].number] = true;
                    aoki_point += dishes_AT[j].point_aoki;
                    j++;
                    break;
                }
            }
        }
    }
    return takahashi_point - aoki_point;
}

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

    vector<Dishes> dishes(N);
    ALLIN1_DISHES(N,dishes);

    vector<Dishes> dishes_TA = dishes;
    Sort_TA(dishes_TA);

    vector<Dishes> dishes_AT = dishes;
    Sort_AT(dishes_AT);

    OUT0(Ans(N,dishes_TA,dishes_AT));

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int N;
  cin >> N;
  priority_queue<long long> point_add;
  long long sumA = 0;
  rep(i, N)
  {
    long long A, B;
    cin >> A >> B;
    point_add.push(A + B);
    sumA += A;
  }
  long long ans = sumA;
  bool turn_is_takahashi = true;
  while (point_add.size())
  {
    if (!turn_is_takahashi)
      ans -= point_add.top();
    turn_is_takahashi = !turn_is_takahashi;
    point_add.pop();
  }
  cout << ans << endl;
  return 0;
}


#include <cstdio>
#include <iostream>

using namespace std ;

typedef long long ll ;

const int N = 300010 ;

int n ;
ll ans ;
ll S[4] ;
ll minx ;
ll maxx ;
ll sum[N] ;
ll base[N] ;

ll gt(ll x){
    return x < 0 ? -x : x ;
}
void chkmin(ll x){
    minx = x >= minx ? minx : x ;
}
void chkmax(ll x){
    maxx = x >= maxx ? x : maxx ;
}
int main(){
    cin >> n ;
    ans = (1ll << 62) ;
    for (int i = 1 ; i <= n ; ++ i){
        scanf("%lld", &base[i]) ;
        sum[i] = sum[i - 1] + base[i] ;
    }
    int l = 2, r = 4 ;
    S[0] = base[1] ; S[2] = base[3] ;
    S[1] = base[2] ; S[3] = sum[n] - sum[3] ;
    for (int i = 3 ; i <= n ; ++ i){
        while (l < i && gt(S[0] - S[1]) > gt(S[0] + base[l] - S[1] + base[l])){
            S[0] += base[l], S[1] -= base[l], ++ l ;
        }
        while (r <= n && gt(S[3] - S[2]) > gt(S[2] + base[r] - S[3] + base[r])){
            S[2] += base[r], S[3] -= base[r], ++ r ;
        }
        minx = (1ll << 61) ; maxx = -(1ll << 61) ;
        for (int j = 0 ; j <= 3 ; ++ j) chkmin(S[j]), chkmax(S[j]) ;
        ans = min(ans, maxx - minx) ; S[1] += base[i] ; S[2] -= base[i] ;
        //for (int j = 0 ; j <= 3 ; ++ j) cout << S[j] << " " ; puts("") ;
    }
    cout << ans << endl ; return 0 ;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const ll INF = TEN(18);

int main() {
    int n;
    cin >> n;
    V<int> A(n);
    rep(i, n) cin >> A[i];
    using pll = pair<ll, ll>;
    V<pll> vl(n, mp(-INF, INF)), vr(n, mp(-INF, INF));

    auto ch = [&](pll& a, pll b) {
        if (abs(a.se - a.fi) > abs(b.fi - b.se)) {
            a = b;
        }
        return;
    };

    rep(t, 2) {
        ll s = 0;
        V<ll> acm;
        V<pll>& vec = (t == 0 ? vl : vr);

        rep(i, n) {
            s += A[i];
            acm.pb(s);
            if (i) {
                int p = lower_bound(ALL(acm), s / 2) - acm.begin();
                if (p == i) --p;
                auto x = mp(acm[p], s - acm[p]);
                ch(vec[i], x);
                --p;
                if (p >= 0) {
                    auto x = mp(acm[p], s - acm[p]);
                    ch(vec[i], x);
                }
            }
        }
        reverse(ALL(A));
    }

    ll ans = INF;
    for (int i = 1; i < n - 2; ++i) {
        auto p = vl[i], q = vr[n - i - 2];
        V<ll> v = {p.fi, p.se, q.fi, q.se};
        sort(ALL(v));
        chmin(ans, v.back() - v[0]);
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  ll N, M;
  cin >> N >> M;
  vector<ll> A(N);
  for (ll i=0; i<N; i++){
    cin >> A[i];
  }
  ll temp=0;

  map<ll,ll> count;
  vector<ll> elem;

  count[0]=1;
  elem.push_back(0);
  for (ll i: A){
    temp=(temp+i)%M;
    //cout<<temp<<endl;
    if (count.find(temp)!=count.end()){
      count[temp]++;
    } else{
      count[temp]=1;
      elem.push_back(temp);
    }
  }
  ll ans=0;
  for (ll i=0; i<elem.size(); i++){
    ll curr=count[elem[i]];
    ans+=(long long) curr*(curr-1)/2;
  }
  cout<<ans<<endl;

}

#include <bits/stdc++.h>
#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 SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
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>;

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N, M;
  cin >> N >> M;
  vll A(N + 1);
  mll m;
  rep(i, N + 1) {
    if (i == 0) {
      A[i] = 0;
      m[0]++;
      continue;
    }
    ll a;
    cin >> a;
    A[i] = A[i - 1] + a;
    m[A[i] % M]++;
  }

  ll ans = 0;
  rep(i, N + 1) {
    ans += m[A[i] % M] - 1;
  }
  ans /= 2;
  ANS;
  return 0;
}


#include <bits/stdc++.h>

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int matrix[11][11];

int main()
{
	int n;

	while( (n = in()) != 0 )
	{
		loop(i, 0, 11)
		{
			loop(j, 0, 11)
			{
				matrix[i][j] = 0;
			}
		}

		loop(i, 0, n)
		{
			loop(j, 0, n)
			{
				matrix[i][j] = in();
			}
		}

		loop(i, 0, n)
		{
			loop(j, 0, n)
			{
				matrix[i][n] += matrix[i][j];
				matrix[n][i] += matrix[j][i];
			}
			matrix[n][n] += matrix[i][n];
		}

		loop(i, 0, n + 1)
		{
			loop(j, 0, n + 1)
			{
				printf("%5d", matrix[i][j]);
			}
			printf("\n");
		}

	}

	return (0);
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

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

    bool changed = false;
    if (A>B){
        swap(A,B);
        changed = true;
    }

    vector<vector<int>> T(100,vector<int>(100,0));

    int b = 1;
    while(b<=B){
        int yoko = (b-1)%25;
        yoko *= 4;
        int tate = (b-1)/25;
        tate *= 4;

        T[tate][yoko] = 1;
        T[tate][yoko+1] = 1;
        T[tate][yoko+2] = 1;
        T[tate+1][yoko] = 1;
        T[tate+1][yoko+1] = 1;
        T[tate+1][yoko+2] = 1;
        T[tate+2][yoko] = 1;
        T[tate+2][yoko+1] = 1;
        T[tate+2][yoko+2] = 1;

        b++;
    }

    int a = 1;
    while(a<=A-1){
        int yoko = (a-1)%25;
        yoko *= 4;
        int tate = (a-1)/25;
        tate *= 4;

        T[tate+1][yoko+1] = 0;

        a++;
    }

    cout << 100 << " " << 100 << endl;
    REP(i,100){
        REP(j,100){
            if(!changed){
                if(T[i][j]==0)cout << ".";
                else cout << "#";
            }else{
                if(T[i][j]==0)cout << "#";
                else cout << ".";
            }

        }
        cout << endl;
    }

    return 0;
}


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

int main() {
    cout << fixed << setprecision(10);

    // cout << 1.0 / 2 << endl;

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

    // 隣り合う二項はm-1個ある
    // (a, b)並んでいた場合の期待値を求めて、それをm-1倍する

    double ans = 0.0;

    double e = 0.0;

    if (d == 0) {
        e = double(1.0) / n;
    } else {
        e = double(2.0);
        ll n2 = ll(n) * n;
        e *= (n-d);
        e /= n2;
    }
    cout << e * (m-1) << endl;
    return 0;
}

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

using namespace std;
using namespace std::chrono;

// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define f0r(a, b) for (long long a = 0; a < (b); ++a)
#define f1r(a, b, c) for (long long a = (b); a < (c); ++a)
#define f0rd(a, b) for (long long a = (b); a >= 0; --a)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); --a)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define fix(prec) {cout << setprecision(prec) << fixed;}
#define mp make_pair
#define f first
#define s second
#define presum(p, a, n) {p[0] = a[0]; for (int i = 1; i < (n); i++) p[i] = a[i] + p[i-1];}
#define all(v) v.begin(), v.end()
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define readgraph(list, edges) for (int i = 0; i < edges; i++) {int a, b; cin >> a >> b; a--; b--; list[a].pb(b); list[b].pb(a);}
#define ai(a, n) for (int ele = 0; ele < n; ele++) cin >> a[ele];
#define ain(a, lb, rb) for (int ele = lb; ele <= rb; ele++) cin >> a[ele];
#define ao(a, n) {for (int ele = 0; ele < (n); ele++) { if (ele) cout << " "; cout << a[ele]; } cout << '\n';}
#define aout(a, lb, rb) {for (int ele = (lb); ele <= (rb); ele++) { if (ele > (lb)) cout << " "; cout << a[ele]; } cout << '\n';}
typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}

// mt19937 rng(steady_clock::now().time_since_epoch().count());
mt19937 rng(61378913);
/* usage - just do rng() */

void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}

const lld pi = 3.14159265358979323846;
const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;

ll n, m, k, q, l, r, x, y, z;
ll a[1000005];
ll b[1000005];
ll c[1000005];
string s, t;
ll ans = 0;

void solve(int tc) {
  lld n, m, d; cin >> n >> m >> d;

  lld v = 0;
  if (d == 0) v = 1 / n;
  else {
    v = 2 * (n - d) / (n * n);
  }
  cout << setprecision(15) << fixed << v * (m - 1) << '\n';
}

int main() {
  send help

  // usaco("file");

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


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    ll k, a[55] = {};
    cin >> k;
    for (int i = 0; i < 50; i++) a[i] = k / 50 + 50 - 1;
    for (int i = 0; i < k % 50; i++) {
        for (int j = 0; j < 50; j++) a[j]--;
        a[i] += 51;
    }
    cout << 50 << '\n';
    for (int i = 0; i < 50; i++) cout << a[i] << ' ';
}

#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <stack>
#include <queue>
#include <tuple>
#include <regex>
#include <cmath>
#include <map>
#include <set>
#include <functional>
#include <cstring>

using namespace std;

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

using ll = long long;
using Pint = pair<int, int>;
using Pll  = pair<ll, ll>;

#define eb emplace_back
#define pb push_back
#define mp make_pair

#define F first
#define S second

#define popcnt __builtin_popcountll

#define rep( i, n ) for ( ll i = 0; i < (ll)( n ); ++i )
#define reps( i, n ) for ( ll i = 1; i <= (ll)( n ); ++i )
#define rrep( i, n ) for ( ll i = (ll)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( ll i = (ll)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

template<typename T = ll> constexpr T MAX = numeric_limits<T>::max();
template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }
template<typename T> T lcm( const T a, const T b ) { return ( a / gcd( a, b ) * b ); }

int main()
{
	ll n; cin >> n;
	vector<vector<ll>> cnt( 20, vector<ll>( 20 ) );
	vector<ll> v;

	rep( i, n )
	{
		string s; cin >> s;
		string t = "", u = "";
		auto idx = string::npos;
		if ( ( idx = s.find( "." ) ) != string::npos )
		{
			t = s.substr( 0, idx );
			u = s.substr( idx + 1 );
			while ( u.length() < 9 ) u += "0";
		}
		else
		{
			t = s;
			u = "0";
		}

		v.eb( atoll( t.c_str() ) * 1e9 + atoll( u.c_str() ) );
	}

	arep( it, v )
	{
		ll tcnt = 0, fcnt = 0;
		while ( it % 2 == 0 && tcnt < 18 )
		{
			it /= 2;
			++tcnt;
		}
		while ( it % 5 == 0 && fcnt < 18 )
		{
			it /= 5;
			++fcnt;
		}

		++cnt[tcnt][fcnt];
	}

	ll ans = 0;
	rep( i, 19 )
	{
		rep( j, 19 )
		{
			rep( k, 19 )
			{
				rep( l, 19 )
				{
					if ( i + k < 18 || j + l < 18 )
						continue;
					if ( i == k && j == l )
						ans += cnt[i][j] * ( cnt[k][l] - 1 );
					else
						ans += cnt[i][j] * cnt[k][l];
				}
			}
		}
	}

	cout << ans / 2 << endl;

	return ( 0 );
}