#include <bits/stdc++.h>
using namespace std;
struct node {
  long long x, v;
} f[500005 * 2];
long long i, j, k, l, s, n, m, r, ans, x, y, ma[500005 * 2], Ma[500005 * 2], mx,
    my, mix, miy, X, Y, q;
inline long long workx(long long o) {
  long long gt = min(ma[n - o + 1 + 500000], ma[-o + 500000]);
  if (gt != 1000000000000000000) return gt;
  if (X == 0) return 1000000000000000000;
  if (X > 0) {
    long long p = n - mx + 1;
    long long dis = p - o;
    dis = (dis - 1) / X + 1;
    o = o + X * dis;
    gt = dis * q;
    return gt + ma[n - o + 1 + 500000];
  } else {
    long long p = -mix;
    long long dis = o - p;
    dis = (dis - 1) / (-X) + 1;
    o = o + X * dis;
    gt = dis * q;
    return gt + ma[-o + 500000];
  }
}
inline long long worky(long long o) {
  long long gt = min(Ma[m - o + 1 + 500000], Ma[-o + 500000]);
  if (gt != 1000000000000000000) return gt;
  if (Y == 0) return 1000000000000000000;
  if (Y > 0) {
    long long p = m - my + 1;
    long long dis = p - o;
    dis = (dis - 1) / Y + 1;
    o = o + Y * dis;
    gt = dis * q;
    return gt + Ma[m - o + 1 + 500000];
  } else {
    long long p = -miy;
    long long dis = o - p;
    dis = (dis - 1) / (-Y) + 1;
    o = o + Y * dis;
    gt = dis * q;
    return gt + Ma[-o + 500000];
  }
}
inline bool cmp(const node &x, const node &y) { return x.v < y.v; }
int main() {
  scanf("%I64d%I64d%I64d", &q, &m, &n);
  for (i = -500000; i <= 500000; i++)
    ma[i + 500000] = Ma[i + 500000] = 1000000000000000000;
  for (i = 1; i <= q; i++) {
    char c = getchar();
    while (c != 'L' && c != 'R' && c != 'U' && c != 'D') c = getchar();
    if (c == 'L')
      x--;
    else if (c == 'R')
      x++;
    else if (c == 'U')
      y--;
    else
      y++;
    Ma[y + 500000] = min(Ma[y + 500000], i);
    ma[x + 500000] = min(ma[x + 500000], i);
    mx = max(mx, x);
    my = max(my, y);
    mix = min(mix, x);
    miy = min(miy, y);
  }
  X = x, Y = y;
  long long s = 0, S = 0;
  for (i = 1; i <= n; i++) f[++r].x = 1, f[r].v = workx(i);
  for (i = 1; i <= m; i++) f[++r].x = 2, f[r].v = worky(i);
  sort(f + 1, f + 1 + r, cmp);
  for (i = 1; i <= r; i++)
    if (f[i].v == 1000000000000000000) {
      if (f[i].x == 1)
        s++;
      else
        S++;
    }
  if (s && S) return printf("-1"), 0;
  for (i = 1; i <= r; i++) {
    if (f[i].x == 1)
      (ans += m * f[i].v) %= 1000000007, n--;
    else
      (ans += n * f[i].v) %= 1000000007, m--;
  }
  printf("%I64d\n", ans);
}
