#include <bits/stdc++.h>
using namespace std;
const int MAXN = 150, MAXM = 100000;
bitset<MAXN> W[MAXN + 10];
bitset<MAXN> cur[MAXN + 10], final[MAXN + 10];
char buf[MAXN + 10], seq[MAXM + 10];
int main(void) {
  int n, m, K;
  scanf("%d%d%d", &n, &m, &K);
  for (int i = 0; i < (n); ++i) {
    scanf("%s", buf);
    for (int j = 0; j < (m); ++j) {
      if (buf[j] == '#') {
        W[i][j] = 1;
      } else {
        cur[i][j] = 1;
        if (buf[j] == 'E') {
          final[i][j] = 1;
        }
      }
    }
  }
  scanf("%s", seq);
  for (int f = 0; f < (K + 1); ++f) {
    bool ok = true;
    for (int i = 0; i < (n); ++i) {
      if (cur[i] != final[i]) {
        ok = false;
      }
    }
    if (ok) {
      printf("%d\n", f);
      return 0;
    }
    if (f == K) {
      break;
    }
    if (seq[f] == 'R') {
      for (int i = 0; i < (n); ++i) {
        bitset<MAXN> w = cur[i] & (W[i] >> 1);
        cur[i] ^= w;
        cur[i] <<= 1;
        cur[i] |= w;
      }
    } else if (seq[f] == 'L') {
      for (int i = 0; i < (n); ++i) {
        bitset<MAXN> w = cur[i] & (W[i] << 1);
        cur[i] ^= w;
        cur[i] >>= 1;
        cur[i] |= w;
      }
    } else if (seq[f] == 'U') {
      for (int i = (1); i < (n); ++i) {
        cur[i - 1] |= (cur[i] & ~W[i - 1]);
        cur[i] &= W[i - 1];
      }
    } else if (seq[f] == 'D') {
      for (int i = n - 2; i >= 0; --i) {
        cur[i + 1] |= (cur[i] & ~W[i + 1]);
        cur[i] &= W[i + 1];
      }
    }
  }
  printf("%d\n", -1);
  return 0;
}
