#include <bits/stdc++.h>
using namespace std;
template <class T>
void maximize(T& x, T y) {
  if (x < y) x = y;
}
template <class T>
void minimize(T& x, T y) {
  if (x > y) x = y;
}
template <typename t>
ostream& operator,(ostream& os, const t& x) {
  return os << ' ' << x;
}
char a[155][155];
int n, m;
int ans = 0;
int endx;
bool dfs(int x, int y, int dir) {
  bool flag = false;
  endx = -1;
  if (dir == 1)
    for (int i = y; i <= m; i++) {
      if (a[x][i] == 'W') endx = i;
    }
  else
    for (int i = y; i >= 1; i--) {
      if (a[x][i] == 'W') endx = i;
    }
  if (endx == -1) {
    if (x == n) return false;
    if (dir == 1)
      for (int i = y; i <= m; i++) {
        if (a[x + 1][i] == 'W') endx = i;
      }
    else
      for (int i = y; i >= 1; i--) {
        if (a[x + 1][i] == 'W') endx = i;
      }
    if (endx == -1) {
      maximize(flag, dfs(x + 1, y, 1 - dir));
      ans += flag;
      return flag;
    }
    ans += abs(y - endx);
    ans += dfs(x + 1, endx, 1 - dir);
    return true;
  } else {
    flag = true;
    ans += abs(y - endx);
    y = endx;
    if (x == n) return true;
    if (dir == 1)
      for (int i = y; i <= m; i++) {
        if (a[x + 1][i] == 'W') endx = i;
      }
    else
      for (int i = y; i >= 1; i--) {
        if (a[x + 1][i] == 'W') endx = i;
      }
    if (endx == -1) {
      maximize(flag, dfs(x + 1, y, 1 - dir));
      ans += flag;
      return flag;
    }
    ans += abs(y - endx);
    ans += dfs(x + 1, endx, 1 - dir);
    return true;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'G') a[i][j] = '.';
    }
  }
  dfs(1, 1, 1);
  cout << ans << '\n';
}
