#include <bits/stdc++.h>
using namespace std;
char s[200][200];
int N, M;
int MoveFront(int nn, int mm, int d) {
  int j, cc;
  cc = 0;
  for (j = mm + d; j >= 0 && j < M; j += d) {
    cc++;
    if (s[nn][j] == 'W') return cc;
  }
  if (nn >= N) return 0;
  cc = 0;
  if (d == 1) {
    for (j = M; j > mm; j--) {
      cc++;
      if (s[nn + 1][j] == 'W') return M - mm - cc + 1;
    }
  } else {
    for (j = 0; j < mm; j++) {
      cc++;
      if (s[nn + 1][j] == 'W') return mm - cc + 1;
    }
  }
  return 0;
}
int main() {
  int nn, mm, allmove, allw, i, j, d;
  cin >> N >> M;
  nn = 0;
  mm = 0;
  d = 1;
  for (i = 0; i < N; i++) cin >> s[i];
  allw = 0;
  for (i = 0; i < N; i++)
    for (j = 0; j < M; j++)
      if (s[i][j] == 'W') allw++;
  if (s[0][0] == 'W') allw--;
  allmove = 0;
  int ccc;
  while (allw != 0) {
    if (ccc = MoveFront(nn, mm, d)) {
      for (i = 1; i <= ccc; i++) {
        mm += d;
        allmove++;
      }
      if (s[nn][mm] == 'W') {
        s[nn][mm] = 'G';
        allw--;
        continue;
      } else {
        nn++;
        d = -d;
        allmove++;
        if (s[nn][mm] == 'W') {
          s[nn][mm] = 'G';
          allw--;
        }
      }
    } else {
      nn++;
      d = -d;
      allmove++;
      if (s[nn][mm] == 'W') {
        s[nn][mm] = 'G';
        allw--;
      }
    }
  }
  cout << allmove << endl;
  return 0;
}
