#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7;
const int N = 5e5 + 5;
struct Point {
  int h1, w1, h2, w2, x, y;
};
int oper[N * 2];
Point opt[N * 2];
int bo[N * 2];
int nex[N * 2];
int main() {
  int n, h, w;
  scanf("%d%d%d", &n, &h, &w);
  for (int i = 1; i <= n; ++i) {
    int &ch = oper[i];
    while (ch = getchar(), !isalpha(ch))
      ;
    oper[i + n] = oper[i];
  }
  opt[0] = (Point){0, 0, 0, 0, 0, 0};
  for (int i = 1; i <= 2 * n; ++i) {
    opt[i] = opt[i - 1];
    if (oper[i] == 'U') {
      --opt[i].x;
      if (opt[i].x < opt[i].h1) {
        opt[i].h1 = opt[i].x;
        bo[i] = 1;
      }
    } else if (oper[i] == 'D') {
      ++opt[i].x;
      if (opt[i].x > opt[i].h2) {
        opt[i].h2 = opt[i].x;
        bo[i] = 2;
      }
    } else if (oper[i] == 'L') {
      --opt[i].y;
      if (opt[i].y < opt[i].w1) {
        opt[i].w1 = opt[i].y;
        bo[i] = 3;
      }
    } else {
      ++opt[i].y;
      if (opt[i].y > opt[i].w2) {
        opt[i].w2 = opt[i].y;
        bo[i] = 4;
      }
    }
  }
  for (int i = 3 * n, t = -1; i >= 0; --i) {
    if (i <= 2 * n) nex[i] = t;
    int bb = 0;
    if (i > 2 * n)
      bb = bo[i - n];
    else
      bb = bo[i];
    if (bb) t = i;
    if (nex[i] > 2 * n) nex[i] -= n;
  }
  Point A = opt[0];
  int i = 0;
  long long num = 0, ans = 0, res = 0;
  while (num < (long long)h * w) {
    if (nex[i] == -1) break;
    A.x += opt[nex[i]].x - opt[i].x;
    A.y += opt[nex[i]].y - opt[i].y;
    res += nex[i] - i;
    if (nex[i] <= i) {
      A.x += opt[n].x;
      A.y += opt[n].y;
      res += n;
    }
    i = nex[i];
    if (bo[i] == 1 || bo[i] == 2) {
      if (A.h2 - A.h1 + 1 <= h) {
        int tmp = max(0, w - (A.w2 - A.w1 + 1) + 1);
        num += tmp;
        ans += (long long)tmp * res % P;
        ans %= P;
        if (bo[i] == 1)
          --A.h1;
        else
          ++A.h2;
      }
    } else {
      if (A.w2 - A.w1 + 1 <= w) {
        int tmp = max(0, h - (A.h2 - A.h1 + 1) + 1);
        num += tmp;
        ans += (long long)tmp * res % P;
        ans %= P;
        if (bo[i] == 3)
          --A.w1;
        else
          ++A.w2;
      }
    }
  }
  if (num < (long long)h * w) ans = -1;
  cout << ans << endl;
  return 0;
}
