#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 15;
const int pos[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 c[MAX_N][MAX_N], a[MAX_N][MAX_N], best = 0, n, m;
inline bool ok(int x, int y) {
  if (x < 0 || y < 0 || x >= n || y >= m) return false;
  if (c[x][y]) return false;
  return true;
}
inline void dfs(int depth) {
  if (depth > best) {
    best = depth;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) a[i][j] = c[i][j];
  }
  bool found = 0;
  int cnt_found = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (found) cnt_found++;
      if (cnt_found > 2) return;
      for (int d = 0; d < 4; d++) {
        int nok = 0;
        for (int k = 0; k < 5; k++)
          if (!ok(i + pos[d][k][0], j + pos[d][k][1])) nok = 1;
        if (!nok)
          found = 1;
        else
          continue;
        for (int k = 0; k < 5; k++)
          c[i + pos[d][k][0]][j + pos[d][k][1]] = depth + 1;
        dfs(depth + 1);
        for (int k = 0; k < 5; k++) c[i + pos[d][k][0]][j + pos[d][k][1]] = 0;
      }
    }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  if (n < 3 || m < 3) {
    cout << best << endl;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) cout << ".";
      cout << endl;
    }
    return 0;
  }
  dfs(0);
  cout << best << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j])
        cout << char('A' + a[i][j] - 1);
      else
        cout << ".";
    }
    cout << endl;
  }
  return 0;
}
