#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
const int inf = 1e9;
const long long linf = 1e18;
const long double eps = 1e-6;
const long long mod1 = 1e9 + 7;
using namespace std;
int a[100][100], n, m;
int maxx = 0, best[100][100];
int ans[100][100];
bool ok1(int i, int j) {
  bool fl = 1;
  if (a[i + 1][j + 1]) fl = 0;
  if (a[i][j]) fl = 0;
  if (a[i][j + 2]) fl = 0;
  if (a[i][j + 1]) fl = 0;
  if (a[i + 2][j + 1]) fl = 0;
  return fl;
}
bool ok2(int i, int j) {
  bool fl = 1;
  if (a[i + 1][j + 1]) fl = 0;
  if (a[i + 1][j]) fl = 0;
  if (a[i + 1][j + 2]) fl = 0;
  if (a[i][j + 2]) fl = 0;
  if (a[i + 2][j + 2]) fl = 0;
  return fl;
}
bool ok3(int i, int j) {
  bool fl = 1;
  if (a[i + 1][j + 1]) fl = 0;
  if (a[i][j + 1]) fl = 0;
  if (a[i + 2][j + 1]) fl = 0;
  if (a[i + 2][j]) fl = 0;
  if (a[i + 2][j + 2]) fl = 0;
  return fl;
}
bool ok4(int i, int j) {
  bool fl = 1;
  if (a[i][j]) fl = 0;
  if (a[i + 1][j]) fl = 0;
  if (a[i + 2][j]) fl = 0;
  if (a[i + 1][j + 1]) fl = 0;
  if (a[i + 1][j + 2]) fl = 0;
  return fl;
}
void go(int i, int j, int k) {
  if (i == n - 1 && j == m) {
    if (k > maxx) {
      maxx = k - 1;
      if (maxx == ans[n][m] || maxx == ans[m][n]) {
        cout << maxx << "\n";
        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 << "\n";
        }
        exit(0);
      }
      for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j) best[i][j] = a[i][j];
    }
    return;
  }
  if (j == m) {
    j = 0;
    i++;
  }
  if (m - j < 3) {
    go(i, j + 1, k);
    return;
  }
  if (n - i < 3) {
    go(i, j + 1, k);
    return;
  }
  if (i > n / 2 && maxx / 2 > k) return;
  if (ok1(i, j)) {
    a[i][j] = k;
    a[i][j + 1] = k;
    a[i][j + 2] = k;
    a[i + 1][j + 1] = k;
    a[i + 2][j + 1] = k;
    go(i, j + 1, k + 1);
    a[i][j] = 0;
    a[i][j + 1] = 0;
    a[i][j + 2] = 0;
    a[i + 1][j + 1] = 0;
    a[i + 2][j + 1] = 0;
  }
  if (ok2(i, j)) {
    a[i + 1][j + 2] = k;
    a[i][j + 2] = k;
    a[i + 1][j + 1] = k;
    a[i + 2][j + 2] = k;
    a[i + 1][j] = k;
    go(i, j + 1, k + 1);
    a[i + 1][j + 2] = 0;
    a[i][j + 2] = 0;
    a[i + 1][j + 1] = 0;
    a[i + 2][j + 2] = 0;
    a[i + 1][j] = 0;
  }
  if (ok3(i, j)) {
    a[i + 2][j] = k;
    a[i + 2][j + 1] = k;
    a[i + 2][j + 2] = k;
    a[i + 1][j + 1] = k;
    a[i][j + 1] = k;
    go(i, j + 1, k + 1);
    a[i + 2][j] = 0;
    a[i + 2][j + 1] = 0;
    a[i + 2][j + 2] = 0;
    a[i + 1][j + 1] = 0;
    a[i][j + 1] = 0;
  }
  if (ok4(i, j)) {
    a[i][j] = k;
    a[i + 1][j] = k;
    a[i + 2][j] = k;
    a[i + 1][j + 1] = k;
    a[i + 1][j + 2] = k;
    go(i, j + 1, k + 1);
    a[i][j] = 0;
    a[i + 1][j] = 0;
    a[i + 2][j] = 0;
    a[i + 1][j + 1] = 0;
    a[i + 1][j + 2] = 0;
  }
  go(i, j + 1, k);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) ans[i][j] = -1;
  ans[7][9] = 10;
  ans[9][9] = 13;
  ans[9][8] = 12;
  ans[6][9] = 8;
  ans[5][9] = 7;
  ans[4][9] = 5;
  ans[8][8] = 10;
  go(0, 0, 1);
  cout << maxx << "\n";
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j)
      if (best[i][j] == 0)
        cout << '.';
      else
        cout << (char)(best[i][j] + 'A' - 1);
    cout << "\n";
  }
  return 0;
}
