#include <bits/stdc++.h>
using namespace std;
const int Maxnum = 500 * 1000 + 100;
long long row[Maxnum], col[Maxnum];
string moves;
long long n, h, w, vertical, horizontal, right, numofmoves, numofrows,
    numofcols;
long long modnum = 1000 * 1000 * 1000 + 7;
int main() {
  cin >> n >> h >> w;
  cin >> moves;
  for (int i = 0; i < n; i++) {
    if (moves[i] == 'U')
      vertical--;
    else if (moves[i] == 'D')
      vertical++;
    else if (moves[i] == 'R')
      horizontal--;
    else if (moves[i] == 'L')
      horizontal++;
    else
      cerr << "ERROR" << endl;
    if (vertical != 0)
      if (row[(vertical % (h + 1) + (h + 1)) % (h + 1)] == 0) {
        row[(vertical % (h + 1) + (h + 1)) % (h + 1)] = i + 1;
      }
    if (horizontal != 0)
      if (col[(horizontal % (w + 1) + w + 1) % (w + 1)] == 0) {
        col[(horizontal % (w + 1) + w + 1) % (w + 1)] = i + 1;
      }
  }
  int drow = (vertical > 0 ? +1 : -1);
  int dcol = (horizontal > 0 ? +1 : -1);
  int startrow = (vertical > 0 ? 1 : h);
  int startcol = (horizontal > 0 ? 1 : w);
  if (vertical != 0)
    for (int i = startrow; i <= h && i > 0; i += drow) {
      if (row[i] != 0)
        continue;
      else
        row[i] = (long long)n + row[i - vertical];
    }
  if (horizontal != 0)
    for (int i = startcol; i <= w && i > 0; i += dcol) {
      if (col[i] != 0)
        continue;
      else {
        col[i] = (long long)n + col[i - horizontal];
      }
    }
  sort(row + 1, row + h + 1);
  sort(col + 1, col + w + 1);
  int prow = 1, pcol = 1;
  while (prow < h + 1 || pcol < w + 1) {
    if (row[prow] == 0 && prow < h + 1) {
      prow++;
      continue;
    }
    if (col[pcol] == 0 && pcol < w + 1) {
      pcol++;
      continue;
    }
    if ((row[prow] < col[pcol] && row[prow] != 0) || col[pcol] == 0) {
      numofrows += 1;
      numofmoves +=
          ((row[prow++] * (w - numofcols)) % modnum + modnum) % modnum;
      numofmoves = (numofmoves % modnum + modnum) % modnum;
    }
    if ((col[pcol] < row[prow] && col[pcol] != 0) || row[prow] == 0) {
      numofcols += 1;
      numofmoves +=
          (((h - numofrows) * col[pcol++]) % modnum + modnum) % modnum;
      numofmoves = (numofmoves % modnum + modnum) % modnum;
    }
  }
  if (numofrows < h && numofcols < w)
    cout << -1 << endl;
  else
    cout << numofmoves << endl;
  return 0;
}
