#include <bits/stdc++.h>
using namespace std;
int main() {
  char arr[100][100];
  int m, n, k = 0;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  if (m == 1 || n == 1) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      if ('f' != arr[i][j] && 'f' != arr[i + 1][j] && 'f' != arr[i][j + 1] &&
          'f' != arr[i + 1][j + 1])
        continue;
      if ('a' != arr[i][j] && 'a' != arr[i + 1][j] && 'a' != arr[i][j + 1] &&
          'a' != arr[i + 1][j + 1])
        continue;
      if ('c' != arr[i][j] && 'c' != arr[i + 1][j] && 'c' != arr[i][j + 1] &&
          'c' != arr[i + 1][j + 1])
        continue;
      if ('e' != arr[i][j] && 'e' != arr[i + 1][j] && 'e' != arr[i][j + 1] &&
          'e' != arr[i + 1][j + 1])
        continue;
      k++;
    }
  }
  cout << k;
  return 0;
}
