#include <bits/stdc++.h>
using namespace std;
string s;
bool xd = true;
bool a[400][400];
int main() {
  memset(a, true, sizeof a);
  cin >> s;
  int x = 200;
  int y = 200;
  a[200][200] = false;
  int u, v;
  for (int i = 0; i < s.length(); i++) {
    u = x;
    v = y;
    if (s[i] == 'L') y--;
    if (s[i] == 'R') y++;
    if (s[i] == 'U') x--;
    if (s[i] == 'D') x++;
    if (a[x][y] == false) {
      xd = false;
      break;
    }
    a[u][v - 1] = false;
    a[u][v + 1] = false;
    a[u - 1][v] = false;
    a[u + 1][v] = false;
  }
  if (xd)
    cout << "OK";
  else
    cout << "BUG";
}
