#include <bits/stdc++.h>
using namespace std;
bool maze[305][305] = {0};
char mov[105];
int main() {
  scanf("%s", &mov);
  bool bug = 0;
  int r = 150, c = 150, len = strlen(mov);
  maze[r][c] = 1;
  for (int i = 0; i < len; ++i) {
    int nr = r, nc = c;
    switch (mov[i]) {
      case 'U':
        nr--;
        break;
      case 'D':
        nr++;
        break;
      case 'L':
        nc--;
        break;
      case 'R':
        nc++;
        break;
    }
    int cnt = maze[nr][nc - 1] + maze[nr][nc + 1] + maze[nr - 1][nc] +
              maze[nr + 1][nc];
    if (maze[nr][nc] || cnt > 1) {
      bug = 1;
      break;
    }
    r = nr;
    c = nc;
    maze[r][c] = 1;
  }
  printf("%s\n", bug ? "BUG" : "OK");
  return 0;
}
