#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <queue>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin() , x.end()
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>

const static int INF = 1001001001;
const static ll LINF = 1001001001001001001LL;
const static lld PI = 3.1415926535897932384626L;
const static int MOD = 1000000009;
//const static int MOD = 998244353;

template < typename T > T gcd (T a , T b) { if (a < b) swap(a , b); if (a % b == 0) return b; else return gcd (b , a % b); }
template < typename T > T lcm (T a , T b) { return (a / gcd (a , b) * b); }
template < typename T > bool chmin (T &a , T b) { if (a > b) { a = b; return true; } else { return false; } }
template < typename T > bool chmax (T &a , T b) { if (a < b) { a = b; return true; } else { return false; } }
int keta (ll x) { int ret = 0; while(x) { ret++; x /= 10; } return ret; }
inline int in () { int x; scanf("%d" , &x); return x; }
inline ll lin () { ll x; scanf("%lld" , &x); return x; }
inline string sin () { string s; cin >> s; return s; }

void io_setup () {
    cout << fixed << setprecision(15);
    //cin.tie(0);
    //ios::sync_with_stdio(false);
}

bool is_prime (ll x) {
    if (x == 2 || x == 3 || x == 5 || x == 7) {
        return true;
    }
    for (ll i = 3; i * i <= x; i++) {
        if (x % i == 0) {
            return false;
        }
    }
    return true;
}

/*
vb prime_table(2020202 , true);
void prime () {
    prime_table[0] = false;
    prime_table[1] = false;
    for (int i = 2; i < 2020202; i++) {
        for(int j = i + i; j < 2020202; j += i) {
            prime_table[j] = false;
        }
    }
}
*/

/*
//memo
v.erase(unique(all(v)), v.end());
*/

void solve() {
    /*
    int H = in();
    int N = in();
    vi A(n) , B(n);
    rep (i,n) {
        A[i] = in();
        B[i] = in();
    }
    */
    string s;
    cin >> s;
    vi cnt(3 , 0);
    rep(i,s.size()) {
        int now = int(s[i] - '0');
        now %= 3;
        cnt[now]++;
    }
    int sum = 0;
    rep(i,3)  sum += cnt[i] * i;
    if (sum % 3 == 0 && (cnt[0] > 0 || cnt[1] > 0 || cnt[2] > 0)) {
        cout << 0 << endl;
        return;
    }

    if (sum % 3 == 1) {
        if (cnt[1] >= 1) {
            cnt[1] -= 1;
            int sum2 = 0;
            rep(i,3) sum2 += cnt[i] * i;
            if (sum2 % 3 == 0 && (cnt[0] > 0 || cnt[1] > 0 || cnt[2] > 0)) {
                cout << 1 << endl;
                return;
            }
        }
        if (cnt[2] >= 2) {
            cnt[2] -= 2;
            int sum2 = 0;
            rep(i,3) sum2 += cnt[i] * i;
            if (sum2 % 3 == 0 && (cnt[0] > 0 || cnt[1] > 0 || cnt[2] > 0)) {
                cout << 2 << endl;
                return;
            }
        }
        cout << -1 << endl;
        return;
    }

    if (sum % 3 == 2) {
        if (cnt[2] >= 1) {
            cnt[2] -= 1;
            int sum2 = 0;
            rep(i,3) sum2 += cnt[i] * i;
            if (sum2 % 3 == 0 && (cnt[0] > 0 || cnt[1] > 0 || cnt[2] > 0)) {
                cout << 1 << endl;
                return;
            }
        }
        if (cnt[1] >= 2) {
            cnt[1] -= 2;
            int sum2 = 0;
            rep(i,3) sum2 += cnt[i] * i;
            if (sum2 % 3 == 0 && (cnt[0] > 0 || cnt[1] > 0 || cnt[2] > 0)) {
                cout << 2 << endl;
                return;
            }
        }
        cout << -1 << endl;
        return;
    }
    return;
}

int main () {
    io_setup();
    //prime();
    solve();
    return 0;
}

//#pragma GCC optimize(2)
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#define DEBUG
#define INF 0x3f3f3f3f3f3f3f3f
#define mod 1000000007
#define PI 3.14159265358979323846
#define Base 23333333
//#define set unordered_set
//#define map unordered_map
#define int long long
#define LL long long
#define NO	cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define mst(x) memset(x,0,sizeof(x))
#define debug(x) cout<<"DEBUG:"<<x<<endl
//#define int unsigned long long
using namespace std;
//#define scanf scanf_s

//#define max(a,b) ((a) > (b) ? (a) : (b))
//#define min(a,b) ((a) < (b) ? (a) : (b))
inline int gcd(int a, int b) { return b > 0 ? gcd(b, a%b) : a; }
inline int lcm(int a, int b) { return a * b / gcd(a, b); }
inline int qpow(int a, int n) { int ans = 1;	while (n) { if (n & 1) { ans *= a; }a *= a; n >>= 1; }return ans; }
/*
#define read() _read()
#define cout fout
#define cin fin
ifstream fin("in.txt");fstream fout("out.txt");
int _read() {	int tmp;	fin >> tmp;	return tmp;}
*/
inline int read() { int x = 0, f = 1;	char ch = getchar();	while (ch<'0' || ch>'9') { if (ch == '-') { f = -1; }		ch = getchar(); }	while (ch >= '0'&&ch <= '9') { x = 10 * x + ch - '0';		ch = getchar(); }	return x * f; }

const int maxnum = 100000005;

int f[maxnum];

signed main()
{
	int n = read(), x = 100*read();
	int ans = -1;
	for (int i = 1; i <= n; i++) {
		int a = read(), b = read();
		x -= a * b;
		if (x < 0) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


#include <bits/stdc++.h>
#define endl '\n'
#define fr first
#define sc second
#define all(v) v.begin(),v.end()
#define bout(x) cout << bitset<sizeof(x)*8>(x) << endl;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, ddy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
const int nx[8] = {1, 2, 2, 1, -1, -2, -2, -1}, ny[8] = {-2, -1, 1, 2, 2, 1, -1, -2};

string arr[200020];
set<string> s1, s2;

void Main(){
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> arr[i];
		int len = arr[i].size();
		if (arr[i][0] == '!'){
			string tmp = "";
			for (int j = 1; j < len; j++){
				tmp += arr[i][j];
			}
			arr[i] = tmp;
			s2.insert(arr[i]);
		}
		else{
			s1.insert(arr[i]);
		}
	}
	for (int i = 1; i <= n; i++){
		if (s1.count(arr[i]) && s2.count(arr[i])){
			cout << arr[i];
			return;
		}
	}
	cout << "satisfiable";
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.setf(ios::fixed);
	cout.precision(0);
	Main();
}

#include <iostream>
#include <cmath>

using namespace std;

 int main()
{
    int  n;
    cin >> n;
    int a;
    int ans = 0;

    for(int i = 0;i < n;i++){
        cin >> a;
        if( a > 10){
             ans = ans + a - 10;
        }
    }
    cout << ans;
   return 0;
}


/*                                بِسْمِ اللَّـهِ الرَّحْمَـٰنِ الرَّحِيمِ

                                    ( إِنِ الْحُكْمُ إِلَّا لِلَّهِ )

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long double pi=acos(-1);
#define x  first
#define y  second
#define read(n,a) for(int i=0;i<n;i++)cin>>a[i];
#define rep(i,z,n)for(ll i=z;i<n;i++)
#define all(v)    v.begin(),v.end()

ll  a[200005];
ll  b[200005];

string s="",ss="";

ll  n,m,k, w;
ll ans ,ans1;
ll mod = 1e9 +7;

int main()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1;
    //cin>>t;
    while(t--)
    {
        cin>>n;
        ans=1e18;
        while(n--)
        {
            cin>>m>>k>>w;
            if(w>m)ans=min(ans,k);
        }
        if(ans==1e18)ans=-1;
        cout<<ans;
    }
    return 0;
}

#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using namespace std;
using ll = long long;
struct Edge
{
    ll to;
    ll cost;
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, ll>;
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), v.end()
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = LLONG_MAX;
const int MAX = 510000;
bool graph[nmax][nmax];
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;

    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, std::vector<long long> P)
{
    vector<bool> swaped(N - 1, false);
    vector<int> pos(N + 1, -1);
    for (int i = 0; i < N; i++)
    {
        pos[P[i]] = i;
    }
    vector<ll> ans;

    for (int i = 0; i < N; i++)
    {
        while (pos[i + 1] != i)
        {
            ll now = pos[i + 1];
            if (swaped[now - 1])
            {
                cout << -1 << endl;
                return;
            }
            swaped[now - 1] = true;
            swap(pos[i + 1], pos[P[pos[i + 1] - 1]]);
            swap(P[now], P[now - 1]);
            ans.push_back(now );
        }
    }

    if (ans.size() == N - 1)
    {

        for (auto &&i : ans)
        {
            cout << i << endl;
        }
    }
    else
    {
        cout << -1 << endl;
    }
}

int main()
{

    long long N;
    scanf("%lld", &N);
    std::vector<long long> P(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &P[i]);
    }
    solve(N, std::move(P));
    return 0;
}


#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int q; cin >> q;
    while(q--){
        int n; cin >> n;
        vector<int> p(n+1);
        for(int i=1;i<=n;i++){
            cin >> p[i];
        }
        vector<int> v;
        int t=1;
        while(1){
            bool ok=true;
            for(int i=1;i<=n;i++){
                if(p[i]!=i){
                    ok=false; break;
                }
            }
            if(ok)break;
            int id;
            if(t){
                id=1;
                for(int i=1;i<n;i+=2){
                    if(p[i]>p[i+1]){
                        id=i;
                    }
                }
            }
            else{
                id=2;
                for(int i=2;i<n;i+=2){
                    if(p[i]>p[i+1]){
                        id=i;
                    }
                }
            }
            t^=1;
            swap(p[id],p[id+1]);
            v.push_back(id);
        }
        printf("%d\n",v.size());
        for(int i:v){
            printf("%d ",i);
        }
        printf("\n");
    }
}

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

void solve(){
  int N;
  cin>>N;
  vector<int> P(N);
  rep(i,N) cin>>P[i];

  rep(i,N) P[i]--;

  vector<int> trans(N,0);
  rep(i,N) trans[P[i]]=i;

  vector<int> output;
  int parity=0;
  for(int k=N-1;k>0;k--){
    int now=trans[k];
    /*cerr<<k<<" "<<parity<<"\n";
    for(auto n:P) cerr<<n<<" ";
    cerr<<"\n";*/
    while(1){
      if(now==k&&(now==N-1||P[now]+1==P[now+1])) break;

      if(now%2==parity){
        output.push_back(now);
        swap(trans[P[now]],trans[P[now+1]]);
        swap(P[now],P[now+1]);
        now++;
        parity^=1;
      }else{
        if(now-1>=0){// opt twice
          output.push_back(now-1);
          swap(trans[P[now]],trans[P[now-1]]);
          swap(P[now],P[now-1]);
          parity^=1;
          now--;

          output.push_back(now+1);
          swap(trans[P[now+1]],trans[P[now+2]]);
          swap(P[now+1],P[now+2]);
          parity^=1;
        }else{// corner case
          if(k!=1){
            output.push_back(now+1);
            swap(trans[P[now+1]],trans[P[now+2]]);
            swap(P[now+1],P[now+2]);
            parity^=1;
          }else{// yabai
            output.push_back(1);
            swap(P[1],P[2]);
            output.push_back(0);
            swap(P[0],P[1]);
            output.push_back(1);
            swap(P[1],P[2]);
            output.push_back(0);
            swap(P[0],P[1]);
            output.push_back(1);
            swap(P[1],P[2]);
            break;
          }
        }
      }
    }
  }

  /*for(auto n:P) cerr<<n<<" ";
  cerr<<"\n";*/

  cout<<output.size()<<"\n";
  rep(i,output.size()) cout<<output[i]+1<<"\n";
}

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

  int T;
  cin>>T;
  rep(i,T) solve();

  return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	string X; cin >> X;
	long long M; cin >> M;
	int length = X.length();
	if (length == 1) {
		cout << (X[0] - 48 <= M);
		exit(0);
	}
	long long n = pow(M / (X[0] - 48), 1. / (length - 1)) - 1;
	long long d = 0;
	for (char x : X) {
		d = max((int)d, x - 48);
	}
	n = max(n, d);
	while (true) {
		long long res = 0;
		for (int i = 0; i < length; ++i) {
			if (res >= LLONG_MAX / n) {
				cout << max(0ll, n - d - 1);
				exit(0);
			}
			res = res * n + (X[i] - 48);
		}
		if (res > M) {
			cout << max(0ll, n - d - 1);
			exit(0);
		}
		++n;
	}
	assert(false);
}

#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N, M;
  cin >> N >> M;
  const int OFS = 100000000;
  if (N == 1) {
    if (M == 0) {
      cout << 1 << " " << 2 << '\n';
    } else {
      cout << -1 << '\n';
    }
  } else if (M < 0 || M > N - 2) {
    cout << -1 << '\n';
  } else {
    cout << 1 << " " << OFS + 1 << '\n';
    for (int i = 1; i <= M + 1; i++) {
      cout << 2 * i << " " << 2 * i + 1 << '\n';
    }
    for (int i = 1; i <= N - (M + 2); i++) {
      cout << OFS + 2 * i << " " << OFS + 2 * i + 1 << '\n';
    }
  }
  return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define per(i, n) for (int i = n - 1; i >= 0; i--)
#define pers(i, n, s) for (int i = n - 1; i >= s; i--)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define lb(v, n) lower_bound(all(v), n)
#define lbi(v, n) lower_bound(all(v), n) - v.begin()
#define ub(v, n) upper_bound(all(v), n)
#define ubi(v, n) upper_bound(all(v), n) - v.begin()

#define mod 1000000007
#define infi 1010000000
#define infl 1100000000000000000
#include <math.h>

#define outve(v)          \
    for (auto i : v)      \
        cout << i << " "; \
    cout << endl
#define outmat(v)             \
    for (auto i : v)          \
    {                         \
        for (auto j : i)      \
            cout << j << " "; \
        cout << endl;         \
    }
#define in(n, v)                  \
    for (int i = 0; i < (n); i++) \
    {                             \
        cin >> v[i];              \
    }
#define IN(n, m, v) \
    rep(i, n) rep(j, m) { cin >> v[i][j]; }
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define cYES cout << "YES" << endl
#define cNO cout << "NO" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
using ve = vector<T>;
template <typename T>
using pq2 = priority_queue<T>;
template <typename T>
using pq1 = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}

ll N, K;
vector<pair<ll, ll>> info;

void solve()
{

    cin >> N >> K;

    for (ll i = 0; i < N; i++)
    {
        ll a, b;
        cin >> a >> b;
        info.push_back(make_pair(a, b));
    }
    sort(info.begin(), info.end());
    for (ll i = 0; i < N; i++)
    {
        if (info[i].first > K)
            break;
        K += info[i].second;
    }
    cout << K << endl;
}
int main()
{

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

    solve();

    return 0;
}

/*Be patient && calm!
All our dreams can come true, if we have the courage to pursue them.
I fear not the man who has practiced 10,000 kicks once, but I fear the man who has practiced one kick 10,000 times.
Do not pray for an easy life, pray for the strength to endure a difficult one.
When something is important enough, you do it even if the odds are not in your favor.
First, solve the problem. Then, write the code.
Fix the cause, not the symptom.
Simplicity is the soul of efficiency.
Make it work, make it right, make it fast.
No matter how hard it gets, NEVER GIVE UP*/
// set<int>::iterator it;
// set<int>::reverse_iterator it;
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
int fact(int n)
{
    int res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}
ll bs(ll a[],ll target,int n){
	int l=0,r=n;
	ll ans=-1;
	while(l<r){
		int mid=(l+r)/2;
		if(a[mid]<target){
			ans=a[mid];
			l=mid+1;
		}
		else if(a[mid]>target){
			r=mid-1;
		}
		else{
			return a[mid];
		}
	}
	return ans;
}
void solve(){
	ll n,k;
	cin>>n>>k;
	ll a[n];
	ll b[n];
	// for(int i=0;i<n;i++)
	// 	cin>>a[i]>>b[i];
	pair<ll,ll> p[n];
	for(int i=0;i<n;i++){
		cin>>p[i].first>>p[i].second;
	}
	sort(p,p+n);
	// for(int i=0;i<n;i++){
	// 	mp[a[i]]=b[i];
	// }
	ll ans=0;
	ans=k;
	int index=0;
	while(index<n&&ans>=p[index].first){
		ans+=p[index++].second;
	}
	cout<<ans<<"\n";
	// for(auto m:mp){
	// 	if(ans<m.first){
	// 		break;
	// 	}
	// 	ans+=m.second;
	// }
	// cout<<ans<<"\n";
}
int main(){
// 	ios::sync_with_stdio(false);
// 	cout.tie(0);
// 	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
    while(t--) {
    	// int n;
    	// cin>>n;
    	solve();
	}
}


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

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

    int sln = 0;

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

            if (i*j > n)
            {
                break;
            }

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

                if (i*j*k <= n)
                {
                    sln++;
                }
                else
                {
                    break;
                }

            }
        }
    }

    cout << sln;

    return 0;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}
#ifdef _GLIBCXX_DEBUG
void _debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void _debug_out(Head H, Tail... T) { cerr << " " << H; _debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", _debug_out(__VA_ARGS__)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#define eprintf(...)
#endif

ll solve(ll n) {
  if(n < 1000) {
    return 0;
  }

  ll c = 0;
  ll r = 1000;
  ll ans = 0;

  while(n >= r-1) {
    ans += (r-1  - (r/1000) + 1) * c;
    debug(ans,r,c);
    c++;
    r *= 1000;
  }
  debug("========");
  debug(n,r,c,ans);
  ans += (n  - (r/1000-1)) * c;
  return ans;
}

int main() {
  ll n; cin >> n;
  cout << solve(n) << endl;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define ull unsigned ll
#define ld long double
#define pb push_back
#define pf push_front
#define dll deque<ll>
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define dpll deque<pll>
#define mapll map<ll,ll>
#define umapll unordered_map<ll,ll,custom_hash>
#define nl "\n"
#define all(v) v.begin(),v.end()
#define ms(a,x) memset(a,x,sizeof(a))
#define fr(aa,bb) for(ll i=aa;i<=bb;i++)
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;
vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.push_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}
#define EVARS(args...) {__evars_begin(__LINE__); __evars(split(#args, ',').begin(), args);}
inline void __evars_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __evars_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __evars_out_var(T* val) { cerr << arrStr(val, 10); }
template<typename T> inline void __evars_out_var(T val) { cerr << val; }
inline void __evars(vector<string>::iterator it) { cerr << endl; }
template<typename T, typename... Args>
inline void __evars(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __evars_out_var(a);
    cerr << "; ";
    __evars(++it, args...);
}
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//template<class T, class H>using umap=unordered_map<T,H,custom_hash>;
//template<class T>using uset=unordered_set<T,custom_hash>;
int32_t main()
{
    clock_t clk = clock();
    fio
    //cerr << '\n'<<"Time (in s): " << double(clock() - clk) * 1.0 / CLOCKS_PER_SEC << '\n';
    ll t=1;
    //cin>>t;
    while(t--)
    {
        ll a,b;cin>>a>>b;
        for(ll c=b;c>=1;c--)
        {
            if(((b/c)-((a-1)/c))>=2)
            {
                cout<<c;return 0;
            }
        }
    }
    return 0;
}

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <tuple>
#include <cmath>
#include <numeric>
#include <set>
#include <map>
#include <array>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>
using ll = long long;
using std::cin;
using std::cout;
using std::endl;
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 inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

void solve()
{
  ll A, B; cin >> A >> B;
  ll res = 1;
  for(ll i = 2; i <= B - A; i++)
  {
    ll p = (A + i - 1) / i;
    if(p * i > B)
      continue;
    ll q = B / i;
    if(p < q)
    {
      chmax(res, i);
    }
  }
  cout << res << "\n";
}
int main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

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


#include<bits/stdc++.h>

using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T> using orderedd_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

// // find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
const long double PI = acos(-1.0L);
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
//const int mod=998244353;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
VL dx={1,0,-1,0};
VL dy={0,1,0,-1};
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
vector<VL> adj;
VL cost,par;
void dfs(ll v,ll p)
{
    par[v]=p;
    for(auto to:adj[v])
    {
        if(to!=p)
        {
            cost[to]+=cost[v];
            dfs(to,v);
        }
    }
}
void solve()
{
    ll n;
    cin>>n;
    vector<PLL> edge;
    cost.assign(n,0);
    adj.resize(n);
    par.resize(n);
    fr(i,0,n-1)
    {
        ll x,y;
        cin>>x>>y;
        x--,y--;
        adj[x].pb(y);
        adj[y].pb(x);
        edge.pb({x,y});
    }
    dfs(0,-1);
    ll q;
    cin>>q;
    fr(i,0,q)
    {
        ll t,e,x;
        cin>>t>>e>>x;
        e--;
        if(t==1)
        {
            if(edge[e].F==par[edge[e].S])
            {
                cost[0]+=x;
                cost[edge[e].S]-=x;
            }
            else
            {
                cost[edge[e].F]+=x;
            }
        }
        else
        {
            if(edge[e].S==par[edge[e].F])
            {
                cost[0]+=x;
                cost[edge[e].F]-=x;
            }
            else
            {
                cost[edge[e].S]+=x;
            }
        }
    }
    dfs(0,-1);
    fr(i,0,n)
    {
        cout<<cost[i]<<endl;
    }
    return;
}
int main()
{
    IOS;
    ll t=1,pp;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("error.txt", "w", stderr);
    // freopen("output.txt", "w", stdout);
    // #endif
    // cin>>t;
    pp=t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<": ";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
        * BE CAREFUL REGARDING THE DEFAULT VALUES IN segement trees etc
        * BE very careful in int vs long long vs unsigned long long
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithmQ

#include <bits/stdc++.h>
#define all(x)    x.begin(), x.end()
#define allr(x)   x.rbegin(), x.rend()
#define sz(x)     ((int)x.size())
#define ln(x)     ((int)x.length())
#define mp        make_pair
#define pb        push_back
#define ff        first
#define ss        second
#define endl      '\n'
#define dbg(x)    cout << #x << ": " << x << endl;
#define clr(x,v)  memset(x, v, sizeof(x));
#define fix(x)    cout << setprecision(x) << fixed;
#define FASTIO    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

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

const double PI = acos(-1.0);
const double eps = 1e-9;
const ll mod = 1e9 + 7;
const int inf = 1e7;
const int MAXN = 4e5 + 5;
vector<vector<int>> adj, edges;
vector<bool> vis, sw;
vector<int> enter, ex;
int TIMER;

void dfs(int u)
{
    vis[u] = 1;
    enter[u] = TIMER++;
    for(int e : adj[u])
    {
        int v = edges[e][0] == u ? edges[e][1] : edges[e][0];
        if(vis[v]) continue;
        dfs(v);
    }
    ex[u] = TIMER++;
}

ll t[4 * MAXN], lazy[4 * MAXN];

void push(int v, int tl, int tr)
{
    int tm = (tl + tr) >> 1;
    t[v << 1] += (tm - tl + 1) * lazy[v];
    t[v << 1 | 1] += (tr - tm) * lazy[v];
    lazy[v << 1] += lazy[v];
    lazy[v << 1 | 1] += lazy[v];
    lazy[v] = 0;
}

void upd(int v, int tl, int tr, int l, int r, int val)
{
    if(l > r) return;
    if(tl == l && tr == r)
        t[v] += (tr - tl + 1) * 1LL * val, lazy[v] += val;
    else
    {
        int tm = (tl + tr) >> 1;
        push(v, tl, tr);
        upd(v << 1, tl, tm, l, min(r, tm), val);
        upd(v << 1 | 1, tm + 1, tr, max(l, tm + 1), r, val);
        t[v] = t[v << 1] + t[v << 1 | 1];
    }
}

ll query(int v, int tl, int tr, int l, int r)
{
    if(l > r) return 0;
    if(tl == l && tr == r) return t[v];
    else
    {
        push(v, tl, tr);
        int tm = (tl + tr) >> 1;
        return query(v << 1, tl, tm, l, min(r, tm)) + query(v << 1 | 1, tm + 1, tr, max(l, tm + 1), r);
    }
}

vector<ll> val;
ll dfs2(int u)
{
    vis[u] = 1;
    val[u] = query(1, 0, TIMER - 1, enter[u], ex[u]);
    ll sub = val[u];
    for(int e : adj[u])
    {
        int v = edges[e][1];
        if(vis[v]) continue;
        ll dv = dfs2(v);
        val[u] -= dv;
    }
    return sub;
}

void cp()
{
    int n;
    cin >> n;
    adj.resize(n);
    for(int i = 0; i < n - 1; i++)
    {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].pb(i);
        adj[v].pb(i);
        edges.pb({u, v});
    }

    vis.assign(n, false);
    sw.assign(n, false);
    enter.assign(n, 0);
    ex.assign(n, 0);

    TIMER = 0;
    dfs(0);

    for(int i = 0; i < n - 1; i++)
        if(enter[edges[i][0]] > enter[edges[i][1]])
            swap(edges[i][0], edges[i][1]), sw[i] = 1;

    int q;
    cin >> q;
    while(q--)
    {
        int t, e, x;
        cin >> t >> e >> x;
        t--;
        e--;
        if(sw[e]) t ^= 1;
        if(t == 0)
        {
            int u = edges[e][0], v = edges[e][1];
            upd(1, 0, TIMER - 1, 0, TIMER - 1, x);
            upd(1, 0, TIMER - 1, enter[v], ex[v], -x);

        }
        else
        {
            int u = edges[e][0], v = edges[e][1];
            upd(1, 0, TIMER - 1, enter[v], ex[v], x);
        }
    }

    vis.assign(n, false);
    val.assign(n, 0);
    dfs2(0);

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

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


#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long int
#define endl "\n"
#define MOD 1000000007
#define mod 1000000007
#define M 1000000007
#define pb push_back
#define take(a,b,c) for(int b=0;b<c;b++) cin>>a[b]
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mx 1000005
#define fiint(a,b) memset(a,b,sizeof(a))
#define bitcount __builtin_popcount
#define fori(i,a,b) for(int i=a;i<b;i++)
#define ford(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cout<<x<<endl;
#define cases(t) int t; cin>>t; while(t--)
#define inf1 INT_MAX
#define all(a) a.begin(),a.end()
#define vec vector<int>
#define pii pair<int,int>
#define plii pair<int,int>
#define pint pair<int,int>
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define mp make_pair

#define sz(x) (int)x.size()
#define PI    3.14159265359

//const long long INF=1e18;

bool chmin(int& a, int b){ if(a > b){ a = b; return 1; } return 0; }

int factorial[10000001]={0};

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

int powerFunction(int x,int y){
    int res = 1;
     int p = mod;
    x = x;
    while (y > 0){
        if (y & 1)
            res = (res*x)%p ;
        y = y>>1;
        x = (x*x)%p ;
    }
    return res;
}

void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
    factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}

int nCr(int n, int r)
{
    if(r < 0 || r > n){
        return 0;
    }
    int temp = factorial[n];
    temp *= (powerFunction(factorial[r], MOD-2)%MOD);
    temp %= MOD;
    temp *= (powerFunction(factorial[n-r], MOD-2)%MOD);
    temp %= MOD;
    return temp;
}

double dp[101][101][101];

double find(int i ,int j ,int k)
{
    if(i == 100 || j == 100 || k == 100   ) return 0;
    if(dp[i][j][k] != -1)
        return dp[i][j][k];
    double a = ( (double)i / (double) (i + j + k) ) * (find(i+1 , j , k) + 1);
    double b = ( (double)j / (double)(i + j + k) ) * (find(i , j+1 , k) + 1);
    double c = ( (double)k / (double) (i + j + k) ) * (find(i, j , k+1) + 1);
    dp[i][j][k] = a + b + c;
    return dp[i][j][k];
}

signed main()
{
    int a , b , c ; cin>>a>>b>>c;
    for(int i = 0 ; i  <= 100 ; i++)
        for(int j = 0 ; j <= 100 ; j++)
            for(int k = 0 ; k <= 100 ; k++)
                dp[i][j][k] = -1;
    cout<<setprecision(8)<<find(a , b , c)<<endl;

}

#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
//#include<bits/stdc++.h>
#define int long long
constexpr long long mod = 1000000007;
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << (x) << "\n"
using namespace std;
int input() {
	int r; cin >> r; //scanf("%lld", &r);
	return r;
}
double p[120][120][120], ans; int a, b, c;
signed main() {
	cin >> a >> b >> c;
	p[a][b][c] = 1;
	for (int i = a; i <= 100; i++)for (int j = b; j <= 100; j++)for (int k = c; k <= 100; k++) {
		if ((i - 100) * (j - 100) * (k - 100) == 0)ans += p[i][j][k] * (i + j + k - a - b - c);
		else {
			p[i + 1][j][k] += p[i][j][k] * (double)i / (i + j + k);
			p[i][j + 1][k] += p[i][j][k] * (double)j / (i + j + k);
			p[i][j][k + 1] += p[i][j][k] * (double)k / (i + j + k);
		}
	}
	printf("%.10f\n", ans);
}


#pragma region
#include <bits/stdc++.h>
#define endl '\n'
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define prec fixed<<setprecision(9)
#define all(x) x.begin(),x.end()
using ll = long long;
using namespace std;
int mod = 998244353;

string to_string(string& s) {return '"'+s+'"';}
string to_string(bool& b) {return b?"true":"false";}
string to_string(const char* s) {string t; return to_string(t=s);}
template <class A, class B> string to_string(pair<A, B>& p) {return "("+to_string(p.first)+", "+to_string(p.second)+")";}
template <class A> string to_string(A& v) {string s; for (auto &x : v) s+=(s.empty()?"":", ")+to_string(x); return "{"+s+"}";}
template<class... Ts> void _debug(Ts&... args){(..., (cerr<<" "<<to_string(args))); cerr<<endl;}
#ifdef apurv
#define debug(args...) cerr<<__LINE__<<" ["<<#args<<"]:", _debug(args)
#else
#define debug(...) 42
#endif
#pragma endregion

vector<int> arr;
int n;
vector<vector<int>> dp;
vector<int> fact;

// https://codeforces.com/contest/1536/submission/118638158
ll mod_add(ll a, ll b, ll m = mod) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}
ll mod_mul(ll a, ll b, ll m = mod) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}

int main()
{
    fastIO
    cin >> n;
    arr = vector<int>(n); for(auto&i : arr) cin >> i;
    if (accumulate(all(arr), 0) % 2) {
        cout << 0 << endl; return 0;
    }
    int h = accumulate(all(arr), 0) / 2;
    vector<int> fact(n + 5); fact[0] = 1;
    ll v = 1;
    for (int i = 1; i < n+5; i++) {
        v *= i;
        if (v >= mod) v %= mod;
        fact[i] = v;
    }
    // debug(fact);
    ll ans = 0;
    vector<vector<ll>> dp(n + 1, vector<ll>(2*h + 1, 0));
    for (int i = n - 1; i >= 0; i--) {
        for (int ln = n; ln >= 1; ln--)
        {
            for (int s = 1; s <= h; s++)
             {
                if (arr[i] == s) {
                    if (ln != 1) continue;
                    dp[1][s] = mod_add(dp[1][s], 1);
                    debug(i, "1", s, "1");
                    if (i == 0 and s == h) {
                        ll v = fact[1];
                        v = mod_mul(v, fact[n - 1]);
                        v = mod_mul(v, 2);
                        ans = mod_add(ans, v);
                    }
                    continue;
                } else if (arr[i] > s) {
                    continue;
                }
                ll kitne = dp[ln - 1][s - arr[i]];
                if(kitne) debug(i, ln, s, kitne);
                dp[ln][s] = mod_add(dp[ln][s], kitne);
                if (i == 0 and ln != n and s == h) {
                    // debug(ln, kitne);
                    ll v = fact[ln];
                    v = mod_mul(v, fact[n - ln]);
                    v = mod_mul(v, 2);
                    v = mod_mul(v, kitne);
                    ans = mod_add(ans, v);
                }
            }
        }
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;
// #define int long long
// #define double long double
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); ++i)
#define repeq(i,a,b) for(int i=(int)(a); i<=(int)(b); ++i)
#define rrep(i,a,b) for(int i=(int)(b)-1; i>=(int)(a); --i)
#define rrepeq(i,a,b) for(int i=(int)(b); i>=(int)(a); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
template<typename T> using Graph = vector<vector<T>>;
template<typename T> using Spacial = vector<vector<vector<T>>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename T> using greater_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
// const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
string interval[2] = {" ", "\n"}; // {" ", "\n"}

template<typename T> struct is_plural : false_type{};
template<typename T1, typename T2> struct is_plural<pair<T1, T2>> : true_type{};
template<typename T> struct is_plural<vector<T>> : true_type{};
template<typename T> struct is_plural<complex<T>> : true_type{};
template<> struct is_plural<string> : true_type{};

template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << " " << p.second; }
template<typename T> istream &operator>>(istream &is, vector<T> &vec) { for(auto itr = vec.begin(); itr != vec.end(); ++itr) is >> *itr; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { if(vec.empty()) return os; bool pl = is_plural<T>(); os << vec.front(); for(auto itr = ++vec.begin(); itr != vec.end(); ++itr) os << interval[pl] << *itr; return os; }

bool CoutYN(bool a, string y = "Yes", string n = "No") { cout << (a ? y : n) << "\n"; return a; }

template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

long long modpow(int a, long long n, int mod = MOD) { long long ret = 1; do { if(n & 1) ret = ret * a % mod; a = 1LL * a * a % mod; } while(n >>= 1); return ret; }

template<typename T> T GCD(T a, T b) { return b ? GCD(b, a%b) : a; }
template<typename T> T LCM(T a, T b) { return a / GCD(a, b) * b; }

template<typename T1, typename T2> bool CompareBySecond(pair<T1, T2> a, pair<T1, T2> b) { return a.second != b.second ? a.second < b.second : a.first < b.first; }
template<typename T1, typename T2> bool CompareByInverse(pair<T1, T2> a, pair<T1, T2> b) { return a.first != b.first ? a.first < b.first : a.second > b.second; }

/* -------- <templates end> -------- */

void solve() {
  int n; cin >> n;
  vector<string> ans(1<<n);
  ans[1] = "AB";

  auto expand = [&](int i) -> void {
    string ret;
    for(auto &c : ans[i]) {
      rep(_,0,2) ret.push_back(c);
    }
    ans[i] = ret;
  };

  rep(i,1,n) {
    int from = 1<<(i-1);
    int to = 1<<i;
    ans[to] = ans[from] + ans[from];
    rep(j,1,to) {
      ans[to + j] = ans[to];
      rep(k,0,to) {
        if(ans[j][k] == 'B') {
          swap(ans[to + j][2*k], ans[to + j][2*k + 1]);
        }
      }
      expand(j);
    }
  }

  cout << ans.size() - 1 << '\n';
  rep(i,1,1<<n) cout << ans[i] << '\n';
}

/* -------- <programs end> -------- */

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

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

    int n = 100;
    vector<vector<vector<double>>> dp(n + 1, vector<vector<double>>(n + 1, vector<double>(n + 1, 0)));
    dp[a][b][c] = 1;

    for (int i = a; i < n; ++i) {
        for (int j = b; j < n; ++j) {
            for (int k = c; k < n; ++k) {
                if (dp[i][j][k] > 0) {
                    double p = dp[i][j][k];
                    int m = i + j + k;
                    dp[i + 1][j][k] += p * i / m;;
                    dp[i][j + 1][k] += p * j / m;
                    dp[i][j][k + 1] += p * k / m;
                }
            }
        }
    }

    double res = 0;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            for (int k = 0; k <= n; ++k) {
                if (i == n || j == n || k == n) {
                    res += (i + j + k - a - b - c) * dp[i][j][k];
                }
            }
        }
    }

    cout << res << '\n';

    return 0;
}


#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 PRINT(a) printf("%.15Lf\n",a);
#define YESNO(a) cout << (a ? "YES" : "NO") << endl
#define YesNo(a) cout << (a ? "Yes" : "No") << endl
#define yesno(a) cout << (a ? "yes" : "no") << endl
#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 H, W; cin >> H >> W;
	VS S(H);
	REP(i, H)cin >> S[i];
	int ans = 0;
	REP(i, H - 1) {
		REP(j, W - 1) {
			int cnt = 0;
			if (S[i][j] == '#')cnt++;
			if (S[i][j + 1] == '#')cnt++;
			if (S[i + 1][j] == '#')cnt++;
			if (S[i + 1][j + 1] == '#')cnt++;
			if (cnt == 1 || cnt == 3)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

// Author: Pawan Raj
// Problem: E - Filters
// Contest: AtCoder - AtCoder Beginner Contest 196
// URL: https://atcoder.jp/contests/abc196/tasks/abc196_e

#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define int long long
#define F(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end()
#define show(A) for (auto i: A) cout << i << " "; cout << '\n';
#define show_(A, n) F(i, n) { show(A[i]) }

using namespace std;
using ld = long double;
using vi = vector < int > ;
using mi = map < int, int > ;
using pi = pair < int, int > ;

const int N = 100005;
const int MOD = 1e9 + 7;
const int inf = 1e18 + 1;
/***************************code begins here*****************************/

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

    int H = 1e9, L = -1e9, T = 0;
    F(i, n){
    	int x,y;
    	cin >> x >> y;
    	if(y==1){
    		L += x;
    		H += x;
    		T += x;
    	}
    	else if(y==2){
    		L = max(L,x);
    		H = max(H,x);
    	}
    	else{
    		L = min(L,x);
    		H = min(H,x);
    	}
    }
    int q; cin >> q;
    while(q--){
    	int x; cin >> x;
    	x += T;
    	x = min(x,H);
    	x = max(x,L);
    	cout << x << '\n';
    }
}

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

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

    return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>

using namespace std;

int main() {
  long long int R;
  long long int X;
  long long int Y;
  cin >> R >> X >> Y;
  double Z;
  Z = sqrt(X*X + Y*Y);
  if(Z==R){
    cout << 1 << endl;
  }
  else if(Z<2*R){
    cout << 2 << endl;
  }
  else{
    cout << ceil(Z/R) << endl;
  }
}

// Problem: C - Compass Walking
// Contest: AtCoder - AtCoder Beginner Contest 198
// URL: https://atcoder.jp/contests/abc198/tasks/abc198_c
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define ff first
#define ss second
#define VI vector <int>
#define VVI vector <VI>
#define pii pair<int, int>
#define ppi pair<pii, int>
#define mii map<int, int>
#define mci map<char, int>
#define miv map<int, VI>
#define mis map<int, set<int>>
#define setbits(n) __builtin_popcount(n)
#define all(v) (v).begin(), (v).end()
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define endl "\n"
#define show2(a, b) cout<<a<<' '<<b<<endl
#define show3(a, b, c) cout<<a<<' '<<b<<' '<<c<<endl
#define show(arr) for (auto i:arr) cout<<i<<' ';

const long long N=1e5+5;
const long long mod=1000000007; //998244353

void cases(){
    int r, x, y;
    cin>>r>>x>>y;
    long double x1=x, y1=y, r1=r;
    long double d=sqrt(x1*x1+y1*y1);
    double p=0.0;
    int ans=0;
    while (p<d){
    	p+=r1;
    	ans++;
    }
    if (ans==1 && d!=r) ans++;
    cout<<ans;
}

int32_t main(){
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t=1;
    // cin>>t;
    for (int i=0; i<t; i++){
    	// cout<<"Case #"<<i+1<<": ";
		cases();
    }
    return 0;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(a) (a).begin(), (a).end()
#define uniq(a) (a).erase(unique(all(a)), (a).end())
#define bit(n) (1LL << (n))
#define dump(a) cerr << #a " = " << (a) << endl
using vint = vector<int>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int sign(int a) { return (a > 0) - (a < 0); }
int cdiv(int a, int b) { return (a - 1 + b) / b; }
template<typename T> void fin(T a) {
    cout << a << endl;
    exit(0);
}
template<typename T> T sq(T a) { return a * a; }
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &a) {
    os << "(" << a.first << ", " << a.second << ")";
    return os;
}
template<typename T, typename U, typename V> ostream &operator<<(ostream &os, const tuple<T, U, V> &a) {
    os << "(" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &a) {
    os << "{";
    for (auto itr = a.begin(); itr != a.end(); itr++) {
        os << *itr << (next(itr) != a.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int N;
    cin >> N;
    vint A(N), B(N);
    auto f = [](int x) { return x * (x + 1) / 2; };
    int ans = 0;
    rep(i, N) {
        cin >> A[i] >> B[i];
        ans += f(B[i]) - f(A[i] - 1);
    }
    cout << ans << endl;
}

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i=0; i<n; i++) {
    int x, y;
    cin >> x >> y;
    ans += (ll)(x+y) * (y-x+1) / 2;
  }
  cout << ans << endl;
}


#include<bits/stdc++.h>
#define ll long long int
#define pll pair<ll,ll>
#define vpll vector< pll >
#define mpll map<ll,ll>
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define s(v) v.size()
#define test ll t;cin>>t;while(t--)
#define vec vector<ll>
#define read0(v,n) for(int i=0;i<n;i++)cin>>v[i];
#define read1(v,n) for(int i=1;i<=n;i++)cin>>v[i];
#define trav(a,x) for (auto& a: x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define cut(x) {cout<<x;return 0;}
#define print(x) {cout<<x<<nl;continue;}
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORB(i,a,b) for(int i=a;i>=b;i--)
#define err1(a) {cout<<#a<<' '<<a<<nl;}
#define err2(a,b) {cout<<#a<<' '<<a<<' '<<#b<<' '<<b<<nl;}
#define mem(a,b) memset(a,b,sizeof(a))

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define nl '\n'
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
#define oset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
ll gcd(ll a, ll b){
	if (b==0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a,ll b){

    return (a*b)/gcd(a,b);
}
ll bpow(ll a, ll b){
	ll ans=1;
	while(b){
		if(b&1)
			ans=(ans*a)%MOD;
		b/=2;
		a=(a*a)%MOD;
	}
	return ans;
}
bool subset[102][100005];
ll v[105];
void precompute(int n,int sum){
	 // If sum is 0, then answer is true
    for (int i = 0; i <= n; i++)
        subset[i][0] = true;

    // If sum is not 0 and set is empty,
    // then answer is false
    for (int i = 1; i <= sum; i++)
        subset[0][i] = false;

    // Fill the subset table in botton up manner
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= sum; j++) {
            if (j < v[i - 1])
                subset[i][j] = subset[i - 1][j];
            if (j >= v[i - 1])
                subset[i][j] = subset[i - 1][j]
                               || subset[i - 1][j - v[i - 1]];
        }
    }
}

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    	#endif
    fast
    int n;
    cin>>n;
    FOR(i,0,n-1)cin>>v[i];
    precompute(n,n*1000+2);
    ll sum=0;
    FOR(i,0,n-1)sum+=v[i];
    ll ans=1e9;
    FOR(j,0,sum){
    	if(subset[n][j]){
    		ans=min(ans,max(sum-j,(ll)j));
    	}
    }
    cut(ans)

}

#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
double N,x[100010],a,U;
long long M;
int i;
cin >> N;
a=0;
M=0;
U=0;
for(i=1;i<=N;i++){
cin >> x[i];
if(x[i]<0){x[i]=-1*x[i];}
if(x[i]>a){a=x[i];}
}

for(i=1;i<=N;i++){M=M+x[i];
U=U+x[i]*x[i];}

cout << M << endl;
cout << setprecision(30) << sqrt(U) << endl;
cout << a << endl;

return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()
ll n,m,k,ans,mod=1000000007;
ll qp(ll a,ll b,ll p){
	ll ans=1;
	while(b){
		if(b&1)ans=ans*a%p;
		a=a*a%p;
		b/=2;
	}
	return ans;
}
ll jc(ll x){
	ll ans=1;
	f(i,1,x)ans=ans*i%mod;
	return ans;
}
ll C(ll n,ll m,ll s){
	ll ans=1;
	f(i,m-s+1,m+n)ans=ans*i%mod;
	return ans*qp(jc(s+n),mod-2,mod)%mod;
}
int main(){
	n=d,m=d;
	f(i,1,n)k+=d;
	printf("%lld",C(n,m,k));
	return 0;
}

#include <iostream>
using namespace std;
int main(void) {
    int a, b;
    cin >> a >> b;
    int bp = b - a;
    int p = bp;
    int d = a % p ? p - a % p : 0;
    while (d + p > bp) {
        p--;
        d = a % p ? p - a % p : 0;
    }
    cout << p << endl;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
#include<complex>
#include<numeric>
#include<functional>
#include<unordered_map>
#include<unordered_set>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,LL> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
    for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
    if(vec_n==-1)vec_n=vec_s.size();
    for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
template<typename T> ostream& operator<<(ostream& os,const vector<T>& v1){
    int n=v1.size();
    for(int i=0;i<n;i++){
        if(i)os<<" ";
        os<<v1[i];
    }
    return os;
}
template<typename T1,typename T2> ostream& operator<<(ostream& os,const pair<T1,T2>& p){
    os<<p.first<<" "<<p.second;
    return os;
}
template<typename T> istream& operator>>(istream& is,vector<T>& v1){
    int n=v1.size();
    for(int i=0;i<n;i++)is>>v1[i];
    return is;
}

namespace sol{

    int n,m;
    vector<vector<int>> grid;

    bool check(int g){
        int i,j,k;
        int a,b,c;
        vector<vector<int>> v1(n+2,vector<int>(n+2,0));
        for(i=0;i<n;i++){
            for(j=0;j<n;j++){
                if(grid[i][j]<=g)v1[i+1][j+1]=1;
            }
        }
        for(i=0;i<=n;i++){
            for(j=0;j<=n;j++){
                if(i)v1[i][j]+=v1[i-1][j];
                if(j)v1[i][j]+=v1[i][j-1];
                if(i && j)v1[i][j]-=v1[i-1][j-1];
            }
        }
        for(i=0;i<=n-m;i++){
            for(j=0;j<=n-m;j++){
                a=v1[i+m][j+m]+v1[i][j]-v1[i][j+m]-v1[i+m][j];
                if(a>=(m*m+1)/2)return true;
            }
        }
        return false;
    }

    void solve(){
        int i,j,k;
        int a,b,c;
        cin>>n>>m;
        grid.assign(n,vector<int>(n));
        cin>>grid;
        int z[3]={-1,INF};
        while(z[1]-z[0]>1){
            z[2]=(z[0]+z[1])/2;
            if(check(z[2]))z[1]=z[2];
            else z[0]=z[2];
        }
        cout<<z[1]<<endl;
    }
}

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

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

const int MAX_LEN = 50;
string DIR[4] = {"U", "D", "L", "R"};

int depth;

int si, sj;
int t[MAX_LEN][MAX_LEN], p[MAX_LEN][MAX_LEN];

int next_sim(int i, int j, bool visited[], int num) {
  if ( num == 0 ) { return p[i][j]; }

  bool *now_visited;
  now_visited = new bool[2500];
  memcpy(now_visited, visited, sizeof(visited));
  now_visited[t[i][j]] = true;

  int sim_p = 0;

  if ( i > 0 && (! visited[t[i-1][j]]) && p[i-1][j] > sim_p ) {
    int tmp = next_sim(i-1, j, now_visited, num-1);
    if ( tmp > sim_p ) { sim_p = tmp; }
  }
  if ( i < MAX_LEN-1 && (! visited[t[i+1][j]]) && p[i+1][j] > sim_p ) {
    int tmp = next_sim(i+1, j, now_visited, num-1);
    if ( tmp > sim_p ) { sim_p = tmp; }
  }
  if ( j > 0 && (! visited[t[i][j-1]]) && p[i][j-1] > sim_p ) {
    int tmp = next_sim(i, j-1, now_visited, num-1);
    if ( tmp > sim_p ) { sim_p = tmp; }
  }
  if ( j < MAX_LEN-1 && (! visited[t[i][j+1]]) && p[i][j+1] > sim_p ) {
    int tmp = next_sim(i, j+1, now_visited, num-1);
    if ( tmp > sim_p ) { sim_p = tmp; }
  }

  delete[] now_visited;
  return p[i][j] + sim_p;
}

int sakiyomi(int i, int j, bool visited[]) {
  int sim_p = next_sim(i, j, visited, depth);

  return sim_p;
}

int next_dir(int i, int j, bool visited[]) {
  int ret  = 4;
  int sim_p = -1;

  int sim_i, sim_j;

  if ( i > 0 && (! visited[t[i-1][j]]) ) {
    int tmp = sakiyomi(i-1, j, visited);
    if ( tmp > sim_p ) { ret = 0; sim_p = tmp; }
  }
  if ( i < MAX_LEN-1 && (! visited[t[i+1][j]]) ) {
    int tmp = sakiyomi(i+1, j, visited);
    if ( tmp > sim_p ) { ret = 1; sim_p = tmp; }
  }
  if ( j > 0 && (! visited[t[i][j-1]]) ) {
    int tmp = sakiyomi(i, j-1, visited);
    if ( tmp > sim_p ) { ret = 2; sim_p = tmp; }
  }
  if ( j < MAX_LEN-1 && (! visited[t[i][j+1]]) ) {
    int tmp = sakiyomi(i, j+1, visited);
    if ( tmp > sim_p ) { ret = 3; sim_p = tmp; }
  }

  return ret;
}

void update_pos(int* i, int* j, int next) {
  if ( next == 0 ) { *i -= 1; }
  if ( next == 1 ) { *i += 1; }
  if ( next == 2 ) { *j -= 1; }
  if ( next == 3 ) { *j += 1; }
}

string calc() {
  string ans = "";
  int max_p = p[si][sj];

  for ( depth = 0 ; depth < 3; depth++ ) {
    bool visited[2500] = {};
    string now_ans = "";
    int point = 0;

    int i = si;
    int j = sj;
    visited[t[i][j]] = true;
    point = p[i][j];

    while ( true ) {
      int next = next_dir(i, j, visited);
      if ( next == 4 ) { break; }
      now_ans += DIR[next];
      update_pos(&i, &j, next);
      visited[t[i][j]] = true;
      point += p[i][j];
    }

    if ( point > max_p ) {
      max_p = point;
      ans = now_ans;
    }
  }

  return ans;
}

int main() {
  cin >> si >> sj;

  for ( int i = 0; i < MAX_LEN; i++ ) {
    for ( int j = 0; j < MAX_LEN; j++ ) {
      cin >> t[i][j];
    }
  }
  for ( int i = 0; i < MAX_LEN; i++ ) {
    for ( int j = 0; j < MAX_LEN; j++ ) {
      cin >> p[i][j];
    }
  }

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


#include "bits/stdc++.h"
#include "random"
#include <unistd.h>

using namespace std;

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD int(1e9) + 7
#define PAI  3.1415926535
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define chmax(x, y) x = max(x,y)
#define chmin(x, y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i, n) for(int i = 0 ; i < n; ++i)

const int dx2[4] = {0,1,0,1};
const int dy2[4] = {0,0,1,1};
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

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

int Uniform_Random(int a, int b){ // (a <= x <= b)

  random_device rd;
  mt19937 mt(rd());

  uniform_int_distribution<int> rv1(a, b);
  return rv1(mt);
}

int H, W;
vector<vector<bool>> used(16, vector<bool>(16, false));

int main(){

  int n; cin >> n;
  ll l = -linf, r = linf;
  ll s = 0;

  rep(i, n){
    ll a, t; cin >> a >> t;
    if(t == 1){
      s += a;
      l += a;
      r += a;
    }else if(t == 2){
      chmax(l, a);
      chmax(r, a);
    }else{
      chmin(l, a);
      chmin(r, a);
    }
  }

  int q; cin >> q;
  rep(i, q){
    ll x; cin >> x;
    ll ans = x + s;
    if(ans < l) ans = l;
    if(ans > r) ans = r;
    cout << ans << endl;
  }

  return 0;
}

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

signed main() {
  int n;
  cin >> n;
  vector<int> a(n),t(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> t[i];
  }
  int q;
  cin >> q;
  vector<int> x(q);
  for (auto &it:x) cin >> it;

  int sum = 0;
  int l = -INT_MAX;
  int r = INT_MAX;
  for (int i = 0; i < n; i++) {
    if (t[i] == 1) {
      sum += a[i];
      l += a[i];
      r += a[i];
    }
    if (t[i] == 2) {
      l = max(l, a[i]);
      r = max(r, a[i]);
    }
    if (t[i] == 3) {
      l = min(l, a[i]);
      r = min(r, a[i]);
    }
  }
  for (int i = 0; i < q; i++) {
    int res = x[i]+sum;
    res = max(l, res);
    res = min(r, res);
    cout << res << '\n';
  }
}


#include <iostream>
using namespace std;
int main(){
    int A, B, C;
    cin >> A >> B >> C;
    cout << (A + C > B ? "Takahashi" : "Aoki") << endl;
}

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,y,z;cin>>x>>y>>z;
    if(x==y && z==0){
    	cout<<"Aoki";
	}
    else if(x==y && z==1){
    	cout<<"Takahashi";
	}
	else if(x>y){
    	cout<<"Takahashi";
	}
	else{
	cout<<"Aoki";

	}
	  return 0;
	  }


#include <bits/stdc++.h>
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define rep(i,n) Rep(i,0,n)
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
#define _GLIBCXX_DEBUG
const double e=0.000001;
const double pi=M_PI;
struct Point{
  double x,y;
  Point(){}
  Point(double a,double b){
    x=a;y=b;
  }
};
const Point O={0,0};
Point operator-(Point a,Point b){
  Point ret;
  ret.x=a.x-b.x;
  ret.y=a.y-b.y;
  return ret;
};
Point operator+(Point a,Point b){
  Point ret;
  ret.x=a.x+b.x;
  ret.y=a.y+b.y;
  return ret;
};
void operator+=(Point &a,Point b){a=a+b;};
void operator-=(Point &a,Point b){a=a-b;};
double dis(Point p,Point q){
  double d2=(p.x-q.x)*(p.x-q.x)+(p.y-q.y)*(p.y-q.y);
  return sqrt(d2);
};
double abs(Point p){
  return dis(p,O);
};
double rtod(double r){
  r/=pi;r*=180;
  return r;
};
double dtor(double d){
  d/=180.0;
  d*=pi;
  return d;
};
double rad(Point p){
  return atan2(p.y,p.x);
};
double dmod(double d){
  int k;
  if(d<0){
    k=(int)(d/180);k--;
  }
  else{
    k=ceil(d/180);
  }
  k/=2;
  return d-k*360;
};
Point rotate(double t,Point p,Point cons){
  p-=cons;
  double r=abs(p);
  double th=t+rad(p);
  Point ret;
  ret.x=r*cos(th);ret.y=r*sin(th);
  return ret+cons;
};
bool s(Point a,Point b){
  if(abs(b.x-a.x)<e) return a.y<b.y;
  return a.x<b.x;
};
bool same(Point a,Point b){
  if(abs(a.x-b.x)<e&&abs(a.y-b.y)<e) return true;
  else return false;
}
int main(){
  int N;cin>>N;
  vector<Point> a(N),b(N);
  rep(i,N){
    double x,y;cin>>x>>y;
    a[i].x=x;a[i].y=y;
  }
  rep(i,N){
    double x,y;cin>>x>>y;
    b[i].x=x;b[i].y=y;
  }
  sort(all(a),s);
  sort(all(b),s);
  if(N<2) cout << "Yes" << endl;
  else{
    bool test=false;
    rep(i,N){
      rep(j,N){
        if(i==j) continue;
        Point q=b[0]-a[i];
        double t2=rad(b[1]-b[0]);
        double t1=rad(a[j]-a[i]);
        vector<Point> c(N);
        rep(k,N){
          c[k]=rotate(t2-t1,a[k]+q,b[0]);
        }
        sort(all(c),s);
        bool tes=true;
        rep(k,N){
          if(same(b[k],c[k])) continue;
          tes=false;
        }
        if(tes) test=true;

      }
    }
    if(test) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main() {
    ll n, k;
    cin >> n >> k;
    ll res = 0;
    for(ll x=2; x<=2*n;x++){
        if((x-k < 2) || (2*n < x - k)) continue;
        res += (x-1 - 2LL*max((x-n-1), 0LL)) * ((x-k-1) - 2LL*max(x-k-1-n, 0LL));
    }
    cout << res << endl;
    return 0;
}


#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T>, greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

void solve() {
    int N, K;
    cin >> N >> K;
    VI a(N);
    REP(i, N) {
        cin >> a[i];
    }
    SORT(a);

    map<int, int> mp;
    FORE(e, a) mp[e]++;

    LL ans = 0;
    bool end = false;
    int cnt = 0;
    while (!end && cnt < K) {
        for (int i = 0; ; i++) {
            if (mp.count(i) == 0) {
                if (i == 0) {
                    end = true;
                }
                ans += i;
                break;
            }
            if (--mp[i] == 0) {
                mp.erase(i);
            }
        }
        cnt++;
    }

    cout << ans << endl;
}

int main(void) {
#ifndef ONLINE_JUDGE
    const auto in_stream = freopen("../in.txt", "r", stdin);
    if (in_stream == nullptr) {
        cerr << "ERROR!" << endl;
        return 1;
    }
#endif

    solve();

#ifndef ONLINE_JUDGE
    fclose(in_stream);
#endif
}

#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono;
const int mod=1e9+7;
const int mex=2002;
#define ll long long
#define test int t;cin>>t;while(t--)
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(i,a,n) for(int i=a;i<n;i++)
#define rfo(i,a,b) for(int i=a;i>=b;i--)
#define bg begin()
#define en end()
#define fi first
#define se second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define veci vector<int>
#define veclli vector<long long int>
#define all(x) x.begin(),x.end()
#define sci(x) scanf("%d",&x);
#define scc(x) scanf("%c",&x);
#define scs(x) scanf("%s",x);
#define debug(arr,n) for(int i=0;i<n;i++) printf("%d ",arr[i]);
#define sz(x) x.size()
#define loop(x) for(auto it=x.begin();it!= x.end();it++)
#define int long long
signed main()
{
    int n,k;
    cin>>n>>k;
    map<int,int> mp;
    int a[n];
    fo(i,0,n)
    {cin>>a[i];
    mp[a[i]]++;
    }
    int bx=k,ans=0;
    fo(i,0,n+1)
    {
        bx=min(bx,mp[i]);
        ans+=bx;
    }
    cout<<ans<<endl;

}


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

#define int long long
#define MS(x) memset((x), -1, sizeof((x)))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int yta(){
	int n;
	cin >> n;
	vector<int> a(n);
	unordered_set<int> st;
	for(int i = 0;i < n;i++) cin >> a[i];
	if(n % 2 == 1){
		cout << "Second" << endl;
		return 0;
	}

	for(int i = 0;i < n;i++){
		if(st.find(a[i]) != st.end()){
			st.erase(a[i]);
		}else{
			st.insert(a[i]);
		}
	}

	cout << (st.size() == 0 ? "Second" : "First") << endl;
	return 0;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t;
	cin >> t;
	while(t--) yta();
	return 0;
}

#define MOD_TYPE 1

#pragma region Macros

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

#if 0
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;
#endif
#if 1
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#endif
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

struct io_init
{
  io_init()
  {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(30) << setiosflags(ios::fixed);
  };
} io_init;
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void calc(vector<int> &a)
{
}

void solve()
{
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  if (n % 2 == 0)
  {
    // 先手はxorを0以外にしたい
    map<ll, ll> cnt;
    rep(i, n) cnt[a[i]]++;
    bool ispair = true;
    for (auto [k, v] : cnt)
    {
      if (v & 1)
      {
        ispair = false;
        break;
      }
    }
    if (!ispair)
      cout << "First\n";
    else
      cout << "Second\n";
  }
  else
  {
    cout << "Second\n";
  }
}

int main()
{
  int testcase;
  cin >> testcase;
  rep(ti, testcase)
  {
    solve();
  }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int array1[N], array2[N];
    for(int i = 0; i < N; i++) cin >> array1[i];
    for(int i = 0; i < N; i++) cin >> array2[i];
    int result = 0;
    for(int i = 1; i <= 1000; i++){
        bool check = true;
        for(int j = 0; j < N; j++){
            if(i < array1[j] || i > array2[j]) check = false;
        }
        if(check) result++;
    }
    cout << result << endl;
    //for(int i = 0; i < N; i++) cout << array1[i] << array2[i];
}

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

int main(){

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

    int l = 0, r = 1000;
    for (int i = 0; i < n; ++i){
        l = max(l, a[i]);
        r = min(r, b[i]);
    }
    cout << max(0, r - l + 1);

    return 0;
}


//   __________________
//  | ________________ |
//  ||          ____  ||
//  ||   /\    |      ||
//  ||  /__\   |      ||
//  || /    \  |____  ||
//  ||________________||
//  |__________________|
//  \###################\
//   \###################\
//    \        ____       \
//     \_______\___\_______\
// An AC a day keeps the doctor away.

#ifdef local
#include <bits/extc++.h>
#define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n"
#define debug(args...) qqbx(#args, args)
using ost = std::ostream;
#define DESTL(STL, BEG, END, OUT) \
    template <typename ...T> ost& operator<<(ost &O, std::STL<T...> v) { int f=0; for(auto x: v) O << (f++ ? ", " : BEG) << OUT; return O << END; }
DESTL(deque, "[", "]", x); DESTL(vector, "[", "]", x);
DESTL(set, "{", "}", x); DESTL(multiset, "{", "}", x); DESTL(unordered_set, "{", "}", x);
DESTL(map , "{", "}", x.first << ":" << x.second); DESTL(unordered_map , "{", "}", x.first << ":" << x.second);
template <typename U, typename V> ost& operator<<(ost &O, std::pair<U,V> p) { return O << '(' << p.first << ',' << p.second << ')'; }
template <typename T, size_t N> ost& operator<<(ost &O, std::array<T,N> a) { int f=0; for(T x: a) O << (f++ ? ", " : "[") << x; return O << "]"; }
template <typename T, size_t ...I> ost& prtuple(ost &O, T t, std::index_sequence<I...>) { return (..., (O << (I ? ", " : "(") << std::get<I>(t))), O << ")"; }
template <typename ...T> ost& operator<<(ost &O, std::tuple<T...> t) { return prtuple(O, t, std::make_index_sequence<sizeof...(T)>()); }
template <typename ...T> void qqbx(const char *s, T ...args) {
    int cnt = sizeof...(T);
    (std::cerr << "\033[1;32m(" << s << ") = (" , ... , (std::cerr << args << (--cnt ? ", " : ")\033[0m\n")));
}
#else
#pragma GCC optimize("Ofast")
#pragma loop_opt(on)
#include <bits/extc++.h>
#include <bits/stdc++.h>
#define debug(...) ((void)0)
#define safe ((void)0)
#endif // local
#define all(v) begin(v),end(v)
#define get_pos(v,x) int(lower_bound(begin(v),end(v),x)-begin(v))
#define sort_uni(v) sort(begin(v),end(v)),v.erase(unique(begin(v),end(v)),end(v))
#define pb emplace_back
#define ff first
#define ss second
#define mem(v,x) memset(v,x,sizeof v)

using namespace std;
using namespace __gnu_pbds;
typedef int64_t ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
template <typename T> using max_heap = std::priority_queue<T,vector<T>,less<T> >;
template <typename T> using min_heap = std::priority_queue<T,vector<T>,greater<T> >;
template <typename T> using rbt = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
constexpr ld PI = acos(-1), eps = 1e-7;
constexpr ll N = 200025, INF = 1e18, MOD = 1000000007, K = 14699, inf = 1e9;
constexpr inline ll cdiv(ll x, ll m) { return x/m + (x%m ? (x<0) ^ (m>0) : 0); } // ceiling divide
constexpr inline ll modpow(ll e,ll p,ll m=MOD) { ll r=1; for(e%=m;p;p>>=1,e=e*e%m) if(p&1) r=r*e%m; return r; }

map<int,int> mp[N];
int pa[N];
int anc(int x) { return x==pa[x] ? x : pa[x]=anc(pa[x]); }
void join(int x, int y) {
    if((x=anc(x)) == (y=anc(y))) return;
    if(mp[x].size() < mp[y].size()) {
        for(auto [a, b]: mp[x])
            mp[y][a] += b;
        mp[x].clear();
        pa[x] = y;
    } else {
        for(auto [a, b]: mp[y])
            mp[x][a] += b;
        mp[y].clear();
        pa[y] = x;
    }
}
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, q;
    cin >> n >> q;
    for(int i = 0; i < n; i++) {
        int c;
        cin >> c;
        mp[i][c] = 1;
    }
    for(int i = 0; i < n; i++) pa[i] = i;
    for(int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if(t == 1) {
            int a, b;
            cin >> a >> b;
            --a, --b;
            join(a, b);
        } else if(t == 2) {
            int x, y;
            cin >> x >> y;
            --x;
            debug(x, mp[anc(x)]);
            cout << mp[anc(x)][y] << '\n';
        }
    }
}


#include <bits/stdc++.h>
#define dbg(args...){ string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define fastio() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define pb push_back
#define ff first
#define ss second

using namespace std;
using ll = long long;

void err(istream_iterator<string> ) {cerr << "NEXT\n"; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << ", ";
	err(++it, args...);
}

const int MOD = 1e9 + 7, MOD1 = (119 << 23) | 1;
const int INF = 1e9 + 5, MAX = 2e5 + 5;

int fat[MAX], siz[MAX], ans = 0;

int get(int x) {
	return ((fat[x] == x)? x : fat[fat[x]] = get(fat[x]));
}

void join(int x, int y) {
	x = get(x);
	y = get(y);

	if (x == y) return;

	++ans;
	if (siz[x] < siz[y]) swap(x, y);

	siz[x] += siz[y];
	fat[y] = x;
}

void run_case() { // don't forget to reset global variables at the end of each test case
	int n;
	cin >> n;
	vector<int> arr(n);
	for (int &x : arr) {
		cin >> x;
		fat[x] = x;
	}

	for (int i = 0; 2 * i < n; ++i) {
		join(arr[i], arr[n - i - 1]);
	}
	cout << ans << "\n";
}

int main() {
	fastio();

	int tests = 1;
	//cin >> tests;
	while (tests--) {
		run_case();
	}

	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/

/* Let n be the main variable in the problem.

	If n ≤ 12, the time complexity can be O(n!).
	If n ≤ 25, the time complexity can be O(2^n).
	If n ≤ 100, the time complexity can be O(n^4).
	If n ≤ 500, the time complexity can be O(n^3).
	If n ≤ 10^4, the time complexity can be O(n^2).
	If n ≤ 10^6, the time complexity can be O(n log n).
	If n ≤ 10^8, the time complexity can be O(n).
	If n > 10^8, the time complexity can be O(log n) or O(1).
*/

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

#define Kshitiz  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define deb(x) cout << #x << " is :" << x << "\n";
#define print(x) cout << x << "\n";
#define int long long
#define forf(i,k,n) for (int i = k; i < n; i++)
#define forb(i,n, k) for (int i = n - 1; i >= k; i--)
#define seti set<int>
#define useti unordered_set<int>
#define mapii map<int, int>
#define umapii unordered_map<int, int>
#define vpi vector <pair<int , int> >
#define vi vector<int>
#define pi pair<int , int >
#define vvi vector<vector<int>>
#define pb push_back
#define sz size()
#define forall(var) var.begin(), var.end()
#define present(c, x) (c.find(x) != c.end())
#define desc greater<int>()
#define spc <<" "<<
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define minus1 cout << "-1\n";
#define ndl cout << "\n";
#define gcd(a, b) __gcd(a, b)
#define PI 3.1415926535897932384626
#define imin INT_MIN
#define imax INT_MAX
#define fi first
#define se second
#define set_bits(x) __builtin_popcountint(x)

const int MN=4e5+1;
int M = 1e9 + 7;

int mod(int n) { return (n % M + M) % M; }
int modM(int n, int m) { return ((n % M * m % M) + M) % M; }
int modA(int n, int m) { return ((n % M + m % M) + M) % M; }
int modS(int n, int m) { return ((n % M - m % M) + M) % M; }
int power(int a , int n);
int mInv(int a){ return power(a , M-2); }

//========================XINYSTER=================================//
vector<int> adj[MN];
bool vis[MN] ;

int dfs( int v  ){
    vis[v]=1;
    //cout<<v<<"->";
    int n =1 ;
    for( auto child : adj[v]){
        if( vis[child]==0)
            n+=dfs( child );
    }
    return n;
}
void solve (){
    int n ; cin >> n ;

    int arr[n] ;

    for(int i=0 ;i<n ;i++){
        cin >> arr [i ];
    }
    for( int i=0 ;i<n/2; i++){
        int a = arr[i] , b= arr[n-i-1];

        adj[a].push_back(b) , adj[b].push_back(a);
    }

int ct=0;

for( int i=0; i<n; i++){
    if( vis[arr[i]]!=1){

        int k = dfs(arr[i] );
        //deb(k)
        ct += k-1 ;
    }
}
    cout << ct ;
}

int32_t main(){

    Kshitiz

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

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

//===================================================================//

int power(int a , int n){
    int result = 1;
    while(n){
        if(n & 1) result = (result * a) % M;
        n >>= 1;
        a = (a * a) % M;
    }
    return result;
}


#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
const vector<int> dy={-1,0,1,0},dx={0,-1,0,1};
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} __init;
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>void debag(const vector<T> &a){cerr<<"debag :";for(auto v:a)cerr<<v<<" ";cerr<<"\n";}
template<class T>void print(const vector<T> &a){for(auto v:a)cout<<v<<" ";cout<<"\n";}

int main(){
  int n;
  cin>>n;
  V<int> id(2*n+5,0);
  V<bool> used(2*n+5,0);
  V<int> a(n),b(n);
  V<int> cont(2*n,-1);
  bool ok=true;
  for(int i=0;i<n;i++){
      cin>>a[i]>>b[i];
      if(a[i]!=-1){
          a[i]--;
          if(used[a[i]])ok=false;
          used[a[i]]=1;
          id[a[i]]=i+1;
      }
      if(b[i]!=-1){
          b[i]--;
          if(used[b[i]])ok=false;
          used[b[i]]=1;
          id[b[i]]=-(i+1);
      }
      if(a[i]!=-1&&b[i]!=-1){
          cont[a[i]]=b[i];
          cont[b[i]]=a[i];
      }
  }
  if(!ok){
      cout<<"No"<<"\n";
      return 0;
  }
  V<bool> dp(2*n+1,false);
  dp[0]=true;
  for(int i=0;i<2*n;i++){
      if(!dp[i])continue;
      for(int j=i+1;j<2*n;j++){//i~jを埋める,i~jは対応関係から偶数長
          int d=j-i+1;
          if(d%2==1)continue;
          d/=2;
          bool able=true;
          V<bool> ex(n,false);
          for(int k=0;k<d;k++){
              int l=i+k,r=i+k+d;
              if(cont[l]!=-1&&!(i<=cont[l]&&cont[l]<=j))able=false;
              if(cont[r]!=-1&&!(i<=cont[r]&&cont[r]<=j))able=false;
              if(id[l]!=0&&id[r]!=0){
                  if(id[l]<0||id[l]+id[r]!=0)able=false;
              }
              if(id[l]<0||id[r]>0){
                  able=false;
              }else{
                  if(id[l]!=0){
                      int v=id[l]-1;
                      if(ex[v]){
                          able=false;
                      }
                      ex[v]=true;
                  }
              }
          }
        if(able)dp[j+1]=1;
      }
  }
  cout<<(dp[2*n]?"Yes":"No")<<"\n";
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define pi 3.141592653589
#define MOD 1000000007
#define to() int tt; cin>>tt; while(tt--)
#define pb push_back
#define in insert
#define mp make_pair
#define ff first
#define ss second
#define si(s) s.size()
#define fori(it,v) for(it=v.begin();it!=v.end(); it++)
#define for1(i,low,high) for(int i=low;i<high;i++)
#define for2(i,low,high) for(int i=low;i<=high;i++)
#define rev(i,high,low)  for(int i=high;i>=low ;i--)
#define all(x) x.begin(), x.end()
#define fil(x,i) memset(x,i,sizeof(x));
#define setbits(x) __builtin_popcount(x)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
void i_o() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
#endif
}
int n,m,k;
vector<vector<int> >g;
vector<int>c;
vector<int>d[20];
int dp[1<<18][20];
void bfs(int i){
	d[i][c[i]]=0;
	queue<int>q;
	q.push(c[i]);
	while(!q.empty()){
		int cur=q.front(); q.pop();
		for(int j:g[cur]){
			if(d[i][j]>d[i][cur]+1){
				if(d[i][j]==1e7) q.push(j);
				d[i][j]=d[i][cur]+1;
			}
		}
	}
}

int fun(int mask,int i){
	if(mask==0)
		return 0;
	if(dp[mask][i]!=-1) return dp[mask][i];
	int ans=1e7;
	if(i==k){
		for(int j=0;j<k;j++){
			ans=min(ans,fun(mask^(1<<j),j)+1);
		}
	}
	else
		for(int j=0;j<k;j++){
			if(!(mask&(1<<j))) continue;
			ans=min(ans,fun(mask^(1<<j),j)+d[j][c[i]]);
		}
	return dp[mask][i]=ans;
}

int main()
{
    boost; i_o();
    cin>>n>>m;
    g.resize(n+1);
    for1(i,0,m){
    	int a,b; cin>>a>>b;
    	g[a].pb(b); g[b].pb(a);
    }
    cin>>k;
	c.resize(k);
	for1(i,0,k) d[i].resize(n+1,1e7);
    for1(i,0,k) cin>>c[i];
    for1(i,0,k) bfs(i);
  /*  for1(i,0,k){
    	cout<<"src= "<<c[i]<<endl;
    	for1(j,1,n+1) cout<<d[i][j]<<" ";
    	cout<<endl;
    }
    */
    fil(dp,-1);
 /*
    for1(mask,0,(1<<k)) for1(i,0,k+1) dp[mask][i]=1e7;
    for1(i,0,k) dp[1<<i][i]=d[0][i]=0;
    for(int mask=0;mask<(1<<k);mask++){
    	for(int i=0;i<k;i++){
    			if(!(mask&(1<<i))) continue;
    			for(int j=0;j<k;j++){
    				 if(!(mask&(i<<j))) continue;
    				dp[mask][i]=min(dp[mask][i],dp[mask^i][j]+d[c[j]][c[i]]);
    			}
    	}
    }
    */
    int ans=fun((1<<k)-1,k);
    if(ans>=1e7) ans=-1;
    cout<<ans<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  long long t;
    cin >> t >> n;

    long long ans = (n*100-1)/t + n;
    cout << ans <<endl;
}

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

int main(){
  ll t,n;
  cin >> t >> n;
  ll l=0,r=1e15;
  while(l+1<r){
    ll i=(l+r)/2;
    ll k=i*(100+t)/100-i;
    if(n<=k) r=i;
    else l=i;
  }
  cout << l*(100+t)/100+1 << endl;
}


#include<bits/stdc++.h>

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

long long GCD(long long a, long long b) {
    if (a < 0) a = -a;
    if (b < 0) b = -b;
    if (b == 0) return a;
    else return GCD(b, a % b);
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

int main(){

    bool exist[1010]={};
    int n,m;
    cin>>n>>m;
    rep(i,n){
        int a;
        cin>>a;
        exist[a]=!exist[a];
    }
    rep(i,m){
        int a;
        cin>>a;
        exist[a]=!exist[a];
    }
    for(int i=1;i<=1000;i++){
        if(exist[i])cout<<i<<" ";
    }
    cout<<endl;
}
/*

*/

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<int>>;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define fi first
#define se second
#define mpa make_pair
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
#define set20 cout<<fixed<<setprecision(20) ;
// ミント

const ll mod = //1e9+7 ;
    998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n,int k){
    return fact[n]*ifact[n-k] ;
  }
  }  ;

mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

mint komb(ll n,ll m){
  mint x=1 ;mint y=1 ;
  rep(i,m){
    x*= n-i ;
    y*= i+1 ;
  }
  return x/y ;
}

 map<ll,ll> factor(ll n){  //素因数とオーダーをマップで管理
  map <ll,ll> ord ;
  for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            int res=0;
            while(n%i==0){
                n/=i;
                res++;
            }
            ord[i]=res;
        }
    }
   if(n!=1) ord[n]++;
   return ord ;
 }

///
template< typename T >
T extgcd(T a, T b, T &x, T &y) {
  T d = a;
  if(b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1;
    y = 0;
  }
  return d;
}

int main(){
  ios::sync_with_stdio(false) ;
  cin.tie(nullptr) ;
  vector<ll> cnt(1005) ;
  vector<ll> dnt(1005) ;
  ll n,m ; cin>>n>>m ;
  rep(i,n){
    ll x ; cin>>x ;
    cnt[x]++ ;
  }
  rep(i,m){
    ll x ; cin>>x ;
    dnt[x]++ ;
  }
  rep(i,1005){
    if(cnt[i]==0 && dnt[i]>0) cout<<i<<" " ;
    else if(cnt[i]>0 && dnt[i]==0 ) cout<<i<<" " ;
  }
  cout<<endl ;
  return 0 ;
  }


#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
#define PRYES(x) PR((x) ? "Yes" : "No")
const long long INF          = numeric_limits<long long>::max();
const long long DP_INF       = 1 << 29;
template <class T> using arr = vector<vector<T> >;
using vint                   = vector<int>;
using vll                    = vector<ll>;
// SourceTest用出力マクロ
#ifdef SOURCE_TEST
#define SPR(x) PR(x)
#define SPS(x) PS(x)
#define STRACE(var) cout << #var << "=" << var << endl;
#define SMAPTRACE(var)  \
    cout << #var << "=" \
         << "{" << var.first << "," << var.second << "}" << endl;
#else
#define SPR(x) \
    {}
#define SPS(x) \
    {}
#define STRACE(var) \
    {}
#define SMAPTRACE(var) \
    {}
#endif
int main() {
    ll N;
    cin >> N;

    ll left = 0;
    for (ll i = 10;; i *= 10) {
        if (N < (i * i)) break;
        left = i;
    }
    ll right = max(left * 10, (ll)10);
    ll mul   = right;
    left--;
    right++;

    auto funcIsOk = [&N, &mul](ll v) {
        ll value = v * mul + v;
        STRACE(value);
        return value <= N;
    };

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        ll mid = left + (right - left) / 2;
        STRACE(mid);
        if (funcIsOk(mid)) {
            SPR("OK");
            left = mid;
        } else {
            SPR("NG");
            right = mid;
        }
    }

    STRACE(left);
    STRACE(right);

    PR(left);
    return 0;
}

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long double> vd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<ll,ll>> vp;

#define int ll
#define PB push_back
#define pb pop_back
#define in insert
#define endl "\n"
#define MP make_pair
#define f first
#define PI 3.141592653589
#define nd second
#define Trav(a,x) for(auto &a: x)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
const int MOD  = 998244353;
const int maxn = 2e6+1;

int a,b,c,d,e,k,n,m,t,s,q,x,y,ans;

int32_t main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    ans = 0;
    for(int i = 1;i <= 999999 ; i++){
    	string s = to_string(i);
    	if(stoll(s+s) <= n)ans++;
	}
	cout<<ans;
    return 0;
}