#include <bits/stdc++.h>
using namespace std;
int n, m;
char in[55][55];
bool v[300], v2[3003];
int main() {
  v['f'] = v['a'] = v['c'] = v['e'] = 1;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", in[i]);
  }
  int c = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < m - 1; j++) {
      memset(v2, 0, sizeof(v2));
      if (v[in[i][j]] && !v2[in[i][j]])
        v2[in[i][j]] = 1;
      else
        continue;
      if (v[in[i + 1][j]] && !v2[in[i + 1][j]])
        v2[in[i + 1][j]] = 1;
      else
        continue;
      if (v[in[i][j + 1]] && !v2[in[i][j + 1]])
        v2[in[i][j + 1]] = 1;
      else
        continue;
      if (v[in[i + 1][j + 1]] && !v2[in[i + 1][j + 1]])
        v2[in[i + 1][j + 1]] = 1;
      else
        continue;
      c++;
    }
  }
  printf("%d\n", c);
  return 0;
}
