#include <bits/stdc++.h>
using namespace std;
int da[] = {-1, 0, 1, 0};
int db[] = {0, 1, 0, -1};
set<pair<int, int> > s;
int main() {
  std::ios::sync_with_stdio(false);
  string ss;
  cin >> ss;
  int n = ss.length();
  int a, b;
  a = b = 0;
  s.insert({0, 0});
  for (__typeof(n) i = 0; i < n; i++) {
    if (ss[i] == 'L')
      b--;
    else if (ss[i] == 'R')
      b++;
    else if (ss[i] == 'U')
      a--;
    else if (ss[i] == 'D')
      a++;
    if (s.count({a, b}) == 1) {
      cout << "BUG" << '\n';
      return 0;
    }
    int f = 0;
    for (__typeof(4) i = 0; i < 4; i++) {
      if (s.count({a + da[i], b + db[i]}) == 1) {
        if (f == 0)
          f = 1;
        else {
          cout << "BUG" << '\n';
          return 0;
        }
      }
    }
    s.insert({a, b});
  }
  cout << "OK" << '\n';
  return 0;
}
