#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long sumh1[500010], h, sumh2[500010], pstvx[500010], pstvy[500010],
    ngtvx[500010], ngtvy[500010], pdisx[500010], pdisy[500010], ndisx[500010],
    ndisy[500010], tim;
bool chck1(long long m) { return pdisy[m] <= tim; }
bool chck2(long long m) { return ndisy[h - 1 - m] <= tim; }
char c[500010];
int main() {
  long long x, y, n, w, mxx, mnx, mxy, mny;
  cin >> n >> h >> w;
  scanf("%s", c);
  x = 0;
  y = 0;
  mxx = mnx = mxy = mny = 0;
  fill(pstvx, pstvx + w + 1, 1e18);
  fill(pstvy, pstvy + h + 1, 1e18);
  fill(ngtvx, ngtvx + w + 1, 1e18);
  fill(ngtvy, ngtvy + h + 1, 1e18);
  fill(pdisx, pdisx + w + 1, 1e18);
  fill(pdisy, pdisy + h + 1, 1e18);
  fill(ndisx, ndisx + w + 1, 1e18);
  fill(ndisy, ndisy + h + 1, 1e18);
  pstvx[0] = 0;
  pstvy[0] = 0;
  ngtvx[0] = 0;
  ngtvy[0] = 0;
  for (long long i = 0; i < n; ++i) {
    if (c[i] == 'R') {
      ++x;
    } else if (c[i] == 'L') {
      --x;
    } else if (c[i] == 'U') {
      ++y;
    } else {
      --y;
    }
    if (x > 0)
      pstvx[x] = min(pstvx[x], i + 1);
    else
      ngtvx[-x] = min(ngtvx[-x], i + 1);
    if (y > 0)
      pstvy[y] = min(pstvy[y], i + 1);
    else
      ngtvy[-y] = min(ngtvy[-y], i + 1);
    mxx = max(mxx, x);
    mxy = max(mxy, y);
    mnx = max(mnx, -x);
    mny = max(mny, -y);
  }
  if (x == 0 && y == 0 && mxx + mnx < w && mxy + mny < h) {
    cout << -1 << endl;
    return 0;
  }
  long long shftx = x;
  long long shfty = y;
  long long cnt = 0, tmp = 0;
  if (shftx > 0) {
    for (long long i = 0; i < w; ++i) {
      if ((i + 1) - cnt > mxx) {
        cnt += shftx;
        tmp += n;
      }
      pdisx[i] = tmp + pstvx[(i + 1) - cnt];
    }
    for (long long i = 0; i < mnx; ++i) {
      ndisx[i] = ngtvx[i + 1];
    }
  } else if (shftx < 0) {
    shftx *= -1ll;
    for (long long i = 0; i < w; ++i) {
      if ((i + 1) - cnt > mnx) {
        cnt += shftx;
        tmp += n;
      }
      ndisx[i] = tmp + ngtvx[(i + 1) - cnt];
    }
    for (long long i = 0; i < mxx; ++i) {
      pdisx[i] = pstvx[i + 1];
    }
  } else {
    for (long long i = 0; i < mnx; ++i) {
      ndisx[i] = ngtvx[i + 1];
    }
    for (long long i = 0; i < mxx; ++i) {
      pdisx[i] = pstvx[i + 1];
    }
  }
  cnt = 0;
  tmp = 0;
  if (shfty > 0) {
    for (long long i = 0; i < h; ++i) {
      if ((i + 1) - cnt > mxy) {
        cnt += shfty;
        tmp += n;
      }
      pdisy[i] = tmp + pstvy[(i + 1) - cnt];
    }
    for (long long i = 0; i < mny; ++i) {
      ndisy[i] = ngtvy[i + 1];
    }
  } else if (shfty < 0) {
    shfty *= -1ll;
    for (long long i = 0; i < h; ++i) {
      if ((i + 1) - cnt > mny) {
        cnt += shfty;
        tmp += n;
      }
      ndisy[i] = tmp + ngtvy[(i + 1) - cnt];
    }
    for (long long i = 0; i < mxy; ++i) {
      pdisy[i] = pstvy[i + 1];
    }
  } else {
    for (long long i = 0; i < mny; ++i) {
      ndisy[i] = ngtvy[i + 1];
    }
    for (long long i = 0; i < mxy; ++i) {
      pdisy[i] = pstvy[i + 1];
    }
  }
  sumh1[0] = pdisy[0];
  for (long long i = 1; i < h; ++i) {
    sumh1[i] = sumh1[i - 1] + pdisy[i];
  }
  sumh2[0] = ndisy[0];
  for (long long i = 1; i < h; ++i) {
    sumh2[i] = sumh2[i - 1] + ndisy[i];
  }
  long long end = -1;
  for (long long i = 0; i < h; ++i) {
    if (pdisy[i] > ndisy[h - i - 1]) break;
    end = i;
  }
  long long res = 0;
  for (long long i = 0; i < w; ++i) {
    tim = min(pdisx[w - i - 1], ndisx[i]);
    long long st = -1, nd = h - 1, mid;
    while (st < nd) {
      mid = (st + nd + 1) / 2ll;
      if (chck1(mid)) {
        st = mid;
      } else {
        nd = mid - 1;
      }
    }
    long long tmp2 = min(end, st);
    res += (end - tmp2) * tim;
    if (tmp2 >= 0) res += sumh1[tmp2];
    st = h, nd = 0;
    while (st > nd) {
      mid = (st + nd) / 2ll;
      if (chck2(mid)) {
        st = mid;
      } else {
        nd = mid + 1;
      }
    }
    tmp2 = max(st, end + 1);
    res += (tmp2 - end - 1) * tim;
    if (tmp2 < h) res += sumh2[h - tmp2 - 1];
    res %= mod;
  }
  cout << res << endl;
  return 0;
}
