#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int INF = (1 << 30) - 1;
string s;
const int dx[5] = {-1, 1, 0, 0, 0};
const int dy[5] = {0, 0, 1, -1, 0};
bool was[1005][1005];
int main() {
  for (int c = getchar(); c != '\n' && c != EOF; c = getchar()) s += c;
  int x = 105, y = 105, pi = 5;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j <= 4; j++) {
      if (j != pi && was[x + dx[j]][y + dy[j]]) {
        cout << "BUG";
        return 0;
      }
    }
    was[x][y] = 1;
    if (s[i] == 'L') {
      pi = 1;
      x--;
    } else if (s[i] == 'R') {
      pi = 0;
      x++;
    } else if (s[i] == 'U') {
      pi = 3;
      y++;
    } else {
      pi = 2;
      y--;
    }
  }
  for (int j = 0; j <= 4; j++) {
    if (j != pi && was[x + dx[j]][y + dy[j]]) {
      cout << "BUG";
      return 0;
    }
  }
  cout << "OK";
  return 0;
}
