#include <bits/stdc++.h>
using namespace std;
char mx[151][151];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", &mx[i]);
  int p = 0;
  int res = 0;
  int last = 0;
  for (int i = 0; i < n; i++) {
    int left = p, right = p;
    for (int j = 0; j < m; j++) {
      if (mx[i][j] == 'W') {
        left = min(j, left);
        right = max(j, right);
        last = i;
      }
    }
    if (i + 1 < n) {
      for (int j = 0; j < m; j++) {
        if (mx[i + 1][j] == 'W') {
          left = min(j, left);
          right = max(j, right);
        }
      }
    }
    if (i % 2 == 0) {
      if (right != p) {
        res += right - p;
        p = right;
      }
    } else {
      if (left != p) {
        res += p - left;
        p = left;
      }
    }
  }
  res += last;
  printf("%d\n", res);
  return 0;
}
