func_code_string: #include <bits/stdc++.h>   const int pi = acos(-1);   const long long MOD = 1000000007;   const int M = 100005;   const int N = 1000006;   using namespace std;   int n, m, x, y, ans;   string s;   char a[55][55];   bool vis[55][55];   vector<string> v;   void calc(int i, string s) {     if (i == 4) {       v.push_back(s);       return;     }     bool u = 0, d = 0, l = 0, r = 0;     for (int i = 0; i < s.size(); i++) {       if (s[i] ==  u ) u = 1;       if (s[i] ==  d ) d = 1;       if (s[i] ==  l ) l = 1;       if (s[i] ==  r ) r = 1;     }     if (!u) calc(i + 1, s +  u );     if (!d) calc(i + 1, s +  d );     if (!l) calc(i + 1, s +  l );     if (!r) calc(i + 1, s +  r );   }   int bfs(string k) {     map<char, char> lol;     lol[ 0 ] = k[0];     lol[ 1 ] = k[1];     lol[ 2 ] = k[2];     lol[ 3 ] = k[3];     queue<pair<int, pair<int, int> > > q;     q.push(make_pair(0, make_pair(x, y)));     while (!q.empty()) {       int x = q.front().second.first;       int y = q.front().second.second;       int i = q.front().first;       q.pop();       if (x < 0 || x >= n || y < 0 || y >= m) return 0;       if (a[x][y] ==  # ) return 0;       if (a[x][y] ==  E ) return 1;       if (i >= s.size()) return 0;       char lel = lol[s[i]];       if (lel ==  d ) q.push(make_pair(i + 1, make_pair(x + 1, y)));       if (lel ==  u ) q.push(make_pair(i + 1, make_pair(x - 1, y)));       if (lel ==  r ) q.push(make_pair(i + 1, make_pair(x, y + 1)));       if (lel ==  l ) q.push(make_pair(i + 1, make_pair(x, y - 1)));     }     return 0;   }   int main() {     cin >> n >> m;     for (int i = 0; i < n; i++) scanf( %s , a[i]);     cin >> s;     calc(0,   );     for (int i = 0; i < n; i++)       for (int j = 0; j < m; j++)         if (a[i][j] ==  S ) {           x = i;           y = j;         }     for (int i = 0; i < v.size(); i++) ans += bfs(v[i]);     cout << ans;     return 0;   }   