#include <bits/stdc++.h>
using namespace std;
bool a[400][400];
bool check(int x, int y, int px, int py) {
  if (a[x][y]) return false;
  if (x - 1 != px)
    if (a[x - 1][y]) return false;
  if (x + 1 != px)
    if (a[x + 1][y]) return false;
  if (y - 1 != py)
    if (a[x][y - 1]) return false;
  if (y + 1 != py)
    if (a[x][y + 1]) return false;
  return true;
}
int main() {
  if (fopen("input.txt", "r")) {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int x = 200, y = 200;
  string s;
  cin >> s;
  a[x][y] = true;
  for (auto c : s) {
    bool ok = true;
    switch (c) {
      case 'L':
        --x;
        ok = check(x, y, x + 1, y);
        break;
      case 'R':
        ++x;
        ok = check(x, y, x - 1, y);
        break;
      case 'U':
        ++y;
        ok = check(x, y, x, y - 1);
        break;
      case 'D':
        --y;
        ok = check(x, y, x, y + 1);
        break;
    }
    if (!ok) {
      cout << "BUG";
      return 0;
    }
    a[x][y] = true;
  }
  cout << "OK";
  return 0;
}
