#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
bool visited[201][201];
int main() {
  string str;
  cin >> str;
  pair<int, int> pos = {100, 100};
  vector<int> seq;
  for (int i = 0; i < str.size(); i++) {
    char ch = str[i];
    switch (ch) {
      case 'U':
        seq.push_back(0);
        break;
      case 'R':
        seq.push_back(1);
        break;
      case 'D':
        seq.push_back(2);
        break;
      case 'L':
        seq.push_back(3);
        break;
    }
  }
  visited[100][100] = true;
  for (int i = 0; i < seq.size(); i++) {
    pos.first += dx[seq[i]];
    pos.second += dy[seq[i]];
    if (visited[pos.first][pos.second]) {
      cout << "BUG";
      return 0;
    }
    visited[pos.first][pos.second] = true;
    int counter = 0;
    for (int dir = 0; dir < 4; dir++) {
      if (visited[pos.first + dx[dir]][pos.second + dy[dir]]) counter++;
    }
    if (counter > 1) {
      cout << "BUG";
      return 0;
    }
  }
  cout << "OK";
  return 0;
}
