#include <bits/stdc++.h>
using namespace std;
const int N = 160;
char mat[N][N];
int Left[N][N];
int Right[N][N];
int sum[N];
int main() {
  int n, m;
  while (scanf("%d %d", &n, &m) == 2) {
    memset(Left, 0, sizeof(Left));
    memset(Right, 0, sizeof(Right));
    memset(sum, 0, sizeof(sum));
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) scanf(" %c", &mat[i][j]);
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++)
        Left[i][j] = Left[i][j - 1] + (mat[i][j] == 'W');
      for (int j = m; j >= 1; j--)
        Right[i][j] = Right[i][j + 1] + (mat[i][j] == 'W');
    }
    for (int i = n; i >= 1; i--) sum[i] = sum[i + 1] + Right[i][1];
    int ans = 0, add = 0;
    for (int i = 1, j = 1; i <= n; i++) {
      if (sum[i] == 0) break;
      if (i % 2) {
        if (i != 1) add++;
        while (Right[i + 1][j + 1] || Right[i][j + 1]) {
          ans++;
          j++;
        }
      } else {
        add++;
        while (Left[i + 1][j - 1] || Left[i][j - 1]) {
          ans++;
          j--;
        }
      }
    }
    cout << ans + add << endl;
  }
  return 0;
}
