#include <bits/stdc++.h>
using namespace std;
int n, m, r[160], l[160];
int last;
int main() {
  char c;
  int sum = 0;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> c;
      if (c == 'W') {
        if (l[i] == 0) l[i] = j;
        r[i] = j;
      }
    }
    if (l[i]) last = i;
  }
  for (int i = 1, bian = 1; i <= last; i++) {
    if (i % 2 != 0) {
      if (l[i]) {
        sum += r[i] - bian;
        bian = r[i];
      }
      if (i < last) {
        if (l[i + 1] && r[i + 1] > bian) {
          sum += r[i + 1] - bian;
          bian = r[i + 1];
        }
        sum++;
      }
    } else {
      if (l[i]) {
        sum += bian - l[i];
        bian = l[i];
      }
      if (i < last) {
        if (l[i + 1] && l[i + 1] < bian) {
          sum += bian - l[i + 1];
          bian = l[i + 1];
        }
        sum++;
      }
    }
  }
  cout << sum;
  return 0;
}
