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

vector<string> f(int n){
    if(n == 1)  return vector<string>{"AB"};
    vector<string> ans = f(n - 1);
    int sz = ans.size();
	for(int t = 0; t < sz; ++t){
        ans[t] = ans[t] + ans[t];
        string s = ans[t];
        int siz = s.size();
        for(int i = siz / 2; i < siz; ++i)  s[i] = "AB"[s[i] == 'A'];
        ans.emplace_back(s);
    }
    string s(1 << (n - 1), 'A'),  ss(1 << (n - 1), 'B');
    ans.emplace_back(s + ss);
    return ans;  
}

int n;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);  cout.tie(0);
    cin >> n;
    vector<string> s = f(n);
    cout << s.size() << "\n";
    for(auto &v : s)  cout << v << "\n";
    return 0;
}
#include <iostream>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll N;
    cin >> N;
    for(ll i = 1; ; i++) if(stoll(to_string(i) + to_string(i)) > N){
        cout << i - 1 << endl;
        return 0;
    }
}
