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