#include <bits/stdc++.h>
using namespace std;
char ch[51][51];
int cnt = 0;
void check(int i, int j) {
  char c1, c2, c3, c4;
  c1 = ch[i][j];
  c2 = ch[i + 1][j];
  c3 = ch[i][j + 1];
  c4 = ch[i + 1][j + 1];
  if (c1 != c2 && c1 != c3 && c1 != c4 &&
      (c1 == 'f' || c1 == 'a' || c1 == 'c' || c1 == 'e') &&
      (c2 == 'f' || c2 == 'a' || c2 == 'c' || c2 == 'e') &&
      (c3 == 'f' || c3 == 'a' || c3 == 'c' || c3 == 'e') &&
      (c4 == 'f' || c4 == 'a' || c4 == 'c' || c4 == 'e')) {
    if (c2 != c3 && c2 != c4) {
      if (c3 != c4) cnt++;
    }
  }
}
int main() {
  int n, m, x;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> ch[i][j];
    }
  }
  if (n == 1 || m == 1) {
    cout << "0" << endl;
    return 0;
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j < m; ++j) {
      check(i, j);
    }
  }
  cout << cnt << endl;
  return 0;
}
