#include <bits/stdc++.h>
using namespace std;
const int shape[4][4][2] = {{{1, 0}, {2, 0}, {1, 1}, {1, 2}},
                            {{1, 0}, {2, 0}, {2, -1}, {2, 1}},
                            {{0, 1}, {0, 2}, {-1, 2}, {1, 2}},
                            {{0, 1}, {0, 2}, {1, 1}, {2, 1}}};
int x, y;
struct node {
  char g[9][9];
  int num;
  int sx, sy;
  node() {
    sx = sy = 0;
    memset(g, 0, sizeof(g));
    num = 0;
  }
  void printNode() {
    for (int i = 0; i < y; i++) {
      for (int j = 0; j < x; j++) printf("%c", g[i][j] ? g[i][j] : '.');
      cout << "" << endl;
    }
  }
};
stack<node> q;
int ans;
node ansNode;
void bfs() {
  while (true) {
  The_End_Where_I_Began:
    if (q.empty()) break;
    node now = q.top();
    q.pop();
    if (now.num > ans) {
      ans = now.num;
      ansNode = now;
    }
    now.num++;
    char ch = 'A' + now.num - 1;
    bool flag = true;
    for (int i = now.sy; i < y; i++) {
      int j = (now.sy == i ? now.sx : 0);
      for (; j < x; j++) {
        if (!now.g[i][j]) {
          flag = true;
          for (int k = 3; k >= 0; k--) {
            flag = true;
            for (int l = 0; l < 4; l++) {
              int tx = j + shape[k][l][1];
              int ty = i + shape[k][l][0];
              if (tx < 0 || tx >= x || ty < 0 || ty >= y || now.g[ty][tx]) {
                flag = false;
                break;
              }
            }
            if (flag) {
              node tNode = now;
              tNode.g[i][j] = ch;
              for (int l = 0; l < 4; l++) {
                int tx = j + shape[k][l][1];
                int ty = i + shape[k][l][0];
                tNode.g[ty][tx] = ch;
              }
              tNode.sx = j + 1;
              tNode.sy = i;
              q.push(tNode);
            }
          }
          if (flag) goto The_End_Where_I_Began;
        }
      }
    }
  }
}
int main() {
  ans = -1;
  cin >> y >> x;
  while (!q.empty()) q.pop();
  q.push(node());
  bfs();
  cout << ans << endl;
  ansNode.printNode();
  return 0;
}
