#include <bits/stdc++.h>
using namespace std;
long long int gc(long long int kl, long long int yu) {
  long long int pp;
  for (pp = min(kl, yu); pp >= 1; pp--) {
    if (kl % pp == 0 && yu % pp == 0) break;
  }
  if (pp == 1)
    return 1;
  else
    return 0;
}
int isP(long int hj) {
  long int op;
  for (op = 2; op <= sqrt(hj); op++) {
    if (hj % op == 0) return 0;
  }
  return 1;
}
void swap(int *p, int *q) {
  int tmp = *p;
  *p = *q;
  *q = tmp;
}
void tog(int *p) {
  if (*p == 1)
    *p = 0;
  else
    *p = 1;
}
int main() {
  long long int max, e, preI, min, t1, t2, g, p, brk, L, clbp, clb, et, jmp, u,
      l1, l2, sp, sq, nd, maxi, li, ri, tr, mp, og, prev, lt1, lt2, n1, n2, c1,
      c2, jb, minI, min1, dp, p2, p3, ze, fst, lst, min2, s, sm1, sm2, sm3, sr,
      sl, l, ln, rz, rn, car, eq, r, shr, ng, d, v, curr, spl, fl, z, ev, od, t,
      m, ct, j, q, k, b, maxI, max1, max2, lt, md, a, f, n, xP, xN, w, h, d2,
      d1, u1, u2, sm, i, x, y;
  cin >> n >> m;
  char c[n][m];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) cin >> c[i][j];
  }
  ct = 0;
  int D[127] = {0};
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (c[i][j] == 'f') {
        if (i - 1 >= 0 && j - 1 >= 0) {
          D[c[i - 1][j]] = 1;
          D[c[i][j - 1]] = 1;
          D[c[i - 1][j - 1]] = 1;
          if (D['a'] == 1 && D['c'] == 1 && D['e'] == 1) ct++;
          for (k = 0; k < 127; k++) D[k] = 0;
        }
        if (i - 1 >= 0 && j + 1 < m) {
          D[c[i][j + 1]] = 1;
          D[c[i - 1][j]] = 1;
          D[c[i - 1][j + 1]] = 1;
          if (D['a'] == 1 && D['c'] == 1 && D['e'] == 1) ct++;
          for (k = 0; k < 127; k++) D[k] = 0;
        }
        if (j - 1 >= 0 && i + 1 < n) {
          D[c[i][j - 1]] = 1;
          D[c[i + 1][j]] = 1;
          D[c[i + 1][j - 1]] = 1;
          if (D['a'] == 1 && D['c'] == 1 && D['e'] == 1) ct++;
          for (k = 0; k < 127; k++) D[k] = 0;
        }
        if (i + 1 < n && j + 1 < m) {
          D[c[i][j + 1]] = 1;
          D[c[i + 1][j + 1]] = 1;
          D[c[i + 1][j]] = 1;
          if (D['a'] == 1 && D['c'] == 1 && D['e'] == 1) ct++;
          for (k = 0; k < 127; k++) D[k] = 0;
        }
      }
    }
  }
  cout << ct;
  return 0;
}
