#include <bits/stdc++.h>
using namespace std;
const char *dir = "LRUD";
const int dr[] = {0, 0, -1, +1};
const int dc[] = {-1, +1, 0, 0};
void input(void);
void solve(void);
int bfs(int sr, int sc, int tr, int tc);
int n;
char S[150];
int grid[2 * 150][2 * 150];
int dist[2 * 150][2 * 150];
queue<int> que;
int main(void) {
  input();
  solve();
  return 0;
}
void input(void) {
  scanf(" %s", S);
  n = strlen(S);
}
void solve(void) {
  int sr = 150;
  int sc = 150;
  int r = sr;
  int c = sc;
  memset(grid, 0, sizeof(grid));
  grid[r][c] = 1;
  for (int i = 0; i < n; i++) {
    int id = -1;
    for (int j = 0; j < 4; j++)
      if (dir[j] == S[i]) id = j;
    r += dr[id];
    c += dc[id];
    grid[r][c] = 1;
  }
  printf("%s\n", (bfs(sr, sc, r, c) == n) ? "OK" : "BUG");
}
int bfs(int sr, int sc, int tr, int tc) {
  while (!que.empty()) que.pop();
  memset(dist, -1, sizeof(dist));
  que.push(sr);
  que.push(sc);
  dist[sr][sc] = 0;
  while (!que.empty()) {
    int r = que.front();
    que.pop();
    int c = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      int nr = r + dr[i];
      int nc = c + dc[i];
      if (!grid[nr][nc]) continue;
      if (dist[nr][nc] != -1) continue;
      que.push(nr);
      que.push(nc);
      dist[nr][nc] = dist[r][c] + 1;
    }
  }
  return dist[tr][tc];
}
