#include <bits/stdc++.h>
using namespace std;
const int N = 200;
char str[N][N];
int mins[N];
int maxs[N];
int main() {
  int n, m;
  cin >> n >> m;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    bool bb = false;
    for (int j = 1; j <= m; j++) {
      cin >> str[i][j];
      if (str[i][j] == 'W') {
        bb = true;
      }
    }
    if (bb) {
      cnt = i;
    }
  }
  maxs[0] = 1;
  mins[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (str[i][j] == 'W') {
        mins[i] = j;
        break;
      }
    }
    for (int j = 1; j <= m; j++) {
      if (str[i][j] == 'W') {
        maxs[i] = j;
      }
    }
  }
  int ans = 0;
  bool flag = true;
  int total = 1;
  for (int i = 1; i < cnt; i++) {
    if (flag) {
      if (maxs[i] != 0) {
        ans += maxs[i] - total;
        total = maxs[i];
      }
      if (maxs[i + 1] != 0 && maxs[i + 1] > total) {
        ans += maxs[i + 1] - total;
        total = maxs[i + 1];
      }
    } else {
      if (mins[i] != 0) {
        ans += total - mins[i];
        total = mins[i];
      }
      if (mins[i + 1] != 0 && mins[i + 1] < total) {
        ans += total - mins[i + 1];
        total = mins[i + 1];
      }
    }
    ans++;
    flag = !flag;
  }
  if (flag) {
    ans += maxs[cnt] - total;
  } else {
    ans += total - mins[cnt];
  }
  cout << ans << endl;
  return 0;
}
