#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  string s;
  cin >> s;
  bool visited[401][401] = {};
  int dr[] = {0, 0, -1, 1};
  int dc[] = {1, -1, 0, 0};
  int r = 200, c = 200;
  visited[r][c] = 1;
  for (auto ch : s)
    if (ch == 'U')
      visited[++r][c] = 1;
    else if (ch == 'D')
      visited[--r][c] = 1;
    else if (ch == 'L')
      visited[r][--c] = 1;
    else if (ch == 'R')
      visited[r][++c] = 1;
  queue<pair<int, int>> q({{200, 200}});
  vector<vector<int>> SP(401, vector<int>(401, 666666));
  SP[200][200] = 0;
  while (!q.empty()) {
    int R = q.front().first;
    int C = q.front().second;
    q.pop();
    for (int k = 0; k < 4; k++)
      if (visited[R + dr[k]][C + dc[k]] &&
          SP[R][C] + 1 < SP[R + dr[k]][C + dc[k]]) {
        SP[R + dr[k]][C + dc[k]] = SP[R][C] + 1;
        q.push({R + dr[k], C + dc[k]});
      }
  }
  cout << (SP[r][c] == s.size() ? "OK\n" : "BUG\n");
}
