#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
int main() {
  string s;
  cin >> s;
  map<pair<int, int>, vector<int> > m;
  queue<pair<int, int> > q;
  m[make_pair(0, 0)].push_back(0);
  q.push(make_pair(0, 0));
  int x = 0, y = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'U') {
      y++;
    } else if (s[i] == 'D') {
      y--;
    } else if (s[i] == 'L') {
      x--;
    } else {
      x++;
    }
    m[make_pair(x, y)].push_back(i + 1);
    q.push(make_pair(x, y));
  }
  while (!q.empty()) {
    x = q.front().first, y = q.front().second;
    q.pop();
    if (m[make_pair(x, y)].size() > 1) {
      cout << "BUG";
      return 0;
    }
    for (int i = 0; i < 4; i++) {
      for (int j = 0; j < m[make_pair(x + dx[i], y + dy[i])].size(); j++) {
        if (abs(m[make_pair(x, y)][0] - m[make_pair(x + dx[i], y + dy[i])][0]) >
            1) {
          cout << "BUG";
          return 0;
        }
      }
    }
  }
  cout << "OK";
  return 0;
}
