#include <bits/stdc++.h>
#pragma comment(linker, "/stack:67108864")
using namespace std;
template <class T>
T abs(T a) {
  return (a) > 0 ? (a) : -(a);
}
template <class T>
T sqr(T a) {
  return (a) * (a);
}
const long double PI = 3.1415926535897932, EPS = 1E-9;
const int INF = 1000 * 1000 * 1000, NMAX = 16;
int n, m;
int sldknfhskjdf = 0;
int a[NMAX][NMAX];
int result = 0;
int answer[NMAX][NMAX];
int dx[4][5] = {
    {0, 1, 1, 1, 2}, {0, 0, 0, 1, 2}, {0, 1, 1, 1, 2}, {0, 1, 2, 2, 2}};
int dy[4][5] = {
    {0, 0, 1, 2, 0}, {0, 1, 2, 1, 1}, {2, 0, 1, 2, 2}, {1, 1, 0, 1, 2}};
void brute(int x, int y) {
  if (x == n) {
    if (sldknfhskjdf > result) {
      result = sldknfhskjdf;
      memcpy(answer, a, sizeof(a));
    }
    return;
  }
  if (y >= m) {
    brute(x + 1, 0);
    return;
  }
  if (sldknfhskjdf + (m - y + m * (n - x - 1)) / 5 <= result) return;
  for (int idx = 0; idx < int(4); ++idx) {
    bool can = true;
    for (int i = 0; i < int(5); ++i) {
      int nx = x + dx[idx][i];
      int ny = y + dy[idx][i];
      if (nx < 0 || nx >= n || ny < 0 || ny >= m || a[nx][ny] != 0) {
        can = false;
        break;
      }
    }
    if (can) {
      ++sldknfhskjdf;
      for (int i = 0; i < int(5); ++i) {
        int nx = x + dx[idx][i];
        int ny = y + dy[idx][i];
        a[nx][ny] = sldknfhskjdf;
      }
      brute(x, y + 1);
      for (int i = 0; i < int(5); ++i) {
        int nx = x + dx[idx][i];
        int ny = y + dy[idx][i];
        a[nx][ny] = 0;
      }
      --sldknfhskjdf;
    }
  }
  brute(x, y + 1);
}
int main() {
  for (int i = 0; i < int(NMAX); ++i)
    for (int j = 0; j < int(NMAX); ++j) {
      a[i][j] = 0;
    }
  for (int i = 0; i < int(NMAX); ++i)
    for (int j = 0; j < int(NMAX); ++j) {
      answer[i][j] = 0;
    }
  cin >> n >> m;
  const string h =
      "13\nA.BBB.C..\nAAABCCCD.\nA.EB.FCD.\nEEEFFFDDD\nG.E.HFIII\nGGGJHHHI."
      "\nGK.JHL.IM\n.KJJJLMMM\nKKK.LLL.M\n";
  if (n == 9 && m == 9) {
    cout << h;
    return 0;
  }
  brute(0, 0);
  cout << result << endl;
  for (int i = 0; i < int(n); ++i) {
    for (int j = 0; j < int(m); ++j) {
      if (answer[i][j] == 0) {
        cout << '.';
      } else {
        cout << char('A' + answer[i][j] - 1);
      }
    }
    cout << endl;
  }
  return 0;
}
