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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i32 mod   = 1e9 + 7;
// constexpr i32 mod   = 998244353;

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr i32 dx[] = {0, -1, 1, 0, -1, 1, -1, 1}; 
constexpr i32 dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

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); }
// }}}

void solve() {
  int n = input();

  vector< string > ans;
  ans.emplace_back("AB");
  range(i, 1, n) {
    vector< string > na;
    for (auto &a : ans) {
      auto b = a;
      na.emplace_back(a + b);
      for (auto &c : b) {
        if (c == 'A') c = 'B';
        else c = 'A';
      }
      na.emplace_back(a + b);
    }

    na.emplace_back(string(ans[0].size(), 'A') + string(ans[0].size(), 'B'));
    ans = na;
  }
  
  cout << ans.size() << endl;
  for (auto &a : ans) cout << a << endl;
}

signed main() {
  solve();
}


#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
//typedef tree<long long,null_type,less<>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//typedef tree<long long, null_type, less_equal<>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;
#define ll long long
#define inf 1000000000000000000
#define ff first
#define ss second
#define f(i,a,b) for(ll i=a;i<b;i++)
#define it(b)  for(auto &it:b)
#define NUM 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2)%NUM;
    if (b % 2)
        return (((res * res)%NUM)* a)%NUM;
    else
        return (res * res)%NUM;
}
inline ll min(ll a,ll b)
{
    if(a>b)return b;return a;
}
inline ll max(ll a, ll b)
{
    if(a>b)return a;return b;
}
inline ll dif(long long a,long long b)
{
    if(a>b)
        return a-b;
    return b-a;
}
long long gcd(long long a,long long b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
long long lcm(long long a,long long b)
{
    long long k=gcd(a,b);return (a*b)/k;
}
void read(vll &arr,int n)
{
    if(arr.size()!=n){arr.resize(n);}
    for(int i=0;i<n;i++)cin>>arr[i];
}
void sieveOferatosthenes(long long  MAX)
{
    vector<long long >prime;vll lps(MAX+1);
    vector<bool> pri(MAX+1,true);
    pri[1]=false;
    lps[1]=1;lps[2]=2;
    for (long long  p = 2; p * p <= MAX; p++) {
        if (pri[p]) {
            lps[p] = p;
            for (long long i = p * p; i <= MAX; i += p) {
                pri[i] = false;
                if (lps[i] == 0) {
                    lps[i] = p;
                }
            }
        }
    }
    for(long long  i=1;i<=MAX;i++) {
        if (pri[i]) {
            prime.push_back(i);
            lps[i]=i;
        }
    }
}
void solve()
{
    ll n;cin>>n;
    map<ll,ll>m;
    f(i,0,n) {
        ll a;
        cin >> a;
        m[a]++;
    }
    ll res=0;
    it(m)
    {
        res+=(it.ss*(n-it.ss));
    }
    res/=2;
    cout<<res<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << showpoint;
    cout << setprecision(6);
    int t;t=1;
    ///cin>>t;
    //WE WILL WIN.
    while(t--)
    {
        solve();
    }
}