#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  getline(cin, s);
  const int n = s.size();
  unordered_map<int, unordered_set<int>> mp;
  int x = 0, y = 0;
  mp[0].insert(0);
  for (auto& c : s) {
    int i = x, j = y;
    if (c == 'U')
      j++;
    else if (c == 'D')
      j--;
    else if (c == 'R')
      i++;
    else
      i--;
    auto it = mp.find(i);
    if (it != mp.end()) {
      auto iit = it->second.find(j);
      if (iit != it->second.end()) {
        cout << "BUG" << endl;
        return 0;
      }
    }
    mp[i].insert(j);
    mp[x + 1].insert(y);
    mp[x - 1].insert(y);
    mp[x].insert(y - 1);
    mp[x].insert(y + 1);
    x = i;
    y = j;
  }
  cout << "OK" << endl;
  return 0;
}
