#include <bits/stdc++.h>
using namespace std;
string biao[] = {
    "0\n.\n",
    "0\n..\n",
    "0\n...\n",
    "0\n....\n",
    "0\n.....\n",
    "0\n......\n",
    "0\n.......\n",
    "0\n........\n",
    "0\n.........\n",
    "0\n.\n.\n",
    "0\n..\n..\n",
    "0\n...\n...\n",
    "0\n....\n....\n",
    "0\n.....\n.....\n",
    "0\n......\n......\n",
    "0\n.......\n.......\n",
    "0\n........\n........\n",
    "0\n.........\n.........\n",
    "0\n.\n.\n.\n",
    "0\n..\n..\n..\n",
    "1\nAAA\n.A.\n.A.\n",
    "1\nAAA.\n.A..\n.A..\n",
    "2\nAAA.B\n.ABBB\n.A..B\n",
    "2\nAAABBB\n.A..B.\n.A..B.\n",
    "3\nAAACBBB\n.A.C.B.\n.ACCCB.\n",
    "3\nAAABBB.C\n.A..BCCC\n.A..B..C\n",
    "4\nAAADBBB.C\n.A.D.BCCC\n.ADDDB..C\n",
    "0\n.\n.\n.\n.\n",
    "0\n..\n..\n..\n..\n",
    "1\nAAA\n.A.\n.A.\n...\n",
    "2\nAAA.\n.AB.\n.AB.\n.BBB\n",
    "2\nAAA..\n.ABBB\n.A.B.\n...B.\n",
    "3\nAAABBB\n.AC.B.\n.AC.B.\n.CCC..\n",
    "4\nAAABBB.\n.AC.BD.\n.AC.BD.\n.CCCDDD\n",
    "4\nAAABBB..\n.AD.BCCC\n.AD.B.C.\n.DDD..C.\n",
    "5\nAAABBBCCC\n.AD.BE.C.\n.AD.BE.C.\n.DDDEEE..\n",
    "0\n.\n.\n.\n.\n.\n",
    "0\n..\n..\n..\n..\n..\n",
    "2\nAAA\n.A.\nBA.\nBBB\nB..\n",
    "2\nAAA.\n.A..\nBA..\nBBB.\nB...\n",
    "4\nAAA.B\n.ABBB\nCA.DB\nCCCD.\nC.DDD\n",
    "4\nAAABBB\n.A..B.\nCA.DB.\nCCCDDD\nC..D..\n",
    "5\nAAABBB.\n.A..BD.\nCA.EBD.\nCCCEDDD\nC.EEE..\n",
    "6\nAAABBB.C\n.A..BCCC\nDA.EB.FC\nDDDEEEF.\nD..E.FFF\n",
    "7\nAAA.BBB.D\n.ACCCBDDD\nEA.CFB.GD\nEEECFFFG.\nE...F.GGG\n",
    "0\n.\n.\n.\n.\n.\n.\n",
    "0\n..\n..\n..\n..\n..\n..\n",
    "2\nAAA\n.A.\nBA.\nBBB\nB..\n...\n",
    "3\nAAA.\n.A..\nBA..\nBBBC\nBCCC\n...C\n",
    "4\nAAA..\n.ABBB\nCA.B.\nCCCBD\nC.DDD\n....D\n",
    "5\nAAABBB\n.A..B.\n.AC.B.\n.ECCCD\n.ECDDD\nEEE..D\n",
    "6\nAAA.BBB\n.AC..B.\n.ACCCB.\nE.CFDDD\nEEEF.D.\nE.FFFD.\n",
    "7\nAAABBB..\n.AD.BCCC\n.AD.B.C.\nEDDDG.CF\nEEE.GFFF\nE..GGG.F\n",
    "8\nAAABBBCCC\n.AD.B..C.\n.AD.BE.C.\nFDDDHEEEG\nFFF.HEGGG\nF..HHH..G\n",
    "0\n.\n.\n.\n.\n.\n.\n.\n",
    "0\n..\n..\n..\n..\n..\n..\n..\n",
    "3\nAAA\n.A.\nBA.\nBBB\nB.C\nCCC\n..C\n",
    "4\nAAA.\n.AB.\n.AB.\nCBBB\nCCCD\nCDDD\n...D\n",
    "5\nAAA..\n.ABBB\nCA.B.\nCCCB.\nCEDDD\n.E.D.\nEEED.\n",
    "6\nAAABBB\n.A..B.\nCA.DB.\nCCCDDD\nCE.DF.\n.EEEF.\n.E.FFF\n",
    "8\nAAAC..B\n.A.CBBB\nDACCCEB\nDDDEEE.\nDHFFFEG\n.H.FGGG\nHHHF..G\n",
    "9\nAAA.BBB.\n.ACCCBE.\n.ADC.BE.\nDDDCFEEE\nG.DIFFFH\nGGGIFHHH\nG.III..H\n",
    "10\nAAA.BBB..\n.ACCCBDDD\n.AECFB.D.\nEEECFFFDG\nH.EJFIGGG\nHHHJ.IIIG\nH."
    "JJJI...\n",
    "0\n.\n.\n.\n.\n.\n.\n.\n.\n",
    "0\n..\n..\n..\n..\n..\n..\n..\n..\n",
    "3\nAAA\n.A.\nBA.\nBBB\nB..\nCCC\n.C.\n.C.\n",
    "4\nAAA.\n.A..\nBA..\nBBB.\nBCCC\n.DC.\n.DC.\nDDD.\n",
    "6\nAAA..\n.ABBB\nCA.B.\nCCCBD\nC.DDD\nEEEFD\n.E.F.\n.EFFF\n",
    "7\nAAABBB\n.A..B.\nCA.DB.\nCCCDDD\nC.ED..\n.GEEEF\n.GEFFF\nGGG..F\n",
    "9\nAAA.BBB\n.ACCCB.\nDA.CEB.\nDDDCEEE\nDFFFE.G\n.IFHGGG\n.IFHHHG\nIIIH..."
    "\n",
    "10\nAAABBB.C\n.A..BCCC\nDA.EB.FC\nDDDEEEF.\nD..EHFFF\nGGGJHHHI\n.G."
    "JHIII\n.GJJJ..I\n",
    "12\nAAA.BBB.D\n.ACCCBDDD\nEA.CFB.GD\nEEECFFFG.\nE.."
    "HFIGGG\nJHHHLIIIK\nJJJHLIKKK\nJ..LLL..K\n",
    "0\n.\n.\n.\n.\n.\n.\n.\n.\n.\n",
    "0\n..\n..\n..\n..\n..\n..\n..\n..\n..\n",
    "4\nAAA\n.A.\nBA.\nBBB\nB.C\nCCC\nD.C\nDDD\nD..\n",
    "5\nAAA.\n.A..\nBA..\nBBBC\nBCCC\nD..C\nDDDE\nDEEE\n...E\n",
    "7\nAAA..\n.ABBB\nCA.B.\nCCCBD\nCEDDD\n.EEED\nGEFFF\nGGGF.\nG..F.\n",
    "8\nAAABBB\n.A..B.\nCA.DB.\nCCCDDD\nC.ED..\nEEEFFF\nG.EHF.\nGGGHF.\nG.HHH."
    "\n",
    "10\nAAABBB.\n.A..BD.\nCA.EBD.\nCCCEDDD\nCFEEE.G\n.FFFGGG\nIFHHHJG\nIIIH.J."
    "\nI..HJJJ\n",
    "12\nAAAC.BBB\n.ADCCCB.\n.ADCE.B.\nFDDDEEEG\nFFFHEGGG\nFHHHIIIG\nJJJHKIL."
    "\n.JKKKIL.\n.J..KLLL\n",
    "13\nAAABBB..C\n.A..BDCCC\nEA.GBDDDC\nEEEG.DFFF\nEHGGG.IF.\n.HHHIIIF."
    "\nKHJJJMI.L\nKKKJ.MLLL\nK..JMMM.L\n"};
void solve() {
  int n, m;
  cin >> n >> m;
  int i = 9 * n + m - 10;
  cout << biao[i] << '\n';
}
int main() {
  solve();
  return 0;
}
