#include <bits/stdc++.h>
using namespace std;
int arrr[1000005];
template <class T>
T pwr(T b, T p) {
  T r = 1, x = b;
  while (p) {
    if (p & 1) r *= x;
    x *= x;
    p = (p >> 1);
  }
  return r;
}
long long modPow(long long a, long long x, long long p) {
  long long res = 1;
  while (x > 0) {
    if (x % 2 != 0) {
      res = (res * a) % p;
    }
    a = (a * a) % p;
    x /= 2;
  }
  return res;
}
typedef struct data {
  long long q;
  long long r;
} data;
int comp(const void *a, const void *b) {
  data m = *((data *)a);
  data n = *((data *)b);
  if (m.q > n.q)
    return 1;
  else if (m.q < n.q)
    return -1;
  else if (m.q == n.q) {
    return 0;
  }
}
char dp[51][52];
int main() {
  int n, m, i, j, k, l;
  int cnt = 0, f, a, c, e;
  scanf("%d %d", &n, &m);
  for (i = 0; i < n; i++) scanf("%s", dp[i]);
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j < m - 1; j++) {
      f = a = c = e = 0;
      for (k = 0; k < 2; k++) {
        for (l = 0; l < 2; l++) {
          if (dp[i + k][j + l] == 'f') f = 1;
          if (dp[i + k][j + l] == 'a') a = 1;
          if (dp[i + k][j + l] == 'c') c = 1;
          if (dp[i + k][j + l] == 'e') e = 1;
        }
      }
      cnt += (f & a & c & e);
    }
  }
  printf("%d", cnt);
}
