#include <bits/stdc++.h>
using namespace std;
int n, m, FW[152], LW[152];
char mp[152][152];
int main() {
  int i, j, LR = 0, NR[152];
  memset(NR, -1, sizeof(NR));
  memset(FW, 32, sizeof(FW));
  memset(LW, 0, sizeof(LW));
  scanf("%d %d\n", &n, &m);
  for (i = 0; i < n; i++) {
    for (j = 0; j <= m; j++) {
      scanf("%c", &mp[i][j]);
      if (mp[i][j] == 'W') {
        FW[i] = min(FW[i], j);
        LW[i] = max(LW[i], j);
        if (i > LR) {
          NR[LR] = i;
          LR = i;
        }
      }
    }
  }
  int cj = 0;
  int ret = 0;
  for (i = 0; i < n; i++) {
    if (!(i % 2)) {
      ret += LW[i] - cj;
      cj = LW[i];
    }
    if (i % 2) {
      ret += cj - FW[i];
      cj = FW[i];
    }
    if (NR[i] == -1) break;
    ret += (NR[i] - i);
    if (NR[i] % 2) {
      if (LW[NR[i]] > cj) ret += LW[NR[i]] - cj;
      cj = max(LW[NR[i]], cj);
    }
    if (!(NR[i] % 2)) {
      if (FW[NR[i]] < cj) ret += cj - FW[NR[i]];
      cj = min(FW[NR[i]], cj);
    }
    i = NR[i] - 1;
  }
  printf("%d\n", ret);
  return 0;
}
