#include <bits/stdc++.h>
using namespace std;
long long a, b, x, y, s, dx, dy, e[4][100005], n, m, zz = 0, qsb, wl;
void as(int c, int y) {
  if (x == 1) {
    n = 0;
    m = y;
  }
  if (x == a) {
    n = 1;
    m = y;
  }
  if (y == 1) {
    n = 2;
    m = x;
  }
  if (y == b) {
    n = 3;
    m = x;
  }
  if (!e[n][m]) {
    e[n][m] = 1;
    zz++;
  }
  if (x == 1) {
    dy = 1;
  }
  if (x == a) {
    dy = -1;
  }
  if (y == 1) {
    dx = 1;
  }
  if (y == b) {
    dx = -1;
  }
}
int main() {
  cin >> a >> b;
  s = 1;
  string z;
  zz = 0;
  cin >> x >> y >> z;
  wl = 0;
  memset(e, 0, sizeof(e));
  z[0] == 'D' ? dy = 1 : dy = -1;
  z[1] == 'R' ? dx = 1 : dx = -1;
  for (int i = 0; i < (a + b - 2) * 2; i++) {
    as(x, y);
    if (zz >= (a + b - 2)) {
      wl++;
      break;
    }
    qsb = min(dy > 0 ? a - x : x - 1, dx > 0 ? b - y : y - 1);
    s += qsb;
    x += dy * qsb;
    y += dx * qsb;
  }
  if (wl) {
    cout << s << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
