#include <bits/stdc++.h>
using namespace std;
char step[110];
int s[501][501], vis[501][501], dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}},
                                f;
void dfs(int i, int j, int fx, int fy) {
  vis[i][j] = 1;
  int u, v, k;
  for (k = 0; k < 4; k++) {
    u = i + dir[k][0], v = j + dir[k][1];
    if (s[u][v]) {
      if (!vis[u][v]) {
        vis[u][v] = 1;
        dfs(u, v, i, j);
      } else {
        if (u == fx && v == fy)
          continue;
        else {
          f = 1;
          return;
        }
      }
    }
  }
  return;
}
int main() {
  int i, j, k, l, count = 0;
  scanf("%s", &step);
  memset(s, 0, sizeof(s));
  memset(vis, 0, sizeof(vis));
  l = strlen(step);
  s[250][250] = 1;
  i = j = 250;
  for (k = 0; k < l; k++) {
    if (step[k] == 'L')
      j--;
    else if (step[k] == 'R')
      j++;
    else if (step[k] == 'U')
      i--;
    else if (step[k] == 'D')
      i++;
    s[i][j] = 1;
  }
  for (i = 0; i < 500; i++)
    for (j = 0; j < 500; j++)
      if (s[i][j]) count++;
  vis[250][250] = 1;
  f = 0;
  if (step[0] == 'L')
    dfs(250, 249, 250, 250);
  else if (step[0] == 'R')
    dfs(250, 251, 250, 250);
  else if (step[0] == 'U')
    dfs(249, 250, 250, 250);
  else if (step[0] == 'D')
    dfs(251, 250, 250, 250);
  if (!f) {
    if (count == l + 1)
      printf("OK\n");
    else
      printf("BUG\n");
  } else
    printf("BUG\n");
  return 0;
}
