#include <bits/stdc++.h>
using namespace std;
bool v[1011][1011];
int d[1011][1011];
int xx[] = {-1, 1, 0, 0};
int yy[] = {0, 0, -1, 1};
int main() {
  set<pair<int, int> > seen;
  string s;
  cin >> s;
  memset(v, 0, sizeof v);
  memset(d, -1, sizeof d);
  int ex = 0, ey = 0;
  bool BAD;
  BAD = false;
  seen.insert(make_pair(ex, ey));
  v[500][500] = true;
  for (int i = 0; i < s.size(); i++) {
    ex += s[i] == 'U', ex -= s[i] == 'D';
    ey += s[i] == 'R', ey -= s[i] == 'L';
    if (seen.find(make_pair(ex, ey)) != seen.end()) {
      BAD = true;
      break;
    }
    v[ex + 500][ey + 500] = true;
    seen.insert(make_pair(ex, ey));
  }
  if (BAD)
    printf("BUG\n");
  else {
    queue<int> q;
    q.push(500), q.push(500);
    d[500][500] = 0;
    while (!q.empty()) {
      int I = q.front();
      q.pop();
      int J = q.front();
      q.pop();
      for (int k = 0; k < 4; k++) {
        int x = xx[k] + I, y = yy[k] + J;
        if (v[x][y] && d[x][y] == -1) {
          d[x][y] = d[I][J] + 1;
          q.push(x), q.push(y);
        }
      }
    }
    if (d[ex + 500][ey + 500] == (int)s.size())
      printf("OK\n");
    else
      printf("BUG\n");
  }
  return 0;
}
