#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  map<pair<int, int>, bool> m;
  int x = 0, y = 0;
  m[make_pair(x, y)] = true;
  bool ans = true;
  for (int i = 0; i < s.size() && ans; i++) {
    int bx = x, by = y;
    if (s[i] == 'L') x--;
    if (s[i] == 'R') x++;
    if (s[i] == 'U') y++;
    if (s[i] == 'D') y--;
    if (m.find(make_pair(x, y)) != m.end())
      ans = false;
    else {
      if ((m.find(make_pair(x - 1, y)) != m.end() &&
           make_pair(x - 1, y) != make_pair(bx, by)) ||
          (m.find(make_pair(x, y - 1)) != m.end() &&
           make_pair(x, y - 1) != make_pair(bx, by)) ||
          (m.find(make_pair(x + 1, y)) != m.end() &&
           make_pair(x + 1, y) != make_pair(bx, by)) ||
          (m.find(make_pair(x, y + 1)) != m.end() &&
           make_pair(x, y + 1) != make_pair(bx, by)))
        ans = false;
      else
        m[make_pair(x, y)] = true;
    }
  }
  if (ans)
    cout << "OK" << endl;
  else
    cout << "BUG" << endl;
}
