#include <bits/stdc++.h>
using namespace std;
const double TOLL = 1e-9;
string grid[161];
int R, C;
int inf = 1000000;
int main() {
  cin >> R >> C;
  for (int i = 0; i < R; i++) cin >> grid[i];
  grid[R] = string(C, 'G');
  int weed = 0;
  int mxR = 0;
  for (int i = 0; i < R; i++)
    for (int j = 0; j < C; j++)
      if (grid[i][j] == 'W') weed++, mxR = max(mxR, i);
  int r = 0, c = 0, dir = 0, rv = 0;
  while (weed) {
    if (dir == 0) {
      int mx = c;
      for (int i = c; i < C; i++)
        if (grid[r][i] == 'W' || grid[r + 1][i] == 'W') mx = i;
      rv += (mx - c);
      for (int i = c; i < C; i++)
        if (grid[r][i] == 'W') weed--;
      r++;
      c = mx;
      dir = 1;
    } else {
      int mx = c;
      for (int i = c; i >= 0; i--)
        if (grid[r][i] == 'W' || grid[r + 1][i] == 'W') mx = i;
      rv += (c - mx);
      for (int i = c; i >= 0; i--)
        if (grid[r][i] == 'W') weed--;
      r++;
      c = mx;
      dir = 0;
    }
  }
  cout << rv + mxR << endl;
}
