#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <class T1, class T2>
struct cmpf {
  bool rev;
  inline bool operator()(const pair<T1, T2>& a, const pair<T1, T2>& b) const {
    return (a.first < b.first) ^ rev;
  }
  cmpf(bool b = false) { rev = b; }
};
template <class T1, class T2>
struct cmps {
  bool rev;
  inline bool operator()(const pair<T1, T2>& a, const pair<T1, T2>& b) const {
    return (a.second < b.second) ^ rev;
  }
  cmps(bool b = false) { rev = b; }
};
void chmn(int& a, const int& b) {
  if (a > b) a = b;
}
void chmn(long long& a, const long long& b) {
  if (a > b) a = b;
}
void chmx(int& a, const int& b) {
  if (a < b) a = b;
}
void chmx(long long& a, const long long& b) {
  if (a < b) a = b;
}
int chr[4] = {-1, 0, 1, 0};
int chc[4] = {0, 1, 0, -1};
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int INIT = 1001001001;
const int MN = 101;
void setIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
long long binpow(const long long& x, const long long& p) {
  if (p == 0) return 1;
  if (p == 1) return x % MOD;
  if (p & 1) return (binpow((x * x) % MOD, p / 2) * x) % MOD;
  return binpow((x * x) % MOD, p / 2) % MOD;
}
set<pair<int, int> > visited;
bool adj(pair<int, int> pos, pair<int, int> prev) {
  for (int i = 0; i < 4; i++) {
    if (pos.first + chr[i] == prev.first && pos.second + chc[i] == prev.second)
      continue;
    if (visited.find(pair<int, int>(pos.first + chr[i], pos.second + chc[i])) !=
        visited.end()) {
      return true;
    }
  }
  return false;
}
int moves[MN];
int main() {
  setIO();
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'L') {
      moves[i] = 3;
    } else if (s[i] == 'R') {
      moves[i] = 1;
    } else if (s[i] == 'U') {
      moves[i] = 2;
    } else {
      moves[i] = 0;
    }
  }
  pair<int, int> cur(0, 0);
  visited.insert(cur);
  pair<int, int> prev(10000, 10000);
  bool opt = true;
  for (int i = 0; i < s.size(); i++) {
    cur.first += chr[moves[i]];
    cur.second += chc[moves[i]];
    if (i > 0 && (visited.find(cur) != visited.end() || adj(cur, prev))) {
      opt = false;
    }
    visited.insert(cur);
    prev = cur;
  }
  cout << (opt ? "OK" : "BUG") << endl;
  return 0;
}
