#include <bits/stdc++.h>
using namespace std;
string s;
const int dir[4][2] = {1, 0, -1, 0, 0, -1, 0, 1};
int sx, sy, ex, ey;
int m[250][250];
int arrx[40000];
int arry[40000];
int step[250][250];
int is(char c) {
  if (c == 'R') return 3;
  if (c == 'L') return 2;
  if (c == 'U') return 1;
  if (c == 'D') return 0;
}
int ck() {
  int nowx = sx, nowy = sy;
  for (int i = 0; i < s.size(); i++) {
    int nx = nowx + dir[is(s[i])][0];
    int ny = nowy + dir[is(s[i])][1];
    nowx = nx;
    nowy = ny;
    if (m[nx][ny] == 1) {
      return 0;
    } else
      m[nx][ny] = 1;
    if ((i + 1) == s.size()) {
      ex = nx;
      ey = ny;
    }
  }
  return 1;
}
int bfs() {
  int head = 0;
  arrx[0] = sx;
  arry[0] = sy;
  m[sx][sy] = -1;
  step[sx][sy] = 0;
  int rear = 1;
  while (head < rear) {
    for (int i = 0; i < 4; i++) {
      int nx = arrx[head] + dir[i][0];
      int ny = arry[head] + dir[i][1];
      if (m[nx][ny] == -1) continue;
      arrx[rear] = nx;
      arry[rear] = ny;
      rear++;
      m[nx][ny] = -1;
      step[nx][ny] = step[arrx[head]][arry[head]] + 1;
      if (nx == ex && ny == ey) return step[ex][ey];
    }
    head++;
  }
}
int main() {
  cin >> s;
  sx = 102;
  sy = 102;
  memset(m, -1, sizeof(m));
  m[sx][sy] = 1;
  if (ck() == 0) {
    cout << "BUG";
  } else {
    int len = s.size();
    int ans = bfs();
    if (ans == len)
      cout << "OK";
    else
      cout << "BUG";
  }
}
