#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const unsigned long long SEED = 1e6 + 7;
const int N = 2e2 + 7;
const int MOD = 1e9 + 7;
const double Pi = acos(-1.);
const double EPS = 1e-8;
int n, m, a[N][N], b[N];
char getChar() {
  char ch = getchar();
  while (!(ch == 'G' || ch == 'W')) ch = getchar();
  return ch;
}
int find(int x, int y) {
  if (y) {
    for (int i = 0; i < m; ++i)
      if (a[x][i]) return i;
  } else {
    for (int i = m - 1; i >= 0; --i)
      if (a[x][i]) return i;
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      a[i][j] = (getChar() == 'W');
      b[i] += a[i][j];
    }
    if (b[i]) ans = i;
  }
  int col = 0, to;
  for (int i = 0; i < n; ++i) {
    to = col;
    if (!(i & 1)) {
      if (b[i]) to = max(to, find(i, 0));
      if (b[i + 1]) to = max(to, find(i + 1, 0));
    } else {
      if (b[i]) to = min(to, find(i, 1));
      if (b[i + 1]) to = min(to, find(i + 1, 1));
    }
    ans += abs(col - to);
    col = to;
  }
  printf("%d", ans);
  return 0;
}
