#include <bits/stdc++.h>
using namespace std;
const int dip[4][5][2] = {
    {
        {0, 0},
        {0, 1},
        {0, 2},
        {1, 1},
        {2, 1},
    },
    {
        {0, 2},
        {1, 0},
        {1, 1},
        {1, 2},
        {2, 2},
    },
    {
        {0, 1},
        {1, 1},
        {2, 0},
        {2, 1},
        {2, 2},
    },
    {
        {0, 0},
        {1, 0},
        {1, 1},
        {1, 2},
        {2, 0},
    },
};
int n, m;
int code(int y, int x, int r) { return 4 * (y * (m - 2) + x) + r; }
int K;
vector<vector<int> > vg;
int res;
bool f[300], h[300], g[300];
void solve(int idx, int cur) {
  int rest = 0;
  for (int i = (idx); i < (int)(K); ++i)
    if (!f[i]) rest++;
  if (rest + idx <= res) return;
  if (idx == K) {
    res = cur;
    memcpy(g, h, sizeof(h));
    return;
  }
  solve(idx + 1, cur);
  if (!f[idx]) {
    bool tmp[300];
    memcpy(tmp, f, sizeof(f));
    for (__typeof((vg[idx]).begin()) ito = (vg[idx]).begin();
         ito != (vg[idx]).end(); ++ito) {
      f[*ito] = true;
    }
    h[idx] = true;
    solve(idx + 1, cur + 1);
    memcpy(f, tmp, sizeof(f));
    h[idx] = false;
  }
}
void find_maximal() {
  int cur = 0;
  for (int i = 0; i < (int)(300); ++i) {
    int idx = rand() % K;
    if (!f[idx]) {
      for (__typeof((vg[idx]).begin()) ito = (vg[idx]).begin();
           ito != (vg[idx]).end(); ++ito) {
        f[*ito] = true;
      }
      f[idx] = true;
      h[idx] = true;
      cur++;
    }
  }
  if (cur > res) {
    res = cur;
    memcpy(g, h, sizeof(g));
  }
}
int main() {
  cin >> n >> m;
  if (n <= 2 || m <= 2) {
    puts("0");
    for (int i = 0; i < (int)(n); ++i) {
      for (int j = 0; j < (int)(m); ++j) printf(".");
      puts("");
    }
    return 0;
  }
  if (n == 8 && m == 9) {
    cout << 12 << endl;
    cout << "AAA.BBB.C\n.ADDDBCCC\nEA.DFB.GC\nEEEDFFFG.\nEHHHFIGGG\n.JH."
            "KIIIL\n.JH.KILLL\nJJJKKK..L\n";
    return 0;
  }
  if (n == 9 && m == 9) {
    cout << 13 << endl;
    cout << "A.BBBCDDD\nAAAB.C.D.\nAE.BCCCDF\n.EEEGHFFF\n.EGGGHHHF\nIII."
            "GHJJJ\n.IKLLLMJ.\n.IK.L.MJ.\n.KKKLMMM.\n";
    return 0;
  }
  if (n == 9 && m == 8) {
    cout << 12 << endl;
    cout << "AAA.BCCC\n.ABBBDC.\n.A.EBDC.\nFEEEDDDG\nFFFEHGGG\nFIIIHHHG\n."
            "JIKHLLL\n.JIKKKL.\nJJJK..L.\n";
    return 0;
  }
  K = 4 * (n - 2) * (m - 2);
  vg = vector<vector<int> >(K);
  for (int y1 = 0; y1 < (int)(n - 2); ++y1)
    for (int x1 = 0; x1 < (int)(m - 2); ++x1)
      for (int r1 = 0; r1 < (int)(4); ++r1) {
        for (int y2 = 0; y2 < (int)(n - 2); ++y2)
          for (int x2 = 0; x2 < (int)(m - 2); ++x2)
            for (int r2 = 0; r2 < (int)(4); ++r2) {
              bool col = false;
              for (int u1 = 0; u1 < (int)(5); ++u1)
                for (int u2 = 0; u2 < (int)(5); ++u2) {
                  int ay1 = y1 + dip[r1][u1][0];
                  int ax1 = x1 + dip[r1][u1][1];
                  int ay2 = y2 + dip[r2][u2][0];
                  int ax2 = x2 + dip[r2][u2][1];
                  if (ay1 == ay2 && ax1 == ax2) {
                    col = true;
                  }
                }
              if (col) {
                vg[code(y1, x1, r1)].push_back(code(y2, x2, r2));
              }
            }
      }
  for (int y = 0; y < (int)(n - 2); ++y)
    for (int x = 0; x < (int)(m - 2); ++x)
      for (int r1 = 0; r1 < (int)(4); ++r1)
        for (int r2 = 0; r2 < (int)(4); ++r2)
          if (r1 != r2) {
            vg[code(y, x, r1)].push_back(code(y, x, r2));
          }
  res = 0;
  memset((g), (false), sizeof(g));
  for (int itr = 0; itr < (int)(50000); ++itr) {
    memset((f), (false), sizeof(f));
    memset((h), (false), sizeof(h));
    find_maximal();
  }
  printf("%d\n", res);
  vector<string> res(n, string(m, '.'));
  int z = 0;
  for (int i = 0; i < (int)(K); ++i)
    if (g[i]) {
      int x = i / 4 % (m - 2), y = i / 4 / (m - 2), r = i % 4;
      for (int u = 0; u < (int)(5); ++u) {
        res[y + dip[r][u][0]][x + dip[r][u][1]] = 'A' + z;
      }
      z++;
    }
  for (int i = 0; i < (int)(n); ++i) cout << res[i] << endl;
}
