#include <bits/stdc++.h>
using namespace std;
char a[3][15] = {"AAA.A.A....A", ".A..A.AAAAAA", ".A.AAAA....A"};
char b[15][15];
char w[15][15];
int n, m;
int maxnow, sp;
void go(int x, int y, int now) {
  if (x >= n - 2) {
    if (now > maxnow) {
      maxnow = now;
      for (int i = 0; i < n; i++) strcpy(w[i], b[i]);
    }
    return;
  }
  if (y >= m - 2) {
    go(x + 1, 0, now);
    return;
  }
  if (sp / 5 + now <= maxnow) return;
  sp -= b[x][y] == '.';
  for (int g = 0; g < 12; g += 3) {
    int ok = 1;
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++)
        if (a[i][g + j] == 'A' && b[x + i][y + j] != '.') ok = 0;
    if (ok) {
      for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
          if (a[i][g + j] == 'A') b[x + i][y + j] = 'A' + now;
      sp -= 5;
      go(x, y + 1, now + 1);
      sp += 5;
      for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
          if (a[i][g + j] == 'A') b[x + i][y + j] = '.';
    }
  }
  go(x, y + 1, now);
  sp += b[x][y] == '.';
}
int main(void) {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) b[i][j] = w[i][j] = '.';
  sp = n * m;
  go(0, 0, 0);
  printf("%d\n", maxnow);
  for (int i = 0; i < n; i++) puts(w[i]);
  return 0;
}
