#include <bits/stdc++.h>
int flag[210][210];
int main() {
  char input[200];
  while (scanf("%s", input) != EOF) {
    int i, l;
    int x = 102, y = 102;
    flag[x][y] = 1;
    l = strlen(input);
    for (i = 0; i < l; i++) {
      if (input[i] == 'L') {
        y--;
        if (flag[x][y - 1] == 1)
          break;
        else if (flag[x - 1][y] == 1)
          break;
        else if (flag[x + 1][y] == 1)
          break;
      } else if (input[i] == 'R') {
        y++;
        if (flag[x][y + 1] == 1)
          break;
        else if (flag[x - 1][y] == 1)
          break;
        else if (flag[x + 1][y] == 1)
          break;
      } else if (input[i] == 'U') {
        x--;
        if (flag[x - 1][y] == 1)
          break;
        else if (flag[x][y - 1] == 1)
          break;
        else if (flag[x][y + 1] == 1)
          break;
      } else if (input[i] == 'D') {
        x++;
        if (flag[x + 1][y] == 1)
          break;
        else if (flag[x][y - 1] == 1)
          break;
        else if (flag[x][y + 1] == 1)
          break;
      }
      if (flag[x][y] == 1) break;
      flag[x][y] = 1;
    }
    if (i == l)
      printf("OK\n");
    else
      printf("BUG\n");
    memset(flag, 0, sizeof(flag));
  }
  return 0;
}
