#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
#include <cstdio>
#include <cstring>
using namespace std;
int r,c,m;
const int N = 502, M = 5000;
bool reach[N][N],tmp[N][N],sea[N][N];
char grid[N][N], msg[M];
int main(){
scanf("%d %d %d",&r,&c,&m);
for(int i = 1; i <= r; ++i)
scanf("%s",grid[i]+1);
scanf("%s",msg);
for(int i = 1; i <= r; ++i)
for(int j = 1; j <= c; ++j){
sea[i][j] = grid[i][j] == '.';
reach[i][j] = grid[i][j] == '.';
}
for(char w : msg){
if(w == 'W')
for(int i = 1; i <= r; ++i){
for(int j = 1; j <= c-1; ++j)
reach[i][j] = reach[i][j+1] & sea[i][j];
reach[i][c] = 0;
}
if(w == 'E')
for(int i = 1; i <= r; ++i){
for(int j = c; j > 1; --j)
reach[i][j] = reach[i][j-1] & sea[i][j];
reach[i][1] = 0;
}
if(w == 'N'){
for(int i = 1; i <= r-1; ++i)
for(int j = 1; j <= c; ++j)
reach[i][j] = reach[i+1][j] & sea[i][j];
memset(reach[r], 0, sizeof reach[0]);
}
if(w == 'S'){
for(int i = r; i > 1; --i)
for(int j = 1; j <= c; ++j)
reach[i][j] = reach[i-1][j] & sea[i][j];
memset(reach[1], 0, sizeof reach[0]);
}
if(w == '?'){
for(int i = 1; i <= r; ++i)
for(int j = 1; j <= c; ++j)
tmp[i][j] = (reach[i-1][j]|reach[i+1][j]|reach[i][j-1]|reach[i][j+1])&sea[i][j];
memmove(reach, tmp, sizeof tmp);
}
}
int ans = 0;
for(int i = 1; i <= r; ++i)
for(int j = 1; j <= c; ++j)
ans += reach[i][j];
printf("%d\n",ans);
}
I3ByYWdtYSBHQ0Mgb3B0aW1pemUoIk9mYXN0IikKI3ByYWdtYSBHQ0MgdGFyZ2V0KCJzc2U0IikKI2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGNzdHJpbmc+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCByLGMsbTsKY29uc3QgaW50IE4gPSA1MDIsIE0gPSA1MDAwOwpib29sIHJlYWNoW05dW05dLHRtcFtOXVtOXSxzZWFbTl1bTl07CmNoYXIgZ3JpZFtOXVtOXSwgbXNnW01dOwppbnQgbWFpbigpewogICAgc2NhbmYoIiVkICVkICVkIiwmciwmYywmbSk7CiAgICBmb3IoaW50IGkgPSAxOyBpIDw9IHI7ICsraSkKICAgICAgICBzY2FuZigiJXMiLGdyaWRbaV0rMSk7CiAgICBzY2FuZigiJXMiLG1zZyk7CiAgICBmb3IoaW50IGkgPSAxOyBpIDw9IHI7ICsraSkKICAgICAgICBmb3IoaW50IGogPSAxOyBqIDw9IGM7ICsrail7CiAgICAgICAgICAgIHNlYVtpXVtqXSA9IGdyaWRbaV1bal0gPT0gJy4nOwogICAgICAgICAgICByZWFjaFtpXVtqXSA9IGdyaWRbaV1bal0gPT0gJy4nOwogICAgICAgIH0KICAgIGZvcihjaGFyIHcgOiBtc2cpewogICAgICAgIGlmKHcgPT0gJ1cnKQogICAgICAgICAgICBmb3IoaW50IGkgPSAxOyBpIDw9IHI7ICsraSl7CiAgICAgICAgICAgICAgICBmb3IoaW50IGogPSAxOyBqIDw9IGMtMTsgKytqKQogICAgICAgICAgICAgICAgICAgIHJlYWNoW2ldW2pdID0gcmVhY2hbaV1baisxXSAmIHNlYVtpXVtqXTsKICAgICAgICAgICAgICAgIHJlYWNoW2ldW2NdID0gMDsKICAgICAgICAgICAgfQogICAgICAgIGlmKHcgPT0gJ0UnKQogICAgICAgICAgICBmb3IoaW50IGkgPSAxOyBpIDw9IHI7ICsraSl7CiAgICAgICAgICAgICAgICBmb3IoaW50IGogPSBjOyBqID4gMTsgLS1qKQogICAgICAgICAgICAgICAgICAgIHJlYWNoW2ldW2pdID0gcmVhY2hbaV1bai0xXSAmIHNlYVtpXVtqXTsKICAgICAgICAgICAgICAgIHJlYWNoW2ldWzFdID0gMDsKICAgICAgICAgICAgfQogICAgICAgIGlmKHcgPT0gJ04nKXsKICAgICAgICAgICAgZm9yKGludCBpID0gMTsgaSA8PSByLTE7ICsraSkKICAgICAgICAgICAgICAgIGZvcihpbnQgaiA9IDE7IGogPD0gYzsgKytqKQogICAgICAgICAgICAgICAgICAgIHJlYWNoW2ldW2pdID0gcmVhY2hbaSsxXVtqXSAmIHNlYVtpXVtqXTsKICAgICAgICAgICAgbWVtc2V0KHJlYWNoW3JdLCAwLCBzaXplb2YgcmVhY2hbMF0pOwogICAgICAgIH0KICAgICAgICBpZih3ID09ICdTJyl7CiAgICAgICAgICAgIGZvcihpbnQgaSA9IHI7IGkgPiAxOyAtLWkpCiAgICAgICAgICAgICAgICBmb3IoaW50IGogPSAxOyBqIDw9IGM7ICsraikKICAgICAgICAgICAgICAgICAgICByZWFjaFtpXVtqXSA9IHJlYWNoW2ktMV1bal0gJiBzZWFbaV1bal07CiAgICAgICAgICAgIG1lbXNldChyZWFjaFsxXSwgMCwgc2l6ZW9mIHJlYWNoWzBdKTsKICAgICAgICB9CiAgICAgICAgaWYodyA9PSAnPycpewogICAgICAgICAgICBmb3IoaW50IGkgPSAxOyBpIDw9IHI7ICsraSkKICAgICAgICAgICAgICAgIGZvcihpbnQgaiA9IDE7IGogPD0gYzsgKytqKQogICAgICAgICAgICAgICAgICAgIHRtcFtpXVtqXSA9IChyZWFjaFtpLTFdW2pdfHJlYWNoW2krMV1bal18cmVhY2hbaV1bai0xXXxyZWFjaFtpXVtqKzFdKSZzZWFbaV1bal07CiAgICAgICAgICAgIG1lbW1vdmUocmVhY2gsIHRtcCwgc2l6ZW9mIHRtcCk7CiAgICAgICAgfQogICAgfQogICAgaW50IGFucyA9IDA7CiAgICBmb3IoaW50IGkgPSAxOyBpIDw9IHI7ICsraSkKICAgICAgICBmb3IoaW50IGogPSAxOyBqIDw9IGM7ICsraikKICAgICAgICAgICAgYW5zICs9IHJlYWNoW2ldW2pdOwogICAgcHJpbnRmKCIlZFxuIixhbnMpOwp9Cg==