#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#define ynmes(a) (a) ? mes("Yes") : mes("No")
#define YNmes(a) (a) ? mes("YES") : mes("NO")
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void)
{
    ll h, w, c = 0;
    cin >> h >> w;
    char s[100][100];
    for (int i = 0; i < h; i++)
    {

        for (int j = 0; j < w; j++)
        {

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

        for (int j = 0; j < w - 1; j++)
        {

            if (s[i][j] == s[i][j + 1] && s[i][j]  == '.')
            {
                c++;

            }
        }
    }
    for (int j = 0; j < w; j++)
    {

        for (int i = 0; i < h - 1; i++)
        {

            if (s[i][j] == s[i + 1][j] && s[i][j] == '.')
            {
                c++;

            }
        }
    }

    mes(c);
}

#include <bits/stdc++.h>
using namespace std;
int dx[4] = {0, 1, 0, 1}, dy[4] = {0, 0, 1, 1};
int main(){
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i = 0; i < H; i++) cin >> S[i];
    int ans = 0;
    for(int i = 0; i < H - 1; i++){
        for(int j = 0; j < W - 1; j++){
            int cnt = 0;
            for(int k = 0; k < 4; k++){
                int nx = i + dx[k], ny = j + dy[k];
                if(S[nx][ny] == '#') cnt++;
            }
            if(cnt % 2 == 1) ans++;
        }
    }
    cout << ans << endl;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <cmath>
#include <cstring>
#define For(i,x,y) for(int i = (x); i <= (y); i ++ )
#define fori(i,x,y) for(int i = (x); i < (y); i ++ )
#define sz(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define mst(x,a) memset(x,a,sizeof(x))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define db double
//#define endl '\n'
#define debug(a) cout << #a << ": " << a << endl
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ULL;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;
typedef pair<int,int>pa;
typedef pair<ll,ll>pai;
typedef pair<db,db> pdd;
const db eps = 1e-6;
const db pi = acos(-1.0);

template<typename T1, typename T2> void ckmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> void ckmax(T1 &a, T2 b) { if (a < b) a = b; }
int read() {
    int x = 0, f = 0; char ch = getchar();
    while (!isdigit(ch)) f |= ch == '-', ch = getchar();
    while (isdigit(ch)) x = 10 * x + ch - '0', ch = getchar();
    return f ? -x : x;
}
template<typename T> void print(T x) {
    if (x < 0) putchar('-'), x = -x;
    if (x >= 10) print(x / 10);
    putchar(x % 10 + '0');
}
template<typename T> void print(T x, char let) {
    print(x), putchar(let);
}
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn = 2e5 + 10;

vector<int>e[maxn];
int dpt[maxn<<1];

int dfs_clock, seq[maxn], dfn[maxn], fa[maxn];
int in[maxn<<1], out[maxn<<1];
vector<vector<int>>dir(maxn);
void dfs(int x, int dis){
    in[x] = ++dfs_clock;
    //seq[dfn[x] = ++dfs_clock] = x;
    dir[dis].pb(in[x]);
   // dir.pb({dpt[x],dfn[x]});
    for(auto v:e[x]){
        dfs(v,dis+1);
    }
    out[x] = ++dfs_clock;
}
int pre[maxn];
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    For(v,2,n){
        cin>>fa[v];
        e[fa[v]].pb(v);
    }
    dfs(1,0);
   // debug("ok");
   // sort(ALL(dir));
    int q;
    cin>>q;
    while(q--){
        int u, d;
        cin>>u>>d;
        const auto di= dir[d];
        cout<<(lower_bound(di.cbegin(),di.cend(),out[u]) - lower_bound(di.cbegin(),di.cend(),in[u]) )<<endl;
    }
  //  }
    return 0;
}

#include <iostream>
using namespace std;

const int N_MX = 1e3;
int n;
int x[N_MX], y[N_MX];
int ans;

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i];

    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            double grad = double(y[j] - y[i]) / (x[j] - x[i]);
            if (grad >= -1.0 && grad <= 1.0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  stack<char> st;
  rep(i, n){
    int ok = 1;
    if(st.size() < 3){
      st.push(s[i]);
      continue;
    }
    while(ok == 1){
      if(st.size() > 2){
        char three = st.top();
        st.pop();
        char two = st.top();
        st.pop();
        char one = st.top();
        st.pop();
        if(one == 'f' && two == 'o' && three == 'x'){
          ok = 1;
        }else{
          st.push(one);
          st.push(two);
          st.push(three);
          ok = 0;
        }
      }else{
        break;
      }
    }
    st.push(s[i]);
  }
  if(st.size() > 2){
    char three = st.top();
    st.pop();
    char two = st.top();
    st.pop();
    char one = st.top();
    st.pop();
    if (one != 'f' || two != 'o' || three != 'x'){
      st.push(one);
      st.push(two);
      st.push(three);
    }
  }
  cout << st.size() << endl;
}

// clang-format off
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

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

#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef gp_hash_table<int, int> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> oset;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pii> vii;

#define INF 1000000000000000000
#define inf 1000000000
// #define MOD 67280421310721
#define MOD  1000000007
// #define MOD 998244353
#define PI 3.1415926535897932385

#define pb push_back
#define bitc __builtin_popcountll
#define mp make_pair
#define all(ar) ar.begin(), ar.end()

#define fr(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define rep(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define frr(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define foreach(it, ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fil(ar, val) memset(ar, val, sizeof(ar))  // 0x3f for inf, 0x80 for -INF can also use with pairs

#ifdef godfather
template<typename T>
void __p(T a) { cout << a << " "; }
template<typename T>
void __p(std::vector<T> a) { cout << "{ "; for (auto p : a) __p(p); cout << "}"; }
template<typename T, typename F>
void __p(pair<T, F> a) { cout << "{ "; __p(a.first); __p(a.second); cout << "}"; }
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) { __p(a1); __p(a...); }
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cout<<name<<" : ";__p(arg1);cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    int bracket=0,i=0;
    for(; ;i++)
        if(names[i]==','&&bracket==0)
            break;
        else if(names[i]=='(')
            bracket++;
        else if(names[i]==')')
            bracket--;
    const char *comma=names+i;
    cout.write(names,comma-names)<<" : ";
    __p(arg1);
    cout<<"| ";
    __f(comma+1,args...);
}
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) { return fabs(a - b) < 1e-9; }
ll modpow(ll b, ll e, ll mod=MOD) {
    ll ans=1; for(;e;b=b*b%mod,e/=2) if(e&1) ans=ans*b%mod; return ans; }

ld modp(ld b, ll e) {
    ld ans=1; for(;e;b=b*b,e/=2) if(e&1) ans=ans*b; return ans; }

void solve()
{
    // START
    ll n;
    cin >> n;
    vi arr(n+1);
    rep(i,n)cin>>arr[i+1];
    sort(all(arr));
    vi pre(n+1);
    fr(i,1,n)pre[i]=pre[i-1]+arr[i];
    ld ans=INF;
    ll tot  = pre[n];
    fr(i,0,n){
        ld tmp = tot;
        ld x = arr[i];
        x/=2;
        tmp += n*x;
        tmp -= (n-i)*arr[i] + pre[i];
        // cout<<tmp<<"\n";
        ans=min(ans, tmp);
    }
    ans/=n;
    cout<<ans<<"\n";

    // END
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(15);   cout<<fixed;
    #ifdef godfather
        cin.exceptions(cin.failbit);
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    fr(i,1,t)
    {
        // cout<<"Case #"<<i<<": ";
        solve();
    }
    end_routine();
}


#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define ll long long int
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define mem memset
#define ff first
#define ss second
#define loop0(i,n) for(i=0;i<n;i++)
#define loop1(i,n) for(i=1;i<=n;i++)
ll dist(pair<ll,ll> p1,pair<ll,ll> p2)
{
	return max(abs(p1.ff-p2.ff),abs(p1.ss-p2.ss));
}
int main()
{
	ll n,i,j,x,y,k,l,a,b;
	cin>>n;
	pair<pair<ll,ll>,ll> p[n],q[n];
	loop0(i,n)
	{
		cin>>x>>y;
		p[i]={{x,y},i};
		q[i]={{y,x},i};
	}
	sort(p,p+n);
	sort(q,q+n);
	priority_queue<ll> pq;
	map<pair<ll,ll>,ll> mp;
	ll ans;
	a=p[0].ss;b=p[n-1].ss;
	x=min(a,b);y=max(a,b);
	if(!mp[{x,y}])
	{
		pq.push(dist(p[0].ff,p[n-1].ff));
		mp[{x,y}]=1;
	}
	a=p[0].ss;b=p[n-2].ss;
	x=min(a,b);y=max(a,b);
	if(!mp[{x,y}])
	{
		pq.push(dist(p[0].ff,p[n-2].ff));
		mp[{x,y}]=1;
	}
	a=p[1].ss;b=p[n-1].ss;
	x=min(a,b);y=max(a,b);
	if(!mp[{x,y}])
	{
		pq.push(dist(p[1].ff,p[n-1].ff));
		mp[{x,y}]=1;
	}
	a=q[0].ss;b=q[n-1].ss;
	x=min(a,b);y=max(a,b);
	if(!mp[{x,y}])
	{
		pq.push(dist(q[0].ff,q[n-1].ff));
		mp[{x,y}]=1;
	}
	a=q[0].ss;b=q[n-2].ss;
	x=min(a,b);y=max(a,b);
	if(!mp[{x,y}])
	{
		pq.push(dist(q[0].ff,q[n-2].ff));
		mp[{x,y}]=1;
	}
	a=q[1].ss;b=q[n-1].ss;
	x=min(a,b);y=max(a,b);
	if(!mp[{x,y}])
	{
		pq.push(dist(q[1].ff,q[n-1].ff));
		mp[{x,y}]=1;
	}
	pq.pop();
	ans=pq.top();
	cout<<ans<<'\n';
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long int ull;
#include <fstream>
#define int long long int
#define mod 1000000007
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n"
#define watch2(x,y) cout<<(#x)<<" is "<<(x)<<" and "<<(#y)<< " is " <<(y)<<"\n"
int powerr(int m,int n){if(m==0 || n==1)return m;if(n==0)return 1;int ans = 1;if(n&1)ans = m*powerr(m,n-1);else {ans = powerr(m,n/2);ans = ans * ans;}return ans%mod;}
int gcdd(int a,int b){if(b==0)return a;   return gcdd(b,a%b);}
int lcmm(int a,int b){return (a*b)/gcdd(a,b);}
/*
signed main(){
    set<pair<int,int>> s;
    s.insert({1,2});
    s.insert({2,1});
    s.insert({1,2});
    cout<<s.size();
}
*/

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

    int n;cin>>n;
    vector<pair<int,int>> x,y;
    vector<pair<int,int>> V;
    for(int i=0;i<n;++i){
        int x1,y1;cin>>x1>>y1;
        x.push_back({x1,i});
        y.push_back({y1,i});
        V.push_back({x1,y1});
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());

    int diff1_x = abs(x[0].first - x[n-1].first);
    int diff2_x = abs(x[1].first - x[n-1].first);
    int diff3_x = abs(x[0].first - x[n-2].first);
    int ind1_x = x[0].second , ind2_x = x[1].second, ind3_x = x[n-2].second, ind4_x = x[n-1].second;

    int diff1_y = abs(y[0].first - y[n-1].first);
    int diff2_y = abs(y[1].first - y[n-1].first);
    int diff3_y = abs(y[0].first - y[n-2].first);
    int ind1_y = y[0].second , ind2_y = y[1].second, ind3_y = y[n-2].second, ind4_y = y[n-1].second;

    set<pair<int,int>> soul;

    if(ind1_x < ind4_x){
        soul.insert({ind1_x,ind4_x});
    }
    else {
        soul.insert({ind4_x,ind1_x});
    }

    if(ind1_x < ind3_x){
        soul.insert({ind1_x,ind3_x});
    }
    else {
        soul.insert({ind3_x,ind1_x});
    }

    if(ind2_x < ind4_x){
        soul.insert({ind2_x,ind4_x});
    }
    else {
        soul.insert({ind4_x,ind2_x});
    }

    //reyy

    if(ind1_y < ind4_y){
        soul.insert({ind1_y,ind4_y});
    }
    else {
        soul.insert({ind4_y,ind1_y});
    }

    if(ind1_y < ind3_y){
        soul.insert({ind1_y,ind3_y});
    }
    else {
        soul.insert({ind3_y,ind1_y});
    }

    if(ind2_y < ind4_y){
        soul.insert({ind2_y,ind4_y});
    }
    else {
        soul.insert({ind4_y,ind2_y});
    }

    vector<int> vec;
    for(auto x:soul){
        int a = x.first , b = x.second;
        vec.emplace_back( max( abs(V[a].first-V[b].first) , abs(V[a].second - V[b].second) ) );
    }

    sort(vec.begin(),vec.end());
    if(vec.size()==1 || vec.size()==2){
        cout<<vec[0];return 0;
    }
    cout<<vec[vec.size()-2];

    return 0;

}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

ll n, m;

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

    cin >> n >> m;

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

    if(m == 0) {
        ll rr = 0;

        for(int i = 1; i <= n; i++) {
            cout << rr + (2*i - 1) << " " << rr + (2*i) << endl;
        }

        return 0;
    }

    if((m > 0) and (n < (m+2))) {
        cout << -1 << endl;
        return 0;
    }

    ll r = n - (m+2);
    ll rr = (m+1) * 2 + 2;

    cout << 1 << " " << rr << endl;

    for(int i = 1; i <= m+1; i++) {
        cout << 2*i << " " << 2*i+1 << endl;
    }

    for(int i = 1; i <= r; i++) {
        cout << rr + (2*i - 1) << " " << rr + (2*i) << endl;
    }

    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cctype>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <stack>
#include <queue>
#include <ctime>
#define _for(i,a,b) for(int i=(a);i<(b);++i)
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
inline int read_int(){
	int t=0;bool sign=false;char c=getchar();
	while(!isdigit(c)){sign|=c=='-';c=getchar();}
	while(isdigit(c)){t=(t<<1)+(t<<3)+(c&15);c=getchar();}
	return sign?-t:t;
}
inline LL read_LL(){
	LL t=0;bool sign=false;char c=getchar();
	while(!isdigit(c)){sign|=c=='-';c=getchar();}
	while(isdigit(c)){t=(t<<1)+(t<<3)+(c&15);c=getchar();}
	return sign?-t:t;
}
inline char get_char(){
	char c=getchar();
	while(c==' '||c=='\n'||c=='\r')c=getchar();
	return c;
}
inline void write(LL x){
	char c[21],len=0;
	if(!x)return putchar('0'),void();
	if(x<0)x=-x,putchar('-');
	while(x)c[++len]=x%10,x/=10;
	while(len)putchar(c[len--]+48);
}
inline void space(LL x){write(x),putchar(' ');}
inline void enter(LL x){write(x),putchar('\n');}
const int MAXN=2e5+5;
int p[MAXN],a[MAXN],b[MAXN];
LL s[MAXN];
int Find(int x){
	return p[x]==x?x:p[x]=Find(p[x]);
}
int main()
{
//	freopen("test.in","r",stdin);
//	freopen("test.out","w",stdout);
	int n=read_int(),m=read_int();
	if(n==1&&m==0)
	printf("%d %d\n",1,2);
	else if(m<0||m>=n-1)puts("-1");
	else if((n-m)%2==1){
		m++;
		int pos=1,d=(n-m)/2;
		_for(i,1,d){
			printf("%d %d\n%d %d\n",pos,pos+3,pos+1,pos+2);
			pos+=4;
		}
		d=n-2*(d-1)-1;
		printf("%d %d\n",pos,pos+1+2*d);
		pos++;
		_rep(i,1,d-2)
		printf("%d %d\n",pos,pos+1),pos+=2;
		printf("%d %d\n%d %d\n",pos,pos+3,pos+1,pos+2);
	}
	else{
		int pos=1,d=(n-m)/2;
		_for(i,1,d){
			printf("%d %d\n%d %d\n",pos,pos+3,pos+1,pos+2);
			pos+=4;
		}
		d=n-2*(d-1)-1;
		printf("%d %d\n",pos,pos+1+2*d);
		pos++;
		_rep(i,1,d)
		printf("%d %d\n",pos,pos+1),pos+=2;
	}
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int>A(2*N);
    vector<pair<int,int>>B(2*N);
    vector<int>C(2*N);
    for(int i = 0; i < 2*N; i++) {
        cin >> A[i];
        B[i] = {A[i],i};
    }
    sort(B.rbegin(),B.rend());
    for(int i = 0; i < N; i++) {
        C[B[i].second]++;
    }
    string ans = "";
    int sum1 = 0,sum2 = 0;
    for(int i = 0; i < 2*N; i++) {
        if(C[i] == 0) {
            if(sum2) {
                sum2--;
                ans += ')';
            }
            else {
                sum1++;
                ans += '(';
            }
        }
        else {
            if(sum1) {
                sum1--;
                ans += ')';
            }
            else {
                sum2++;
                ans += '(';
            }
        }
    }
    cout << ans << endl;
}

#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define repr(i,l,r) for(int i=(r)-1,i##_left=(l);i>=i##_left;--i)
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
const ll INF = 1e9;
template<class T=ll> using V = vector<T>;
template<class T=ll> using PQ = priority_queue<T>;
template<class T=ll> using PQG = priority_queue<T, V<T>, greater<T>>;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail) { cin >> head; in(move(tail)...); }
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define TIN(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
#define VIND(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem,--_elem
#define OUT(x) cout << (x);
#define OUTL(x) cout << (x) << endl;
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
template<class T>
string join(vector<T>& v, string delim="") { ostringstream os; rep(i,v.size())i?os<<delim<<v[i]:os<<v[0]; return os.str(); }
#pragma endregion RegionDefs

ll acc[214514];

void solve()
{
    IN(n, w);
    rep(i, n) {
        IN(s, t, p);
        acc[s] += p;
        acc[t] -= p;
    }
    ll tmp = 0;
    rep(i, 214514) {
        tmp += acc[i];
        if (tmp > w) {
            OUTL("No");
            return;
        }
    }
    OUTL("Yes");
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}


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

using namespace std;

int main()
{
    #ifndef ONLINE_JUDGE
freopen("l.txt", "r", stdin);
freopen("m.txt", "w", stdout);
#else
#endif
ll n,s,d;
cin>>n>>s>>d;
bool f=false;
for(ll i=0;i<n;i++)
{
  ll a,b;
  cin>>a>>b;
  if(a<s && b>d)
  {
    f=true;
  }
}
if(f)
{
  cout<<"Yes"<<endl;
}
else
{cout<<"No"<<endl;}
}

#include <iostream>

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

  std::cin >> a >> b >> c;

  if ( a > b )
    std::cout << "Takahashi" << std::endl;
  else if ( a < b )
    std::cout << "Aoki" << std::endl;
  else {
    if ( c == 0 )
      std::cout << "Aoki" << std::endl;
    else
      std::cout << "Takahashi" << std::endl;
  }
  return 0;
}


//#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << "[" << H << "]";
    debug_out(T...);
}

#ifdef dddxxz
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SZ(s) ((int)s.size())

clock_t startTime;

double getCurrentTime() {
    return (double) (clock() - startTime) / CLOCKS_PER_SEC;
}

typedef long long ll;
//mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const double eps = 0.00001;
const int MOD = 1e9 + 7;
const int INF = 1000000101;
const long long LLINF = 1223372000000000555;
const int N = 1e6 + 4e4;
const int M = 1234;
const int LOG = 18;

int sum(int x){
    return x / 100 + x / 10 % 10 + x % 10;
}

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

    cout << max(sum(a), sum(b));

}

int main() {
    startTime = clock();
    ios_base::sync_with_stdio(false);

    bool llololcal = false;
#ifdef dddxxz
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    llololcal = true;
#endif

    int TC = 1;
    //cin >> TC;

    for (int test = 1; test <= TC; test++) {
        debug(test);
        solve(test);
    }

    if (llololcal) cerr << endl << "Time: " << getCurrentTime() * 1000 << " ms" << endl;

    return 0;
}

//#include <atcoder/all>
//using namespace atcoder;

#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>
#include <limits>
#include <iomanip>
#include <cmath>

using namespace std;

using ll = long long;
using ull = unsigned long long;
template <typename T = ll>
using Coord = pair<T, T>;
template <typename T = ll>
using Mat = vector<vector<T>>;

template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p)
{
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}
template <class T>
Mat<T> MakeMat(size_t w, size_t h)
{
	return Mat<T>(h, vector<T>(w));
}
template <class ...Args>
void Input(Args &...args)
{
	(cin >> ... >> args);
}
template <class T>
void InputArray(size_t size, T& t)
{
	t.resize(size);
	for (auto& e : t) {
		cin >> e;
	}
}
template <class ...Args>
void InputArray(size_t size, Args &...args)
{
	(InputArray(size, args), ...);
}
template <class ...Args>
void InputVerticalArray(size_t size, Args &...args)
{
	(args.resize(size), ...);
	for (int i = 0; i < size; i++) {
		((cin >> args[i]), ...);
	}
}
template <class T>
void InputMatrix(size_t width, size_t height, T& t)
{
	t.assign(height, typename T::value_type(width));
	for (auto& a : t) {
		for (auto& e : a) {
			cin >> e;
		}
	}
}
template <class ...Args>
void InputMatrix(size_t width, size_t height, Args &...args)
{
	(InputMatrix(width, height, args), ...);
}
template <class ...Args>
void Output(const Args &...args)
{
	((cout << args << ' '), ...) << endl;
}
template <class ...Args>
void OutputVertical(const Args &...args)
{
	((cout << args << endl), ...);
}
template <class T>
void OutputArray(const T& t)
{
	for (const auto& e : t) {
		cout << e << ' ';
	}
	cout << endl;
}
template <class ...Args>
void OutputArray(const Args &...args)
{
	(OutputArray(args), ...);
}
template <class ...Args>
void OutputVerticalArray(const Args &...args)
{
	for (int i = 0; i < min({ args.size()... }); i++) {
		((cout << args[i] << ' '), ...) << endl;
	}
}
template <class T>
void OutputMatrix(const T& t)
{
	for (const auto& a : t) {
		for (const auto& e : a) {
			cout << e << ' ';
		}
		cout << '\n';
	}
	cout << flush;
}
template <class ...Args>
void OutputMatrix(const Args &...args)
{
	(OutputMatrix(args), ...);
}

#define X first
#define Y second

#define inp(type, ...) type __VA_ARGS__; Input(__VA_ARGS__)
#define inpa(type, size, ...) type __VA_ARGS__; InputArray((size), __VA_ARGS__)
#define inpva(type, size, ...) type __VA_ARGS__; InputVerticalArray((size), __VA_ARGS__)
#define inpm(type, width, height, ...) type __VA_ARGS__; InputMatrix((width), (height), __VA_ARGS__)
#define otp(...) Output(__VA_ARGS__)
#define otpv(...) OutputVertical(__VA_ARGS__)
#define otpa(...) OutputArray(__VA_ARGS__)
#define otpva(...) OutputVerticalArray(__VA_ARGS__)
#define otpm(...) OutputMatrix(__VA_ARGS__)
#define rep(counter, range) for (ll (counter) = 0; (counter) < (range); (counter)++)
#define rep2(counter, start, end) for (ll (counter) = (start); (counter) < (end); (counter)++)
#define rep3(counter, start, end, step) for (ll (counter) = (start); (counter) < (end); (counter) += (step))
#define repi(range) rep(i, range)
#define repi2(start, end) rep2(i, start, end)
#define repi3(start, end, step) rep3(i, start, end, step)
#define rrep(counter, range) for (ll (counter) = (range) - 1; (counter) >= 0; (counter)--)
#define rrepi(range) rrep(i, range)
#define repc(element, container) for (auto &(element) : (container))
#define repe(container) repc(e, container)
#define all(container) (begin(container)), (end(container))

#ifdef DBG
#	define dbg(x) x
#else
#	define dbg(x)
#endif

int main()
{
	inp(string, a, b);

	int sa = a[0] + a[1] + a[2] - '0' * 3;
	int sb = b[0] + b[1] + b[2] - '0' * 3;

	otp(sa >= sb ? sa : sb);

	return 0;
}


#include <bits/stdc++.h>

#define For(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rFor(i, a, b) for (int i = (int)(a)-1; i >= (int)(b); --i)
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second

using namespace std;

typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

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

template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

template <typename T>
struct coord_comp {
    vector<T> v;
    bool sorted = false;

    coord_comp() {}

    int size() { return v.size(); }

    void add(T x) { v.push_back(x); }

    void build() {
        sort(v.begin(), v.end());
        v.erase(unique(v.begin(), v.end()), v.end());
        sorted = true;
    }

    int get_idx(T x) {
        assert(sorted);
        return lower_bound(v.begin(), v.end(), x) - v.begin();
    }

    T &operator[](int i) { return v[i]; }
};

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    rrep(x, b + 1) if (div_floor(b, x) - div_floor(a - 1, x) >= 2) {
        printf("%d\n", x);
        return 0;
    }
}

#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 222
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
int n , m , k;
const int P = 1e9 + 7;
int A[MAXN];

int Pow( int x , int a ) {
	int ret = 1;
	while( a ) {
		if( a & 1 ) ret = ret * 1ll * x % P;
		x = x * 1ll * x % P , a >>= 1;
	}
	return ret;
}

struct mtrx {
	#define N 100
	int A[103][103] , flg;
	mtrx( ) {
		mem( A );
	}
	int* operator [] ( int x ) { return A[x]; }
	mtrx operator * ( mtrx B ) {
		mtrx as;
		rep( i , 0 , N ) rep( k , 0 , N ) if( A[i][k] ) rep( j , 0 , N )
			as[i][j] = ( as[i][j] + A[i][k] * 1ll * B[k][j] ) % P;
		return as;
	}
} tr , cur ;

void Pow( int a ) {
	while( a ) {
		if( a & 1 ) cur = tr * cur;
		a >>= 1 , tr = tr * tr;
	}
}
int deg[MAXN];

void solve() {
	cin >> n >> m >> k;
	int im = Pow( 2 * m , P - 2 );
	rep( i , 1 , n ) scanf("%d",A + i) , cur[i][1] = A[i];
	rep( i , 1 , m ) {
		int u , v;
		scanf("%d%d",&u,&v);
		tr[u][v] = tr[v][u] = im;
		tr[u][u] = ( tr[u][u] + im ) % P;
		tr[v][v] = ( tr[v][v] + im ) % P;
		++ deg[u] , ++ deg[v];
	}
	rep( u , 1 , n ) tr[u][u] += ( m - deg[u] ) * 1ll * Pow( m , P - 2 ) % P;
	Pow( k );
	rep( i , 1 , n ) printf("%d\n",cur[i][1]);
}

signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}


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

int main() {
 int a;
 cin>>a;
 int b;
 b=100-a%100;
 cout<<b<<endl;
}

#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12
//priority_queue<int,vector<int>, greater<int> > q2;

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

	int X, Y, N, M, A, B, C;
	cin >> A;
	A %= 100;

	cout << 100 -A << endl;

	return 0;
}


#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end()
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){

ll N, Q;
string S, x, y;cin >> N >> S >> Q;
bool C = 0;

x = S.substr(0, N);

y = S.substr(N, N);

rep(i, 0, Q){

    ll T, A, B;cin >> T >> A >> B;A--;B--;

    if(T == 1 && !C){

      if(A < N){

        if(B < N)swap(x[A], x[B]);

        if(N <= B)swap(x[A], y[B - N]);

      }

      if(N <= A)swap(y[A - N], y[B - N]);

    }

    if(T == 1 && C){

      if(A < N){

        if(B < N)swap(y[A], y[B]);

        if(N <= B)swap(y[A], x[B - N]);

      }

      if(N <= A)swap(x[A - N], x[B - N]);

    }

    if(T == 2){

        if(C)C = 0;

        else C = 1;

    }
}

if(C)cout << y << x;

else cout << x << y;

}

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

//LPFI
int main()
{
	int n, q;
	cin >> n;
	string s;
	cin >> s;
	cin >> q;
	/*string s1 = s.substr(0, n);
	string s2 = s.substr(n, 2 * n);*/
	string s1, s2;
	for (int i = 0; i < n; i++)
		s1 += s[i];
	for (int i = n; i < 2 * n; i++)
		s2 += s[i];
	int t, a, b;
	while(q--)
	{
		cin >> t >> a >> b;
		if (t == 1)
		{
			if (a <= n && b <= n)
			{
				swap(s1[a - 1], s1[b - 1]);
			}
			else if (a > n && b <= n)
			{
				if (a == 2 * n)
					swap(s2[n - 1], s1[b - 1]);
				else
				{
					a -= n;
					swap(s2[a - 1], s1[b - 1]);
				}
			}
			else if (a <= n && b > n)
			{
				if (b == 2 * n)
					swap(s1[a - 1], s2[n - 1]);
				else
				{
					b -= n;
					swap(s1[a - 1], s2[b - 1]);
				}
			}
			else if (a > n && b > n)
			{
				if (a == 2 * n)
					a = n;
				else
					a -= n;
				if (b == 2 * n)
					b = n;
				else
					b -= n;
				swap(s2[a - 1], s2[b - 1]);
			}
		}
		else if (t == 2)
			swap(s1, s2);
	}
	s = s1 + s2;
	cout << s << endl;
	return 0;
}


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

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

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

	ll N;
	cin >> N;

	int kotae = 0;
	rep1(i, 3000000) {
		if (N % i == 0) {
			ll a = i;
			ll b = N / i;
			if (a > b) break;
			if (a % 2 == 1) kotae++;
			if (a != b) {
				if (b % 2 == 1) kotae++;
			}
		}
	}
	rep1(i, 3000000) {
		if (2 * N % i == 0) {
			ll a = i;
			ll b = 2 * N / i;
			if (a > b) break;
			if (a % 2) {
				kotae++;
			}
			if (a != b) {
				if (b % 2) kotae++;
			}

		}
	}
	co(kotae);

	Would you please return 0;
}


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

#include <bits/stdc++.h>
#define int long long int
#define ll long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define rep(i, init, n) for (int i = init; i < (int)n; i++)
#define rev(i, n, init) for (int i = (int)n; i >= init; i--)
#define MOD1 1e9 + 7
#define MOD2 998244353
#define f first
#define s second
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int>
#define all(v) v.begin(), v.end()
#define mt make_tuple
#define precise(i) cout << fixed << setprecision(i)
#define codejam cout << "Case #" << ii + 1 << ": ";
#define impossible cout << "IMPOSSIBLE" << endl;
#define error(s) throw runtime_error(s)
#define hash hash1
#define prev prev1
std::mt19937_64 gen(std::chrono::steady_clock::now().time_since_epoch().count());
std::mt19937 gen1(std::chrono::steady_clock::now().time_since_epoch().count());

//change according to int or long long int
int rng(int l, int r)
{
     return std::uniform_int_distribution<int>(l, r)(gen);
}

const long double PI = atan(1.0) * 4;
const int32_t INF32 = 2e9 + 7;
const int64_t INF64 = 3e18;
const int32_t LOG = 21;
int32_t MOD = MOD1;

using namespace std;

//-------------------DEBUGGING-------------------------
void my_debugger(string s, int LINE_NUM) { cerr << endl; }
template <typename start, typename... end>
void my_debugger(string s, int LINE_NUM, start x, end... y)
{
     if (s.back() != ',')
     {
          s += ',';
          cerr << "LINE(" << LINE_NUM << "): ";
     }
     int i = s.find(',');
     cerr << s.substr(0, i) << " = " << x;
     s = s.substr(i + 1);
     if (!s.empty())
          cerr << ", ";
     my_debugger(s, LINE_NUM, y...);
}

#ifdef AJIT
#define debug(...) my_debugger(#__VA_ARGS__, __LINE__, __VA_ARGS__);
#else
#define debug(...) ;
#endif

void setMod(int mod_val)
{
     MOD = mod_val;
}

void files_init()
{
     freopen("file.in", "r", stdin);
     freopen("file.out", "w", stdout);
}

const int N = 1e6 + 5;
const int LOGN = 20;

//-----------------------------------------------------

int dp[3005][3005];
int pref[3005][3005];

int32_t main()
{
     getFaster;
     //files_init();
     int tests = 1;
     //cin >> tests;
     rep(ii, 0, tests)
     {
          int n;
          cin>>n;

          vector<int> a(n+1);

          rep(i,1,n+1)
          cin>>a[i];

          dp[0][0]=1;
          pref[0][1]=1;

          int sum=0;
          rep(i,1,n+1)
          {
               sum+=a[i];
               rep(j,1,n+1)
               {
                    int rem=sum%j;
                    dp[i][j]=pref[rem][j];
               }

               rep(j,1,n+1)
               {
                    int rem=sum%j;
                    pref[rem][j]+=dp[i][j-1];
                    while(pref[rem][j]>=MOD)
                    pref[rem][j]-=MOD;
               }
          }

          int ans=0;
          rep(j,1,n+1)
          {
               ans+=dp[n][j];
               while(ans>=MOD)
               ans-=MOD;
          }

          cout<<ans<<endl;

     }
     return 0;
}

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
//#include<atcoder/scc>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
//#define MOD 1000000007
#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

class DisjointSet{
    public:
        vector<ll> rank,p,siz;

        DisjointSet(){}
        DisjointSet(ll size){
            rank.resize(size,0);
            p.resize(size,0);
            siz.resize(size,1);
            rep(i,size) makeSet(i);
        }

        void makeSet(ll x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(ll x, ll y){
            return root(x) == root(y);
        }

        void unite(ll x, ll y){
            x = root(x);
            y = root(y);
            if(rank[x] > rank[y]){
                siz[x] += siz[y];
                p[y] = x;
            }
            else{
                siz[y] += siz[x];
                p[x] = y;
                if(rank[x] == rank[y]) rank[y]++;
            }
        }
        ll root(ll x){
            if(x != p[x]){
                p[x] = root(p[x]);
            }
            return p[x];
        }

        ll size(ll x){
            return siz[root(x)];
        }

};

ll modpow(ll a, ll n, ll m){
    if(n == 0) return 1;
    ll half = modpow(a,n/2,m);
    ll res = half * half % m;
    if(n & 1) res = res * (a%m) % m;
    return res;
}

int main(){
    int n; cin >> n;
    DisjointSet uf(n);
    rep(i,n){
        int f; cin >> f;
        f--;
        if(!uf.same(i,f)) uf.unite(i,f);
    }
    vector<bool> used(n,false);
    int ans0 = 0;
    rep(i,n){
        if(!used[uf.root(i)]){
            used[uf.root(i)] = true;
            ans0++;
        }
    }
    cout << modpow(2,ans0,MOD)-1 << endl;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
#define mod 1000000007
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    string s;   cin>>s;
    int ans=0;
    f(i,0,9)
    f(j,0,9)
    f(k,0,9)
    f(l,0,9){
        if(s[i]!='x'&& s[j]!='x' && s[k]!='x' && s[l]!='x')
        {
            int x=1;
            f(a,0,9)
            if(a!=i && a!= j && a!= k && a!= l && s[a]=='o')
                x=0;
            ans+=x;
        }
    }
    cout<<ans;
}

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define rep(i, n) for(int i=0;i<n;i++)
#define all(i, v) for(auto& i : v)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

const ll N = 200007;
ll fac[N],finv[N],inv[N];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cominit();
    ll cnt = 0, cnt1 = 0;
    all(e, s) {
        if(e == 'o') cnt++;
        else if(e == '?') cnt1++;
    }
    ll ans = 0;
    rep(bit, 1 << cnt1) {
        int num = __builtin_popcount(bit);
        if(num + cnt >= 5) continue;
        if(num + cnt == 0) continue;
        num += cnt;
        if(num == 1) ans += 1;
        if(num == 2) ans += 14;
        if(num == 3) ans += 36;
        if(num == 4) ans += 24;
    }
    cout << ans << endl;
    return 0;
}


#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define out(x) cerr<<#x<<" = "<<x<<" "
#define outln(x) cerr<<#x<<" = "<<x<<endl
#define outarr(x,l,r) cerr<<#x"["<<l<<"-"<<r<<"] = "; for (int _i=l;_i<=r;++_i) cerr<<x[_i]<<" ";cerr<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define gc() getchar()
//char buf[1<<23],*p1=buf,*p2=buf;
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x)
{
    x=0; char c=gc(); int flag=0;
    while (c<'0'||c>'9') flag|=(c=='-'),c=gc();
    while (c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=gc();
    if (flag) x=-x;
}
template <class T> inline T _max(T a,T b){return a>b ? a : b;}
template <class T> inline T _min(T a,T b){return a<b ? a : b;}
template <class T> inline bool checkmax(T &a,T b){return b>a ? a=b,1 : 0;}
template <class T> inline bool checkmin(T &a,T b){return b<a ? a=b,1 : 0;}
const int N=105,inf=0x3f3f3f3f;
int n;
int g[N][N];
int d[N];
char mp[N];
void init()
{
	read(n);
	for (int i=1;i<=n;++i)
	{
		scanf("%s",mp+1);
		for (int j=1;j<=n;++j)
		{
			g[i][j]=(i==j ? 0 : inf);
			if (mp[j]=='1') g[i][j]=1;
		}
	}
	for (int k=1;k<=n;++k)
		for (int i=1;i<=n;++i)
			for (int j=1;j<=n;++j)
				if (g[i][k]<inf&&g[k][j]<inf)
					checkmin(g[i][j],g[i][k]+g[k][j]);
	for (int i=1;i<=n;++i)
		for (int j=1;j<=n;++j)
			if (g[j][i]<inf) ++d[i];
}

void solve()
{
	double ans=0;
	for (int i=1;i<=n;++i) ans+=1.0/d[i];
	printf("%.12lf\n",ans);
}

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

#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;
ll dist[105][105];
ll N;
string S[105];
long double ans;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> S[i];
        for(int j = 0; j < N; j++) {
            if(S[i][j] == '1') dist[i][j] = 1;
            else dist[i][j] = INF;
        }
        dist[i][i] = 0;
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            for(int k = 0; k < N; k++) {
                chmin(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    for(int i = 0; i < N; i++) {
        //cerr << "---" << i << "---" << endl;
        ll num = 0;
        for(int j = 0; j < N; j++) {
            if(dist[j][i] < INF) {
                //cerr << j << endl;
                num++;
            }
        }
        ans += (long double)1 / num;
    }
    cout << fixed << setprecision(30) << ans << endl;
    return 0;
}


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

const int MAX_NUM = 3e5 + 10;

int bit[MAX_NUM];

inline int low(int i) { return i & (-i); }

void update(int i, int k) {
    while (i < MAX_NUM) {
        bit[i] ^= k;
        i += low(i);
    }
}

int query(int i) {
    int res = 0;
    while (i > 0) {
        res ^= bit[i];
        i -= low(i);
    }
    return res;
}

int main() {
    int N, Q, num;
    cin >> N >> Q;
    for (int i = 0; i < N; i++) {
        cin >> num;
        update(i + 1, num);
    }
    int t, x, y;
    for (int i = 0; i < Q; i++) {
        cin >> t >> x >> y;
        if (t == 1) {
            update(x, y);
        }
        else {
            cout << (query(y) ^ query(x - 1)) << "\n";
        }
    }
    return 0;
}

//ye moh moh ke dhaage,tere ungliyon se ja uljhe

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[3*100002];
ll tree1[12*100002];//0 based indexing  (max)

void recalculate1(ll node){
    tree1[node]=(tree1[2*node+1]^tree1[2*node+2]);
}

void build1(ll node,ll l,ll r){
    if(l==r){
        tree1[node]=a[l];
        return;
    }
    ll m=(l+r)/2;
    build1(2*node+1,l,m);
    build1(2*node+2,m+1,r);
    recalculate1(node);
}

ll query1(ll node,ll l,ll r,ll ql,ll qr){
    if((ql>r)||(qr<l)) return(-1);
    if((ql<=l)&&(qr>=r)) return(tree1[node]);
    ll m=(l+r)/2;
    ll q1=query1(2*node+1,l,m,ql,qr);
    ll q2=query1(2*node+2,m+1,r,ql,qr);
    if(q1==-1) return(q2);
    if(q2==-1) return(q1);
    return(q1^q2);
}

void update1(ll node,ll l,ll r,ll pos,ll val){
      if(l==r){
            a[l]=(a[l]^val);
            tree1[node]=a[l];
            return;
      }
      ll m=(l+r)/2;
      if(pos>m) (update1(2*node+2,m+1,r,pos,val));
      else (update1(2*node+1,l,m,pos,val));
      recalculate1(node);
      return;
}

int main(){
      ll n,q;
      cin>>n>>q;
      forn(i,n) cin>>a[i];
      build1(0,0,n-1);
      forn(i,q){
            ll t,x,y;
            cin>>t>>x>>y;
            if(t==1){
                  update1(0,0,n-1,x-1,y);
            }
            else{
                  //cout<<"---";
                  cout<<query1(0,0,n-1,x-1,y-1)<<endl;
            }
      }
      //cout<<a[9]<<" ";
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define ll long long
#define F(type, i, a, b, incr) for (type i = a; i <= (type)(b); i += (type)(incr))
#define RF(type, i, a, b, decr) for (type i = a; i >= (type)(b); i -= (type)(decr))
#define sz(a) sizeof(a)
#define deb(a) cerr << " [" << #a << "->" << a << "] "
#define next_line cerr << '\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for (auto it = s.begin(); it != s.end(); it++)
#define setbits(x) __builtin_popcountll(x)
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

void solve()
{
    int n;
    cin>> n;
    string s, fir, sec;
    vector<string> parts(2);
    cin>>s;
    F(int,i, 0, n - 1, 1)
        fir += s[i];
    F(int,i, n, 2*n - 1, 1)
        sec += s[i];
    parts[0] = fir;
    parts[1] = sec;
    int q, t = 0;
    cin >> q;
    while(q --){
        int ty,a,b;
        cin >> ty >> a >> b;
        if(ty == 1){
            a --;
            b --;
            int a_id = (a < n)?0:1;
            if(a >= n)
                a-=n;
            int b_id = (b < n)?0:1;
            if(b >= n)
                b -= n;
            char c = parts[a_id ^ t][a];
            parts[a_id ^ t][a] = parts[b_id ^ t][b];
            parts[b_id ^ t][b] = c;
        }else{
            t ^= 1;
        }
        // deb(parts[0]);deb(parts[1]);next_line;
    }
    cout << parts[t] + parts[t ^ 1];
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
        // freopen("output.txt", "w", stdout);
        // freopen("Debug.txt", "w", stderr);
    #else
    #endif
    // cout << fixed << setprecision(10);
    // int _t;
    // cin>>_t;
    // F(int, i, 1, _t, 1){
        // cout << "Case #" << i << ": ";
        solve();
    // }
}


#include<bits/stdc++.h>
// no of bits to store no 2e5 is 19
// 2e5 ka 5 times square root lene se 2 or 3 ke pass pahunch jate hai
using namespace std;

#define int               long long
#define mod               1000000007
#define MOD               1000000007
#define MAX               1000000000
#define inf               1e18
#define ff                first
#define ss                second
#define mp                make_pair
#define pb                push_back
#define pii               pair<int,int>
#define mii               map<int, int>
#define all(x)            (x).begin(), (x).end()
#define fill(a,b)         memset(a, b, sizeof(a))
#define sp(x,y)           fixed<<setprecision(y)<<x
#define setbits(x)        __builtin_popcount(x)
#define fast_in_out       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define ll                long long

//   powermod(a,b,m) ==  powermod(a,b%(m-1),m)  when m is prime fermat's theorem a^(p-1) %p=1 p is prime
int powermod(int a,int b,int c) //  gives (a^b)%c
{
    int ans = 1,tempans=a%c;
    while(b>0)
    {
        if(b&1==1)
        {
            ans=(ans*tempans)%c;
        }
             tempans=(tempans*tempans)%c;
             b=b>>1;
    }
    return ans;
}

int modinverse(int a,int m)   // gives a inverse wrt m and m is prime
{
    return powermod(a,m-2,m);
}

ll add(ll x, ll y) {
   x += y;
   if (x >= mod) return x - mod;
   return x;
}
ll sub(ll x, ll y) {
   x -= y;
   if (x < 0) return x + mod;
   return x;
}
ll mult(ll x, ll y) {
   return (x * y) % mod;
}
// my template                                              m
// prime factorization                                      pf
// ncr and factorials                                       ncr
// matrix exponentiation of fibonacci series in log(n)      matexpofib
// cycles in a graph                                        cycle
// prime factorization in log(n)                            spf

void solve()
{
   string s;
   cin>>s;
   int ans =0;
   int n=s.length();
   int a[26]={0};
   for(int i=n-1;i>=1;i--)
   {
      if(s[i]==s[i-1])
      {
         int re= n-i-1;
         int fr= a[s[i]-'a'];
         ans+=(re-fr);
         for(int j=0;j<26;j++)
            a[j]=0;
         a[s[i]-'a']=n-i;

      }
      else
      {
         a[s[i]-'a']++;
      }
   }
   cout<<ans<<endl;

}

int32_t main()
{
  fast_in_out;

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

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

#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <tuple>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <bitset>
#include <list>
#include<iomanip>

using namespace std;
using ll = long long;
using ULL = unsigned long long;
using pll = std::pair<ll, ll>;
using vi = std::vector<int>;
using vl = std::vector<ll>;
using vb = std::vector<bool>;
using db = double;
using vdb = std::vector<db>;
using qlg= std::priority_queue<ll, vl, std::greater<ll> > ; //ascending
using qll= std::priority_queue<ll, vl, std::less<ll> > ; // descending
using qdg= std::priority_queue<db, vdb, std::greater<db> > ; //ascending
using qdl= std::priority_queue<db, vdb, std::less<db> > ; // descending
template<class T>
using vv = std::vector<std::vector<T> >;

#define REPL(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FORL(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FORL(i, 0, n)

#define MREP(i, n) for (ll i= (ll)(n)-1; i>=0; i-- )
#define MFOR(i, a, b) for (ll i = (ll)(b)-1; i >= (ll)(a); i--)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
#define INF pow(10, 10)

void change(ll id, vl &counts, ll &Times)
{
    ll num = 0;
    REP(i, 26)
    {
        if(i != id)
        {
            num += counts[i];
            counts[i] = 0;
        }
    }
    counts[id] += num;
    Times += num;
}

int main(void)
{

    ll  N, K;
    string Str;

    cin >> Str;

    ll Len = Str.size();

    vl counts(26, 0);

    ll Time_Max = 0;
    MFOR(i, 1, Len)
    {
        ll id = Str[i]-'a';
        if(Str[i] == Str[i-1])
        {
            change(id, counts, Time_Max);
            // cout << i << " " << Str[i] << ", "<< Time_Max << endl;
            counts[id] ++;
        }
        else
        {
            counts[id] ++;
        }
    }

    cout << Time_Max << endl;

    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
char In[1 << 20], *ss = In, *tt = In;
#define getchar() (ss == tt && (tt = (ss = In) + fread(In, 1, 1 << 20, stdin), ss == tt) ? EOF : *ss++)
ll read() {
	ll x = 0, f = 1; char ch = getchar();
	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
	for(; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + int(ch - '0');
	return x * f;
}
enum col{
	cB = 0,
	cW = 1,
	cR = 2
};
int readc() {
	char ch = getchar();
	for(; ch < 'A' || ch > 'Z'; ch = getchar());
	return ch == 'B' ? cB : (ch == 'W' ? cW : cR);
}
const int MAXN = 400005;
int n, c[MAXN], ans;
int C(int n, int m) {
	if(n < 0 || m < 0 || n < m) return 0;
	if(m == 0) return 1;
	else if(m == 1) return n;
	else return n * (n-1) / 2 % 3;
}
int Lucas(int n, int m) {
	if(m == 0) return 1;
	return Lucas(n / 3, m / 3) * C(n % 3, m % 3) % 3;
}
int main() {
	n = read();
	for(int i = 1; i <= n; i++) c[i] = readc();
	for(int i = 1; i <= n; i++)
		(ans += c[i] * Lucas(n-1, i-1)) %= 3;
	if(~n & 1) ans = (3 - ans) % 3;
	printf(ans == cB ? "B\n" : (ans == cW ? "W\n" : "R\n"));
	return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
using ld = long double;

typedef tree<
        int,
        null_type,
        less<int>,
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;

#define mp make_pair

int MOD =  1e9 + 7;

int mul(int a, int b) {
    return (1LL * a * b) % MOD;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=MOD) s-=MOD;
    return s;
}

int sub(int a, int b) {
    int s = (a+MOD-b);
    if (s>=MOD) s-=MOD;
    return s;
}

int po(int a, ll deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, MOD-2);
}

mt19937 rnd(time(0));

/*const int LIM = 1e6;

vector<int> facs(LIM), invfacs(LIM);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<LIM; i++) facs[i] = mul(facs[i-1], i);
    invfacs[LIM-1] = inv(facs[LIM-1]);
    for (int i = LIM-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/

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

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return find_set(parent[v]);
    }

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

        a = find_set(a);
        b = find_set(b);

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

    DSU (int n)
    {
        parent.resize(n);
        sz.resize(n);
        for (int i = 0; i<n; i++) make_set(i);
    }
};*/

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

    int n; cin>>n;
    string s; cin>>s;

    map<char, int> m;
    m['B']=0;
    m['R']=1;
    m['W']=2;

    map<int, char> m1;
    for (auto it: m) m1[it.second]=it.first;

    vector<int> facs(n), degs(n);
    facs[0]=1;
    degs[0]=0;
    for (int i = 1; i<n; i++)
    {
        facs[i] = facs[i-1];
        degs[i] = degs[i-1];
        int i1 = i;
        while (i1%3==0)
        {
            i1/=3; degs[i]++;
        }
        facs[i] = (facs[i]*i1)%3;
    }

    int tot = 0;
    for (int i = 0; i<n; i++)
    {
        int C;
        int deg = degs[n-1] - degs[i] - degs[n-i-1];
        if (deg>0) C=0;
        else C = (facs[n-1]*facs[i]*facs[n-i-1])%3;
        tot+=m[s[i]]*C; tot%=3;

        //cout<<degs[i]<<' '<<C<<' '<<tot<<endl;
    }

    if (n%2==0) tot = (3-tot)%3;

    //cout<<tot<<endl;
    cout<<m1[tot];

}
/*
W
BR
RWB
RRBB

-a1-3a2-3a3-a4

-4 = 2

 */


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

#define int long long
#define pb push_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

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

    int ans = 0;

    f(i,1,1e6+1){
        int len = log10(i) + 1;
        int cur = 1;
        f(j,0,len) cur*=10;
        if(cur*i + i <= n){
            ans++;
        }
    }
    cout << ans << "\n";
}

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

#include<bits/stdc++.h>
using namespace std;
int main() {
long long int n,count=0;
cin>>n;
for(int i=1;i<=1000000;i++){
    string s=to_string(i);
    string r=s+s;
  long long   int res=stoll(r);
    count++;
    if(res>n){
        break;
    }
}
cout<<count-1<<endl;
	return 0;
}


 /*Jai Shree Ram*/
// Never Give Up
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define F(i,s,e,j)        for(int i=s;i<=e;i+=j)
#define mt19937                 rng(chrono::steady_clock::now().tjhe_since_epoch().count());
//shuffle(arr,arr+n,rng)
 void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
vector<vi> graph[100001];
int32_t main()
{   c_p_c();
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    vi vt(3);
    for(int i=0;i<m;i++)
    {
        int a,b,t,k;
        cin>>a>>b>>vt[1]>>vt[2];
        vt[0] = b;
        graph[a].pb(vt);
        vt[0] = a;
        graph[b].pb(vt);
    }
   priority_queue<pii,vector<pii>,greater<pii> > pq;
   pq.push(mp(0,x));
   vector<bool> vis(n+1,false);
   int ans = -1;
   while(!pq.empty())
   {
     pii node = pq.top();
     pq.pop();
     if(vis[node.ss])
        continue;
     vis[node.ss] = true;
     if(node.ss==y)
     {
        ans = node.ff;
        break;
     }

     for(vi v:graph[node.ss])
     {
        if(!vis[v[0]])
        {
            int t = node.ff;
            t += node.ff%v[2]==0?0:v[2]-node.ff%v[2];
            t += v[1];
            pq.push(mp(t,v[0]));
        }
     }
   }
   cout<<ans<<endl;
}

#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}
template <typename T> ostream& operator<<(ostream &os, const vector<T> &v){print(v); return os;};
template <typename T> ostream& operator<<(ostream &os, const vector<vector<T>> &vv){print_vv(vv); return os;};
template <class T, class U> ostream& operator<<(ostream &os, const map<T,U>  &m){print_m(m); return os;};
template <class T, class U> ostream& operator<<(ostream &os, const pair<T, U> &pr){debp(pr); return os;};
template <class T, class U> ostream& operator<<(ostream &os, const vector<pair<T, U>> &vp){ print_vp(vp); return os;};

typedef tuple<ll,ll,ll> tii; // ad, ti, ki
const ll inf =  1e18L;
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n, m;
    while(cin>>n>>m){
        ll st, ed; cin>>st>>ed;
        vector<vector<tii>> adj(n+1);
        forn(i,m){
            ll x,y,t,k; cin>>x>>y>>t>>k;
            adj[x].pb({y,t,k});
            adj[y].pb({x,t,k});
        }

        vector<bool> vis(n+1);
        vl dist(n+1,inf);
        priority_queue<pll,vector<pll>, greater<pll>> pq; // {time, node}
        dist[st] = 0;
        pq.push({0,st});

        while(!pq.empty()){
            auto [d, node] = pq.top(); pq.pop();
            if(d>dist[node]) continue;
            vis[node] = 1;

            for(auto [ad, t, k]: adj[node]){
                if(vis[ad]) continue;
                ll depart = ((d+k-1)/k)*k;
                ll reach = depart + t;
                // deb(node,d,depart,reach,k);
                if(reach<dist[ad]){
                    dist[ad] = reach;
                    pq.push({reach,ad});
                }
            }
            // if(node==ed) break;
        }

        ll ans = dist[ed];
        cout<<(ans>=inf ? -1 : ans)<<"\n";

    }
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

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

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

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

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

    ll N, X;
    cin >> N >> X;
    vector<ll> A(N);
    REP(i, N)
    cin >> A[i];

    vector<ll> B(N - 1);
    REP(i, N - 1)
    {
        B[i] = A[i + 1] / A[i];
    }

    vector<map<ll, ll>> dp(N, map<ll, ll>());
    REP_REV(i, N)
    {

        ll res = X % A[i];

        if (i == N - 1)
        {
            dp[i][res] += 1;
            dp[i][res - A[i]] += 1;
        }
        else
        {
            for (auto d : dp[i + 1])
            {
                if ((abs(d.first - res) % A[i] == 0) && ((abs(d.first - res) / A[i]) < B[i]))
                {
                    dp[i][res] += d.second;
                }
                if (res == 0)
                    continue;

                if ((abs(d.first - res + A[i]) % A[i] == 0) && ((abs(d.first - res + A[i]) / A[i]) < B[i]))
                {
                    dp[i][res - A[i]] += d.second;
                }
            }
        }
        //        print(dp[i]);
    }

    ll ans = 0;
    for (auto d : dp[0])
    {
        if (d.first == 0)
        {
            ans += d.second;
        }
    }

    print(ans);

    //    vector<int> ans2;
    //    REPN(y, X, X+A.back()+1){
    //
    //        bool valid = true;
    //        ll yy = y;
    //        vector<int> C(N);
    //        REP_REV(i, N){
    //            C[i] = yy / A[i];
    //            yy %= A[i];
    //        }
    //
    //        yy = y - X;
    //        REP_REV(i, N){
    //            if (C[i] > 0 && yy / A[i]){
    //                valid = false;
    //                break;
    //            }
    //            yy %= A[i];
    //        }
    //
    //        if (valid){
    //            ans2.emplace_back(y);
    //        }
    //
    //    }
    //
    //    print(ans2.size());
    //    print(ans2);

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long C(int n, int r){
  __int128 ans = 1;
  for(int i=n;i>n-r;i--){
    ans=ans*i;
  }
  for(int i=1;i<r+1;i++){
    ans = ans/i;
  }
  return ans;
}

int main(){
  int L;
  cin >> L;
  cout << C((L-1),11) << endl;
}

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define mem(a) memset(a, 0, sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef __int128_t int128;
const int maxn = 1e3 + 10;
char a[maxn];
char b[] = "atcoder";
int c[30];
int main()
{
    //cout << ("atcodeer" < "atcoder") << endl;
    IOS;
    int t;
    cin >> t;
    while (t--)
    {
        int ans = -1;
        cin >> a;
        int len = strlen(a);
        if (strcmp(a,b)>0)
            ans = 0;
        else
            for (int i = 0; i < len; i++)
            {
                if(a[i]=='a')
                    continue;
                if(a[i]<='t')
                {
                    ans = i;
                    break;
                }
                else
                {
                    ans = i - 1;
                    break;
                }
            }

        cout << ans << endl;
    }
    return 0;
}


#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

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

const long long int mod = 998244353;
const long long int INF = 1e16;
const long double PI=3.14159265358979323;
const long long int pl=1100;
const long double eps =0.0000001;

long long int N,M,K,A[200200],check[200200]={},res=0,sum=0;
long double dp[200200]={},a[200200]={},b[200200]={};
string S;
bool wana[200200]={};

pll op[200200];
pair<pll,pll>mode[200200];
int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>M>>K;
    for (long long int i = 1; i <= K; i++)
    {
        cin>>A[i];
        wana[A[i]]=true;
        check[A[i]]++;
        b[A[i]]=1.0;
    }
    for (long long int i = 1; i <= N; i++)
    {
        check[i]+=check[i-1];
    }

    for (long long int i = 1; i <= N; i++)
    {
        if(check[M+i]-check[i-1]==M){
            cout<<-1<<endl;return 0;
        }
    }
    long double tmp=0.0,tmpb=0.0;
    for (long long int i = N-1; i >=0; i--)
    {
        tmp+=(a[i+1]-a[i+M+1]);
        tmpb+=(b[i+1]-b[i+M+1]);
        if(b[i]<=0.99999999)a[i]=tmp/M+1.0;
        if(b[i]<=0.99999999)b[i]=tmpb/M;

    }

    cout<<a[0]/(1.0-b[0])<<endl;

}

// #define _GLIBCXX_DEBUG

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++(i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++(i))
#define REP_R(i, n) for (int i = (int)(n)-1; (i) >= 0; --(i))
#define REP3R(i, m, n) for (int i = (int)(n)-1; (i) >= (int)(m); --(i))
#define ALL(x) std::begin(x), std::end(x)
using namespace std;
void dump_func()
{
    cerr << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&h, Tail &&... t)
{
    cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...);
}
#define dump(...)                                                                                \
    cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), \
        cerr << "*/\n\n";
typedef long long ll;
template <class T>
using V = vector<T>;
template <class T>
using P = pair<T, T>;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(20);
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a * a + b * b < c * c ? "Yes" : "No") << '\n';
    return 0;
}


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

int main(){

 long long  N, L = 0;
 long long ans = 0;
 cin >> N;

 vector<long long> vec(N);

 for (int i = 0; i < N; i++){
   int x;
   cin >> x;
   vec.at(i) = x;
 }

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

  for (int i = 0; i < N; i++){

    if( vec.at(L) != vec.at(i) ){
      ans += (i - L) * ( N - i );
      L = i;
    }

  }

  cout << ans << endl;

}

using namespace std;
#include "bits/stdc++.h"
#define len(X) (int)(X).size()
#define all(X) (X).begin(), (X).end()
#define elif else if
#define ceil(x,y) (x + y-1)/y

#define int long long

int32_t main() { cin.tie(nullptr)->sync_with_stdio(false);

	int n;cin>>n;
	map<int,int> m;
	for(int a,i {}; i < n; ++i) cin>>a,m[a]++;
	// for(auto i : m) cout << i.second << ' ';
	// cout << '\n';

	vector<int> v;
	for(auto &i : m) v.push_back(i.second);

	vector<int> suff=v;

	for(int i = len(v)-2; i >= 0; --i) suff[i] += suff[i+1];
	// for(auto i : suff) cout << i << ' ';
	// cout << '\n';

	int ans{};

	for(int i {}; i < len(v)-1; ++i) {
		int res = v[i]; //res*suffix
		res *= suff[i+1];
		ans += res;
	}
	cout << ans << '\n';
	return 0;
}
// taskkill /IM "3.exe" /F


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

int main(){
  int n, q, t, e, x, l, r;
  cin >> n;
  vector<vector<int>> g(n);
  int a[n-1], b[n-1];
  rep(i,n-1) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    g[a[i]].push_back(b[i]); g[b[i]].push_back(a[i]);
  }
  vector<ll> par(n), val(n);
  par[0] = -1;
  auto dfs1 = [&](auto self, int v, int p) -> void {
    for(auto x : g[v]) {
      if(x == p) continue;
      par[x] = v;
      self(self,x,v);
    }
  };
  dfs1(dfs1,0,-1);
  cin >> q;
  rep(i,q) {
    cin >> t >> e >> x;
    e--;
    l = a[e], r = b[e];
    if(t == 2) swap(l,r);
    if(par[l] == r) val[l] += x;
    else val[0] += x, val[r] -= x;
  }
  auto dfs2 = [&](auto self, int v, int p) -> void {
    for(auto x : g[v]) {
      if(x == p) continue;
      val[x] += val[v];
      self(self,x,v);
    }
  };
  dfs2(dfs2,0,-1);
  rep(i,n) cout << val[i] << endl;
  return 0;
}

#include <bits/stdc++.h>

using namespace std;

#define ll long long

priority_queue < pair < ll, int > > q;

int n, m, tot, hd[100005], vis[100005], to[200005], nxt[200005], c[200005], d[200005];

ll dis[100005];

int read()
{
	int x = 0, fl = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') fl = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = (x << 1) + (x << 3) + ch - '0'; ch = getchar();}
	return x * fl;
}

void add(int x, int y, int c0, int d0)
{
	tot ++ ;
	to[tot] = y;
	nxt[tot] = hd[x];
	c[tot] = c0;
	d[tot] = d0;
	hd[x] = tot;
	return;
}

ll s(ll x, ll y)
{
	if (x <= 0) return 1e18;
	return x + y / x;
}

void Dij()
{
	for (int i = 2; i <= n; i ++ )
		dis[i] = 1e18;
	q.push(make_pair(0, 1));
	while (!q.empty())
	{
		pair < int, int > h = q.top(); q.pop();
		int x = h.second;
		if (vis[x]) continue; vis[x] = 1;
		for (int i = hd[x]; i; i = nxt[i])
		{
			int y = to[i], c0 = c[i], d0 = d[i], p0, p = (int)(sqrt(d0));
			ll r1 = s(p - 1, d0), r2 = s(p, d0), r3 = s(p + 1, d0), z, tmp;
			if (r1 <= r2 && r1 <= r3) p0 = p - 1; else if (r2 <= r1 && r2 <= r3) p0 = p; else p0 = p + 1;
//			printf("%lld %lld %lld %d %d\n", r1, r2, r3, p, p0);
			if (dis[x] < p0 - 1) tmp = (ll)(s(p0, d0) + c0 - 1); else tmp = (ll)(s(dis[x] + 1, d0) + c0 - 1);
//			printf("%d %d %lld\n", x, y, tmp);
			if (dis[y] > tmp)
			{
				dis[y] = tmp;
				q.push(make_pair(-dis[y], y));
			}
		}
	}
	return;
}

int main()
{
	n = read(); m = read();
	for (int i = 1; i <= m; i ++ )
	{
		int x = read(), y = read(), c0 = read(), d0 = read();
		add(x, y, c0, d0), add(y, x, c0, d0);
	}
	Dij();
	printf("%lld\n", dis[n] == 1e18 ? -1 : dis[n]);
	return 0;
}


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

#define F first
#define S second
#define pb push_back
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef string str;
const ll maxn = 105, inf = 2e18;
ll n, s[maxn];
ld ans, x = 1, y;
bool mark[maxn];
vector <ll> adj[maxn];
void dfs(ll u){
	mark[u] = 1;
	s[u] ++;
	for(ll j : adj[u]){
		if(!mark[j])dfs(j);
	}
}
int main(){
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for(ll i = 1; i <= n; i ++){
		for(ll j = 1; j <= n; j ++){
			char c;
			cin >> c;
			if(c == '1')adj[i].pb(j);
		}
	}
	for(ll i = 1; i <= n; i ++){
		dfs(i);
		memset(mark, 0, sizeof mark);
	}
	for(ll i = 1; i <= n; i ++){
		y = s[i];
		ans += x / y;
	}
	cout << fixed << setprecision(10) << ans << endl;
}

//#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	string S[102];
	int A[102][102];
	scan(N);
	rep(i,N) scan(S[i]);
	fill(A[0],A[N],INF);
	rep(i,N) rep(j,N) if(i==j||S[i][j]=='1') A[i][j]=0;
	rep(k,N){
		rep(i,N){
			rep(j,N){
				if(k==i||k==j) continue;
				if(A[i][j]>A[i][k]+A[k][j]) A[i][j]=A[i][k]+A[k][j];
			}
		}
	}
	int ikeru[101]={};
	rep(i,N){
		rep(j,N){
			if(A[i][j]==0) ikeru[j]++;
		}
	}
	double ans=0;
	rep(i,N) ans+=1.0/ikeru[i];
	prin(setprecision(11)<<ans);
	return 0;
}


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

const int N = 3e5 + 5;

int tree[4 * N], n, a[N];

void built(int l = 1, int r = n, int pos = 1) {
	if (l == r) {
		tree[pos] = a[l];
		return;
	}

	int m = (l + r) / 2;

	built(l, m, 2 * pos);
	built(m + 1, r, 2 * pos + 1);

	tree[pos] = tree[2 * pos] ^ tree[2 * pos + 1];

}

void udt(int id, int val, int l = 1, int r = n, int pos = 1) {
	if (l == r) {
		tree[pos] ^= val;
		return;
	}

	int m = (l + r) / 2;
	if (id <= m) udt(id, val, l, m, 2 * pos);
	else udt(id, val, m + 1, r, 2 * pos + 1);

	tree[pos] = tree[2 * pos] ^ tree[2 * pos + 1];

}

int get(int tl, int tr, int l = 1, int r = n, int pos = 1) {
	if (tl > r || l > tr) return 0;
	if (tl <= l && r <= tr) return tree[pos];

	int m = l + r >> 1;
	int k1 = get(tl, tr, l, m, 2 * pos);
	int k2 = get(tl, tr, m + 1, r, 2 * pos + 1);
	return k1 ^ k2;
}

void solve(){
	int q;
	cin >> n >> q;

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

	built();

	while (q--) {
		int type, x, y;
		cin >> type >> x >> y;
		if (type & 1) udt(x, y);
		else cout << get(x, y) << '\n';
	}

}

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

	solve();

}

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define pi 2*acos(0.0)

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define FORE(x, a) for (auto& x: a)

#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

template <class T> struct Tree {
	static const T LOW = INT_MIN;
	T f(T a, T b) { return a^b; } // any associative func
	vector<T> s; int n; // main segtree vector, size of init vector
	Tree(int n = 0) : s(2*n, 0), n(n) {}
	void update(int pos, T val) { // s[pos] = val
		for (s[pos += n] = val; pos > 1; pos /= 2)
			s[pos / 2] = f(s[pos & ~1], s[pos | 1]);
	}
	T query(int b, int e) { // query [b, e)
		T ra = LOW, rb = LOW;
		for (b += n, e += n; b < e; b /= 2, e /= 2) {
			if (b&1) ra = f(ra, s[b++]);
			if (e&1) rb = f(s[--e], rb);
		}
		return f(ra, rb);
	}
};
// kactl

void solve(){
    int n,q; cin >> n >> q;
    vector<int> a(n);
    FOR(n) cin >> a[i];
    Tree<int> st(n);
    FOR(n) st.update(i,a[i]);
    FOR(q){
        int t,x,y; cin >> t >> x >> y;
        --x; --y;
        if(t == 1){
            a[x] ^= (y+1);
            st.update(x,a[x]);
        } else{
            cout << st.query(x,y+1) << '\n';
        }
    }
}

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

	solve();
	return 0;
}


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

//typedef
typedef unsigned int UINT;
typedef unsigned long long ULL;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef tuple<LL, LL, LL> TLL3;
typedef tuple<LL, LL, LL, LL> TLL4;
typedef set<LL, greater<LL> > setdownLL;
#define PQ priority_queue
typedef PQ<LL, vector<LL>, greater<LL> > pqupLL;
//container utill
#define ALL(v) (v).begin(),(v).end()
#define CR [](auto element1, auto element2){return element1>element2;}
#define LB lower_bound
#define UP upper_bound
#define PB push_back
#define MP make_pair
#define MT make_tuple
//constant
#define PI 3.141592653589793

const LL MOD=1000000007;

void solve(LL N, LL A, LL B){
    if(A+B>N){
            cout << 0 << endl;
            return;
        }
        if(A<B) swap(A,B);
        LL ans=0;
        LL val,val2;
        //0
        ans=N-A+1LL;
        ans%=MOD;
        ans*=ans;
        ans%=MOD;
        val2=N-B+1LL;
        val2%=MOD;
        ans*=val2;
        ans%=MOD;
        val2=N-B+1LL;
        val2%=MOD;
        ans*=val2;
        ans%=MOD;
        //1st
        val=N-A+1LL;
        val%=MOD;
        val*=val;
        val%=MOD;
        val2=A-B+1LL;
        val2%=MOD;
        val*=val2;
        val%=MOD;
        val*=val2;
        val%=MOD;
        ans+=(MOD-val);
        ans%=MOD;
        //2nd
        val=((B-1LL)*B)/2LL;
        val%=MOD;
        val2=(B-1LL)*(N-A-B+1LL);
        val2%=MOD;
        val+=val2;
        val%=MOD;
        val2=A-B+1;
        val*=val2;
        val%=MOD;
        val2=N-A+1;
        val2%=MOD;
        val*=val2;
        val%=MOD;
        val*=4LL;
        val%=MOD;
        ans+=(MOD-val);
        ans%=MOD;
        //3rd 1
        val=((B-1LL)*B)/2LL;
        val%=MOD;
        val*=val;
        val%=MOD;
        val*=4LL;
        val%=MOD;
        ans+=(MOD-val);
        ans%=MOD;
        //3rd 2
        val=B-1;
        val%=MOD;
        val2=N-A-B+1;
        val2%=MOD;
        val*=val2;
        val%=MOD;
        val2=B-1;
        val2%=MOD;
        val*=val2;
        val%=MOD;
        val*=B;
        val%=MOD;// 2/2=1
        val*=4LL;
        val%=MOD;
        ans+=(MOD-val);
        ans%=MOD;
        //3rd 3
        val=N-A-B+1;
        val%=MOD;
        val*=val;
        val%=MOD;
        val2=B-1;
        val2%=MOD;
        val*=val2;
        val%=MOD;
        val*=val2;
        val%=MOD;
        val*=4LL;
        val%=MOD;
        ans+=(MOD-val);
        ans%=MOD;
        //output
        cout << ans << endl;
}

int main(){
    LL T;
    cin >> T;
    LL N,A,B;
    LL t;
    for(t=0; t<T; t++){
        cin >> N >> A >> B;
        solve(N,A,B);
    }
    system("pause");
    return 0;
}

// 問題の URL を書いておく
//

#include <bits/stdc++.h>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

using ll = int64_t;

template<int Mod>
struct MintBase {
  int64_t x; // typedef long long int64_t;
  MintBase(int64_t x=0):x((x%Mod+Mod)%Mod){}
  MintBase operator-() const { return MintBase(-x);}
  MintBase& operator+=(const MintBase a) {
    if ((x += a.x) >= Mod) x -= Mod;
    return *this;
  }
  MintBase& operator-=(const MintBase a) {
    if ((x += Mod-a.x) >= Mod) x -= Mod;
    return *this;
  }
  MintBase& operator*=(const MintBase a) { (x *= a.x) %= Mod; return *this;}
  MintBase operator+(const MintBase a) const { return MintBase(*this) += a;}
  MintBase operator-(const MintBase a) const { return MintBase(*this) -= a;}
  MintBase operator*(const MintBase a) const { return MintBase(*this) *= a;}
  MintBase pow(int64_t t) const {
    if (!t) return 1;
    MintBase a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

//const int Mod = 1000000007;
//const int Mod = 998244353;

using mint = MintBase<1000000007>;
void solve()
{
    ll n, a, b;
    cin >> n >> a >> b;
    mint amax = mint((n - a + 1) * (n - a + 1));
    mint bmax = mint((n - b + 1) * (n - b + 1));
    auto total = amax * bmax;
    Print(total.x);
    auto x = (n - a - b + 1);
    Print(x.x);
    auto nonOverlapX = (n - a - b >= 0) ? ((1 + x) * x) : 0;
    Print(nonOverlapX.x);
    mint ab = mint(n - a + 1) * mint(n - b + 1);
    auto overlapX = ab - nonOverlapX;
    auto overlap = overlapX * overlapX;
    Print(overlap.x);
    auto ans = total - overlap;
    cout << ans.x << endl;
}

int main(int, const char**)
{
    ll t;
    cin >> t;
    rep(i, t)
    {
        solve();
    }
    return 0;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long
//using mint = atcoder::modint;

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long x){
    cout << ((x >= 0) ? x : 0) << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long x;
    scanf("%lld",&x);
    solve(x);
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<pair<ll,ll> > vpl;//追加はmake_pairを使う
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqg; //昇順のPriority queue
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define all(v) v.begin(), v.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;}
#define dbl(i) fixed << setprecision(15) << i << endl;
#define GET_VARIABLE_NAME(Variable) (#Variable)
#define dbc(a) cout << GET_VARIABLE_NAME(a) << "=" << a << endl;
#define vsum(v) accumulate(all(v), 0);
#define rsort(v) sort(v.begin(),v.end(),greater<ll>());
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }
    // 素数である
    return true;
}
vector<ll> enum_divisors(ll N) {//約数列挙
    vector<ll> res;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}
vector<pair<long long, long long> > prime_factorize(long long N) {//因数分解
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        pair <ll,ll> push;
        push.first=a;
        push.second=ex;
        res.push_back(push);
    }

    // 最後に残った数について
    if (N != 1){
        pair <ll,ll> push;
        push.first=N;
        push.second=1;
        res.push_back(push);
    }
    return res;
}
ll gcd(ll a, ll b){//最大公約数
        if (a%b == 0){
            return(b);
        }else{
            return(gcd(b, a%b));
        }
    }
ll lcm(ll a, ll b){//最小公倍数
   return a / gcd(a, b) * b;
}
ll comb(ll n, ll r) {
if(n<r) return 0;
  if ( r * 2 > n ) r = n - r;
  ll dividend = 1;
  ll divisor  = 1;
  for ( ll i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
void exgcd(ll a,ll b,ll &x,ll &y)
{
	if(b==0){ x=1;y=0; }
	else{ exgcd(b,a%b,y,x);y-=a/b*x; }
}
ll inv(ll a,ll Mod){//modにおけるaの逆元
	ll x,y;
	exgcd(a,Mod,x,y);
	return (x%Mod+Mod)%Mod;
}
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}
ll rui(ll a,ll n){
    ll x=1;
    while(n>0){
        if(n&1){
            x=x*a;
        }
        a=a*a;
        n>>=1;
    }
    return x;
}

ll f(ll n, vector <string>s){
    if(s[n]=="OR"){
        if(n==0)return 3;
        return rui(2,n+1)+f(n-1,s);
    }else{
        if(n==0)return 1;
        return f(n-1,s);
    }
}

int main(){
    ll n;
    cin>>n;
    vector <string>s(n);
    rep(i,n) cin>>s[i];
    ll ans=f(n-1,s);
    cout<<ans<<endl;

}