#include <bits/stdc++.h>
using namespace std;
int d[200][200];
int l[200], r[200];
int main() {
  int n, m;
  string s;
  scanf("%d%d\n", &n, &m);
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < m; j++) {
      if (s[j] == 'W') d[i][j] = 1;
      if (s[j] == 'G') d[i][j] = 0;
    }
    int fst = 1000000, lst = -1000000;
    for (int j = 0; j < m; j++) {
      if (d[i][j] && fst == 1000000) fst = j;
      if (d[i][j]) lst = j;
    }
    l[i] = fst;
    r[i] = lst;
  }
  while (n > 0) {
    if (l[n - 1] == 1000000 && r[n - 1] == -1000000)
      n--;
    else
      break;
  }
  int st = 0, to, ans = 0;
  for (int i = 0; i < n - 1; i++) {
    if (i % 2 == 0) {
      to = max(r[i], r[i + 1]);
      if (to == -1000000) to = st;
      if (st > to)
        ans++;
      else {
        ans += (to - st + 1);
        st = to;
      }
    } else {
      to = min(l[i], l[i + 1]);
      if (to == 1000000) to = st;
      if (to > st)
        ans++;
      else {
        ans += (st - to + 1);
        st = to;
      }
    }
  }
  if ((n - 1) % 2 == 0) {
    to = r[n - 1];
    ans += (to - st);
  } else {
    to = l[n - 1];
    ans += (st - to);
  }
  cout << ans;
  return 0;
}
