#include <bits/stdc++.h>
using namespace std;
int main() {
  int x = 200, y = 200;
  map<int, int> M{{x << 16 | y, 1}};
  for (char c; cin >> c;) {
    ++M[x + 1 << 16 | y];
    ++M[x - 1 << 16 | y];
    ++M[x << 16 | y + 1];
    ++M[x << 16 | y - 1];
    c == 'R' ? ++x : c == 'L' ? --x : c == 'U' ? ++y : --y;
    if (M[x << 16 | y] > 1) return cout << "BUG\n", 0;
  }
  cout << "OK\n";
}
