#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
std::istream& operator>>(std::istream& i, pair<T, U>& p) {
  i >> p.x >> p.y;
  return i;
}
template <typename T>
std::istream& operator>>(std::istream& i, vector<T>& t) {
  for (auto& v : t) {
    i >> v;
  }
  return i;
}
template <typename T, typename U>
std::ostream& operator<<(std::ostream& o, const pair<T, U>& p) {
  o << p.x << ' ' << p.y;
  return o;
}
template <typename T>
std::ostream& operator<<(std::ostream& o, const vector<T>& t) {
  if (t.empty()) o << '\n';
  for (size_t i = 0; i < t.size(); ++i) {
    o << t[i] << " \n"[i == t.size() - 1];
  }
  return o;
}
void solve() {
  string s;
  cin >> s;
  int n = s.size();
  bool yes[400][400] = {false};
  int x = 100, y = 100;
  yes[x][y] = true;
  for (int i = 0; i < n; ++i) {
    int sx = x, sy = y;
    yes[x][y] = false;
    if (s[i] == 'U')
      --x;
    else if (s[i] == 'D')
      ++x;
    else if (s[i] == 'R')
      ++y;
    else
      --y;
    if (yes[x][y] || yes[x + 1][y] || yes[x - 1][y] || yes[x][y + 1] ||
        yes[x][y - 1]) {
      cout << "BUG";
      return;
    }
    yes[x][y] = true;
    yes[sx][sy] = true;
  }
  cout << "OK";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
