#include <bits/stdc++.h>
using namespace std;
const char NL = '\n';
long long int mod = 1000000007;
clock_t startTime;
double getCurrentTime() {
  return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}
void read(vector<long long int> &a) {
  for (auto &it : a) cin >> it;
}
inline void solve() {
  string s;
  cin >> s;
  map<pair<long long int, long long int>, long long int> st;
  long long int x = 0, y = 0;
  st.insert({{0, 0}, 1});
  long long int n = s.length();
  for (long long int i = -1; i < n; i++) {
    if (i >= 0) {
      if (s[i] == 'L')
        x--;
      else if (s[i] == 'R')
        x++;
      else if (s[i] == 'U')
        y++;
      else
        y--;
      st[{x, y}]++;
      if (st[{x, y}] >= 2) {
        cout << "BUG" << NL;
        return;
      }
    }
    if (i < n - 1) {
      long long int cx = x, cy = y;
      st[{x + 1, y}]++;
      st[{x - 1, y}]++;
      st[{x, y - 1}]++;
      st[{x, y + 1}]++;
      if (s[i + 1] == 'L')
        cx--;
      else if (s[i + 1] == 'R')
        cx++;
      else if (s[i + 1] == 'U')
        cy++;
      else
        cy--;
      st[{cx, cy}]--;
    }
  }
  cout << "OK" << NL;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  startTime = clock();
  solve();
  fflush(stdin);
  fflush(stdout);
  return 0;
}
