#include <bits/stdc++.h>
using namespace std;
int dx[4][4] = {{-1, +1, 0, 0}, {-1, +1, 0, 0}, {0, 0, +1, +2}, {0, 0, -1, -2}};
int dy[4][4] = {{0, 0, +1, +2}, {0, 0, -1, -2}, {+1, -1, 0, 0}, {+1, -1, 0, 0}};
int vis[9][9], out[9][9];
int x, y, maxi;
void solve(int posx, int posy, int any) {
  if (any + y * (x - posx) / 5 <= maxi) return;
  if (posx == x) {
    if (any > maxi) {
      maxi = any;
      for (int i = 0; i < x; ++i)
        for (int j = 0; j < y; ++j) out[i][j] = vis[i][j];
    }
    return;
  }
  solve(posx + (posy == y - 1), (posy + 1) % y, any);
  if (vis[posx][posy] == 0)
    for (int i = 0; i < 4; ++i) {
      bool puedo = true;
      for (int j = 0; j < 4; ++j) {
        int xnew = posx + dx[i][j];
        int ynew = posy + dy[i][j];
        if (xnew < 0 || xnew >= x || ynew < 0 || ynew >= y || vis[xnew][ynew]) {
          puedo = false;
          break;
        }
      }
      if (puedo) {
        for (int j = 0; j < 4; ++j) {
          int xnew = posx + dx[i][j];
          int ynew = posy + dy[i][j];
          vis[xnew][ynew] = any;
        }
        vis[posx][posy] = any;
        solve(posx + (posy == y - 1), (posy + 1) % y, any + 1);
        for (int j = 0; j < 4; ++j) {
          int xnew = posx + dx[i][j];
          int ynew = posy + dy[i][j];
          vis[xnew][ynew] = 0;
        }
        vis[posx][posy] = 0;
      }
    }
}
int main() {
  cin >> x >> y;
  solve(0, 0, 1);
  cout << maxi - 1 << endl;
  for (int i = 0; i < x; ++i) {
    for (int j = 0; j < y; ++j)
      if (out[i][j] == 0)
        cout << ".";
      else
        cout << char(out[i][j] - 1 + 'A');
    cout << endl;
  }
  return 0;
}
