#include <bits/stdc++.h>
using namespace std;
int n, m;
int l[155];
int r[155];
int main() {
  int i, t, ans, w, j, maxt, k;
  char s;
  bool f;
  while (scanf("%d%d", &n, &m) != EOF) {
    ans = 0;
    maxt = 0;
    for (i = 0; i <= n; ++i) {
      l[i] = 200;
      r[i] = -1;
    }
    for (i = 0; i < n; ++i) {
      getchar();
      f = 1;
      for (j = 0; j < m; ++j) {
        scanf("%c", &s);
        if (s == 'W') {
          if (f == 1) {
            f = 0;
            maxt = i;
            l[i] = j;
          }
          t = j;
        }
      }
      if (!f) {
        r[i] = t;
      }
    }
    w = t = k = 0;
    for (i = 0; i <= maxt; ++i) {
      if (l[i] == 200 && l[i + 1] == 200) {
        ans++;
        continue;
      }
      if (i & 1) {
        t = min(l[i], l[i + 1]);
        if (k >= t) {
          ans += k - t;
          k = t;
        }
        ans++;
      } else {
        w = max(r[i], r[i + 1]);
        if (w >= k) {
          ans += w - k;
          k = w;
        }
        ans++;
      }
    }
    if (ans == 0)
      puts("0");
    else
      printf("%d\n", ans - 1);
  }
  return 0;
}
