#include <bits/stdc++.h>
using namespace std;
void Get(int &T) {
  char C;
  bool F = 0;
  for (; C = getchar(), C < '0' || C > '9';)
    if (C == '-') F = 1;
  for (T = C - '0'; C = getchar(), C >= '0' && C <= '9'; T = T * 10 + C - '0')
    ;
  F && (T = -T);
}
int N, M;
int X, Y;
char Dir[5];
void Init() {
  Get(N);
  Get(M);
  Get(X);
  Get(Y);
  gets(Dir + 1);
}
int A[1000005];
int B[1000005];
int C[1000005];
int E[1000005];
int Sum;
long long Ans;
void No() {
  puts("-1");
  exit(0);
}
void Delete() {
  if (Y == 1) {
    if (A[X] == 0) Sum--;
    A[X]++;
    if (A[X] > 5) No();
  } else if (Y == M) {
    if (B[X] == 0) Sum--;
    B[X]++;
    if (B[X] > 5) No();
  } else if (X == 1) {
    if (C[Y] == 0) Sum--;
    C[Y]++;
    if (C[Y] > 5) No();
  } else if (X == N) {
    if (E[Y] == 0) Sum--;
    E[Y]++;
    if (E[Y] > 5) No();
  }
}
void Go() {
  int DX, DY, D;
  if (Dir[1] == 'U')
    DX = X - 1;
  else
    DX = N - X;
  if (Dir[2] == 'L')
    DY = Y - 1;
  else
    DY = M - Y;
  D = std::min(DX, DY);
  Ans += D;
  if (Dir[1] == 'U')
    X -= D;
  else
    X += D;
  if (Dir[2] == 'L')
    Y -= D;
  else
    Y += D;
  if (D == DX) Dir[1] ^= ('U' ^ 'D');
  if (D == DY) Dir[2] ^= ('L' ^ 'R');
  Delete();
  if (Sum == 0) {
    printf("%I64d\n", Ans);
    exit(0);
  }
}
void Work() {
  Ans = 1;
  for (int i = 1; i <= N; i++) {
    if (((i ^ 1 ^ X ^ Y) & 1) == 0) {
      Sum++;
    }
    if (((i ^ M ^ X ^ Y) & 1) == 0) {
      Sum++;
    }
  }
  for (int i = 2; i < M; i++) {
    if (((i ^ 1 ^ X ^ Y) & 1) == 0) {
      Sum++;
    }
    if (((i ^ N ^ X ^ Y) & 1) == 0) {
      Sum++;
    }
  }
  for (Delete();;) Go();
}
int main() {
  Init();
  Work();
  return 0;
}
