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