#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define INF LONG_MAX/3
//#define DIV 1000000007
//#define DIV 998244353

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 dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

	vector<string> ans;
	ans.push_back("AB");

	rep(i, N-1) {
		vector<string> n_ans;
		for(string s: ans) {
			n_ans.push_back(s + s);
		}

		for(string s: ans) {
			string rev = "";
			for(char ch: s) {
				if(ch == 'A') {
					rev += "B";
				} else {
					rev += "A";
				}
			}
			n_ans.push_back(s + rev);
		}

		string s = "";
		rep(i, n_ans[0].size()/2) s += "A";
		rep(i, n_ans[0].size()/2) s += "B";
		n_ans.push_back(s);

		swap(ans, n_ans);
	}
	cout << ans.size() << endl;
	for(auto s: ans) cout << s << endl;
}

#include<cstdio>
#include<vector>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;

namespace Elaina{
    // #define NDEBUG
    #include<cassert>

    #define rep(i, l, r) for(int i=(l), i##_end_=(r); i<=i##_end_; ++i)
    #define drep(i, l, r) for(int i=(l), i##_end_=(r); i>=i##_end_; --i)
    #define fi first
    #define se second
    #define mp(a, b) make_pair(a, b)
    #define Endl putchar('\n')
    #define mmset(a, b) memset(a, b, sizeof a)
    typedef long long ll;
    typedef pair<int, int> pii;
    typedef pair<ll, ll> pll;
    template<class T>inline T fab(T x){ return x<0? -x: x; }
    template<class T>inline void getmin(T& x, const T rhs){ x=min(x, rhs); }
    template<class T>inline void getmax(T& x, const T rhs){ x=max(x, rhs); }
    template<class T>inline T readin(T x){
        x=0; int f=0; char c;
        while((c=getchar())<'0' || '9'<c) if(c=='-') f=1;
        for(x=(c^48); '0'<=(c=getchar()) && c<='9'; x=(x<<1)+(x<<3)+(c^48));
        return f? -x: x;
    }
    template<class T>inline void writc(T x, char s='\n'){
        static int fwri_sta[1005], fwri_ed=0;
        if(x<0) putchar('-'), x=-x;
        do fwri_sta[++fwri_ed]=x%10, x/=10; while(x);
        while(putchar(fwri_sta[fwri_ed--]^48), fwri_ed);
        putchar(s);
    }
}
using namespace Elaina;

int a[5];

signed main(){
    rep(i, 1, 3) a[i]=readin(1);
    sort(a+1, a+4);
    if(a[1]==a[2]) writc(a[3]);
    else if(a[2]==a[3]) writc(a[1]);
    else writc(0);
    return 0;
}