#include <bits/stdc++.h>
using namespace std;
char a[210][210], visit[210][210];
int heng[] = {-1, 1, 0, 0};
int zong[] = {0, 0, -1, 1};
int bfs(int p, int q) {
  memset(visit, '0', sizeof(visit));
  deque<int> Q, P;
  int m, n, i, x1, y1, sum = 0;
  Q.push_back(102);
  Q.push_back(102);
  visit[102][102] = '1';
  while (!Q.empty()) {
    sum++;
    while (!Q.empty()) {
      m = Q.front();
      Q.pop_front();
      n = Q.front();
      Q.pop_front();
      for (i = 0; i < 4; i++) {
        x1 = m + heng[i];
        y1 = n + zong[i];
        if (a[x1][y1] == '1' && visit[x1][y1] == '0') {
          if (x1 == p && y1 == q) return sum;
          P.push_back(x1);
          P.push_back(y1);
          visit[x1][y1] = '1';
        }
      }
    }
    Q = P;
    P.clear();
  }
  return 0;
}
int main() {
  int i, x = 102, y = 102, ans = 0;
  memset(a, '0', sizeof(a));
  a[x][y] = '1';
  char str[101];
  cin >> str;
  for (i = 0; *(str + i); i++) {
    if (str[i] == 'L') {
      --y;
      if (a[x][y] != '0') {
        ans = 1;
        break;
      }
      a[x][y] = '1';
    } else if (str[i] == 'U') {
      --x;
      if (a[x][y] != '0') {
        ans = 1;
        break;
      }
      a[x][y] = '1';
    } else if (str[i] == 'R') {
      ++y;
      if (a[x][y] != '0') {
        ans = 1;
        break;
      }
      a[x][y] = '1';
    } else {
      ++x;
      if (a[x][y] != '0') {
        ans = 1;
        break;
      }
      a[x][y] = '1';
    }
  }
  if (ans)
    cout << "BUG" << endl;
  else {
    if (bfs(x, y) == i)
      cout << "OK" << endl;
    else
      cout << "BUG" << endl;
  }
}
