#include <bits/stdc++.h>
using namespace std;
map<int, char> mp[100005];
int n, m;
char getCode(char x) { return x == 'U' || x == 'L'; }
int getDistance(int positive, int current, int mymax) {
  if (positive == 1) return current - 1;
  return mymax - current;
}
char invalid(int x, int mymax) {
  if (x < 1 || x > mymax) return 1;
  return 0;
}
int direction[4];
char str[4];
void modify(int currentx, int currenty) {
  if (invalid(currentx - direction[0], n)) direction[0] *= -1;
  if (invalid(currenty - direction[1], m)) direction[1] *= -1;
}
void out() {
  printf("-1\n");
  exit(0);
}
void check(int v) {
  for (int j = 1; j <= m; j++)
    if ((j - 1) % 2 == v && mp[1][j] == 0) out();
  for (int j = 1; j <= m; j++)
    if (abs(j - n) % 2 == v && mp[n][j] == 0) out();
  for (int i = 1; i <= n; i++)
    if (abs(i - 1) % 2 == v && mp[i][1] == 0) out();
  for (int i = 1; i <= n; i++)
    if (abs(i - m) % 2 == v && mp[i][m] == 0) out();
}
int main() {
  int currentx, currenty, startx, starty;
  scanf("%d%d", &n, &m);
  scanf("%d%d", &currentx, &currenty);
  startx = currentx;
  starty = currenty;
  scanf("%s", str);
  for (int i = 0; i < 2; i++)
    if (str[i] == 'U' || str[i] == 'L')
      direction[i] = 1;
    else
      direction[i] = -1;
  modify(currentx, currenty);
  int dirx = direction[0];
  int diry = direction[1];
  long long sm = 1;
  int d;
  long long sv = 0;
  int z;
  while (!mp[currentx][currenty]) {
    z = 1;
    if (mp[currentx][currenty] == 0) sv = sm;
    mp[currentx][currenty] = 1;
    int h = getDistance(direction[0], currentx, n);
    int v = getDistance(direction[1], currenty, m);
    d = min(h, v);
    currentx = currentx - direction[0] * d;
    currenty = currenty - direction[1] * d;
    if (h <= v) direction[0] *= -1;
    if (v <= h) direction[1] *= -1;
    sm += d;
  }
  z = 0;
  long long sv2 = 0;
  sm = d;
  while (!mp[currentx][currenty] || z == 0) {
    if (currentx == startx && currenty == starty) z = 1;
    if (mp[currentx][currenty] == 0) sv2 = sm;
    mp[currentx][currenty] = 1;
    int h = getDistance(direction[0], currentx, n);
    int v = getDistance(direction[1], currenty, m);
    d = min(h, v);
    currentx = currentx - direction[0] * d;
    currenty = currenty - direction[1] * d;
    if (h <= v) direction[0] *= -1;
    if (v <= h) direction[1] *= -1;
    sm += d;
  }
  check(abs((startx - starty) % 2));
  printf("%I64d\n", sv + sv2);
}
