#include <bits/stdc++.h>
int map[200][200];
int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
int finde(int n, int m) {
  int i;
  for (i = 0; i < 4; i++) {
    if (map[n + dir[i][0]][m + dir[i][1]] == 1) return 1;
  }
  return 0;
}
int main() {
  char c[105];
  int i, n = 99, m = 99, bug;
  while (scanf("%s", c) != EOF) {
    getchar();
    bug = 0;
    memset(map, 0, sizeof(map));
    map[n][m] = 1;
    for (i = 0; i < strlen(c); i++) {
      switch (c[i]) {
        case 'U':
          if (map[++n][m] != 1) {
            map[n - 1][m] = 0;
            map[n][m] = 1;
            bug = finde(n, m);
            map[n - 1][m] = 1;
            break;
          } else {
            bug = 1;
            break;
          }
        case 'D':
          if (map[--n][m] != 1) {
            map[n + 1][m] = 0;
            map[n][m] = 1;
            bug = finde(n, m);
            map[n + 1][m] = 1;
            break;
          } else {
            bug = 1;
            break;
          }
        case 'L':
          if (map[n][--m] != 1) {
            map[n][m + 1] = 0;
            map[n][m] = 1;
            bug = finde(n, m);
            map[n][m + 1] = 1;
            break;
          } else {
            bug = 1;
            break;
          }
        case 'R':
          if (map[n][++m] != 1) {
            map[n][m - 1] = 0;
            map[n][m] = 1;
            bug = finde(n, m);
            map[n][m - 1] = 1;
            break;
          } else {
            bug = 1;
            break;
          }
      }
      if (bug) break;
    }
    if (bug)
      printf("BUG\n");
    else
      printf("OK\n");
  }
}
