#include <bits/stdc++.h>
using namespace std;
char buf[100001];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  bitset<151 * 151> exit, walls;
  walls.flip();
  for (int i = 0; i < n; ++i) {
    scanf("%s", buf);
    for (int j = 0; j < m; ++j) {
      if (buf[j] != '#') walls.reset(i * 151 + j);
      if (buf[j] == 'E') exit.set(i * 151 + j);
    }
    walls.set(i * 151 + 151 - 1);
  }
  scanf("%s", buf);
  bitset<151 * 151> possible = ~walls;
  int turn = 0;
  for (; turn < k; ++turn) {
    if (possible == exit) break;
    switch (buf[turn]) {
      case 'U':
        possible = ((possible >> 151) & (~walls)) | ((walls << 151) & possible);
        break;
      case 'R':
        possible = ((possible << 1) & (~walls)) | ((walls >> 1) & possible);
        break;
      case 'D':
        possible = ((possible << 151) & (~walls)) | ((walls >> 151) & possible);
        break;
      case 'L':
        possible = ((possible >> 1) & (~walls)) | ((walls << 1) & possible);
        break;
    }
  }
  if (possible != exit) turn = -1;
  printf("%d\n", turn);
  return 0;
}
