#include <bits/stdc++.h>
using namespace std;
int a[400][400];
int i = 200, j = 200, k;
string s, res = "OK";
int main() {
  cin >> s;
  for (k = 0; k < s.length(); k++) {
    a[i][j] = 1;
    if (s[k] == 'L') j--;
    if (s[k] == 'R') j++;
    if (s[k] == 'U') i--;
    if (s[k] == 'D') i++;
    if (a[i - 1][j] + a[i + 1][j] + a[i][j - 1] + a[i][j + 1] + a[i][j] > 1) {
      res = "BUG";
      break;
    }
  }
  cout << res;
  return 0;
}
