#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", 3, "inline")
using namespace std;
int n, m, ch[13][13], a[13][13], ans = 0;
int w[4][3][3] = {{{1, 1, 1}, {0, 1, 0}, {0, 1, 0}},
                  {{1, 0, 0}, {1, 1, 1}, {1, 0, 0}},
                  {{0, 1, 0}, {0, 1, 0}, {1, 1, 1}},
                  {{0, 0, 1}, {1, 1, 1}, {0, 0, 1}}};
bool ok(int x, int y, int i) {
  for (int u = 0; u < 3; u++)
    for (int v = 0; v < 3; v++)
      if (w[i][u][v])
        if (a[x + u][y + v]) return 0;
  return 1;
}
void dfs(int x, int y, int now) {
  if ((n - x) * m - y <= (ans - now) * 6.5) return;
  if (y + 2 >= m) {
    dfs(x + 1, 0, now);
    return;
  }
  if (x + 2 >= n) {
    if (now > ans) {
      ans = now;
      memcpy(ch, a, sizeof a);
    }
    return;
  }
  for (int i = 0; i < 4; i++)
    if (ok(x, y, i)) {
      now++;
      for (int u = 0; u < 3; u++)
        for (int v = 0; v < 3; v++)
          if (w[i][u][v]) a[x + u][y + v] = now;
      dfs(x, y + 2, now);
      now--;
      for (int u = 0; u < 3; u++)
        for (int v = 0; v < 3; v++)
          if (w[i][u][v]) a[x + u][y + v] = 0;
    }
  dfs(x, y + 1, now);
}
void out() {
  ios_base::sync_with_stdio(false);
  printf("%d\n", ans);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++)
      printf("%c", ch[i][j] ? 'A' + ch[i][j] - 1 : '.');
    puts("");
  }
  exit(0);
}
int main() {
  cin >> n >> m;
  if (min(n, m) < 3) out();
  dfs(0, 0, 0);
  out();
}
