#include <bits/stdc++.h>
using namespace std;
int main() {
  string str1;
  cin >> str1;
  int st_x = 101, st_y = 101, lenth = str1.size();
  int g[202][202];
  for (int i = 0; i < 202; ++i)
    for (int j = 0; j < 202; ++j) g[i][j] = 0;
  for (int i = 0; i < lenth; ++i) {
    g[st_x][st_y] = 1;
    if (str1[i] == 'L')
      st_x--;
    else if (str1[i] == 'R')
      st_x++;
    else if (str1[i] == 'U')
      st_y++;
    else if (str1[i] == 'D')
      st_y--;
    if (g[st_x][st_y] + g[st_x - 1][st_y] + g[st_x][st_y - 1] +
            g[st_x + 1][st_y] + g[st_x][st_y + 1] >
        1) {
      cout << "BUG\n";
      return 0;
    }
  }
  cout << "OK\n";
  return 0;
}
