#include <bits/stdc++.h>
using namespace std;
int n, m, res[20][20], now[20][20], best, empt;
int dx[4][5] = {
    {0, 0, 0, 1, 2}, {0, 1, 1, 1, 2}, {0, 1, 2, 2, 2}, {0, 1, 1, 1, 2}};
int dy[4][5] = {
    {0, 1, 2, 1, 1}, {0, -2, -1, 0, 0}, {0, 0, -1, 0, 1}, {0, 0, 1, 2, 0}};
void paint(int color, int type, int a, int b) {
  for (int i = 0; i < 5; ++i) {
    int na = dx[type][i] + a;
    int nb = dy[type][i] + b;
    now[na][nb] = color;
  }
}
bool clr(int type, int a, int b) {
  for (int i = 0; i < 5; ++i) {
    int na = dx[type][i] + a;
    int nb = dy[type][i] + b;
    if (na < 0 || na >= n || nb < 0 || nb >= m || now[na][nb] >= 0)
      return false;
  }
  return true;
}
void dfs(int a, int b, int curr) {
  if (a == n) {
    if (curr > best) {
      best = curr;
      for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j) res[i][j] = now[i][j];
    }
    return;
  }
  if (b == m) {
    dfs(a + 1, 0, curr);
    return;
  }
  empt = 0;
  for (int i = a; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      if (i == a && j < b) continue;
      empt += (now[i][j] == -1);
    }
  if (curr + empt / 5 <= best) return;
  for (int i = 0; i < 4; ++i)
    if (clr(i, a, b)) {
      paint(curr, i, a, b);
      dfs(a, b + 1, curr + 1);
      paint(-1, i, a, b);
    }
  dfs(a, b + 1, curr);
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  memset(res, -1, sizeof(res));
  memset(now, -1, sizeof(now));
  cin >> n >> m;
  empt = n * m;
  dfs(0, 0, 0);
  cout << best << endl;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j)
      if (res[i][j] == -1)
        cout << ".";
      else
        cout << (char)('A' + res[i][j]);
    cout << endl;
  }
  return 0;
}
