#include <bits/stdc++.h>
using namespace std;
int flat[205][205];
int x = 102, y = 102;
bool sosedi(int x, int y, char from) {
  if (flat[x - 1][y] > 0 && from != 'R') return false;
  if (flat[x + 1][y] > 0 && from != 'L') return false;
  if (flat[x][y - 1] > 0 && from != 'U') return false;
  if (flat[x][y + 1] > 0 && from != 'D') return false;
  return true;
}
bool step(char t) {
  if (t == 'R') {
    if (flat[x + 1][y] != 0)
      return false;
    else {
      flat[x][y] = 1;
      x++;
      flat[x][y] = 2;
      return sosedi(x, y, t);
    }
  }
  if (t == 'L') {
    if (flat[x - 1][y] != 0)
      return false;
    else {
      flat[x][y] = 1;
      x--;
      flat[x][y] = 2;
      return sosedi(x, y, t);
    }
  }
  if (t == 'U') {
    if (flat[x][y + 1] != 0)
      return false;
    else {
      flat[x][y] = 1;
      y++;
      flat[x][y] = 2;
      return sosedi(x, y, t);
    }
  }
  if (t == 'D') {
    if (flat[x][y - 1] != 0)
      return false;
    else {
      flat[x][y] = 1;
      y--;
      flat[x][y] = 2;
      return sosedi(x, y, t);
    }
  }
}
int main() {
  char c = 0;
  flat[x][y] = 2;
  while (c != '\n') {
    c = getchar();
    if (step(c) == false) {
      cout << "BUG" << endl;
      return 0;
    }
  }
  cout << "OK" << endl;
  return 0;
}
