#include <bits/stdc++.h>
using namespace std;
struct state {
  int mask, mask1, mask2, mask3, calc;
};
int n, m;
char ress[15][15];
int dp[10][(1 << 9) + 10][(1 << 9) + 10];
int way[10][(1 << 9) + 10][(1 << 9) + 10];
vector<state> a;
int r(int p, int mask1, int mask2) {
  if (p == n) return 0;
  if (dp[p][mask1][mask2] != -1) return dp[p][mask1][mask2];
  int res = -1;
  for (int i = (0); i < (a.size()); ++i) {
    int m1 = a[i].mask1;
    int m2 = a[i].mask2;
    if (m1 & mask1) continue;
    if (m2 & mask2) continue;
    int res1 = a[i].calc + r(p + 1, mask2 | m2, a[i].mask3);
    if (res1 > res) {
      res = res1;
      way[p][mask1][mask2] = i;
    }
  }
  return dp[p][mask1][mask2] = res;
}
int main() {
  cin >> n >> m;
  if ((n < 3) || (m < 3)) {
    cout << 0 << endl;
    for (int i = (0); i < (n); ++i) {
      for (int j = (0); j < (m); ++j) printf(".");
      printf("\n");
    }
    return 0;
  }
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j) ress[i][j] = '.';
  int v = 1;
  for (int i = (0); i < (m); ++i) v *= 5;
  for (int i = (0); i < (v); ++i) {
    int mask1 = 0, mask2 = 0, mask3 = 0;
    bool f = true;
    int cur = i;
    int cnt = 0;
    for (int j = (0); j < (m); ++j) {
      int c = cur % 5;
      cur /= 5;
      if (c == 0) continue;
      if (c == 1) {
        cnt++;
        if ((mask3 >> j) & 1) {
          f = false;
          break;
        }
        if ((mask2 >> j) & 1) {
          f = false;
          break;
        }
        if ((j < 1) || (j > m - 2)) {
          f = false;
          break;
        }
        if ((mask1 >> j) & 1) {
          f = false;
          break;
        }
        if ((mask1 >> (j - 1)) & 1) {
          f = false;
          break;
        }
        if ((mask1 >> (j + 1)) & 1) {
          f = false;
          break;
        }
        mask1 |= (1 << (j - 1));
        mask1 |= (1 << j);
        mask1 |= (1 << (j + 1));
        mask2 |= (1 << j);
        mask3 |= (1 << j);
      }
      if (c == 2) {
        cnt++;
        if ((mask3 >> j) & 1) {
          f = false;
          break;
        }
        if ((mask2 >> j) & 1) {
          f = false;
          break;
        }
        if ((mask1 >> j) & 1) {
          f = false;
          break;
        }
        if (j < 2) {
          f = false;
          break;
        }
        if ((mask2 >> (j - 1)) & 1) {
          f = false;
          break;
        }
        if ((mask2 >> (j - 2)) & 1) {
          f = false;
          break;
        }
        mask1 |= (1 << (j));
        mask2 |= (1 << j);
        mask2 |= (1 << (j - 1));
        mask2 |= (1 << (j - 2));
        mask3 |= (1 << j);
      }
      if (c == 3) {
        cnt++;
        if ((mask3 >> j) & 1) {
          f = false;
          break;
        }
        if (j > m - 3) {
          f = false;
          break;
        }
        if ((mask2 >> (j + 1)) & 1) {
          f = false;
          break;
        }
        if ((mask1 >> (j + 1)) & 1) {
          f = false;
          break;
        }
        if ((mask3 >> (j + 1)) & 1) {
          f = false;
          break;
        }
        if ((mask3 >> (j + 2)) & 1) {
          f = false;
          break;
        }
        mask1 |= (1 << (j + 1));
        mask2 |= (1 << (j + 1));
        mask3 |= (1 << (j + 2));
        mask3 |= (1 << (j + 1));
        mask3 |= (1 << j);
      }
      if (c == 4) {
        cnt++;
        if ((mask3 >> j) & 1) {
          f = false;
          break;
        }
        if (j > m - 3) {
          f = false;
          break;
        }
        if ((mask2 >> (j)) & 1) {
          f = false;
          break;
        }
        if ((mask1 >> (j)) & 1) {
          f = false;
          break;
        }
        if ((mask2 >> (j + 1)) & 1) {
          f = false;
          break;
        }
        if ((mask2 >> (j + 2)) & 1) {
          f = false;
          break;
        }
        mask1 |= (1 << (j));
        mask2 |= (1 << (j));
        mask2 |= (1 << (j + 1));
        mask2 |= (1 << (j + 2));
        mask3 |= (1 << j);
      }
    }
    if (f) {
      state v = {i, mask1, mask2, mask3, cnt};
      a.push_back(v);
    }
  }
  memset(dp, -1, sizeof(dp));
  int res = r(2, 0, 0);
  cout << res << endl;
  int p = 2, mask1 = 0, mask2 = 0;
  int cur = 0;
  while (p < n) {
    int i = way[p][mask1][mask2];
    int mask = a[i].mask;
    for (int j = (0); j < (m); ++j) {
      int k = mask % 5;
      mask /= 5;
      if (k == 0) continue;
      if (k == 1) {
        ress[p][j] = ress[p - 1][j] = ress[p - 2][j] = ress[p - 2][j - 1] =
            ress[p - 2][j + 1] = 'A' + cur;
        cur++;
      }
      if (k == 2) {
        ress[p][j] = ress[p - 1][j] = ress[p - 2][j] = ress[p - 1][j - 1] =
            ress[p - 1][j - 2] = 'A' + cur;
        cur++;
      }
      if (k == 3) {
        ress[p][j] = ress[p][j + 1] = ress[p][j + 2] = ress[p - 1][j + 1] =
            ress[p - 2][j + 1] = 'A' + cur;
        cur++;
      }
      if (k == 4) {
        ress[p][j] = ress[p - 1][j] = ress[p - 2][j] = ress[p - 1][j + 2] =
            ress[p - 1][j + 1] = 'A' + cur;
        cur++;
      }
    }
    p++;
    mask1 = mask2 | a[i].mask2;
    mask2 = a[i].mask3;
  }
  for (int i = (0); i < (n); ++i) {
    for (int j = (0); j < (m); ++j) printf("%c", ress[i][j]);
    printf("\n");
  }
  return 0;
}
