#include <bits/stdc++.h>
using namespace std;
using namespace std;
int main() {
  bool map[300][300] = {0};
  string input;
  cin >> input;
  int x = 150, y = 150;
  map[x][y] = 1;
  bool status = 1;
  for (int i = 0; i < input.size(); i++) {
    switch (input[i]) {
      case 'L':
        x++;
        break;
      case 'R':
        x--;
        break;
      case 'U':
        y++;
        break;
      case 'D':
        y--;
        break;
    }
    int collisions = 0;
    if (map[x][y] == 1) {
      status = 0;
      break;
    } else
      map[x][y] = 1;
    if (map[x + 1][y] == 1) collisions++;
    if (map[x - 1][y] == 1) collisions++;
    if (map[x][y + 1] == 1) collisions++;
    if (map[x][y - 1] == 1) collisions++;
    if (collisions >= 2) {
      status = 0;
      break;
    }
  }
  if (status)
    printf("OK");
  else
    printf("BUG");
}
