#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cout.precision(20);
  map<int, map<int, string> > R;
  map<int, vector<int> > V;
  R[3][0] = "AAABCCCD.";
  R[3][1] = ".A.B.C.D.";
  R[3][2] = ".ABBBCDDD";
  V[3] = {0, 0, 0, 1, 1, 2, 2, 3, 3, 4};
  R[4][0] = "AAAC..EEE";
  R[4][1] = ".ABCCCDE.";
  R[4][2] = ".ABCDDDE.";
  R[4][3] = ".BBB..D..";
  V[4] = {0, 0, 0, 1, 2, 2, 3, 4, 4, 5};
  R[5][0] = "AAA.CFFF.";
  R[5][1] = ".ACCCEF..";
  R[5][2] = "BA.DCEFG.";
  R[5][3] = "BBBDEEEG.";
  R[5][4] = "B.DDD.GGG";
  V[5] = {0, 0, 0, 2, 2, 4, 4, 5, 6, 7};
  R[6][0] = "AAA.DF...";
  R[6][1] = ".ADDDFFFH";
  R[6][2] = ".A.CDFHHH";
  R[6][3] = "BCCCEGGGH";
  R[6][4] = "BBBCE.G..";
  R[6][5] = "B..EEEG..";
  V[6] = {0, 0, 0, 2, 3, 4, 5, 5, 7, 8};
  R[7][0] = "AAADFFF.I";
  R[7][1] = ".A.D.FIII";
  R[7][2] = "BADDDFG.I";
  R[7][3] = "BBB.GGG..";
  R[7][4] = "BCEEEHG.J";
  R[7][5] = ".C.E.HJJJ";
  R[7][6] = "CCCEHHH.J";
  V[7] = {0, 0, 0, 3, 3, 5, 5, 8, 8, 10};
  R[8][0] = "AAAE..H..";
  R[8][1] = ".A.EHHHJ.";
  R[8][2] = "BAEEEFHJ.";
  R[8][3] = "BBBFFFJJJ";
  R[8][4] = "BDDD.FI..";
  R[8][5] = ".CDGIIIK.";
  R[8][6] = ".CDGGGIK.";
  R[8][7] = "CCCG..KKK";
  V[8] = {0, 0, 0, 3, 4, 5, 7, 9, 9, 11};
  R[9][0] = "AAA..G...";
  R[9][1] = ".A.GGGKKK";
  R[9][2] = "BAEEEGJK.";
  R[9][3] = "BBBEH.JK.";
  R[9][4] = "B.CEHJJJL";
  R[9][5] = "CCCHHHLLL";
  R[9][6] = "D.CFIIIML";
  R[9][7] = "DDDF.I.M.";
  R[9][8] = "D.FFFIMMM";
  V[9] = {0, 0, 0, 4, 4, 6, 8, 9, 10, 13};
  int n, m;
  cin >> n >> m;
  if (min(n, m) < 3) {
    cout << 0 << endl;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        cout << '.';
      }
      cout << endl;
    }
    return 0;
  }
  if (min(n, m) == 6 && max(n, m) == 7) {
    vector<string> E(7);
    E[0] = "AAAD..";
    E[1] = ".A.D..";
    E[2] = "BADDDF";
    E[3] = "BBBFFF";
    E[4] = "BCEEEF";
    E[5] = ".C.E..";
    E[6] = "CCCE..";
    cout << 6 << endl;
    if (n == 7) {
      for (int i = 0; i < n; ++i) cout << E[i] << endl;
    } else {
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
          cout << E[j][i];
        }
        cout << endl;
      }
    }
    return 0;
  }
  if (n == 8 && m == 8) {
    cout << 10 << endl;
    cout << "AAAE.III" << endl;
    cout << ".ADEEEI." << endl;
    cout << ".ADEF.IJ" << endl;
    cout << "BDDDFJJJ" << endl;
    cout << "BBBFFFHJ" << endl;
    cout << "B.CGHHH." << endl;
    cout << "CCCGGGH." << endl;
    cout << "..CG...." << endl;
    return 0;
  }
  if (min(n, m) == 8 and max(m, n) == 9) {
    cout << 12 << endl;
    vector<string> E(8);
    E[0] = "A.EEE.JJJ";
    E[1] = "AAAEHHHJ.";
    E[2] = "AB.EFHKJ.";
    E[3] = ".BFFFHKKK";
    E[4] = "BBBDFIK..";
    E[5] = "CDDDGIIIL";
    E[6] = "CCCDGILLL";
    E[7] = "C..GGG..L";
    if (n == 8) {
      for (int i = 0; i < n; ++i) cout << E[i] << endl;
    } else {
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
          cout << E[j][i];
        }
        cout << endl;
      }
    }
    return 0;
  }
  if (V[n][m] < V[m][n]) {
    cout << V[m][n] << endl;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (R[m][j][i] < 'A' + V[m][n]) {
          cout << R[m][j][i];
        } else {
          cout << '.';
        }
      }
      cout << endl;
    }
  } else {
    cout << V[n][m] << endl;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if (R[n][i][j] < 'A' + V[n][m]) {
          cout << R[n][i][j];
        } else {
          cout << '.';
        }
      }
      cout << endl;
    }
  }
  return 0;
}
