#include <bits/stdc++.h>
using namespace std;
const int inf = ~0U >> 1;
const long long INF = ~0ULL >> 1;
template <class T>
inline void read(T &n) {
  char c;
  int flag = 1;
  for (c = getchar(); !(c >= '0' && c <= '9' || c == '-'); c = getchar())
    ;
  if (c == '-')
    flag = -1, n = 0;
  else
    n = c - '0';
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) n = n * 10 + c - '0';
  n *= flag;
}
const int maxn = 2000000;
const long long mo = 1000000007;
int K, N, M, x[maxn], y[maxn];
char step[maxn];
long long calc(int lx1, int rx1, int ly1, int ry1, int lx2, int rx2, int ly2,
               int ry2, int lx3, int rx3, int ly3, int ry3, int dx, int dy) {
  long long ret = inf;
  for (int i = (1); i <= (K); ++i) {
    lx1 = max(lx1, 1 - x[i]);
    ly1 = max(ly1, 1 - y[i]);
    rx1 = min(rx1, N - x[i]);
    ry1 = min(ry1, M - y[i]);
    lx2 = max(lx2, 1 - (x[i] + dx));
    ly2 = max(ly2, 1 - (y[i] + dy));
    rx2 = min(rx2, N - (x[i] + dx));
    ry2 = min(ry2, M - (y[i] + dy));
    lx3 = max(lx3, 1 - (x[i] + dx * 2));
    ly3 = max(ly3, 1 - (y[i] + dy * 2));
    rx3 = min(rx3, N - (x[i] + dx * 2));
    ry3 = min(ry3, M - (y[i] + dy * 2));
    long long curx = rx1 - lx1 + 1, cury = ry1 - ly1 + 1;
    curx = rx2 - lx2 + 1, cury = ry2 - ly2 + 1;
    if (curx > 0 && cury > 0) {
      long long sx = curx - (rx3 - lx3 + 1);
      long long sy = cury - (ry3 - ly3 + 1);
      if (sx) ret = min(ret, curx / sx);
      if (sy) ret = min(ret, cury / sy);
    }
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &K, &N, &M);
  scanf("%s", step + 1);
  for (int i = (K + 1); i <= (3 * K); ++i) step[i] = step[i - K];
  int minx = 0, maxx = 0, miny = 0, maxy = 0;
  int lx = 1, rx = N, ly = 1, ry = M;
  for (int i = (1); i <= (K); ++i) {
    x[i] = x[i - 1];
    y[i] = y[i - 1];
    if (step[i] == 'L')
      --y[i];
    else if (step[i] == 'R')
      ++y[i];
    else if (step[i] == 'U')
      --x[i];
    else
      ++x[i];
    minx = min(minx, x[i]);
    maxx = max(maxx, x[i]);
    miny = min(miny, y[i]);
    maxy = max(maxy, y[i]);
    lx = max(lx, 1 - x[i]);
    ly = max(ly, 1 - y[i]);
    rx = min(rx, N - x[i]);
    ry = min(ry, M - y[i]);
  }
  if (maxx - minx + 1 <= N && maxy - miny + 1 <= M && x[K] == 0 && y[K] == 0) {
    puts("-1");
    return 0;
  }
  int lx1 = 1, rx1 = N, ly1 = 1, ry1 = M;
  int lx2 = lx, rx2 = rx, ly2 = ly, ry2 = ry;
  for (int i = (K + 1); i <= (2 * K); ++i) {
    x[i] = x[i - 1];
    y[i] = y[i - 1];
    if (step[i] == 'L')
      --y[i];
    else if (step[i] == 'R')
      ++y[i];
    else if (step[i] == 'U')
      --x[i];
    else
      ++x[i];
    lx = max(lx, 1 - x[i]);
    ly = max(ly, 1 - y[i]);
    rx = min(rx, N - x[i]);
    ry = min(ry, M - y[i]);
  }
  int lx3 = lx, rx3 = rx, ly3 = ly, ry3 = ry;
  int dx = x[K], dy = y[K];
  long long lim = 1 + calc(lx1, rx1, ly1, ry1, lx2, rx2, ly2, ry2, lx3, rx3,
                           ly3, ry3, dx, dy);
  long long ans = (long long)N * M % mo;
  for (int i = (1); i <= (K); ++i) {
    lx1 = max(lx1, 1 - x[i]);
    ly1 = max(ly1, 1 - y[i]);
    rx1 = min(rx1, N - x[i]);
    ry1 = min(ry1, M - y[i]);
    lx2 = max(lx2, 1 - (x[i] + dx));
    ly2 = max(ly2, 1 - (y[i] + dy));
    rx2 = min(rx2, N - (x[i] + dx));
    ry2 = min(ry2, M - (y[i] + dy));
    lx3 = max(lx3, 1 - (x[i] + dx * 2));
    ly3 = max(ly3, 1 - (y[i] + dy * 2));
    rx3 = min(rx3, N - (x[i] + dx * 2));
    ry3 = min(ry3, M - (y[i] + dy * 2));
    long long curx = rx1 - lx1 + 1, cury = ry1 - ly1 + 1;
    if (curx > 0 && cury > 0)
      ans += curx * cury, ans %= mo;
    else
      break;
    curx = rx2 - lx2 + 1, cury = ry2 - ly2 + 1;
    if (curx > 0 && cury > 0) {
      long long sx = curx - (rx3 - lx3 + 1);
      long long sy = cury - (ry3 - ly3 + 1);
      if (sx) lim = min(lim, curx / sx);
      if (sy) lim = min(lim, cury / sy);
      ans += curx * cury % mo * (lim + 1) % mo;
      ans %= mo;
      ans -= curx * sy % mo * ((0 + lim) * (lim + 1) / 2 % mo) % mo;
      ans -= cury * sx % mo * ((0 + lim) * (lim + 1) / 2 % mo) % mo;
      ans += (long long)sx * sy % mo *
             (lim * (lim + 1) * (2ll * lim + 1) / 6 % mo) % mo;
      ans %= mo;
    }
  }
  ans %= mo;
  ans = (ans + mo) % mo;
  printf("%d\n", (int)ans);
  return 0;
}
