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