#include <bits/stdc++.h>
using namespace std;
const int M = 125;
char S[M];
int len;
int book[M << 1][M << 1];
int main() {
  scanf("%s", S + 1);
  len = strlen(S + 1);
  int x = M, y = M;
  for (int i = 1; i <= len; i++) {
    book[x][y] = 1;
    if (S[i] == 'L') y--;
    if (S[i] == 'R') y++;
    if (S[i] == 'D') x--;
    if (S[i] == 'U') x++;
    int sum = book[x - 1][y] + book[x][y - 1] + book[x + 1][y] + book[x][y + 1];
    if (book[x][y] || sum >= 2) {
      puts("BUG");
      return 0;
    }
  }
  puts("OK");
  return 0;
}
