#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int i, j, k;
  bool foo = true;
  cin >> s;
  i = 1, j = 1;
  map<pair<int, int>, int> ha;
  ha[{i, j}] = 1;
  for (k = 0; k < s.size(); k++) {
    if (s[k] == 'U') i++;
    if (s[k] == 'D') i--;
    if (s[k] == 'R') j++;
    if (s[k] == 'L') j--;
    if (ha[{i, j}] + ha[{i + 1, j}] + ha[{i - 1, j}] + ha[{i, j + 1}] +
            ha[{i, j - 1}] >
        1)
      foo = false;
    ha[{i, j}] = 1;
  }
  if (!foo)
    cout << "BUG";
  else
    cout << "OK";
  return 0;
}
