#include <bits/stdc++.h>
struct Position {
  int r, c;
};
int main() {
  int N, M, i, j, moves, E;
  bool dir, empty[151];
  Position pos;
  char field[151][151];
  int rmax[151], rmin[151], next[151];
  scanf("%d %d\n", &N, &M);
  for (i = 0; i < N; i++) {
    for (j = 0; j < M; j++) {
      scanf("%c", &field[i][j]);
    }
    scanf("%*c");
  }
  for (i = 0; i < N; i++) {
    int last = 0;
    int first = M;
    bool e = true;
    for (j = 0; j < M; j++) {
      if (field[i][j] == 'W') {
        e = false;
        if (j < first) first = j;
        if (j > last) last = j;
      }
    }
    empty[i] = e;
    if (!e) E = i;
    rmax[i] = last;
    rmin[i] = first;
  }
  for (i = 0; i < N; i++) {
    if (!empty[i]) {
      continue;
    }
    for (j = i + 1; j < N; j++) {
      if ((j + 1) % 2 == 0) {
        for (int k = i + 1; k < j; k++) {
          rmin[k] = rmax[k] = rmin[j];
        }
      } else {
        for (int k = i + 1; k < j; k++) {
          rmin[k] = rmax[k] = rmax[j];
        }
      }
      i = j;
      break;
    }
  }
  pos.r = 0;
  pos.c = 0;
  moves = 0;
  dir = true;
  for (i = 0; i <= E; i++) {
    if (dir == true) {
      if (rmax[i] > pos.c) {
        moves += rmax[i] - pos.c;
        pos.c = rmax[i];
      }
      if (i + 1 <= E && rmax[i + 1] > rmax[i] && rmax[i + 1] > pos.c) {
        moves += rmax[i + 1] - pos.c;
        pos.c = rmax[i + 1];
      }
    } else {
      if (rmin[i] < pos.c) {
        moves += pos.c - rmin[i];
        pos.c = rmin[i];
      }
      if (i + 1 <= E && rmin[i + 1] < rmin[i] && rmin[i + 1] < pos.c) {
        moves += pos.c - rmin[i + 1];
        pos.c = rmin[i + 1];
      }
    }
    if (i + 1 <= E) {
      pos.r += 1;
      dir = !dir;
      moves++;
    }
  }
  printf("%d\n", moves);
  return 0;
}
