#include <bits/stdc++.h>
using namespace std;
int adj[500][500];
bool vis[500][500];
int dist[500][500];
int main() {
  int i, j, k;
  int n, m, t;
  string s;
  cin >> s;
  i = 110, j = 110;
  n = s.length();
  memset(adj, 0, sizeof(adj));
  memset(vis, 0, sizeof(vis));
  for (k = 0; k < n; k++) {
    if (s[k] == 'R')
      j++;
    else if (s[k] == 'L')
      j--;
    else if (s[k] == 'U')
      i--;
    else
      i++;
    adj[i][j] = 1;
  }
  int ti = i;
  int tj = j;
  i = 110, j = 110;
  queue<pair<int, int> > q;
  q.push({i, j});
  vis[i][j] = true;
  dist[i][j] = 0;
  int dx[] = {1, -1, 0, 0};
  int dy[] = {0, 0, 1, -1};
  while (!q.empty()) {
    pair<int, int> u = q.front();
    q.pop();
    for (k = 0; k < 4; k++) {
      int x = u.first + dx[k];
      int y = u.second + dy[k];
      if (adj[x][y] && !vis[x][y]) {
        dist[x][y] = 1 + dist[u.first][u.second];
        vis[x][y] = true;
        q.push({x, y});
      }
    }
  }
  if (dist[ti][tj] == n)
    printf("%s", "OK\n");
  else
    printf("%s", "BUG\n");
  return 0;
}
