#include <bits/stdc++.h>
using namespace std;
const double PI = 2.0 * acos(0.0);
const double E = exp(1);
char box[100][100];
int row, col, letters[50];
int call(int x, int y) {
  memset(letters, 0, sizeof(letters));
  letters[box[x][y] - 'a'] = 1;
  if (y + 1 < col) letters[box[x][y + 1] - 'a'] = 1;
  if (x + 1 < row) letters[box[x + 1][y] - 'a'] = 1;
  if (x + 1 < row && y + 1 < col) letters[box[x + 1][y + 1] - 'a'] = 1;
  if (letters['f' - 'a'] && letters['a' - 'a'] && letters['c' - 'a'] &&
      letters['e' - 'a'])
    return 1;
  return 0;
}
int check() {
  int ans = 0;
  for (int i = 0; i < row; i++) {
    for (int j = 0; j < col; j++) {
      if (box[i][j] == 'f' || box[i][j] == 'a' || box[i][j] ||
          box[i][j] == 'c' || box[i][j] == 'e') {
        ans += call(i, j);
      }
    }
  }
  return ans;
}
int main() {
  scanf("%d %d", &row, &col);
  for (int i = 0; i < row; i++) {
    scanf("%s", &box[i]);
  }
  printf("%d\n", check());
  return 0;
}
