#include <bits/stdc++.h>
using namespace std;
int Map[1010][1010], Move[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
char s[110];
int main() {
  int i, x = 105, y = 105, x1, y1, len, cnt, flag = 0;
  scanf("%s", s);
  memset(Map, 0, sizeof(Map));
  Map[105][105] = 1;
  len = strlen(s);
  for (int i = 0; i < len; i++) {
    if (s[i] == 'L') {
      y--;
      if (Map[x][y]) {
        flag = 1;
        break;
      }
      Map[x][y] = 1;
    } else if (s[i] == 'R') {
      y++;
      if (Map[x][y]) {
        flag = 1;
        break;
      }
      Map[x][y] = 1;
    } else if (s[i] == 'U') {
      x--;
      if (Map[x][y]) {
        flag = 1;
        break;
      }
      Map[x][y] = 1;
    } else if (s[i] == 'D') {
      x++;
      if (Map[x][y]) {
        flag = 1;
        break;
      }
      Map[x][y] = 1;
    }
    cnt = 0;
    for (int i = 0; i < 4; i++) {
      x1 = x + Move[i][0];
      y1 = y + Move[i][1];
      if (Map[x1][y1]) cnt++;
    }
    if (cnt != 1) {
      flag = 1;
      break;
    }
  }
  if (flag)
    puts("BUG");
  else
    puts("OK");
  return 0;
}
