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

#define ll long long
#define vt vector
#define ar array
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define pb push_back

template<class A> void read(vt<A>& v);
template<class A, size_t S> void read(ar<A, S>& a);
template<class T> void read(T& x) {
	cin >> x;
}
void read(double& d) {
	string t;
	read(t);
	d=stod(t);
}
void read(long double& d) {
	string t;
	read(t);
	d=stold(t);
}
template<class H, class... T> void read(H& h, T&... t) {
	read(h);
	read(t...);
}
template<class A> void read(vt<A>& x) {
	for (A & it : x) read(it);
}
template<class A, size_t S> void read(array<A, S>& x) {
    for (A & it : x) read(it);
}
template<class A> void read(vt<vt<A>> & x) {
    for (vt<A> & it : x) for (A & itt : it) read(itt);
}
template<class A> void read(vt<pair<A, A>> & x) {
    for (pair<A, A> & it : x) {
        read(it.first);
        read(it.second);
    }
}

string to_string(char c) {
	return string(1, c);
}
string to_string(bool b) {
	return b?"true":"false";
}
string to_string(const char* s) {
	return string(s);
}
string to_string(string s) {
	return s;
}
string to_string(vt<bool> v) {
	string res;
	for (int i = 0; i < sz(v); i++)
		res+=char('0'+v[i]);
	return res;
}

template<size_t S> string to_string(bitset<S> b) {
	string res;
	for (int i = 0; i < S; i++)
		res+=char('0'+b[i]);
	return res;
}
template<class T> string to_string(T v) {
    bool f=1;
    string res;
    for (T & x : v) {
		if(!f)
			res+=' ';
		f=0;
		res+=to_string(x);
	}
    return res;
}

template<class A> void print(A x) {
	cout << to_string(x);
}
template<class H, class... T> void print(const H& h, const T&... t) {
	print(h);
	print(t...);
}
void println() {
	cout << endl;
}
template<class A> void println(A x) {
	print(x);
    println();
}
template<class H, class... T> void println(const H& h, const T&... t) {
	print(h);
	print(t...);
    println();
}

template<class A> bool umin(A & x, A a) {
    if (a < x) {
        x = a;
        return 1;
    }
    return 0;
}
template<class A> bool umax(A & x, A a) {
    if (a > x) {
        x = a;
        return 1;
    }
    return 0;
}

int readInt () {
	bool minus = false;
	int result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

//----------------------------------Solution starts here-------------------------------//

void solve() {
	ll n;
	read(n);

	set<ll> s;
	for (ll i = 2; i <= sqrt(n); i++) {
		ll j = i * i;
		while (j <= n) {
			s.insert(j);
			j *= i;
		}
	}
	println(n - sz(s));
}

int main() {
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

    /*
    freopen("in.txt", "r", stdin);
    freopen ("out.txt", "w", stdout);
    */

    int t = 1;
    //read(t);
    for (int i = 1; i <= t; i++) {
        //print("Case #", i, ": ");
        solve();
    }
}

//Δke_D
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 333;
int n,m,a[N][N];
int main()
{
	int i,j,k;
	cin>>n;
	for(i=1;i<=n;i=i+1){
		m=1<<(i-1);
		for(j=m;j<m*2;j=j+1)
			for(k=0;k<m;k=k+1)
				a[j][k]=a[j-m][k];
		for(j=0;j<m;j=j+1)
			for(k=m;k<m*2;k=k+1)
				a[j][k]=a[j][k-m];
		for(j=m;j<m*2;j=j+1)
			for(k=m;k<m*2;k=k+1)
				a[j][k]=a[j-m][k-m]^1;
	}
	m=1<<n;
	cout<<m-1<<endl;
	for(i=1;i<m;i=i+1){
		for(j=0;j<m;j=j+1)
			cout<<(char)(a[i][j]+'A');
		cout<<endl;
	}
	return 0;
}