#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
int dpl[155], dpr[155], mxr = 0;
int main() {
  memset(dpr, -1, sizeof(dpr));
  ;
  memset(dpl, -1, sizeof(dpl));
  ;
  int n, m;
  char grid[155][155];
  cin >> n >> m;
  for (int r = (int)1; r <= (int)n; r++) {
    scanf("%s", grid[r]);
  }
  for (int r = 1; r <= n; ++r) {
    for (int c = 1; c <= m; ++c) {
      if (grid[r][c - 1] == 'W') {
        mxr = r;
        if (dpr[r] == -1) {
          dpr[r] = dpl[r] = c;
        } else {
          dpl[r] = min(dpl[r], c);
          dpr[r] = max(dpr[r], c);
        }
      }
    }
  }
  int moves = 0, pr = 1, pc = 1, dir = 1;
  for (int r = 1; r <= mxr; ++r) {
    switch (dir) {
      case 1:
        if (dpr[r] > pc) {
          moves += dpr[r] - pc;
          pc = dpr[r];
        }
        if (r < n) {
          if (dpr[r + 1] > pc) {
            moves += dpr[r + 1] - pc;
            pc = dpr[r + 1];
          }
        }
        dir = -1;
        break;
      case -1:
        if (dpl[r] < pc && dpl[r] != -1) {
          moves += pc - dpl[r];
          pc = dpl[r];
        }
        if (r < n) {
          if (dpl[r + 1] < pc && dpl[r + 1] != -1) {
            moves += pc - dpl[r + 1];
            pc = dpl[r + 1];
          }
        }
        dir = 1;
        break;
    }
  }
  if (mxr) moves += mxr - 1;
  printf("%d\n", moves);
  return 0;
}
