#include <bits/stdc++.h>
using namespace std;
int n, m;
bool debug = false;
int k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int d[4][5][2] = {0, 0, 1, 0, 1, 1, 1, 2, 2, 0, 0, 0, 0, 1, 0, 2, 1, 1, 2, 1,
                  0, 2, 1, 0, 1, 1, 1, 2, 2, 2, 0, 1, 1, 1, 2, 0, 2, 1, 2, 2};
int ans[10][10], a[10][10], cnt;
bool ck(int i, int j) {
  return (i >= 1 && i <= n && j >= 1 && j <= m && a[i][j] == 0);
}
void dfs(int x, int y, int t, int ss) {
  if (y == m + 1) {
    x++;
    y = 1;
  }
  if (t + ss / 5 <= cnt) return;
  if (x == n + 1) {
    memcpy(ans, a, sizeof ans);
    cnt = t;
    return;
  }
  int i, j;
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 5; j++)
      if (!ck(x + d[i][j][0], y + d[i][j][1])) break;
    if (j != 5) continue;
    for (j = 0; j < 5; j++) a[x + d[i][j][0]][y + d[i][j][1]] = t + 1;
    dfs(x, y + 1, t + 1, ss - 5 - (a[x][y] == 0));
    for (j = 0; j < 5; j++) a[x + d[i][j][0]][y + d[i][j][1]] = 0;
  }
  dfs(x, y + 1, t, ss - (a[x][y] == 0));
}
int main() {
  scanf("%d%d", &n, &m);
  cnt = -1;
  dfs(1, 1, 0, n * m);
  printf("%d\n", cnt);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (ans[i][j] == 0)
        putchar('.');
      else
        printf("%c", (ans[i][j] - 1) + 'A');
    }
    puts("");
  }
  return 0;
}
