#include <bits/stdc++.h>
using namespace std;
using namespace std;
int D[4][5][2] = {{{0, 0}, {1, 0}, {2, 0}, {0, 1}, {0, -1}},
                  {{0, 0}, {-1, 0}, {-2, 0}, {0, 1}, {0, -1}},
                  {{0, 0}, {0, 1}, {0, 2}, {1, 0}, {-1, 0}},
                  {{0, 0}, {0, -1}, {0, -2}, {1, 0}, {-1, 0}}};
int n, m, best;
char u[10][10], b[10][10];
bool ok(int x, int y) {
  return x >= 0 && y >= 0 && x < n && y < m && u[x][y] == '.';
}
void dfs(int step) {
  if (step > best) {
    best = step;
    for (int i = 0; i < (int)n; ++i)
      for (int j = 0; j < (int)m + 1; ++j) b[i][j] = u[i][j];
  }
  bool found = false;
  int cntfound = 0;
  for (int x = 0; x < (int)n; ++x)
    for (int y = 0; y < (int)m; ++y) {
      if (found) cntfound++;
      if (cntfound > 2) return;
      for (int s = 0; s < (int)4; ++s) {
        bool uok = true;
        for (int d = 0; d < (int)5; ++d) {
          if (!ok(x + D[s][d][0], y + D[s][d][1])) uok = false;
        }
        if (!uok) continue;
        found = true;
        for (int d = 0; d < (int)5; ++d)
          u[x + D[s][d][0]][y + D[s][d][1]] = 'A' + step;
        dfs(step + 1);
        for (int d = 0; d < (int)5; ++d)
          u[x + D[s][d][0]][y + D[s][d][1]] = '.';
      }
    }
}
int main() {
  cin >> n >> m;
  if (min(n, m) < 3) {
    cout << 0 << endl;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cout << ".";
      }
      cout << endl;
    }
    return 0;
  }
  for (int i = 0; i < (int)n; ++i)
    for (int j = 0; j < (int)m; ++j) u[i][j] = '.';
  for (int i = 0; i < (int)n; ++i) u[i][m] = '\0';
  for (int i = 0; i < (int)n; ++i)
    for (int j = 0; j < (int)m + 1; ++j) b[i][j] = u[i][j];
  best = 0;
  dfs(0);
  cout << best << endl;
  for (int i = 0; i < (int)n; ++i) cout << b[i] << endl;
  return 0;
}
