#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, -1, 1};
int dy[] = {-1, -1, 1, 1};
int n, m, x, y, dir;
char str[10];
int main() {
  while (scanf("%d%d", &n, &m) == 2) {
    scanf("%d%d", &x, &y);
    scanf("%s", str);
    dir = 0;
    if (str[0] == 'D') dir += 1;
    if (str[1] == 'R') dir += 2;
    int tot = 0;
    if ((x + y) % 2 == 0)
      tot += (n + 1) / 2 + m / 2 - 1;
    else
      tot += n / 2 + (m - 1) / 2;
    if ((x + y) % 2 == (m + 1) % 2)
      tot += (n + 1) / 2;
    else
      tot += n / 2;
    if ((x + y) % 2 == (2 + n) % 2)
      tot += (m - 1) / 2;
    else
      tot += (m - 2) / 2;
    set<pair<int, int> > st;
    long long ans = 1;
    for (int i = 0; i < (n + m) * 4; i++) {
      st.insert(make_pair(x, y));
      if (st.size() == tot) {
        printf("%I64d\n", ans);
        break;
      }
      int l = 0, r = max(n, m) + 1;
      while (l + 1 < r) {
        int mid = (l + r) / 2;
        int xx = x + dx[dir] * mid;
        int yy = y + dy[dir] * mid;
        if (xx >= 1 && xx <= n && yy >= 1 && yy <= m)
          l = mid;
        else
          r = mid;
      }
      ans = ans + l;
      x = x + l * dx[dir];
      y = y + l * dy[dir];
      if (x == 1 || x == n) dir = dir ^ 1;
      if (y == 1 || y == m) dir = dir ^ 2;
      if (x == 1 && y == 1) dir = 3;
      if (x == 1 && y == m) dir = 1;
      if (x == n && y == 1) dir = 2;
      if (x == n && y == m) dir = 0;
    }
    if (st.size() != tot) printf("-1\n");
  }
  return 0;
}
