#include <bits/stdc++.h>
using namespace std;
bool isprime(int64_t n) {
  for (int64_t i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
int64_t factorial(int64_t n) {
  return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
int64_t gcd(int64_t a, int64_t b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int64_t lcm(int64_t a, int64_t b) { return (a / gcd(a, b) * b); }
int64_t max(int64_t a, int64_t b) {
  int64_t sol = a > b ? a : b;
  return sol;
}
int64_t min(int64_t a, int64_t b) {
  int64_t sol = a < b ? a : b;
  return sol;
}
int64_t power(int64_t x, int64_t y) {
  int64_t ans = 1;
  while (y > 0) {
    if (y & 1) {
      ans *= x;
    }
    y >>= 1LL;
    x *= x;
  }
  return ans;
}
int64_t mod = 1000000007;
int64_t a[505][505], dist[505][505];
int64_t dx[] = {-1, 1, 0, 0};
int64_t dy[] = {0, 0, -1, 1};
void bfs(int64_t x, int64_t y) {
  queue<pair<int64_t, int64_t> > q;
  q.push(make_pair(x, y));
  dist[x][y] = 1;
  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    int64_t x = p.first;
    int64_t y = p.second;
    for (int64_t i = 0; i < 4; i++) {
      int64_t xn = x + dx[i];
      int64_t yn = y + dy[i];
      if (a[xn][yn] && !dist[xn][yn]) {
        q.push(make_pair(xn, yn));
        dist[xn][yn] = 1 + dist[x][y];
      }
    }
  }
}
inline int64_t solve() {
  string s;
  cin >> s;
  int64_t n = s.size();
  int64_t x = 250, y = 250;
  a[x][y] = 1;
  for (int64_t i = 0; i < n; i++) {
    if (s[i] == 'L') x--;
    if (s[i] == 'R') x++;
    if (s[i] == 'U') y++;
    if (s[i] == 'D') y--;
    a[x][y] = 1;
  }
  bfs(250, 250);
  if (dist[x][y] == n + 1)
    cout << "OK\n";
  else
    cout << "BUG\n";
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
}
