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