#include <bits/stdc++.h>
using namespace std;
int grid[201][201]{0};
int main() {
  string s;
  cin >> s;
  int x = 100;
  int y = 100;
  grid[x][y] = true;
  for (auto& it : s) {
    switch (it) {
      case 'L':
        x--;
        break;
      case 'R':
        x++;
        break;
      case 'U':
        y--;
        break;
      case 'D':
        y++;
    }
    if (grid[x][y] || (it != 'L' && grid[x + 1][y]) ||
        (it != 'R' && grid[x - 1][y]) || (it != 'U' && grid[x][y + 1]) ||
        (it != 'D' && grid[x][y - 1])) {
      cout << "BUG" << endl;
      return 0;
    }
    grid[x][y] = true;
  }
  cout << "OK" << endl;
}
