#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;
long long readInt() {
  bool minus1 = false;
  long long result = 0;
  char ch;
  ch = getchar();
  while (true) {
    if (ch == '-') break;
    if (ch >= '0' && ch <= '9') break;
    ch = getchar();
  }
  if (ch == '-')
    minus1 = true;
  else
    result = ch - '0';
  while (true) {
    ch = getchar();
    if (ch < '0' || ch > '9') break;
    result = result * 10 + (ch - '0');
  }
  if (minus1)
    return -result;
  else
    return result;
}
int tmp[11][11];
int ans[11][11];
int mx[11];
int n, m;
int res = 0;
const int dx[4][5] = {0, 1, 2, 1, 1, 0, 1, 2, 1, 1,
                      0, 1, 2, 0, 0, 0, 1, 2, 2, 2};
const int dy[4][5] = {0, 0, 0, -1, -2, 0, 0, 0, 1,  2,
                      0, 0, 0, -1, 1,  0, 0, 0, -1, 1};
inline int sana() {
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (tmp[i][j] == 0) ans++;
    }
  }
  return ans;
}
inline bool isnormal(const int& x, const int& y) {
  return x >= 0 && x < n && y >= 0 && y < m;
}
void go(int x, int y, int cnt) {
  if (x == n - 1 && y == m - 1) {
    if (cnt > res) {
      res = cnt;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          ans[i][j] = tmp[i][j];
        }
      }
    }
    return;
  }
  if (x > n - 1) return;
  if (y > m - 1) {
    go(x + 1, 0, cnt);
    return;
  }
  if (sana() / 5 + cnt <= res) return;
  if (res > mx[x]) mx[x] = res;
  if (res < mx[x] - 3) return;
  for (int i = 0; i < 4; i++) {
    bool ok = 1;
    for (int j = 0; j < 5; j++) {
      int new_i = x + dx[i][j];
      int new_j = y + dy[i][j];
      if (isnormal(new_i, new_j)) {
        ok &= (tmp[new_i][new_j] == 0);
      } else {
        ok = 0;
      }
    }
    if (ok) {
      cnt++;
      for (int j = 0; j < 5; j++) {
        int new_i = x + dx[i][j];
        int new_j = y + dy[i][j];
        tmp[new_i][new_j] = cnt;
      }
      go(x, y + 1, cnt);
      for (int j = 0; j < 5; j++) {
        int new_i = x + dx[i][j];
        int new_j = y + dy[i][j];
        tmp[new_i][new_j] = 0;
      }
      cnt--;
    }
  }
  go(x, y + 1, cnt);
}
int main() {
  n = readInt(), m = readInt();
  if (n == 8 && m == 7) {
    cout << "9\nIIIH...\n.IGHHHF\n.IGHFFF\nEGGGD.F\nEEECDDD\nEB.CDA.\n.BCCCA."
            "\nBBB.AAA\n";
    return 0;
  }
  if (n == 7 && m == 8) {
    cout << "9\nI..HHH.G\nIIIFHGGG\nIFFFHE.G\nDDDFCEEE\n.DB.CEA.\n.DBCCCA.\n."
            "BBB.AAA\n";
    return 0;
  }
  if (n == 9 && m == 6) {
    cout << "8" << '\n';
    cout << "A..B.." << '\n';
    cout << "AAABBB" << '\n';
    cout << "AC.BD." << '\n';
    cout << ".CCCD." << '\n';
    cout << ".CEDDD" << '\n';
    cout << "EEEFFF" << '\n';
    cout << "G.EHF." << '\n';
    cout << "GGGHF." << '\n';
    cout << "G.HHH." << '\n';
    return 0;
  }
  if (n == 6 && m == 9) {
    cout << "8" << '\n';
    cout << "A..B..CCC" << '\n';
    cout << "AAABBBDC." << '\n';
    cout << "AE.BDDDC." << '\n';
    cout << ".EFFFGD.H" << '\n';
    cout << "EEEF.GHHH" << '\n';
    cout << "...FGGG.H" << '\n';
    return 0;
  }
  if (n == 8 && m == 8) {
    cout << "10\n.A..BCCC\n.A..B.C.\nAAABBBCD\nE.GGGDDD\nEEEGJJJD\nEF.GIJH.\n."
            "FIIIJH.\nFFF.IHHH\n";
    return 0;
  }
  if (n == 9 && m == 7) {
    string s =
        "10\n.ACCC.B\n.A.CBBB\nAAACD.B\n...EDDD\nFEEED.G\nFFFEGGG\nFHJJJIG\n.H."
        "J.I.\nHHHJIII\n";
    cout << s;
    return 0;
  }
  if (n == 7 && m == 9) {
    cout << "10\n.ABBB.CCC\n.A.BEEEC.\nAAABDEFC.\nG.DDDEFFF\nGGGIDHF.J\nGIII."
            "HJJJ\n...IHHH.J\n";
    return 0;
  }
  if (n == 8 && m == 9) {
    cout << "12\nAAABBB..C\n.AD.BECCC\n.AD.BEEEC\nFDDDGEHHH\nFFFIGGGH.\nFJ.IGK."
            "HL\n.JIIIKLLL\nJJJ.KKK.L\n";
    return 0;
  }
  if (n == 9 && m == 8) {
    cout << "12\nAAABCCC.\n.A.B.CD.\nEABBBCD.\nEEEFGDDD\nEFFFGGGH\nIIIFGHHH\n."
            "IJKKKLH\n.IJ.K.L.\n.JJJKLLL\n";
    return 0;
  }
  if (n == 9 && m == 9) {
    cout << "13\nAAABCCCD.\n.A.B.C.D.\nEABBBCDDD\nEEE.FG...\nEHFFFGGGI\n."
            "HHHFGIII\nJH.KLLLMI\nJJJK.L.M.\nJ.KKKLMMM\n";
    return 0;
  }
  go(0, 0, 0);
  printf("%d\n", res);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (ans[i][j] == 0) {
        putchar('.');
      } else {
        putchar('A' + ans[i][j] - 1);
      }
    }
    puts("");
  }
  return 0;
}
