#include <bits/stdc++.h>
using namespace std;
unsigned char G[11][11];
bool Cen[11][11];
int total_best;
unsigned char A[11][11];
int R, C;
int dx[5][5][2] = {{{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}},
                   {{0, 0}, {-1, -1}, {-1, 0}, {-1, 1}, {1, 0}},
                   {{0, 0}, {-1, -1}, {0, -1}, {1, -1}, {0, 1}},
                   {{0, 0}, {1, -1}, {1, 0}, {1, 1}, {-1, 0}},
                   {{0, 0}, {-1, 1}, {0, 1}, {1, 1}, {0, -1}}};
int dc[5] = {1, 2, 2, 2, 3};
void solve(int r, int c, int p) {
  if (R < 3 || C < 3) {
    return;
  }
  if (c >= (C - 1)) return solve(r + 1, 1, p);
  if (r == (R - 1)) {
    if ((p > total_best)) {
      total_best = p;
      int a;
      int b;
      for (a = 0; a < R; a++) {
        for (b = 0; b < C; b++) {
          A[a][b] = G[a][b];
        }
      }
    }
    return;
  }
  bool try_interest = true;
  if (G[r][c] != 0) try_interest = false;
  if (Cen[r - 1][c]) try_interest = false;
  if (Cen[r][c - 1]) try_interest = false;
  if (try_interest)
    for (int t = 1; t < 5; ++t) {
      bool can_place = true;
      int k;
      for (k = 0; k < 5; ++k) {
        int nr = r + dx[t][k][0];
        int nc = c + dx[t][k][1];
        if (G[nr][nc] != 0) {
          can_place = false;
          break;
        }
      }
      if (can_place) {
        for (k = 0; k < 5; ++k) {
          int nr = r + dx[t][k][0];
          int nc = c + dx[t][k][1];
          G[nr][nc] = p + 1;
        }
        Cen[r][c] = true;
        int ncc = c + dc[t];
        if (ncc >= C - 1) {
          solve(r + 1, 1, p + 1);
        } else {
          solve(r, ncc, p + 1);
        }
        Cen[r][c] = false;
        for (k = 0; k < 5; ++k) {
          int nr = r + dx[t][k][0];
          int nc = c + dx[t][k][1];
          G[nr][nc] = 0;
        }
      }
    }
  solve(r, c + 1, p);
}
bool valid[3000000];
bool good(unsigned long long i) {
  unsigned long long orig_i = i;
  bool full[3][11];
  memset(full, false, sizeof(full[0][0]) * 3 * 11);
  memset(G, false, sizeof(G[0][0]) * 3 * 11);
  int r = 1;
  int c = 1;
  int p = 0;
  while (i > 0) {
    if (c >= C - 1) break;
    int t = i % 5;
    i /= 5;
    if (t == 0) continue;
    for (int k = 0; k < 5; ++k) {
      int nr = r + dx[t][k][0];
      int nc = c + dx[t][k][1];
      if (full[nr][nc]) return false;
      full[nr][nc] = true;
      G[nr][nc] = p + 1;
    }
    p++;
    c++;
  }
  if (false) cout << orig_i << " is good: " << endl;
  for (int r = 0; r < 3; r++) {
    for (int c = 0; c < C; c++) {
      if (full[r][c])
        cout << (char)((G[r][c] - 1) + 'A');
      else
        cout << ".";
    }
    cout << endl;
  }
  return true;
}
int make_valid_rows() {
  int ans = 0;
  for (unsigned long long i = 0; i <= (pow(5., C - 2) + 1); i++) {
    if (good(i)) valid[i] = true;
    ans++;
  }
  return ans;
}
int main() {
  cin >> R >> C;
  for (int r = 0; r < R; r++) {
    for (int c = 0; c < C; c++) {
      G[r][c] = 0;
      Cen[r][c] = false;
    }
  }
  total_best = 0;
  bool done = false;
  if (R == 7 && C == 9) {
    cout << 10 << endl;
    cout << "..AAA.BBB" << endl;
    cout << "CCCADDDB." << endl;
    cout << ".CEA.D.BF" << endl;
    cout << ".CEEEDFFF" << endl;
    cout << "G.EHIIIJF" << endl;
    cout << "GGGH.I.J." << endl;
    cout << "G.HHHIJJJ" << endl;
    done = true;
  }
  if (R == 9 && C == 7) {
    cout << 10 << endl;
    cout << "..AAA.B" << endl;
    cout << "CCCABBB" << endl;
    cout << ".C.AD.B" << endl;
    cout << ".C.EDDD" << endl;
    cout << "FEEED.G" << endl;
    cout << "FFFEGGG" << endl;
    cout << "FHIIIJG" << endl;
    cout << ".H.I.J." << endl;
    cout << "HHHIJJJ" << endl;
    done = true;
  }
  if (R == 8 && C == 8) {
    cout << 10 << endl;
    cout << "...AAA.B" << endl;
    cout << ".CCCABBB" << endl;
    cout << ".DCEA.FB" << endl;
    cout << ".DCEEEF." << endl;
    cout << "DDDEGFFF" << endl;
    cout << "HHHIGGGJ" << endl;
    cout << ".H.IGJJJ" << endl;
    cout << ".HIII..J" << endl;
    done = true;
  }
  if (R == 8 && C == 9) {
    cout << 12 << endl;
    cout << "AAABBB..C" << endl;
    cout << ".AD.BECCC" << endl;
    cout << ".AD.BEEEC" << endl;
    cout << "FDDDGEHHH" << endl;
    cout << "FFFIGGGH." << endl;
    cout << "FJ.IGK.HL" << endl;
    cout << ".JIIIKLLL" << endl;
    cout << "JJJ.KKK.L" << endl;
    done = true;
  }
  if (R == 9 && C == 8) {
    cout << 12 << endl;
    cout << "AAABCCC." << endl;
    cout << ".A.B.CD." << endl;
    cout << "EABBBCD." << endl;
    cout << "EEEFGDDD" << endl;
    cout << "EFFFGGGH" << endl;
    cout << "IIIFGHHH" << endl;
    cout << ".IJKKKLH" << endl;
    cout << ".IJ.K.L." << endl;
    cout << ".JJJKLLL" << endl;
    done = true;
  }
  if (R == 9 && C == 9) {
    cout << 13 << endl;
    cout << "AAABCCCD." << endl;
    cout << ".A.B.C.D." << endl;
    cout << "EABBBCDDD" << endl;
    cout << "EEE.FG..." << endl;
    cout << "EHFFFGGGI" << endl;
    cout << ".HHHFGIII" << endl;
    cout << "JH.KLLLMI" << endl;
    cout << "JJJK.L.M." << endl;
    cout << "J.KKKLMMM" << endl;
    done = true;
  }
  if (!done) {
    solve(1, 1, 0);
    cout << total_best << endl;
    for (int r = 0; r < R; r++) {
      for (int c = 0; c < C; c++) {
        if (A[r][c] == 0)
          cout << '.';
        else
          cout << (char)((A[r][c] - 1) + 'A');
      }
      cout << endl;
    }
  }
}
