#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int main(){
    int n;
    cin >> n;
    int m = (1<<n);
    vector<string> res;
    rep(bits,1<<n){
        if(bits==0)continue;
        vector<bool> flag(m);
        rep(i,m){
            int c = 0;
            rep(j,n){
                if((bits>>j)&1){
                    if((i>>j)&1)c++;
                }
            }    
            if(c%2==1)flag[i] = 1;
        }
        string s;
        rep(i,m){
            if(flag[i]){
                s.push_back('A');
            }else{
                s.push_back('B');
            }
        }
        res.push_back(s);
    }
    cout << res.size() << "\n";
    for(auto x:res){
        cout << x << "\n";
    }
    return 0;
}
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ff first
#define ss second
#define pi acos(-1.0)
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
 
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl "\n"
 
//#define inf 1<<30
 
// isupper() -> upper case check
// tolower() -> convert upper to lower case
// idx = str.find("bear", pos)) != string::npos =>substring find
// Tuple access -> get<0>(v[i])
// cmnt - ctrl []
// stoi("...") -> decimel
// istringstream ss(str) while(ss >> n)
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tpl = tuple<int, int, int>;
using pcc = pair<char, char>;
 
const ll inf = 2e18+100;
const ll mod = 1e9+7;
 
int dr[] = {-1, 0, 1,  0};// up, right, down, left
int dc[] = { 0, 1, 0, -1};
 
// King moves similar to 8 direction
//int dr[] = {-1, -1, 0, 1, 1,  1, 0, -1};
//int dc[] = { 0,  1, 1, 1, 0, -1,-1, -1};
 
// Knight moves
int kr[] = {-1,  1, -2, -2, -1, 1,  2,  2};
int kc[] = {-2, -2, -1,  1,  2, 2, -1,  1};
// diagonal moves
int dgr[] = {-1, -1,  1, 1};
int dgc[] = { 1, -1, -1, 1};


void solve()
{
    ll x;
    cin >> x;

    if(x <= 10) cout << 0 << endl;
    else {
        ll ans = 0;
        ll val = 9, pwr = 1;

        for(ll i = 99; ; ){
            
            ans += (val*pwr);
            pwr *= 10;
            //cout << i << endl;
            if(i == x) {
                //cout << "as\n";
                cout << ans << endl;
                return;
            }
            if(i > x) {
                string now = to_string(x);
                ll mn_pwr = 1;
                //cout << ans << endl;
                int siz = now.size();
                
                if(siz%2) {
                    string a, b;
                    b = now.substr(0, (siz/2)+1);
                    for(int l=(siz/2)+1; l >= 1; l--) {
                        if(l == 1) a += "1";
                        else a += "0";
                    }
                    reverse(all(a));
                    ll tmp1 = stoll(b);
                    ll tmp2 = stoll(a);
                    //cout << tmp1 << " " << tmp2 << endl;
                    //cout << ans << endl;
                    ans -= (tmp1-tmp2);
                    //cout << ans << endl;
                    //return;
                }
                for(int j = (siz/2)-(!(siz%2)); j >= 0; j--) {
                    ll dig = now[j]-'0';
                    dig = 9 - dig;
                    ans -= (dig*mn_pwr);
                    mn_pwr *= 10;
                    //cout << ans << endl;
                }
                int ck = 0;
                /*
                for(int l = 0, r = siz-1;! l < r; l++, r--) {
                    if(now[l] != now[r]) {
                        ck = 1;
                        break;
                    }
                }*/
                if(siz%2 or now.substr(0, siz/2) > now.substr(siz/2)) ans--;
                cout << ans << endl;
                return;
            }
            
            i *= 100;
            i += 99;
        }
    }
}   
 
int main()
{
    fast_io;

    int tt = 1;

    //cin >> tt;

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