#include <bits/stdc++.h>
using namespace std;
const int M = 203;
string s[4] = {"RL", "LR", "UD", "DU"};
bool mk[M][M], bl;
int main() {
  int ud = 0, rl = 0, x = 101, y = 101;
  string in;
  cin >> in;
  mk[x][y] = 1;
  for (int i = 0; i < in.size() && !bl; i++) {
    switch (in[i]) {
      case 'R':
        rl++;
        x++;
        mk[x][y] = 1;
        if (mk[x][y + 1] || mk[x][y - 1] || mk[x + 1][y]) bl = 1;
        break;
      case 'L':
        rl--;
        x--;
        mk[x][y] = 1;
        if (mk[x][y + 1] || mk[x][y - 1] || mk[x - 1][y]) bl = 1;
        break;
      case 'U':
        ud++;
        y++;
        mk[x][y] = 1;
        if (mk[x + 1][y] || mk[x - 1][y] || mk[x][y + 1]) bl = 1;
        break;
      case 'D':
        ud--;
        y--;
        mk[x][y] = 1;
        if (mk[x + 1][y] || mk[x - 1][y] || mk[x][y - 1]) bl = 1;
        break;
    }
    for (int i = 0; i < 4; i++)
      if (in.find(s[i]) < in.size()) bl = 1;
  }
  if (bl)
    cout << "BUG";
  else
    cout << "OK";
  return 0;
}
