#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
inline int getBit(long long x, int pos) { return ((x >> pos) & 1); }
const double eps = 1e-9;
const double pi = acos(-1.0);
bool update(int &x, int y) {
  if (x < y) {
    x = y;
    return true;
  } else
    return false;
}
int n, m;
int dp[10][(1 << 19)];
char ans[10][10];
char curC;
int cm1, cm2;
void go(int i, int j, int mask1, int mask2, int mask3, int cnt) {
  if (j >= m - 2) {
    update(dp[i + 1][(mask2 << m) | mask3], cnt);
    return;
  }
  go(i, j + 1, mask1, mask2, mask3, cnt);
  if (((mask1 >> j) & 7) == 0 && getBit(mask2, j + 1) == 0 &&
      getBit(mask3, j + 1) == 0) {
    go(i, j + 2, mask1 | (7 << j), mask2 | (1 << (j + 1)),
       mask3 | (1 << (j + 1)), cnt + 1);
  }
  if (getBit(mask1, j + 2) == 0 && ((mask2 >> j) & 7) == 0 &&
      getBit(mask3, j + 2) == 0) {
    go(i, j + 3, mask1 | (1 << (j + 2)), mask2 | (7 << j),
       mask3 | (1 << (j + 2)), cnt + 1);
  }
  if (getBit(mask1, j + 1) == 0 && getBit(mask2, j + 1) == 0 &&
      ((mask3 >> j) & 7) == 0) {
    go(i, j + 2, mask1 | (1 << (j + 1)), mask2 | (1 << (j + 1)),
       mask3 | (7 << j), cnt + 1);
  }
  if (getBit(mask1, j) == 0 && ((mask2 >> j) & 7) == 0 &&
      getBit(mask3, j) == 0) {
    go(i, j + 2, mask1 | (1 << j), mask2 | (7 << j), mask3 | (1 << j), cnt + 1);
  }
}
bool go2(int i, int j, int mask1, int mask2, int mask3, int cnt) {
  if (j >= m - 2) {
    if (mask2 == cm1 && mask3 == cm2 && cnt == dp[i + 1][(cm1 << m) | cm2]) {
      return true;
    }
    return false;
  }
  if (go2(i, j + 1, mask1, mask2, mask3, cnt)) {
    return true;
  }
  if (((mask1 >> j) & 7) == 0 && getBit(mask2, j + 1) == 0 &&
      getBit(mask3, j + 1) == 0 &&
      go2(i, j + 2, mask1 | (7 << j), mask2 | (1 << (j + 1)),
          mask3 | (1 << (j + 1)), cnt + 1)) {
    ans[i][j] = ans[i][j + 1] = ans[i][j + 2] = ans[i + 1][j + 1] =
        ans[i + 2][j + 1] = curC;
    curC++;
    return true;
  }
  if (getBit(mask1, j + 2) == 0 && ((mask2 >> j) & 7) == 0 &&
      getBit(mask3, j + 2) == 0 &&
      go2(i, j + 3, mask1 | (1 << (j + 2)), mask2 | (7 << j),
          mask3 | (1 << (j + 2)), cnt + 1)) {
    ans[i][j + 2] = ans[i + 1][j] = ans[i + 1][j + 1] = ans[i + 1][j + 2] =
        ans[i + 2][j + 2] = curC;
    curC++;
    return true;
  }
  if (getBit(mask1, j + 1) == 0 && getBit(mask2, j + 1) == 0 &&
      ((mask3 >> j) & 7) == 0 &&
      go2(i, j + 2, mask1 | (1 << (j + 1)), mask2 | (1 << (j + 1)),
          mask3 | (7 << j), cnt + 1)) {
    ans[i][j + 1] = ans[i + 1][j + 1] = ans[i + 2][j] = ans[i + 2][j + 1] =
        ans[i + 2][j + 2] = curC;
    curC++;
    return true;
  }
  if (getBit(mask1, j) == 0 && ((mask2 >> j) & 7) == 0 &&
      getBit(mask3, j) == 0 &&
      go2(i, j + 2, mask1 | (1 << j), mask2 | (7 << j), mask3 | (1 << j),
          cnt + 1)) {
    ans[i][j] = ans[i + 1][j] = ans[i + 1][j + 1] = ans[i + 1][j + 2] =
        ans[i + 2][j] = curC;
    curC++;
    return true;
  }
  return false;
}
int main() {
  scanf("%d%d", &n, &m);
  if (n < 3 || m < 3) {
    puts("0");
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        putchar('.');
      }
      puts("");
    }
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < (1 << (m * 2)); j++) {
      dp[i][j] = -1;
    }
  }
  dp[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int mask1 = 0; mask1 < (1 << m); mask1++) {
      for (int mask2 = 0; mask2 < (1 << m); mask2++) {
        cm1 = mask1;
        cm2 = mask2;
        if (dp[i][(mask1 << m) | mask2] != -1)
          go(i, 0, mask1, mask2, 0, dp[i][(mask1 << m) | mask2]);
      }
    }
  }
  cout << dp[n][0] << endl;
  curC = 'A';
  cm1 = cm2 = 0;
  for (int i = n - 1; i >= 0; i--) {
    bool found = false;
    for (int mask1 = 0; mask1 < (1 << m) && !found; mask1++) {
      for (int mask2 = 0; mask2 < (1 << m) && !found; mask2++) {
        if (dp[i][(mask1 << m) | mask2] != -1) {
          if (go2(i, 0, mask1, mask2, 0, dp[i][(mask1 << m) | mask2])) {
            cm1 = mask1;
            cm2 = mask2;
            found = true;
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if ('A' <= ans[i][j] && ans[i][j] <= 'Z') continue;
      ans[i][j] = '.';
    }
    ans[i][m] = '\0';
  }
  for (int i = 0; i < n; i++) {
    puts(ans[i]);
  }
  return 0;
}
