#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 15;
const int pos[4][3][3] = {{{1, 1, 1}, {0, 1, 0}, {0, 1, 0}},
                          {{0, 0, 1}, {1, 1, 1}, {0, 0, 1}},
                          {{0, 1, 0}, {0, 1, 0}, {1, 1, 1}},
                          {{1, 0, 0}, {1, 1, 1}, {1, 0, 0}}};
int n, m, c[MAX_N][MAX_N], a[MAX_N][MAX_N], best = 0;
inline bool check(int x, int y, int cnt) {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (pos[cnt][i][j])
        if (c[x + i][y + j]) return 0;
    }
  }
  return 1;
}
inline void out_normal() {
  cout << best << endl;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 0)
        cout << ".";
      else
        cout << char(a[i][j] + 'A' - 1);
    }
    cout << endl;
  }
  exit(0);
}
inline void out_special() {
  cout << best << endl;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (a[j][i] == 0)
        cout << ".";
      else
        cout << char(a[j][i] + 'A' - 1);
    }
    cout << endl;
  }
  exit(0);
}
inline void dfs(int x, int y, int sum) {
  if ((n - x) * m - y <= (best - sum) * 6.5) return;
  if (y + 2 >= m) {
    dfs(x + 1, 0, sum);
    return;
  }
  if (x + 2 >= n) {
    if (sum > best) {
      best = sum;
      memcpy(a, c, sizeof(c));
    }
    return;
  }
  for (int cnt = 0; cnt < 4; cnt++)
    if (check(x, y, cnt)) {
      for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
          if (pos[cnt][i][j]) c[x + i][y + j] = sum + 1;
      dfs(x, y + 1, sum + 1);
      for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
          if (pos[cnt][i][j]) c[x + i][y + j] = 0;
    }
  dfs(x, y + 1, sum);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  if (n < 3 || m < 3) out_normal();
  bool f = 0;
  if (n > m) {
    f = 1;
    swap(n, m);
  }
  dfs(0, 0, 0);
  if (f)
    out_special();
  else
    out_normal();
  return 0;
}
