#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200;
char c[MAXN][MAXN];
int Min[MAXN], Max[MAXN];
int main() {
  ios::sync_with_stdio(false);
  fill(Min, Min + MAXN, 1e9 + 10);
  int n, m, w = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> c[i][j];
      if (c[i][j] == 'W') {
        Min[i] = min(Min[i], j);
        Max[i] = max(Max[i], j);
        w++;
      }
    }
  if (w == 0) {
    cout << 0 << endl;
    return 0;
  }
  int x = 1, y = 1, d = 0, ans = 0;
  while (w) {
    if (c[x][y] == 'W') {
      c[x][y] = 'G';
      w--;
    }
    if (d == 0) {
      int M = max(Max[x], Max[x + 1]);
      if (y >= M) {
        x++;
        d = 1 - d;
        ans++;
        continue;
      } else {
        y++;
        ans++;
        continue;
      }
    } else {
      int M = min(Min[x], Min[x + 1]);
      if (y <= M) {
        x++;
        d = 1 - d;
        ans++;
        continue;
      } else {
        y--;
        ans++;
        continue;
      }
    }
  }
  cout << ans - 1 << endl;
  return 0;
}
