#include <bits/stdc++.h>
using namespace std;
bool adj(int x, int y, int x1, int y1) {
  if (x == x1) {
    return ((y - y1) >= 0 ? (y - y1) : (-(y - y1))) <= 1;
  }
  if (y == y1) {
    return ((x - x1) >= 0 ? (x - x1) : (-(x - x1))) <= 1;
  }
  return false;
}
int main() {
  vector<pair<int, int> > passed;
  passed.push_back(make_pair(0, 0));
  int x = 0, y = 0;
  while (!cin.eof()) {
    char c;
    cin >> c;
    if (c == 'q') break;
    if (c == 'U') {
      y++;
    } else if (c == 'D') {
      y--;
    } else if (c == 'L') {
      x--;
    } else {
      x++;
    }
    cerr << x << " " << y << "\n";
    int cnt = 0;
    for (int i = 0; i < passed.size(); i++) {
      if (adj(x, y, passed[i].first, passed[i].second))
        cnt++, cerr << passed[i].first << " " << passed[i].second << "\n";
    }
    if (cnt > 1) {
      cout << "BUG";
      return 0;
    }
    passed.push_back(make_pair(x, y));
  }
  cout << "OK";
}
