#include <bits/stdc++.h>
using namespace std;
int const N = 200;
char maze[N][N];
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    for (int n_ = (n), i = 0; i < n_; ++i) scanf("%s", maze[i]);
    int curr = 0;
    int ans = 0;
    int last_height = 0;
    for (int n_ = (n), r = 0; r < n_; ++r) {
      int last = curr;
      bool hasw = false;
      if (r % 2 == 0) {
        for (int j = curr; j < m; ++j) {
          if (maze[r][j] == 'W') last = j, hasw = true;
        }
        if (r != n - 1) {
          for (int j = last; j < m; ++j) {
            if (maze[r + 1][j] == 'W') last = j;
          }
        }
      } else {
        for (int j = curr; j >= 0; --j) {
          if (maze[r][j] == 'W') last = j, hasw = true;
        }
        if (r != n - 1) {
          for (int j = last; j >= 0; --j) {
            if (maze[r + 1][j] == 'W') last = j;
          }
        }
      }
      if (hasw) last_height = r;
      ans += labs(curr - last);
      curr = last;
    }
    printf("%d\n", ans + last_height);
  }
  return 0;
}
