#include <bits/stdc++.h>
using namespace std;
char str[101];
bool a[202][202];
int main() {
  cin.getline(str, 100);
  int x = 102, y = 102, i = 0;
  for (; str[i]; i++) {
    a[x][y] = true;
    switch (str[i]) {
      case 'L':
        y--;
        break;
      case 'R':
        y++;
        break;
      case 'U':
        x--;
        break;
      case 'D':
        x++;
        break;
    }
    if (a[x + 1][y] + a[x - 1][y] + a[x][y - 1] + a[x][y + 1] + a[x][y] > 1) {
      cout << "BUG";
      return 0;
    }
  }
  cout << "OK";
  return 0;
}
