#include <iostream>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <cstring>
#include <iomanip>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cstdlib>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using piii = tuple<int,int,int>;
using piiii = tuple<int,int,int,int>;
#define f first
#define s second
#define endl '\n'
#define all(x) begin(x),end(x)
#define m_p make_pair
int main(){
int n;cin >> n;
int m;cin >> m;
int d;cin >> d;
int k;cin >> k;
vector<vector<int>> dp(n+1,vector<int>(m+1,0));
vector<pii> vc;
for(int i{1};i <= n;i++){
for(int j{1};j <= m;j++){
char c;cin >> c;
dp[i][j] = dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
if(c == 'M') vc.emplace_back(i,j);
else if(c == 'S') dp[i][j] += 1;
//cout << dp[i][j] << " ";
}
//cout << endl;
}
int ans = 0;
for(auto [i,j]:vc){
int i1 = min(n,i+d);
int j1 = min(m,j+d);
int i2 = max(1,i-d)-1;
int j2 = max(1,j-d)-1;
int cnt = dp[i1][j1]-dp[i1][j2]-dp[i2][j1]+dp[i2][j2];
//cout << cnt << endl;
ans += (cnt>=k);
}
cout << ans;
}