#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long INFL = LLONG_MAX;
const int output_precision = 15;
const long double pi = acos(-1);
const bool debug = true;
int n, m;
bool field[200][200];
int currentPosition = 0;
bool isWeedBelow(int row) {
  for (int i = row + 1; i < n; i++) {
    for (int(j) = 0, j1234 = m; (j) < j1234; (j)++) {
      if (field[i][j]) return true;
    }
  }
  return false;
}
int furthestRight(int row) {
  int current = -1;
  for (int(i) = 0, j1234 = m; (i) < j1234; (i)++) {
    if (field[row][i]) current = i;
  }
  if (current == -1) return currentPosition;
  return current;
}
int furthestLeft(int row) {
  int current = -1;
  for (int i = m - 1; i > -1; i--) {
    if (field[row][i]) current = i;
  }
  if (current == -1) return currentPosition;
  return current;
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.precision(output_precision);
  cout << fixed;
  cout.tie(0);
  cin >> n >> m;
  for (int(i) = 0, j1234 = n; (i) < j1234; (i)++) {
    for (int(j) = 0, j1234 = m; (j) < j1234; (j)++) {
      char fieldVal;
      cin >> fieldVal;
      field[i][j] = fieldVal == 'W';
    }
  }
  bool right = true;
  int numMoves = 0;
  for (int(i) = 0, j1234 = n; (i) < j1234; (i)++) {
    int mustMoveTo;
    if (right) {
      int farRightThisRow = furthestRight(i);
      int farRight = furthestRight(i + 1);
      mustMoveTo = max(farRightThisRow, farRight);
    } else {
      int farLeftThisRow = furthestLeft(i);
      int farLeft = furthestLeft(i + 1);
      mustMoveTo = min(farLeftThisRow, farLeft);
    }
    numMoves += abs(currentPosition - mustMoveTo);
    currentPosition = mustMoveTo;
    right = !right;
    if (!isWeedBelow(i)) break;
    if (i != n - 1) numMoves += 1;
  }
  cout << numMoves << '\n';
}
