#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> vis;
bool DFS(int i, int j, int idx, int level, string s) {
  if (vis[i][j] == 1) return false;
  if (idx == s.length()) {
    return true;
  }
  vis[i][j] = 1;
  if (s[idx] == 'L') {
    --j;
    if (vis[i][j] + vis[i][j - 1] + vis[i][j + 1] + vis[i + 1][j] +
            vis[i - 1][j] >
        1)
      return false;
    return DFS(i, j, idx + 1, level + 1, s);
  } else if (s[idx] == 'U') {
    --i;
    if (vis[i][j] + vis[i][j - 1] + vis[i][j + 1] + vis[i + 1][j] +
            vis[i - 1][j] >
        1)
      return false;
    return DFS(i, j, idx + 1, level + 1, s);
  } else if (s[idx] == 'R') {
    ++j;
    if (vis[i][j] + vis[i][j - 1] + vis[i][j + 1] + vis[i + 1][j] +
            vis[i - 1][j] >
        1)
      return false;
    return DFS(i, j, idx + 1, level + 1, s);
  } else {
    ++i;
    if (vis[i][j] + vis[i][j - 1] + vis[i][j + 1] + vis[i + 1][j] +
            vis[i - 1][j] >
        1)
      return false;
    return DFS(i, j, idx + 1, level + 1, s);
  }
  return false;
}
int main() {
  string str;
  cin >> str;
  vis.resize(200, vector<int>(200, 0));
  if (DFS(100, 100, 0, 0, str))
    cout << "OK";
  else
    cout << "BUG";
  return 0;
}
