#include <bits/stdc++.h>
using namespace std;
bool mow_weed(string *garden, int m, int n) {
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (garden[i][j] == 'W') {
        return false;
      }
    }
  }
  return true;
}
int main() {
  int n, i, position, m, moves;
  cin >> n >> m;
  string garden[n];
  for (i = 0; i < n; i++) {
    cin >> garden[i];
  }
  for (i = 0, position = 0, moves = 0; i < n - 1; i++) {
    int c1, c2;
    if (i % 2) {
      for (c1 = 0; c1 < m && garden[i][c1] == 'G'; c1++)
        ;
      for (c2 = 0; c2 < m && garden[i + 1][c2] == 'G'; c2++)
        ;
      if (c1 == m) {
        c1 = position;
      }
      if (c2 == m) {
        c2 = position;
      }
      moves += abs(min(c1, c2) - position);
      position = min(c1, c2);
      for (int j = 0; j < m; j++) {
        garden[i][j] = 'G';
      }
    } else {
      for (c1 = m - 1; c1 >= 0 && garden[i][c1] == 'G'; c1--)
        ;
      for (c2 = m - 1; c2 >= 0 && garden[i + 1][c2] == 'G'; c2--)
        ;
      if (c1 == -1) {
        c1 = position;
      }
      if (c2 == -1) {
        c2 = position;
      }
      moves += abs(max(c1, c2) - position);
      position = max(c1, c2);
      for (int j = 0; j < m; j++) {
        garden[i][j] = 'G';
      }
    }
    if (mow_weed(garden, m, n)) {
      cout << moves;
      return 0;
    } else {
      moves += 1;
    }
  }
  if ((n - 1) % 2) {
    for (i = 0; i < m && garden[n - 1][i] == 'G'; i++)
      ;
    if (i == m) {
      cout << moves;
      return 0;
    }
  } else {
    for (i = m - 1; i >= 0 && garden[n - 1][i] == 'G'; i--)
      ;
    if (i == -1) {
      cout << moves;
      return 0;
    }
  }
  moves += abs(i - position);
  cout << moves;
}
