#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 29;
const int N = 250 + 20;
typedef int arr[N];
char Ga[N][N];
arr Lx, Rx;
int n, m, res(1), now, ans, flag(0), Lim(1);
void init() {
  scanf("%d %d\n", &n, &m);
  for (int i = 1; i <= n + 2; i++) Lx[i] = inf, Rx[i] = 0;
  for (int i = 1; i <= n; i++, scanf("\n"))
    for (int j = 1; j <= m; j++) {
      scanf("%c", &Ga[i][j]);
      if (Ga[i][j] == 'W') {
        if (Lx[i] == inf) Lx[i] = j;
        Rx[i] = j;
        Lim = i;
      }
    }
  ans += Lim - 1;
}
int main() {
  int i;
  init();
  for (i = 1; i <= n; i++) {
    if (i & 1) {
      now = max(Rx[i], Rx[i + 1]);
      if (now < res) continue;
    } else {
      now = min(Lx[i], Lx[i + 1]);
      if (now > res) continue;
    }
    ans += abs(res - now);
    res = now;
  }
  printf("%d\n", ans);
  return 0;
}
