#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 300;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
string s;
int gx[] = {0, 0, 1, -1};
int gy[] = {1, -1, 0, 0};
bool used[MAX_N][MAX_N];
bool check(int x, int y) {
  int cnt = 0;
  for (int i = 0; i < 4; ++i) {
    int nx = x + gx[i];
    int ny = y + gy[i];
    if (used[nx][ny]) ++cnt;
  }
  return cnt == 1;
}
bool solve() {
  cin >> s;
  int x = 100, y = 100;
  used[x][y] = true;
  for (auto &ch : s) {
    if (ch == 'U')
      ch = ch - 'U' + '3';
    else if (ch == 'D')
      ch = ch - 'D' + '2';
    else if (ch == 'L')
      ch = ch - 'L' + '1';
    else
      ch = ch - 'R' + '0';
  }
  for (auto ch : s) {
    x += gx[ch - '0'];
    y += gy[ch - '0'];
    if (used[x][y]) return false;
    used[x][y] = true;
    if (!check(x, y)) return false;
  }
  return true;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  while (t--) {
    if (solve())
      cout << "OK" << '\n';
    else
      cout << "BUG" << '\n';
  }
  return 0;
}
