#include <bits/stdc++.h>
using namespace std;
const int d[][2] = {{1, -1}, {1, 1}, {-1, -1}, {-1, 1}};
const char* ds[] = {"DL", "DR", "UL", "UR"};
int gdi(const char* s) {
  int i = -1;
  while (++i < 4) {
    if (!strcmp(s, ds[i])) return i;
  }
}
bool sv[4] = {false};
int fdi(const int dr, const int dc) {
  int i = -1;
  while (++i < 4 && !(dr == d[i][0] && dc == d[i][1]))
    ;
  return i;
}
void pr1(map<pair<int, int>, bool>& mp) {
  map<pair<int, int>, bool>::iterator it = mp.begin();
  while (it != mp.end()) {
    printf("%d, %d\n", it->first.first, it->first.second);
    ++it;
  }
  printf("------------\n");
}
int main() {
  int n, m, xs, ys, di;
  char drs[3];
  scanf("%d%d%d%d%s", &n, &m, &xs, &ys, drs);
  const int n1 = n - 1, m1 = m - 1;
  --xs, --ys;
  const int xy = ((xs + ys) & 1);
  di = gdi(drs);
  int dr = d[di][0], dc = d[di][1], cr = xs, cc = ys;
  if (n == m && n > 2) {
    if ((((!xs && !ys) || (xs == n1 && ys == n1)) && dr * dc > 0) ||
        (((!xs && ys == m1) || (xs == n1 && !ys)) && dr * dc < 0)) {
      printf("-1\n");
      return 0;
    }
  }
  map<pair<int, int>, bool> mp;
  int i = -1;
  while (++i < n) {
    pair<int, int> p1(i, 0), p2(i, m1);
    if (((p1.first + p1.second) & 1) == xy) mp[p1] = false;
    if (((p2.first + p2.second) & 1) == xy) mp[p2] = false;
  }
  i = -1;
  while (++i < m) {
    pair<int, int> p1(0, i), p2(n1, i);
    if (((p1.first + p1.second) & 1) == xy) mp[p1] = false;
    if (((p2.first + p2.second) & 1) == xy) mp[p2] = false;
  }
  int nm = mp.size();
  long long pn = 1;
  pair<int, int> pc(xs, ys);
  map<pair<int, int>, bool>::iterator it = mp.find(pc);
  if (it != mp.end()) {
    it->second = true;
    --nm;
  }
  while (nm) {
    int d1, d2;
    if (dr < 0) {
      d1 = cr;
      if (dc > 0) {
        d2 = m1 - cc;
      } else {
        d2 = cc;
      }
    } else {
      d1 = n1 - cr;
      if (dc > 0) {
        d2 = m1 - cc;
      } else {
        d2 = cc;
      }
    }
    if (d1 > d2) {
      d1 = d2;
      cr += d1 * dr;
      cc += d1 * dc;
      dc = -dc;
    } else if (d1 < d2) {
      cr += d1 * dr;
      cc += d1 * dc;
      dr = -dr;
    } else {
      cr += d1 * dr;
      cc += d2 * dc;
      dr = -dr;
      dc = -dc;
    }
    pn += d1;
    pc.first = cr, pc.second = cc;
    it = mp.find(pc);
    if (it != mp.end() && !it->second) {
      --nm;
      it->second = true;
    }
    if (nm && cr == xs && cc == ys) {
      int j = fdi(dr, dc);
      if (sv[j]) {
        printf("-1\n");
        return 0;
      } else {
        sv[j] = true;
      }
    }
  }
  printf("%I64d\n", pn);
  return 0;
}
