#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<vector<bool>> visited(204, vector<bool>(204, true));
  visited[102][102] = false;
  int row = 102;
  int column = 102;
  string s;
  cin >> s;
  bool chk = true;
  for (auto i : s) {
    if (i == 'L') {
      column--;
      if (visited[row][column] == false) {
        chk = false;
      }
      visited[row][column] = false;
    } else if (i == 'R') {
      column++;
      if (visited[row][column] == false) {
        chk = false;
      }
      visited[row][column] = false;
    } else if (i == 'U') {
      row--;
      if (visited[row][column] == false) {
        chk = false;
      }
      visited[row][column] = false;
    } else {
      row++;
      if (visited[row][column] == false) {
        chk = false;
      }
      visited[row][column] = false;
    }
  }
  if (chk == false) {
    cout << "BUG";
    return 0;
  }
  int ct = 0;
  for (int i = 1; i <= 202; i++) {
    for (int j = 1; j <= 202; j++) {
      if (visited[i][j]) continue;
      if (i == j && i == 102) {
        ct = 0;
        if (visited[i - 1][j] == false) ct++;
        if (visited[i + 1][j] == false) ct++;
        if (visited[i][j - 1] == false) ct++;
        if (visited[i][j + 1] == false) ct++;
        if (ct > 1) {
          cout << "BUG"
               << "\n";
          return 0;
        }
      } else if (i == row && j == column) {
        ct = 0;
        if (visited[i - 1][j] == false) ct++;
        if (visited[i + 1][j] == false) ct++;
        if (visited[i][j - 1] == false) ct++;
        if (visited[i][j + 1] == false) ct++;
        if (ct > 1) {
          cout << "BUG"
               << "\n";
          return 0;
        }
      } else {
        ct = 0;
        if (visited[i - 1][j] == false) ct++;
        if (visited[i + 1][j] == false) ct++;
        if (visited[i][j - 1] == false) ct++;
        if (visited[i][j + 1] == false) ct++;
        if (ct > 2) {
          cout << "BUG"
               << "\n";
          return 0;
        }
      }
    }
  }
  cout << "OK"
       << "\n";
  return 0;
}
