#include <bits/stdc++.h>
using namespace std;
char ans[10][10];
long long dp[10][513][513];
pair<pair<long long, long long>, long long> recur[10][513][513];
long long insert[10][513][513];
long long curr, nexty, n, m;
long long setBit(long long num, long long i) { return num | (1 << i); }
long long unsetBit(long long num, long long i) {
  num ^= 1 << i;
  return num;
}
bool checkBit(long long num, long long i) {
  if (num & 1 << i)
    return true;
  else
    return false;
}
string binary(long long num, long long m) {
  string ans;
  for (long long i = 0; i < m; i++) {
    if (checkBit(num, i))
      ans = "1" + ans;
    else
      ans = "0" + ans;
  }
  return ans;
}
void backtrack(long long j, long long mask1, long long mask2, long long mask3,
               long long newT, long long ogmask1, long long ogmask2,
               long long ts) {
  if (j == m) {
    if (dp[curr][ogmask1][ogmask2] + newT > dp[nexty][mask2][mask3]) {
      dp[nexty][mask2][mask3] = dp[curr][ogmask1][ogmask2] + newT;
      recur[nexty][mask2][mask3] = pair<pair<long long, long long>, long long>(
          pair<long long, long long>(ogmask1, ogmask2), mask1);
      insert[nexty][mask2][mask3] = ts;
    }
    return;
  }
  if (j > 1) {
    if (!checkBit(mask1, j) && !checkBit(mask1, j - 1) &&
        !checkBit(mask1, j - 2) && !checkBit(mask2, j - 1) &&
        !checkBit(mask3, j - 1)) {
      long long tempmask1 = setBit(mask1, j);
      tempmask1 = setBit(tempmask1, j - 1);
      tempmask1 = setBit(tempmask1, j - 2);
      backtrack(j + 1, tempmask1, setBit(mask2, j - 1), setBit(mask3, j - 1),
                newT + 1, ogmask1, ogmask2, ts);
    }
  }
  if (j > 1) {
    if (!checkBit(mask1, j - 1) && !checkBit(mask2, j - 1) &&
        !checkBit(mask3, j - 1) && !checkBit(mask3, j) &&
        !checkBit(mask3, j - 2)) {
      long long newmask = setBit(mask3, j - 1);
      newmask = setBit(newmask, j);
      newmask = setBit(newmask, j - 2);
      backtrack(j + 1, setBit(mask1, j - 1), setBit(mask2, j - 1), newmask,
                newT + 1, ogmask1, ogmask2, setBit(ts, 2 * (j - 1) + 1));
    }
  }
  if (j > 1) {
    if (!checkBit(mask1, j - 2) && !checkBit(mask3, j - 2) &&
        !checkBit(mask2, j) && !checkBit(mask2, j - 1) &&
        !checkBit(mask2, j - 2)) {
      long long newmask = setBit(mask2, j);
      newmask = setBit(newmask, j - 1);
      newmask = setBit(newmask, j - 2);
      backtrack(j + 1, setBit(mask1, j - 2), newmask, setBit(mask3, j - 2),
                newT + 1, ogmask1, ogmask2, setBit(ts, 2 * (j - 2)));
    }
  }
  if (j > 1) {
    if (!checkBit(mask1, j) && !checkBit(mask3, j) && !checkBit(mask2, j) &&
        !checkBit(mask2, j - 1) && !checkBit(mask2, j - 2)) {
      long long newmask = setBit(mask2, j);
      newmask = setBit(newmask, j - 1);
      newmask = setBit(newmask, j - 2);
      ts = setBit(ts, 2 * j);
      ts = setBit(ts, 2 * j + 1);
      backtrack(j + 1, setBit(mask1, j), newmask, setBit(mask3, j), newT + 1,
                ogmask1, ogmask2, ts);
      ts = unsetBit(ts, 2 * j);
      ts = unsetBit(ts, 2 * j + 1);
    }
  }
  backtrack(j + 1, mask1, mask2, mask3, newT, ogmask1, ogmask2, ts);
}
char currchar = 'A';
void recursion(long long i, long long mask1, long long mask2) {
  if (i == 0) return;
  recursion(i - 1, recur[i][mask1][mask2].first.first,
            recur[i][mask1][mask2].first.second);
  long long mask = insert[i][mask1][mask2];
  for (long long j = 0; j < m; j++) {
    if (!checkBit(recur[i][mask1][mask2].second, j)) {
      ans[i][j] = '.';
      continue;
    }
    if (checkBit(mask, j * 2) && checkBit(mask, j * 2 + 1)) {
      ans[i][j] = ans[i + 1][j] = ans[i + 2][j] = ans[i + 1][j - 1] =
          ans[i + 1][j - 2] = currchar;
      currchar++;
    } else if (checkBit(mask, j * 2) && !checkBit(mask, j * 2 + 1)) {
      ans[i][j] = ans[i + 1][j + 2] = ans[i + 2][j] = ans[i + 1][j + 1] =
          ans[i + 1][j] = currchar;
      currchar++;
    } else if (!checkBit(mask, j * 2) && checkBit(mask, j * 2 + 1)) {
      ans[i][j] = ans[i + 1][j] = ans[i + 2][j + 1] = ans[i + 2][j - 1] =
          ans[i + 2][j] = currchar;
      currchar++;
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  memset(dp, -1, sizeof(dp));
  memset(ans, 0, sizeof(ans));
  dp[0][0][0] = 0;
  for (long long i = 0; i < n; i++) {
    curr = i;
    nexty = i + 1;
    for (long long mask1 = 0; mask1 < (1 << m); mask1++) {
      for (long long mask2 = 0; mask2 < (1 << m); mask2++) {
        if (dp[curr][mask1][mask2] != -1) {
          backtrack(0, mask1, mask2, 0, 0, mask1, mask2, 0);
        }
      }
    }
  }
  cout << dp[n][0][0] << "\n";
  recursion(n, 0, 0);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < m; j++) {
      if (ans[i][j] == 0 && ans[i][j - 1] == 0 && ans[i][j + 1] == 0 &&
          ans[i + 1][j] == 0 && ans[i + 2][j] == 0) {
        ans[i][j] = ans[i][j - 1] = ans[i][j + 1] = ans[i + 1][j] =
            ans[i + 2][j] = currchar;
        currchar++;
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j < m; j++) cout << ans[i][j];
    cout << "\n";
  }
}
