#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int len = s.length();
  int pos[len + 1][2];
  pos[0][0] = 0;
  pos[0][1] = 0;
  for (int i = 0; i < len; i++) {
    switch (s[i]) {
      case 'U':
        pos[i + 1][0] = pos[i][0];
        pos[i + 1][1] = pos[i][1] + 1;
        break;
      case 'R':
        pos[i + 1][0] = pos[i][0] + 1;
        pos[i + 1][1] = pos[i][1];
        break;
      case 'D':
        pos[i + 1][0] = pos[i][0];
        pos[i + 1][1] = pos[i][1] - 1;
        break;
      case 'L':
        pos[i + 1][0] = pos[i][0] - 1;
        pos[i + 1][1] = pos[i][1];
        break;
    }
  }
  bool k = true;
  for (int i = 0; i < len - 1 && k; i++) {
    for (int j = i + 2; j <= len && k; j++) {
      if (pos[i][0] == pos[j][0]) {
        int d = pos[i][1] - pos[j][1];
        if (d >= -1 && d <= 1) k = false;
      } else if (pos[i][1] == pos[j][1]) {
        int d = pos[i][0] - pos[j][0];
        if (d == -1 || d == 1 || d == 0) k = false;
      } else
        ;
    }
  }
  if (k)
    cout << "OK";
  else
    cout << "BUG";
  return 0;
}
