#include <bits/stdc++.h>
using namespace std;
const int MAX = 155;
const int INF = 1 << 30;
int N, M;
int l;
int f[MAX], s[MAX];
char b[MAX][MAX];
int main() {
  scanf("%d%d\n", &N, &M);
  for (int i = 0; i < (N); ++i) {
    scanf("%s", b[i]);
    f[i] = INF;
    s[i] = -1;
    for (int j = 0; j < (M); ++j)
      if (b[i][j] == 'W') {
        if (f[i] == INF) {
          f[i] = s[i] = j;
          l = i;
        } else
          s[i] = j;
      }
  }
  f[N] = INF;
  s[N] = -1;
  int ans = 0;
  int j = 0, t;
  for (int i = (0); i <= l; ++i) {
    if (i & 1) {
      t = min(f[i], f[i + 1]);
      if (t < j) {
        ans += (j - t);
        j = t;
      }
    } else {
      t = max(s[i], s[i + 1]);
      if (t > j) {
        ans += (t - j);
        j = t;
      }
    }
  }
  printf("%d\n", ans + l);
  return 0;
}
