#include <bits/stdc++.h>
using namespace std;
char ch;
int n, m, s = 1, k, ff = 1, ans;
int l[161];
int r[161];
bool f[161];
inline int qr() {
  while ((ch = getchar()) < '0' || ch > '9')
    ;
  int res = ch ^ 48;
  while ((ch = getchar()) >= '0' && ch <= '9') res = res * 10 + (ch ^ 48);
  return res;
}
inline void init() {
  n = qr(), m = qr();
  l[0] = 1;
  for (register int i = 1; i <= n; ++i) l[i] = 160;
  for (register int i = 1; i <= n; ++i) {
    for (register int j = 1; j <= m; ++j) {
      while ((ch = getchar()) != 'G' && ch != 'W')
        ;
      if (ch == 'W') {
        l[i] = min(l[i], j);
        r[i] = j;
        f[i] = 1;
      }
    }
    if (!f[i]) l[i] = r[i] = (i & 1 ? l[i - 1] : r[i - 1]);
  }
  l[n + 1] = l[n];
  r[n + 1] = r[n];
}
inline void work() {
  for (register int i = n; i; --i)
    if (f[i]) {
      ff = i;
      break;
    }
  for (register int i = 1; i <= ff; ++i, s = k) {
    if (i & 1)
      ans += (k = max(r[i], r[i + 1])) - s + 1;
    else
      ans += s - (k = min(l[i], l[i + 1])) + 1;
  }
  printf("%d\n", --ans);
}
int main() {
  init();
  work();
  return 0;
}
