#include <bits/stdc++.h>
using namespace std;
int p[400][400];
int main() {
  string a;
  cin >> a;
  int t = 200;
  int u = 200;
  int s = 1;
  for (int i = 0; a[i]; i++) {
    p[t][u] = s;
    if (a[i] == 'L') {
      t++;
      s++;
      if (p[t][u]) {
        cout << "BUG";
        return 0;
      }
      p[t][u] = s;
    } else if (a[i] == 'R') {
      t--;
      s++;
      if (p[t][u]) {
        cout << "BUG";
        return 0;
      }
      p[t][u] = s;
    } else if (a[i] == 'U') {
      u++;
      s++;
      if (p[t][u]) {
        cout << "BUG";
        return 0;
      }
      p[t][u] = s;
    } else {
      u--;
      s++;
      if (p[t][u]) {
        cout << "BUG";
        return 0;
      }
      p[t][u] = s;
    }
  }
  int l = 0;
  for (int i = 1; i < 390; i++)
    for (int j = 1; j < 390; j++) {
      if (!p[i][j]) continue;
      if (p[i + 1][j]) {
        l = max(l, abs(p[i + 1][j] - p[i][j]));
      }
      if (p[i - 1][j]) {
        l = max(l, abs(p[i - 1][j] - p[i][j]));
      }
      if (p[i][j + 1]) {
        l = max(l, abs(p[i][j + 1] - p[i][j]));
      }
      if (p[i][j - 1]) {
        l = max(l, abs(p[i][j - 1] - p[i][j]));
      }
      if (l >= 2) {
        cout << "BUG";
        return 0;
      }
    }
  cout << "OK";
}
