#include <bits/stdc++.h>
using namespace std;
ifstream inp(".in");
ofstream out(".out");
string alf = "UDLR";
int di[4] = {-1, +1, 0, 0};
int dj[4] = {0, 0, -1, +1};
int main() {
  string p;
  vector<int> pi, pj;
  cin >> p;
  pi.push_back(0);
  pj.push_back(0);
  for (int i = 0; i < p.size(); i++) {
    int d = alf.find(p[i]);
    pi.push_back(pi[i] + di[d]);
    pj.push_back(pj[i] + dj[d]);
  }
  int n = pi.size(), f = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (abs(i - j) <= 1) {
        continue;
      }
      if (pi[i] == pi[j] && pj[i] == pj[j]) {
        f = 0;
        break;
      }
      for (int k = 0; k < 4; k++) {
        if ((pi[i] + di[k] == pi[j]) && (pj[i] + dj[k] == pj[j])) {
          f = 0;
          break;
        }
      }
    }
    if (!f) {
      break;
    }
  }
  if (f) {
    cout << "OK\n";
  } else {
    cout << "BUG\n";
  }
  return 0;
}
