#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  map<pair<int, int>, bool> G;
  string s;
  cin >> s;
  int dx = 0, dy = 0;
  G[make_pair(dx, dy)] = 1;
  for (int i = (0); i < (s.length()); ++i) {
    int ox = dx, oy = dy;
    switch (s[i]) {
      case 'L':
        dx--;
        break;
      case 'R':
        dx++;
        break;
      case 'U':
        dy++;
        break;
      case 'D':
        dy--;
        break;
    }
    if (G.find(make_pair(dx, dy)) != G.end()) {
      puts("BUG");
      return 0;
    }
    G[make_pair(dx, dy)] = 1;
    int x[4] = {-1, 0, 1, 0}, y[4] = {0, 1, 0, -1};
    for (int p = (0); p < (4); ++p) {
      int j = x[p], k = y[p];
      if (!j || !k) {
        int nx = dx + j, ny = dy + k;
        if ((nx != ox || ny != oy) && G.find(make_pair(nx, ny)) != G.end()) {
          puts("BUG");
          return 0;
        }
      }
    }
  }
  puts("OK");
  return 0;
}
