func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 50 + 10, dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};   int main() {     int n, m, x, y;     while (~scanf( %d%d , &n, &m)) {       getchar();       char a[N][N];       for (int i = 0; i < n; i++) {         scanf( %s , a[i]);         for (int j = 0; j < m; j++) {           if (a[i][j] ==  S ) {             x = i;             y = j;           }         }       }       string str;       cin >> str;       int sum = 0, mmp[5], sz[5];       memset(sz, 0, sizeof(sz));       for (int i = 0; i < 4; i++) {         mmp[0] = i;         sz[i] = 1;         for (int j = 0; j < 4; j++) {           if (!sz[j]) {             sz[j] = 1;             mmp[1] = j;             for (int k = 0; k < 4; k++) {               if (!sz[k]) {                 mmp[2] = k;                 sz[k] = 1;                 for (int l = 0; l < 4; l++) {                   if (!sz[l]) {                     mmp[3] = l;                     int nx = x, ny = y;                     for (int zz = 0; zz < str.size(); zz++) {                       nx += dx[mmp[str[zz] -  0 ]];                       ny += dy[mmp[str[zz] -  0 ]];                       if (a[nx][ny] ==  #  ||                           !(nx >= 0 && nx < n && ny >= 0 && ny < m))                         break;                       if (a[nx][ny] ==  E ) {                         sum++;                         break;                       }                     }                   }                 }                 sz[k] = 0;               }             }             sz[j] = 0;           }         }         sz[i] = 0;       }       printf( %d n , sum);     }     return 0;   }   