#include <bits/stdc++.h>
using namespace std;
int v[211][211], d[211][211], l, dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
char c;
int main() {
  int y = 100, x = 100;
  while (cin >> c) {
    if (c == 'U') y--;
    if (c == 'L') x--;
    if (c == 'D') y++;
    if (c == 'R') x++;
    v[y][x] = 1;
    l++;
  }
  for (int i = 0; i < 211; i++)
    for (int j = 0; j < 211; j++) d[i][j] = 1000000007LL;
  queue<pair<int, int> > Q;
  Q.push(pair<int, int>(100, 100));
  d[100][100] = 0;
  while (Q.size()) {
    pair<int, int> p = Q.front();
    Q.pop();
    if (p.first == y && p.second == x) {
      cout << (d[y][x] < l ? "BUG" : "OK");
      return 0;
    }
    for (int i = 0; i < 4; i++) {
      int ny = p.first + dy[i], nx = p.second + dx[i];
      if (v[ny][nx] && d[ny][nx] == 1000000007LL) {
        Q.push(pair<int, int>(ny, nx));
        d[ny][nx] = d[p.first][p.second] + 1;
      }
    }
  }
}
