#include <bits/stdc++.h>
using namespace std;
const long double pi = 3.1415926535897932384626433832795l;
template <typename T>
inline auto sqr(T x) -> decltype(x * x) {
  return x * x;
}
template <typename T>
inline T abs(T x) {
  return x > T() ? x : -x;
}
template <typename T1, typename T2>
inline bool umx(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool umn(T1& a, T2 b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 60;
struct Input {
  int n, m;
  char c[N][N];
  bool read() {
    if (scanf("%d %d", &n, &m) != 2) return 0;
    for (int i = int(0); i < int(n); ++i) {
      string qwe;
      getline(cin, qwe);
      for (int j = int(0); j < int(m); ++j) {
        scanf("%c", &c[i][j]);
      }
    }
    return 1;
  }
  void init(const Input& input) { *this = input; }
};
struct Data : Input {
  int ans;
  void write() { cout << ans << endl; }
  virtual void solve() {}
  virtual void clear() { *this = Data(); }
};
struct Solution : Data {
  void solve() {
    ans = 0;
    for (int i = int(0); i < int(n - 1); ++i) {
      for (int j = int(0); j < int(m - 1); ++j) {
        vector<char> a;
        for (int k = 0; k < 2; ++k) {
          for (int z = 0; z < 2; ++z) {
            a.push_back(c[i + k][j + z]);
          }
        }
        sort((a).begin(), (a).end());
        if (a[0] == 'a' && a[1] == 'c' && a[2] == 'e' && a[3] == 'f') {
          ans++;
        }
      }
    }
  }
  void clear() { *this = Solution(); }
};
Solution sol;
int main() {
  cout.setf(ios::showpoint | ios::fixed);
  cout.precision(20);
  sol.read();
  sol.solve();
  sol.write();
  return 0;
}
