#include <bits/stdc++.h>
using namespace std;
int n, m, cnt, ans, ted;
char a[9][9], ansi[9][9];
int sh[4][5][2] = {{{0, 0}, {-1, -1}, {0, -1}, {1, -1}, {0, 1}},
                   {{0, 0}, {-1, 1}, {0, 1}, {1, 1}, {0, -1}},
                   {{0, 0}, {-1, 1}, {-1, 0}, {-1, -1}, {1, 0}},
                   {{0, 0}, {1, 1}, {1, 0}, {1, -1}, {-1, 0}}};
bool empty(int x, int y, int type) {
  bool mark = true;
  for (int i = 0; i < 5; ++i)
    if (a[x + sh[type][i][0]][y + sh[type][i][1]] != '.') {
      mark = false;
      break;
    }
  return mark;
}
void mark(int x, int y, int type) {
  for (int i = 0; i < 5; ++i)
    a[x + sh[type][i][0]][y + sh[type][i][1]] = 'A' + cnt;
}
void clear(int x, int y, int type) {
  for (int i = 0; i < 5; ++i) a[x + sh[type][i][0]][y + sh[type][i][1]] = '.';
}
void bt(int x, int y) {
  if (ans >= cnt + (ted / 5)) return;
  for (int k = 0; k < 4; ++k) {
    if (empty(x, y, k)) {
      mark(x, y, k);
      cnt++;
      ted -= 4;
      if (y < m - 3)
        bt(x, y + 2);
      else if (x < n - 2)
        bt(x + 1, 1);
      else if (cnt > ans) {
        ans = cnt;
        for (int i = 0; i < n; ++i)
          for (int j = 0; j < m; ++j) ansi[i][j] = a[i][j];
      }
      ted += 4;
      cnt--;
      clear(x, y, k);
    }
  }
  if (y < m - 2) {
    ted -= 1;
    bt(x, y + 1);
    ted += 1;
  } else if (x < n - 2) {
    ted -= 1;
    bt(x + 1, 1);
    ted += 1;
  } else if (cnt > ans) {
    ans = cnt;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j) ansi[i][j] = a[i][j];
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  for (int i = 0; i < 9; ++i) {
    for (int j = 0; j < 9; ++j) {
      a[i][j] = '.';
    }
  }
  cin >> n >> m;
  ted = n * m;
  if (n < 3 || m < 3) {
    cout << 0 << '\n';
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) cout << '.';
      cout << '\n';
    }
    return 0;
  }
  bt(1, 1);
  cout << ans << '\n';
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) cout << ansi[i][j];
    cout << '\n';
  }
  return 0;
}
