func_code_string: #include <bits/stdc++.h>   const long long maxn = 1e3 + 5;   const long long w = 1e8;   using namespace std;   int m, n, p, kq;   char a[maxn][maxn];   string s;   char dir[4] = { D ,  L ,  U ,  R };   int tdx, tdy;   int x, y;   inline void init() {     cin >> n >> m;     cin.ignore();     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         cin >> a[i][j];         if (a[i][j] ==  S ) {           x = j;           y = i;         }       }     cin >> s;     p = s.length();   }   inline void solve() {     sort(dir, dir + 4);     do {       tdx = x;       tdy = y;       for (int i = 0; i < p; i++) {         if (dir[s[i] - 48] ==  D ) tdy++;         if (dir[s[i] - 48] ==  U ) tdy--;         if (dir[s[i] - 48] ==  L ) tdx--;         if (dir[s[i] - 48] ==  R ) tdx++;         if (a[tdy][tdx] ==  #  || tdx < 1 || tdy < 1 || tdx > m || tdy > n) break;         if (a[tdy][tdx] ==  E ) {           kq++;           break;         }       }     } while (next_permutation(dir, dir + 4));     cout << kq;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     init();     solve();     return 0;   }   