#include <bits/stdc++.h>
using namespace std;
string s;
int vs[205][205];
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
int main(int argc, char* argv[]) {
  if (argc > 1) {
    freopen(argv[1], "r", stdin);
  }
  cin >> s;
  int x = 100, y = 100;
  vs[100][100] = 1;
  for (int i = (0); i < (((int)s.size())); i++) {
    if (s[i] == 'R') y++;
    if (s[i] == 'U') x++;
    if (s[i] == 'D') x--;
    if (s[i] == 'L') y--;
    if (vs[x][y]) {
      cout << "BUG";
      return 0;
    }
    int cnt = 0;
    for (int j = 0; j < 4; j++) {
      int nx = x + dx[j];
      int ny = y + dy[j];
      if (nx >= 0 && ny >= 0 && vs[nx][ny]) {
        cnt++;
      }
    }
    if (cnt == 2) {
      cout << "BUG";
      return 0;
    }
    vs[x][y] = 1;
  }
  cout << "OK";
  return 0;
}
