#include <bits/stdc++.h>
using namespace std;
int N, M, leftMost[155], rightMost[155];
char g[155][155];
int main() {
  int lastRow = 1;
  scanf("%d %d", &N, &M);
  for (int i = 1; i <= N; i++) {
    scanf("%s", g[i] + 1);
    leftMost[i] = M + 1;
    for (int j = 1; j <= M; j++) {
      if (g[i][j] == 'W') {
        leftMost[i] = min(leftMost[i], j);
        rightMost[i] = j;
        lastRow = i;
      }
    }
  }
  leftMost[N + 1] = M + 1;
  int res = 0, c = 1;
  for (int i = 1; i <= lastRow; i++) {
    if (i % 2) {
      int nextC = max(rightMost[i], rightMost[i + 1]);
      if (nextC >= c) {
        res += nextC - c;
        c = nextC;
      }
    } else {
      int nextC = min(leftMost[i], leftMost[i + 1]);
      if (c >= nextC) {
        res += c - nextC;
        c = nextC;
      }
    }
  }
  printf("%d\n", res + lastRow - 1);
  return 0;
}
