#include <bits/stdc++.h>
using namespace std;
namespace IO {
const int MAXIOSIZE = 1 << 24 | 1;
unsigned char buf[MAXIOSIZE], *p1, *p2;
template <typename T>
void read(T& x) {
  x = 0;
  char ch =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2)
           ? EOF
           : *p1++);
  bool flg = false;
  for (; ch < '0' || '9' < ch;
       ch = (p1 == p2 &&
                     (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2)
                 ? EOF
                 : *p1++))
    if (ch == '-') flg |= true;
  for (; '0' <= ch && ch <= '9';
       ch = (p1 == p2 &&
                     (p2 = (p1 = buf) + fread(buf, 1, 1 << 24, stdin), p1 == p2)
                 ? EOF
                 : *p1++))
    x = x * 10 + ch - '0';
  flg ? x = -x : 0;
}
template <typename T>
void out(const T& x) {
  if (x > 9) out(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
inline void write(const T& x, const char& ed = ' ') {
  if (x < 0)
    putchar('-'), out(-x);
  else
    out(x);
  putchar(ed);
}
}  // namespace IO
const int MAXN = 10 + 10;
const int MAXSTATUS = (1 << 9) + 10;
int n, m, f[MAXN][MAXSTATUS][MAXSTATUS];
pair<vector<pair<int, int> >, pair<int, int> > pre[MAXN][MAXSTATUS][MAXSTATUS];
const int dx[4][5] = {{-1, -1, -1, 0, 1},
                      {-1, 0, 0, 0, 1},
                      {-1, 0, 1, 1, 1},
                      {-1, 0, 0, 0, 1}},
          dy[4][5] = {{-1, 0, 1, 0, 0},
                      {-1, -1, 0, 1, -1},
                      {0, 0, -1, 0, 1},
                      {1, -1, 0, 1, 1}};
vector<pair<int, int> > curTrans;
int preIdx, preVal, preS1, preS2;
char fans[MAXN][MAXN];
void dfs(int S1, int S2, int S3, int i) {
  if (i == m - 1) {
    if (f[preIdx + 1][S2][S3] < preVal + (int)curTrans.size()) {
      f[preIdx + 1][S2][S3] = preVal + (int)curTrans.size();
      pre[preIdx + 1][S2][S3].first = curTrans;
      pre[preIdx + 1][S2][S3].second.first = preS1,
                   pre[preIdx + 1][S2][S3].second.second = preS2;
    }
    return;
  }
  for (int way = (0), wayend = (4); way < wayend; ++way) {
    bool ok = true;
    for (int j = (0), jend = (5); j < jend; ++j) {
      if (dx[way][j] == -1) {
        if ((((S1) >> (i + dy[way][j])) & 1)) ok = false;
      } else if (dx[way][j] == 0) {
        if ((((S2) >> (i + dy[way][j])) & 1)) ok = false;
      } else if ((((S3) >> (i + dy[way][j])) & 1)) {
        ok = false;
      }
    }
    if (ok) {
      for (int j = (0), jend = (5); j < jend; ++j) {
        if (dx[way][j] == -1)
          S1 |= 1 << (i + dy[way][j]);
        else if (dx[way][j] == 0)
          S2 |= 1 << (i + dy[way][j]);
        else
          S3 |= 1 << (i + dy[way][j]);
      }
      curTrans.push_back(make_pair(i, way));
      dfs(S1, S2, S3, i + 1);
      curTrans.pop_back();
      for (int j = (0), jend = (5); j < jend; ++j) {
        if (dx[way][j] == -1)
          S1 ^= 1 << (i + dy[way][j]);
        else if (dx[way][j] == 0)
          S2 ^= 1 << (i + dy[way][j]);
        else
          S3 ^= 1 << (i + dy[way][j]);
      }
    }
  }
  dfs(S1, S2, S3, i + 1);
}
int main() {
  IO::read(n), IO::read(m);
  if (min(n, m) <= 2) {
    puts("0");
    for (int i = (0), iend = (n); i < iend; ++i) {
      for (int j = (0), jend = (m); j < jend; ++j) putchar('.');
      puts("");
    }
    return 0;
  }
  memset(f, -1, sizeof f);
  f[0][0][0] = 0;
  for (int i = (0), iend = (n - 2); i < iend; ++i) {
    for (int S1 = (0), S1end = (1 << m); S1 < S1end; ++S1)
      for (int S2 = (0), S2end = (1 << m); S2 < S2end; ++S2)
        if (f[i][S1][S2] != -1) {
          preIdx = i, curTrans.clear(), preVal = f[i][S1][S2], preS1 = S1,
          preS2 = S2;
          dfs(S1, S2, 0, 1);
        }
  }
  int ans = -1, aS1, aS2;
  for (int S1 = (0), S1end = (1 << m); S1 < S1end; ++S1)
    for (int S2 = (0), S2end = (1 << m); S2 < S2end; ++S2) {
      if (ans < f[n - 2][S1][S2]) ans = f[n - 2][S1][S2], aS1 = S1, aS2 = S2;
    }
  IO::write(ans, '\n');
  int cnt = 0;
  int ci = n - 2;
  for (int i = (0), iend = (n); i < iend; ++i)
    for (int j = (0), jend = (m); j < jend; ++j) fans[i][j] = '.';
  while (ci >= 1) {
    for (pair<int, int> cur : pre[ci][aS1][aS2].first) {
      int x = ci, y = cur.first;
      for (int jj = (0), jjend = (5); jj < jjend; ++jj)
        fans[x + dx[cur.second][jj]][y + dy[cur.second][jj]] = 'A' + cnt;
      cnt++;
    }
    auto tmp = pre[ci][aS1][aS2].second;
    aS1 = tmp.first, aS2 = tmp.second;
    ci--;
  }
  for (int i = (0), iend = (n); i < iend; ++i) puts(fans[i]);
  return 0;
}
