#include <bits/stdc++.h>
using namespace std;
const long long maxn = 10;
long long tmp = 0, ans = 0;
long long mat[maxn][maxn], fin[maxn][maxn];
long long n, m;
void cpy() {
  ans = tmp;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      fin[i][j] = mat[i][j];
    }
  }
}
void bt(long long row, long long col) {
  if (row == n) {
    if (tmp > ans) cpy();
    return;
  }
  if (col == 0) {
    long long cnt = n - row + 1;
    cnt = cnt / 3 + (cnt % 3 != 0);
    if (4 * cnt + tmp < ans) return;
  }
  long long cc = m - col + 1;
  cc += (n - row - 1) * m;
  if ((cc / 7 + tmp) < ans) return;
  if (col >= m) {
    bt(row + 1, 0);
    return;
  }
  bt(row, col + 1);
  if (mat[row][col] == -1) {
    if (row < (n - 2) and col < (m - 2)) {
      bool fl = 0;
      if (mat[row][col + 1] != -1 or mat[row][col + 2] != -1 or
          mat[row + 1][col + 1] != -1 or mat[row + 2][col + 1] != -1) {
        fl = 1;
      }
      if (fl == 0) {
        mat[row][col] = mat[row][col + 1] = mat[row][col + 2] =
            mat[row + 1][col + 1] = mat[row + 2][col + 1] = tmp;
        tmp++;
        bt(row, col + 1);
        tmp--;
        mat[row][col] = mat[row][col + 1] = mat[row][col + 2] =
            mat[row + 1][col + 1] = mat[row + 2][col + 1] = -1;
      }
    }
    if (row < (n - 2) and col < (m - 2)) {
      bool fl = 0;
      if (mat[row + 1][col] != -1 or mat[row + 1][col + 1] != -1 or
          mat[row + 1][col + 2] != -1 or mat[row + 2][col] != -1)
        fl = 1;
      if (fl == 0) {
        mat[row][col] = mat[row + 1][col] = mat[row + 1][col + 1] =
            mat[row + 1][col + 2] = mat[row + 2][col] = tmp;
        tmp++;
        bt(row, col + 1);
        tmp--;
        mat[row][col] = mat[row + 1][col] = mat[row + 1][col + 1] =
            mat[row + 1][col + 2] = mat[row + 2][col] = -1;
      }
    }
    if (row < (n - 2) and col > 0 and col < (m - 1)) {
      bool fl = 0;
      if (mat[row + 1][col] != -1 or mat[row + 2][col - 1] != -1 or
          mat[row + 2][col] != -1 or mat[row + 2][col + 1] != -1)
        fl = 1;
      if (fl == 0) {
        mat[row][col] = mat[row + 1][col] = mat[row + 2][col - 1] =
            mat[row + 2][col] = mat[row + 2][col + 1] = tmp;
        tmp++;
        bt(row, col + 1);
        tmp--;
        mat[row][col] = mat[row + 1][col] = mat[row + 2][col - 1] =
            mat[row + 2][col] = mat[row + 2][col + 1] = -1;
      }
    }
    if (row < (n - 2) and col > 1) {
      bool fl = 0;
      if (mat[row + 1][col - 2] != -1 or mat[row + 1][col - 1] != -1 or
          mat[row + 1][col] != -1 or mat[row + 2][col] != -1)
        fl = 1;
      if (fl == 0) {
        mat[row][col] = mat[row + 1][col - 2] = mat[row + 1][col - 1] =
            mat[row + 1][col] = mat[row + 2][col] = tmp;
        tmp++;
        bt(row, col + 1);
        tmp--;
        mat[row][col] = mat[row + 1][col - 2] = mat[row + 1][col - 1] =
            mat[row + 1][col] = mat[row + 2][col] = -1;
      }
    }
  }
}
int main() {
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      mat[i][j] = fin[i][j] = -1;
    }
  }
  cin >> n >> m;
  bt(0, 0);
  cout << ans << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (fin[i][j] == -1)
        cout << ".";
      else {
        char o = 'A';
        o += fin[i][j];
        cout << o;
      }
    }
    cout << endl;
  }
}
