#include <bits/stdc++.h>
using namespace std;
int n, m, ans, kol, w[250];
char s[250][250];
inline bool fre(const int& ph, const int& i, const int& j) {
  if (ph == 1) {
    for (int _j = j + 1; _j < m; _j++)
      if (s[i + 1][_j] == 'W') return false;
  } else {
    for (int _j = j - 1; _j >= 0; _j--)
      if (s[i + 1][_j] == 'W') return false;
  }
  return 1;
}
int main() {
  scanf("%d%d\n", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      scanf(j + 1 == m ? "%c\n" : "%c", &s[i][j]);
      if (s[i][j] == 'W') kol++, w[i]++;
    }
  int i = 0, j = 0, ng = 0;
  int res = 0;
  bool rigth = 1;
  while (res != kol) {
    if (s[i][j] == 'W') ng++, res++;
    if (res == kol) break;
    if (ng == w[i]) {
      ng = 0;
      if (i + 1 == n) break;
      if (rigth) {
        while (!fre(1, i, j)) j++, ans++;
        rigth = 0;
      } else {
        while (!fre(0, i, j)) j--, ans++;
        rigth = 1;
      }
      i++;
      ans++;
    } else {
      if (rigth)
        j++, ans++;
      else
        j--, ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
