#include <bits/stdc++.h>
using namespace std;
struct row {
  int columns[151];
  int counter;
};
int main() {
  int n, m, counter, bigcounter = 0;
  char input[155];
  scanf("%d", &n);
  scanf("%d", &m);
  row rows[n];
  for (int i = 0; i < n; i++) {
    scanf("%s", input);
    counter = 0;
    for (int j = 0; j < m; j++)
      if (input[j] == 'W') {
        bigcounter++;
        rows[i].columns[counter++] = j;
      }
    rows[i].counter = counter;
  }
  int moves = 0, pos = 0;
  bool faceright = true;
  for (int i = 0; i < n && bigcounter; i++) {
    if (rows[i].counter) {
      if (faceright) {
        moves += rows[i].columns[rows[i].counter - 1] - pos;
        pos = rows[i].columns[rows[i].counter - 1];
        bigcounter -= rows[i].counter;
      } else {
        moves += pos - rows[i].columns[0];
        pos = rows[i].columns[0];
        bigcounter -= rows[i].counter;
      }
    }
    if (i != n - 1 && rows[i + 1].counter) {
      if (faceright) {
        if (pos < rows[i + 1].columns[rows[i + 1].counter - 1]) {
          moves += rows[i + 1].columns[rows[i + 1].counter - 1] - pos;
          pos = rows[i + 1].columns[rows[i + 1].counter - 1];
        }
      } else {
        if (pos > rows[i + 1].columns[0]) {
          moves += pos - rows[i + 1].columns[0];
          pos = rows[i + 1].columns[0];
        }
      }
    }
    if (i != n - 1 && bigcounter) moves++;
    faceright = !faceright;
  }
  printf("%d", moves);
  return 0;
}
