#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
const int N = 1e5 + 5;
const double pi = acos(-1);
long long n, m, ans;
char arr[55][55];
bool inrange(int i, int j) {
  if (i < n && i >= 0 && j < m && j >= 0) return true;
  return false;
}
void solve(int i, int j) {
  int cntr1 = 0, cntr2 = 0, cntr3 = 0;
  if (inrange(i + 1, j) && inrange(i + 1, j + 1) && inrange(i, j + 1)) {
    if (arr[i + 1][j] == 'a' || arr[i + 1][j + 1] == 'a' ||
        arr[i][j + 1] == 'a')
      cntr1++;
    if (arr[i + 1][j] == 'e' || arr[i + 1][j + 1] == 'e' ||
        arr[i][j + 1] == 'e')
      cntr2++;
    if (arr[i + 1][j] == 'c' || arr[i + 1][j + 1] == 'c' ||
        arr[i][j + 1] == 'c')
      cntr3++;
  }
  if (cntr1 == 1 && cntr3 == 1 && cntr2 == 1) ans++;
  cntr1 = 0, cntr2 = 0, cntr3 = 0;
  if (inrange(i + 1, j) && inrange(i + 1, j - 1) && inrange(i, j - 1)) {
    if (arr[i + 1][j] == 'a' || arr[i + 1][j - 1] == 'a' ||
        arr[i][j - 1] == 'a')
      cntr1++;
    if (arr[i + 1][j] == 'e' || arr[i + 1][j - 1] == 'e' ||
        arr[i][j - 1] == 'e')
      cntr2++;
    if (arr[i + 1][j] == 'c' || arr[i + 1][j - 1] == 'c' ||
        arr[i][j - 1] == 'c')
      cntr3++;
  }
  if (cntr1 == 1 && cntr3 == 1 && cntr2 == 1) ans++;
  cntr1 = 0, cntr2 = 0, cntr3 = 0;
  if (inrange(i - 1, j) && inrange(i - 1, j - 1) && inrange(i, j - 1)) {
    if (arr[i - 1][j] == 'a' || arr[i - 1][j - 1] == 'a' ||
        arr[i][j - 1] == 'a')
      cntr1++;
    if (arr[i - 1][j] == 'e' || arr[i - 1][j - 1] == 'e' ||
        arr[i][j - 1] == 'e')
      cntr2++;
    if (arr[i - 1][j] == 'c' || arr[i - 1][j - 1] == 'c' ||
        arr[i][j - 1] == 'c')
      cntr3++;
  }
  if (cntr1 == 1 && cntr3 == 1 && cntr2 == 1) ans++;
  cntr1 = 0, cntr2 = 0, cntr3 = 0;
  if (inrange(i - 1, j) && inrange(i - 1, j + 1) && inrange(i, j + 1)) {
    if (arr[i - 1][j] == 'a' || arr[i - 1][j + 1] == 'a' ||
        arr[i][j + 1] == 'a')
      cntr1++;
    if (arr[i - 1][j] == 'e' || arr[i - 1][j + 1] == 'e' ||
        arr[i][j + 1] == 'e')
      cntr2++;
    if (arr[i - 1][j] == 'c' || arr[i - 1][j + 1] == 'c' ||
        arr[i][j + 1] == 'c')
      cntr3++;
  }
  if (cntr1 == 1 && cntr3 == 1 && cntr2 == 1) ans++;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> arr[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == 'f') solve(i, j);
    }
  }
  cout << ans << endl;
  return 0;
}
