#include <bits/stdc++.h>
using namespace std;
int const N = 9;
int n, m;
char f[(N - 2) * N + 1][1 << (2 * N + 1)];
int p[(N - 2) * N + 1][1 << (2 * N + 1)];
int T[4][4];
char art[N][N + 1];
inline bool bit(int mask, int b) { return mask >> b & 1; }
inline int mask_setter(int mask, int b[]) {
  for (int i = 0; i < 4; ++i) mask ^= 1 << b[i];
  return mask;
}
inline bool all_free(int mask, int b[]) {
  for (int i = 0; i < 4; ++i)
    if (bit(mask, b[i])) return false;
  return true;
}
int putT(int x, int y, int mask, int t) {
  if (t == 0 && (y - 1 < 0 || y + 1 >= m)) return -1;
  if (t == 1 && y + 2 >= m) return -1;
  if (t == 2 && y - 2 < 0) return -1;
  if (t == 3 && y - 2 < 0) return -1;
  if (!all_free(mask, T[t])) return -1;
  mask = mask_setter(mask, T[t]);
  mask <<= 1;
  mask |= 1;
  mask &= ~(1 << (2 * m + 1));
  return mask;
}
void drawT(int i, int j, int t, char c) {
  art[i][j] = c;
  for (int k = 0; k < 4; ++k) {
    int x = i * m + j - T[t][k] - 1;
    art[x / m][x % m] = c;
  }
}
void init() {
  T[0][0] = m - 1, T[0][1] = 2 * m - 2, T[0][2] = 2 * m - 1, T[0][3] = 2 * m;
  T[1][0] = m - 1, T[1][1] = m - 2, T[1][2] = 2 * m - 1, T[1][3] = m - 3;
  T[2][0] = m - 1, T[2][1] = 2 * m - 1, T[2][2] = m, T[2][3] = m + 1;
  T[3][0] = 0, T[3][1] = 1, T[3][2] = m, T[3][3] = 2 * m;
}
int main() {
  scanf("%d%d", &n, &m);
  memset(art, '.', sizeof(art));
  for (int i = 0; i < n; ++i) art[i][m] = '\0';
  if (n < 3 || m < 3) {
    puts("0");
    for (int i = 0; i < n; ++i) puts(art[i]);
    return 0;
  }
  init();
  int t = 2 * m + 1, mm = 1 << t;
  for (int i = 0; i + 2 < n; ++i)
    for (int j = 0; j < m; ++j) {
      for (int mask = 0, nm; mask < mm; ++mask) {
        int v = f[i * m + j][mask];
        int ni = j == m - 1 ? i + 1 : i, nj = j == m - 1 ? 0 : j + 1;
        int nn = ni * m + nj;
        for (int k = 0; k < 4; ++k) {
          if ((nm = putT(i, j, mask, k)) != -1)
            if (f[nn][nm] < v + 1) {
              f[nn][nm] = v + 1;
              p[nn][nm] = (mask << 2) | k;
            }
        }
        if (f[nn][(mask << 1) & ~(1 << t)] < v) {
          f[nn][(mask << 1) & ~(1 << t)] = v;
          p[nn][(mask << 1) & ~(1 << t)] = mask << 2;
        }
      }
    }
  int mask = 0;
  for (int i = 1; i < mm; ++i)
    if (f[(n - 2) * m][i] > f[(n - 2) * m][mask]) mask = i;
  printf("%d\n", f[(n - 2) * m][mask]);
  memset(art, '.', sizeof(art));
  for (int i = 0; i < n; ++i) art[i][m] = '\0';
  for (int i = n - 2, j = 0, pi, pj, pm, pt, c = 0; f[i * m + j][mask];
       i = pi, j = pj, mask = pm) {
    pm = p[i * m + j][mask] >> 2;
    pt = p[i * m + j][mask] & 3;
    pi = j == 0 ? i - 1 : i;
    pj = j == 0 ? m - 1 : j - 1;
    if (f[i * m + j][mask] > f[pi * m + pj][pm])
      drawT(pi + 2, pj, pt, (c++) + 'A');
  }
  for (int i = 0; i < n; ++i) puts(art[i]);
  return 0;
}
