#include <bits/stdc++.h>
using namespace std;
long long n, m, x, y, sum = 1;
long long dx = 1, dy = 1;
char a, b;
long long sum1 = 0;
set<pair<long long, long long> > s;
void operation() {
  long long k = 0;
  while (1) {
    s.insert(pair<long long, long long>(x, y));
    k++;
    if (s.size() == n + m - 2) {
      printf("%I64d", sum);
      exit(0);
    }
    long long stepa, stepb;
    if (dx == -1) {
      stepa = x - 1;
    } else
      stepa = n - x;
    if (dy == -1) {
      stepb = y - 1;
    } else
      stepb = m - y;
    long long temp = sum;
    sum += min(stepa, stepb);
    if (temp == sum) {
      sum1++;
      if (sum1 > (long long)1e6) {
        printf("-1");
        exit(0);
      }
    } else
      sum1 = 0;
    if (k > (long long)1e6) {
      printf("-1");
      exit(0);
    }
    x += dx * (sum - temp);
    y += dy * (sum - temp);
    if (x * -dx == 1 || x * dx == n) {
      dx = -1 * dx;
    }
    if (y * -dy == 1 || y * dy == m) {
      dy = -1 * dy;
    }
  }
}
int main() {
  scanf("%lld%lld%lld%lld", &n, &m, &x, &y);
  cin >> a >> b;
  if (a == 'U') dx = -1;
  if (b == 'L') dy = -1;
  operation();
}
