#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, x, y;
  string kier;
  cin >> n >> m >> x >> y >> kier;
  int dx, dy;
  if (kier[0] == 'U')
    dx = -1;
  else
    dx = 1;
  if (kier[1] == 'L')
    dy = -1;
  else
    dy = 1;
  set<pair<int, int> > S;
  S.insert(make_pair(x, y));
  int il_kr = n + m - 2;
  long long odp = 1;
  bool ost = false;
  for (int i = 0; i < 2 * (n + m); ++i) {
    if (dx == -1 && dy == -1) {
      int l = y - 1, g = x - 1;
      x -= min(l, g);
      y -= min(l, g);
      odp += min(l, g);
      if (x == 1 && y == 1) {
        dx = 1;
        dy = 1;
      } else {
        if (x == 1)
          dx = 1;
        else
          dy = 1;
      }
    } else {
      if (dx == -1 && dy == 1) {
        int p = m - y, g = x - 1;
        x -= min(p, g);
        y += min(p, g);
        odp += min(p, g);
        if (x == 1 && y == m) {
          dx = 1;
          dy = -1;
        } else {
          if (x == 1)
            dx = 1;
          else
            dy = -1;
        }
      } else {
        if (dx == 1 && dy == 1) {
          int p = m - y, d = n - x;
          x += min(p, d);
          y += min(p, d);
          odp += min(p, d);
          if (x == n && y == m) {
            dx = -1;
            dy = -1;
          } else {
            if (x == n)
              dx = -1;
            else
              dy = -1;
          }
        } else {
          if (dx == 1 && dy == -1) {
            int l = y - 1, d = n - x;
            x += min(l, d);
            y -= min(l, d);
            odp += min(l, d);
            if (x == n && y == 1) {
              dx = -1;
              dy = 1;
            } else {
              if (x == n)
                dx = -1;
              else
                dy = 1;
            }
          }
        }
      }
    }
    S.insert(make_pair(x, y));
    if (S.size() == il_kr) {
      cout << odp;
      return 0;
    }
  }
  cout << "-1";
  return 0;
}
