#include <bits/stdc++.h>
namespace orz {
const char *LL_SPECIFIER = "%I64d";
inline void read(int &x) { scanf("%d", &x); }
inline void read(char *x) { scanf("%s", x); }
template <typename T1, typename T2>
inline void read(T1 &x1, T2 &x2) {
  read(x1);
  read(x2);
}
template <typename T1, typename T2, typename T3>
inline void read(T1 &x1, T2 &x2, T3 &x3) {
  read(x1);
  read(x2);
  read(x3);
}
template <typename T1, typename T2, typename T3, typename T4>
inline void read(T1 &x1, T2 &x2, T3 &x3, T4 &x4) {
  read(x1);
  read(x2);
  read(x3);
  read(x4);
}
inline void write(const int x) { printf("%d", x); }
inline void write(const long long x) { printf(LL_SPECIFIER, x); }
inline void write(const double x) { printf("%.15lf", x); }
template <typename T>
inline void writeln(T x) {
  write(x);
  putchar('\n');
}
template <typename T>
inline std::set<T> &operator<<(std::set<T> &S, const T a) {
  S.insert(a);
  return S;
}
}  // namespace orz
using namespace orz;
std::set<std::pair<int, int> > vi;
int main() {
  int n, m, cx, cy, dx, dy;
  read(n, m, cx, cy);
  {
    char tmp[4];
    read(tmp);
    if (tmp[0] == 'D')
      dx = 1;
    else
      dx = -1;
    if (tmp[1] == 'R')
      dy = 1;
    else
      dy = -1;
  }
  long long ans = 1;
  vi.insert(std::pair<int, int>(cx, cy));
  ;
  for (int rem = n + m - 3, cs = 0;; ++cs) {
    if (cs >= 555555) {
      writeln(-1);
      return 0;
    }
    int cd = 23333333;
    if (dx == 1) {
      if (n - cx < cd) cd = n - cx;
    } else {
      if (cx - 1 < cd) cd = cx - 1;
    }
    if (dy == 1) {
      if (m - cy < cd) cd = m - cy;
    } else {
      if (cy - 1 < cd) cd = cy - 1;
    }
    cx += dx * cd;
    cy += dy * cd;
    ans += (long long)cd;
    if (cx == 1) dx = 1;
    if (cx == n) dx = -1;
    if (cy == 1) dy = 1;
    if (cy == m) dy = -1;
    if (!vi.count(std::pair<int, int>(cx, cy))) {
      vi << std::pair<int, int>(cx, cy);
      if (!(--rem)) {
        writeln(ans);
        return 0;
      }
    }
  }
}
