#include <bits/stdc++.h>
int main() {
  char arena[205][205];
  char caminho[101];
  int px, py;
  char flag;
  int i;
  while (!feof(stdin)) {
    scanf("%s\n", caminho);
    int len = strlen(caminho);
    memset(arena, 0, sizeof(arena));
    px = 101;
    py = 101;
    arena[px][py] = 1;
    flag = 0;
    for (i = 0; i < len; i++) {
      switch (caminho[i]) {
        case 'L':
          arena[px + 1][py] = 1;
          arena[px][py + 1] = 1;
          arena[px][py - 1] = 1;
          px--;
          break;
        case 'R':
          arena[px - 1][py] = 1;
          arena[px][py + 1] = 1;
          arena[px][py - 1] = 1;
          px++;
          break;
        case 'U':
          arena[px + 1][py] = 1;
          arena[px - 1][py] = 1;
          arena[px][py + 1] = 1;
          py--;
          break;
        case 'D':
          arena[px + 1][py] = 1;
          arena[px - 1][py] = 1;
          arena[px][py - 1] = 1;
          py++;
          break;
      }
      if (arena[px][py] == 1) {
        printf("BUG\n");
        flag = 1;
        break;
      } else {
        arena[px][py] = 1;
      }
    }
    if (flag == 0) printf("OK\n");
  }
  return 0;
}
