#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int c[300][300];
int main() {
  int a = 150, b = 150;
  set<pair<long long, long long> > st;
  string s;
  cin >> s;
  for (int i = 0; i < 300; ++i)
    for (int j = 0; j < 300; ++j) c[i][j] = 1000000;
  c[a][b] = 1;
  int aa = -1;
  int bb = -1;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'L') ++a;
    if (s[i] == 'R') --a;
    if (s[i] == 'U') ++b;
    if (s[i] == 'D') --b;
    if (c[a + 1][b] < i + 1 || c[a - 1][b] < i + 1 || c[a][b + 1] < i + 1 ||
        c[a][b - 1] < i + 1) {
      cout << "BUG";
      return 0;
    }
    if (c[a][b] < 10000) {
      cout << "BUG";
      return 0;
    }
    c[a][b] = i + 2;
    aa = a;
    bb = b;
  }
  cout << "OK";
  return 0;
}
