#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
inline int read() {
  int X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) {
    w |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return w ? -X : X;
}
int n, m;
int dx[4][5] = {
    {2, 1, 0, 0, 0}, {1, 0, 0, 0, -1}, {0, 0, 0, -1, -2}, {1, 0, 0, 0, -1}};
int dy[4][5] = {
    {0, 0, -1, 0, 1}, {0, 0, 1, 2, 0}, {-1, 0, 1, 0, 0}, {0, -2, -1, 0, 0}};
char maze[9][9];
int ans = -1;
char as[9][9];
bool check(int x, int y, int dir, char c) {
  for (int i = 0; i < 5; i++) {
    int nx = x + dx[dir][i];
    int ny = y + dy[dir][i];
    if (nx < 0 or nx >= n or ny < 0 or ny >= m) {
      return 0;
    }
    if (!(c == '.' or maze[nx][ny] == '.')) {
      return 0;
    }
  }
  for (int i = 0; i < 5; i++) {
    int nx = x + dx[dir][i];
    int ny = y + dy[dir][i];
    maze[nx][ny] = c;
  }
  return 1;
}
void dfs(int x, int y, char c) {
  if (x == n) {
    if (c - 'A' > ans) {
      ans = c - 'A';
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          as[i][j] = maze[i][j];
        }
      }
    }
    return;
  }
  if ((n - x) * m / 5 + c - 'A' <= ans) {
    return;
  }
  if (y == m) {
    dfs(x + 1, 0, c);
    return;
  }
  for (int i = 0; i < 4; i++) {
    if (check(x, y, i, c)) {
      dfs(x, y + 1, c + 1);
      check(x, y, i, '.');
    }
  }
  dfs(x, y + 1, c);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      maze[i][j] = '.';
    }
  }
  dfs(0, 0, 'A');
  printf("%d\n", ans);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      printf("%c", as[i][j]);
    }
    printf("\n");
  }
  return 0;
}
