#include <bits/stdc++.h>
using namespace std;
int l[201], r[201], ans, maxn;
char c;
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      c = getchar();
      while (c != 'G' && c != 'W') c = getchar();
      if (c == 'W' && l[i] == 0) l[i] = j;
      if (c == 'W') r[i] = j;
    }
    if (r[i] != 0) maxn = i;
  }
  for (int w = 1, i = 1; i <= maxn; i++) {
    if (i & 1) {
      if (r[i]) {
        ans += r[i] - w;
        w = r[i];
      }
      if (i < maxn) {
        if (r[i + 1] && r[i + 1] > w) {
          ans += r[i + 1] - w;
          w = r[i + 1];
        }
        ans++;
      }
    } else {
      if (l[i]) {
        ans += w - l[i];
        w = l[i];
      }
      if (i < maxn) {
        if (l[i + 1] && l[i + 1] < w) {
          ans += w - l[i + 1];
          w = l[i + 1];
        }
        ans++;
      }
    }
  }
  cout << ans;
}
