#include <bits/stdc++.h>
using namespace std;
int dir[4][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}};
const char *str = "UDLR";
bool mark[204][204];
char s[102];
int direct(char c) {
  for (int i = 0; i < 4; i++) {
    if (c == str[i]) return i;
  }
}
bool Check(int x, int y) {
  if (mark[x][y]) return 1;
  int cnt = 0, i, j;
  for (int k = 0; k < 4; k++) {
    i = x + dir[k][0];
    j = y + dir[k][1];
    if (mark[i][j]) ++cnt;
  }
  return cnt > 1;
}
bool Solve(int x, int y) {
  mark[x][y] = 1;
  int t;
  for (int i = 0; s[i]; i++) {
    t = direct(s[i]);
    x += dir[t][0];
    y += dir[t][1];
    if (Check(x, y)) return 0;
    mark[x][y] = 1;
  }
  return 1;
}
int main() {
  scanf("%s", s);
  printf("%s", Solve(101, 101) ? "OK" : "BUG");
  return 0;
}
