#include <bits/stdc++.h>
using namespace std;
int vis[400][400];
char s[110];
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int main() {
  int i, j;
  memset(vis, 0, sizeof(vis));
  scanf("%s", s);
  int ok = 1;
  int cx = 110, cy = 110;
  vis[cx][cy] = 1;
  for (i = 0; s[i] && ok; i++) {
    int tt = -1;
    if (s[i] == 'U') {
      cy++;
      tt = 1;
    } else if (s[i] == 'D') {
      cy--;
      tt = 0;
    } else if (s[i] == 'L') {
      cx--;
      tt = 2;
    } else if (s[i] == 'R') {
      cx++;
      tt = 3;
    }
    if (vis[cx][cy]) {
      ok = 0;
      break;
    }
    for (j = 0; j < 4; j++)
      if (j != tt) {
        int xx = cx + dx[j];
        int yy = cy + dy[j];
        if (vis[xx][yy]) ok = 0;
      }
    vis[cx][cy] = 1;
  }
  if (ok)
    printf("OK\n");
  else
    printf("BUG\n");
  return 0;
}
