#include <bits/stdc++.h>
using namespace std;
int main() {
  int x = 0, y = 0, ok = 1;
  string s;
  map<pair<int, int>, int> mem;
  mem[make_pair((0), (0))] = 1;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'L') {
      x--;
    } else if (s[i] == 'R') {
      x++;
    } else if (s[i] == 'U') {
      y++;
    } else if (s[i] == 'D') {
      y--;
    }
    if (mem[make_pair((x), (y))]) {
      ok = 0;
      break;
    }
    if (mem[make_pair((x - 1), (y))] && mem[make_pair((x - 1), (y))] < i + 1) {
      ok = 0;
      break;
    }
    if (mem[make_pair((x + 1), (y))] && mem[make_pair((x + 1), (y))] < i + 1) {
      ok = 0;
      break;
    }
    if (mem[make_pair((x), (y - 1))] && mem[make_pair((x), (y - 1))] < i + 1) {
      ok = 0;
      break;
    }
    if (mem[make_pair((x), (y + 1))] && mem[make_pair((x), (y + 1))] < i + 1) {
      ok = 0;
      break;
    }
    mem[make_pair((x), (y))] = i + 2;
  }
  if (ok) {
    cout << "OK" << endl;
  } else {
    cout << "BUG" << endl;
  }
}
