#include <bits/stdc++.h>
int n, m;
int check[15][15];
int cnt, tlimit;
int print[15][15];
void dfs(int x, int y, int sw, int dep) {
  int i, j;
  tlimit++;
  if (tlimit >= 7000000) return;
  if (sw == 1)
    check[x][y] = check[x + 1][y] = check[x + 2][y] = check[x][y - 1] =
        check[x][y + 1] = dep;
  if (sw == 2)
    check[x][y] = check[x + 1][y] = check[x - 1][y] = check[x][y + 1] =
        check[x][y + 2] = dep;
  if (sw == 3)
    check[x][y] = check[x - 1][y] = check[x - 2][y] = check[x][y - 1] =
        check[x][y + 1] = dep;
  if (sw == 4)
    check[x][y] = check[x + 1][y] = check[x - 1][y] = check[x][y - 1] =
        check[x][y - 2] = dep;
  if (dep > cnt) {
    cnt = dep;
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        print[i][j] = check[i][j];
      }
    }
  }
  for (i = x; i <= n; i++) {
    for (j = (i == x) ? y : 1; j <= m; j++) {
      if (j > m) break;
      if (check[i][j]) continue;
      if (tlimit >= 7000000) return;
      if (j >= 2 && j < m && i <= n - 2) {
        if (check[i][j] + check[i + 1][j] + check[i + 2][j] + check[i][j - 1] +
                check[i][j + 1] ==
            0)
          dfs(i, j, 1, dep + 1);
      }
      if (tlimit >= 7000000) return;
      if (i >= 2 && i < n && j <= m - 2) {
        if (check[i][j] + check[i + 1][j] + check[i - 1][j] + check[i][j + 1] +
                check[i][j + 2] ==
            0)
          dfs(i, j, 2, dep + 1);
      }
      if (tlimit >= 7000000) return;
      if (j >= 2 && j < m && i >= 3) {
        if (check[i][j] + check[i - 1][j] + check[i - 2][j] + check[i][j - 1] +
                check[i][j + 1] ==
            0)
          dfs(i, j, 3, dep + 1);
      }
      if (tlimit >= 7000000) return;
      if (i >= 2 && i < n && j >= 3) {
        if (check[i][j] + check[i + 1][j] + check[i - 1][j] + check[i][j - 1] +
                check[i][j - 2] ==
            0)
          dfs(i, j, 4, dep + 1);
      }
      if (tlimit >= 7000000) return;
    }
  }
  if (sw == 1)
    check[x][y] = check[x + 1][y] = check[x + 2][y] = check[x][y - 1] =
        check[x][y + 1] = 0;
  if (sw == 2)
    check[x][y] = check[x + 1][y] = check[x - 1][y] = check[x][y + 1] =
        check[x][y + 2] = 0;
  if (sw == 3)
    check[x][y] = check[x - 1][y] = check[x - 2][y] = check[x][y - 1] =
        check[x][y + 1] = 0;
  if (sw == 4)
    check[x][y] = check[x + 1][y] = check[x - 1][y] = check[x][y - 1] =
        check[x][y - 2] = 0;
}
int main(void) {
  int i, j;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (j >= 2 && j < m && i <= n - 2) dfs(i, j, 1, 1);
      if (tlimit >= 7000000) break;
      if (i >= 2 && i < n && j <= m - 2) dfs(i, j, 2, 1);
      if (tlimit >= 7000000) break;
      if (j >= 2 && j < m && i >= 3) dfs(i, j, 3, 1);
      if (tlimit >= 7000000) break;
      if (i >= 2 && i < n && j >= 3) dfs(i, j, 4, 1);
      if (tlimit >= 7000000) break;
    }
  }
  printf("%d\n", cnt);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (print[i][j] == 0)
        printf(".");
      else
        printf("%c", (print[i][j] - 1) + 'A');
    }
    printf("\n");
  }
  return false;
}
