#include <bits/stdc++.h>
using namespace std;
long long n;
int dx = 101, dy = 101;
bool visit[205][205];
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string second;
  cin >> second;
  n = second.length();
  int x = dx, y = dy;
  for (int i = 0; i < n; ++i) {
    visit[x][y] = true;
    if (second[i] == 'L')
      --x;
    else if (second[i] == 'R')
      ++x;
    else if (second[i] == 'U')
      ++y;
    else
      --y;
    if (visit[x][y]) {
      cout << "BUG" << endl;
      return 0;
    }
    if (second[i] == 'L' and
        (visit[x - 1][y] or visit[x][y - 1] or visit[x][y + 1])) {
      cout << "BUG" << endl;
      return 0;
    }
    if (second[i] == 'R' and
        (visit[x + 1][y] or visit[x][y - 1] or visit[x][y + 1])) {
      cout << "BUG" << endl;
      return 0;
    }
    if (second[i] == 'U' and
        (visit[x - 1][y] or visit[x + 1][y] or visit[x][y + 1])) {
      cout << "BUG" << endl;
      return 0;
    }
    if (second[i] == 'D' and
        (visit[x - 1][y] or visit[x + 1][y] or visit[x][y - 1])) {
      cout << "BUG" << endl;
      return 0;
    }
  }
  cout << "OK" << endl;
  return 0;
}
