#include <bits/stdc++.h>
using namespace std;
int main() {
  int w, h, mh = 0;
  int ml[200], mr[200];
  char g[200][200];
  cin >> h >> w;
  for (int i = 0; i < h; i++) cin >> g[i];
  int x = 0, sum = 0, d = 1;
  for (int i = 0; i < h; i++) {
    ml[i] = w;
    mr[i] = -1;
    for (int j = 0; j < w; j++) {
      if (g[i][j] == 'W') {
        mh = max(mh, i);
        ml[i] = min(ml[i], j);
        mr[i] = max(mr[i], j);
      }
    }
  }
  int q;
  for (int i = 0; i < mh; i++) {
    if (d == 1) {
      q = max(mr[i], mr[i + 1]);
      if (q == -1 || q < x)
        ;
      else {
        sum += q - x;
        x = q;
      }
    } else {
      q = min(ml[i], ml[i + 1]);
      if (q == w || q > x)
        ;
      else {
        sum += x - q;
        x = q;
      }
    }
    d++;
    d = d % 2;
  }
  if (d == 1) {
    q = mr[mh];
    if (q == -1 || q < x)
      ;
    else {
      sum += q - x;
    }
  } else {
    q = ml[mh];
    if (q == w || q > x)
      ;
    else {
      sum += x - q;
    }
  }
  sum += mh;
  cout << sum << endl;
  return 0;
}
