#include <bits/stdc++.h>
using namespace std;
string ff[55];
int n, m;
int main() {
  cin.sync_with_stdio(false);
  cout.sync_with_stdio(false);
  cin >> n >> m;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    cin >> ff[i];
    ff[i] = " " + ff[i];
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 2; j <= m; j++) {
      bool _f = false, _a = false, _c = false, _e = false;
      switch (ff[i][j]) {
        case 'f':
          _f = true;
          break;
        case 'a':
          _a = true;
          break;
        case 'c':
          _c = true;
          break;
        case 'e':
          _e = true;
          break;
      }
      switch (ff[i][j - 1]) {
        case 'f':
          _f = true;
          break;
        case 'a':
          _a = true;
          break;
        case 'c':
          _c = true;
          break;
        case 'e':
          _e = true;
          break;
      }
      switch (ff[i - 1][j]) {
        case 'f':
          _f = true;
          break;
        case 'a':
          _a = true;
          break;
        case 'c':
          _c = true;
          break;
        case 'e':
          _e = true;
          break;
      }
      switch (ff[i - 1][j - 1]) {
        case 'f':
          _f = true;
          break;
        case 'a':
          _a = true;
          break;
        case 'c':
          _c = true;
          break;
        case 'e':
          _e = true;
          break;
      }
      if (_f && _a && _c && _e) {
        cnt++;
      }
    }
  }
  cout << cnt << endl;
}
