#include <bits/stdc++.h>
using namespace std;
string t;
set<pair<int, int> > S;
vector<pair<int, int> > Q;
int main() {
  cin >> t;
  S.clear();
  Q.clear();
  Q.push_back(make_pair(0, 0));
  int x = 0, y = 0;
  for (int(i) = 0; (i) < (t).size(); (i)++) {
    if (t[i] == 'L') x++;
    if (t[i] == 'R') x--;
    if (t[i] == 'U') y++;
    if (t[i] == 'D') y--;
    Q.push_back(make_pair(x, y));
  }
  bool ok = true;
  for (int(i) = 0; (i) < (Q).size(); (i)++)
    for (int(j) = 0; (j) < (Q).size(); (j)++)
      if (i + 1 < j)
        if (abs(Q[i].first - Q[j].first) + abs(Q[i].second - Q[j].second) < 2)
          ok = false;
  printf(ok ? "OK\n" : "BUG\n");
  return 0;
}
