#include <bits/stdc++.h>
using namespace std;
int x, y;
bool bo[1005][1005];
string s;
int main() {
  getline(cin, s);
  bo[500][500] = 1;
  x = y = 500;
  for (register int i = 0; i < s.size(); i++) {
    if (s[i] == 'U') {
      if (bo[x - 1][y] || bo[x - 2][y] || bo[x - 1][y - 1] ||
          bo[x - 1][y + 1]) {
        printf("BUG");
        return 0;
      }
      bo[--x][y] = 1;
    }
    if (s[i] == 'L') {
      if (bo[x][y - 1] || bo[x][y - 2] || bo[x + 1][y - 1] ||
          bo[x - 1][y - 1]) {
        printf("BUG");
        return 0;
      }
      bo[x][--y] = 1;
    }
    if (s[i] == 'D') {
      if (bo[x + 1][y] || bo[x + 2][y] || bo[x + 1][y - 1] ||
          bo[x + 1][y + 1]) {
        printf("BUG");
        return 0;
      }
      bo[++x][y] = 1;
    }
    if (s[i] == 'R') {
      if (bo[x][y + 1] || bo[x][y + 2] || bo[x + 1][y + 1] ||
          bo[x - 1][y + 1]) {
        printf("BUG");
        return 0;
      }
      bo[x][++y] = 1;
    }
  }
  printf("OK");
}
