#include <bits/stdc++.h>
using namespace std;
const int OO = 0x3f3f3f3f, N = 3e5 + 5, mod = 1e9 + 7;
const double pi = acos(-1), EPS = 1e-12;
int n, m, l[155], r[155], nxt[155], ir, jc, ans, nx;
char str[155][155];
int main() {
  memset(l, OO, sizeof l);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    scanf("%s", str[i]);
    for (int j = 0; j < m; ++j)
      if (str[i][j] == 'W') {
        r[i] = j;
        if (l[i] == OO) l[i] = j;
      }
  }
  while (n && l[n - 1] == OO) --n;
  nx = n;
  for (int i = n - 1; i >= 0; --i) {
    nxt[i] = nx;
    if (l[i] != OO) nx = i;
  }
  while (ir < n) {
    if (ir % 2) {
      ans += jc - l[ir];
      jc = l[ir];
    } else {
      ans += r[ir] - jc;
      jc = r[ir];
    }
    if (nxt[ir] != n) {
      if ((nxt[ir] - ir) % 2) {
        if (ir % 2 && jc > l[nxt[ir]]) {
          ans += jc - l[nxt[ir]];
          jc = l[nxt[ir]];
        } else if (ir % 2 == 0 && jc < r[nxt[ir]]) {
          ans += r[nxt[ir]] - jc;
          jc = r[nxt[ir]];
        }
      } else {
        if (ir % 2 && jc > r[nxt[ir]]) {
          ans += jc - r[nxt[ir]];
          jc = r[nxt[ir]];
        } else if (ir % 2 == 0 && jc < l[nxt[ir]]) {
          ans += l[nxt[ir]] - jc;
          jc = l[nxt[ir]];
        }
      }
    }
    ++ir;
    ans += (ir != n);
  }
  printf("%d", ans);
  return 0;
}
