#include <bits/stdc++.h>
using namespace std;
int main() {
  string p, k;
  char q[1000][1000], s;
  long long a, b, c = 0, d = 0, e = 0, f = 0, g = 0, h, i, j, l, m, n, o, r, t,
                  u, v, w;
  cin >> a >> b;
  for (i = 0; i < a; i++) {
    for (j = 0; j < b; j++) {
      cin >> q[i][j];
    }
  }
  for (i = 0; i < a; i++) {
    for (j = 0; j < b; j++) {
      if (q[i][j] == 'f' || q[i + 1][j] == 'f' || q[i][j + 1] == 'f' ||
          q[i + 1][j + 1] == 'f') {
        if (q[i][j] == 'a' || q[i + 1][j] == 'a' || q[i][j + 1] == 'a' ||
            q[i + 1][j + 1] == 'a') {
          if (q[i][j] == 'c' || q[i + 1][j] == 'c' || q[i][j + 1] == 'c' ||
              q[i + 1][j + 1] == 'c') {
            if (q[i][j] == 'e' || q[i + 1][j] == 'e' || q[i][j + 1] == 'e' ||
                q[i + 1][j + 1] == 'e') {
              c++;
            }
          }
        }
      }
    }
  }
  cout << c;
}
