#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MN = 105;
bool mark[500][500];
char s[MN];
int dis[500][500];
int ask(pair<int, int> now) {
  int res = INF;
  if (mark[now.first][now.second]) res = min(res, dis[now.first][now.second]);
  if (mark[now.first - 1][now.second])
    res = min(res, dis[now.first - 1][now.second] + 1);
  if (mark[now.first + 1][now.second])
    res = min(res, dis[now.first + 1][now.second] + 1);
  if (mark[now.first][now.second - 1])
    res = min(res, dis[now.first][now.second - 1] + 1);
  if (mark[now.first][now.second + 1])
    res = min(res, dis[now.first][now.second + 1] + 1);
  return res;
}
int main() {
  scanf("%s", s);
  int l = strlen(s);
  pair<int, int> now = make_pair(105, 105);
  mark[105][105] = 1;
  dis[105][105] = 0;
  int len = 0;
  for (int i = 0; i < l; ++i) {
    ++len;
    if (s[i] == 'U') now.second += 1;
    if (s[i] == 'D') now.second -= 1;
    if (s[i] == 'L') now.first -= 1;
    if (s[i] == 'R') now.first += 1;
    if (ask(now) < len) {
      printf("BUG\n");
      return 0;
    }
    mark[now.first][now.second] = 1;
    dis[now.first][now.second] = len;
  }
  printf("OK\n");
  return 0;
}
