#include <bits/stdc++.h>
using namespace std;
const char figure[4][4][4] = {{"AAA", ".A.", ".A."},
                              {"..A", "AAA", "..A"},
                              {".A.", ".A.", "AAA"},
                              {"A..", "AAA", "A.."}};
int n, m;
int lef;
int best;
char w[15][15], b[15][15];
void dfs(int x, int y, int now) {
  if (x + 2 >= n) {
    if (now > best) {
      best = now;
      for (int i = 0; i < n; i++) strcpy(w[i], b[i]);
    }
    return;
  }
  if (y + 2 >= m) {
    dfs(x + 1, 0, now);
    return;
  }
  if ((now + lef / 5) <= best) return;
  lef -= b[x][y] == '.';
  for (int fi = 0; fi < 4; fi++) {
    bool ok = true;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (figure[fi][i][j] == 'A' && b[i + x][j + y] != '.') {
          ok = false;
          break;
        }
      }
    }
    if (ok) {
      lef -= 5;
      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
          if (figure[fi][i][j] == 'A') {
            b[i + x][j + y] = now + 'A';
          }
        }
      }
      dfs(x, y + 1, now + 1);
      lef += 5;
      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
          if (figure[fi][i][j] == 'A') {
            b[i + x][j + y] = '.';
          }
        }
      }
    }
  }
  dfs(x, y + 1, now);
  lef += b[x][y] == '.';
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) b[i][j] = w[i][j] = '.';
  lef = n * m;
  if (n * m < 9 || n < 3 || m < 3) {
    cout << 0 << endl;
    for (int i = 0; i < n; i++) puts(w[i]);
    return 0;
  }
  dfs(0, 0, 0);
  cout << best << endl;
  for (int i = 0; i < n; i++) {
    puts(w[i]);
  }
  return 0;
}
