#include <bits/stdc++.h>
using namespace std;
const int M = 10 + 10;
int n, m;
int board[M][M], bestboard[M][M];
int p[4][8] = {{0, -1, 0, 1, -1, 0, -2, 0},
               {0, -1, 0, 1, 1, 0, 2, 0},
               {0, -1, 0, -2, -1, 0, 1, 0},
               {0, 1, 0, 2, -1, 0, 1, 0}};
void DFS(int row, int col, int &maxv, int &tmpv) {
  int lft = (n - row - 1) * m + m - col;
  if (lft / 5 + tmpv - 1 <= maxv || row == n) {
    return;
  } else {
    for (int i = row; i < n; i++) {
      for (int j = 0; j < m; j++) {
        bool chk = true;
        if (i == row && j < col) {
          chk = false;
        }
        if (board[i][j] == 0 && chk == true) {
          for (int k = 0; k < 4; k++) {
            bool ok = true;
            for (int d = 0; d < 8; d += 2) {
              int nrow = i + p[k][d];
              int ncol = j + p[k][d + 1];
              if (nrow < 0 || nrow > n - 1 || ncol < 0 || ncol > m - 1) {
                ok = false;
              } else {
                if (board[nrow][ncol] != 0) {
                  ok = false;
                }
              }
            }
            if (ok == true) {
              board[i][j] = tmpv;
              for (int d = 0; d < 8; d += 2) {
                int nrow = i + p[k][d];
                int ncol = j + p[k][d + 1];
                board[nrow][ncol] = tmpv;
              }
              tmpv++;
              int nrow = j == m - 1 ? i + 1 : i;
              int ncol = j == m - 1 ? 0 : j + 1;
              DFS(nrow, ncol, maxv, tmpv);
              if (maxv < tmpv - 1) {
                maxv = tmpv - 1;
                for (int r = 0; r < n; r++) {
                  for (int c = 0; c < m; c++) {
                    bestboard[r][c] = board[r][c];
                  }
                }
              }
              tmpv--;
              board[i][j] = 0;
              for (int d = 0; d < 8; d += 2) {
                int nrow = i + p[k][d];
                int ncol = j + p[k][d + 1];
                board[nrow][ncol] = 0;
              }
            }
          }
        }
      }
    }
    return;
  }
}
int main() {
  time_t t_start, t_end;
  t_start = clock();
  cin >> n >> m;
  int maxv = 0;
  int tmpv = 1;
  DFS(0, 0, maxv, tmpv);
  cout << maxv << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (bestboard[i][j] == 0) {
        cout << ".";
      } else {
        char c = bestboard[i][j] - 1 + 'A';
        cout << c;
      }
    }
    cout << endl;
  }
  t_end = clock();
  return 0;
}
