#include <bits/stdc++.h>
using namespace std;
int main() {
  int r, c;
  int i, j;
  char grid[200][200];
  while (scanf("%d%d", &r, &c) == 2) {
    for (i = 0; i < r; i++) scanf("%s", grid[i]);
    for (i = 0; i < c; i++) grid[r][i] = 'G';
    int prv = 0, tot = 0, x, y = 0;
    for (i = 0; i < r; i++) {
      if (i % 2 == 0) {
        for (j = c - 1; j >= 0; j--)
          if (grid[i][j] == 'W' || grid[i + 1][j] == 'W') {
            if (j - prv >= 0) {
              x = j;
              y = i;
              tot += (x - prv);
            }
            break;
          }
      } else {
        for (j = 0; j < c; j++)
          if (grid[i][j] == 'W' || grid[i + 1][j] == 'W') {
            if (prv - j >= 0) {
              x = j;
              y = i;
              tot += (prv - x);
            }
            break;
          }
      }
      prv = x;
    }
    tot += y;
    printf("%d\n", tot);
  }
  return 0;
}
