#include <bits/stdc++.h>
using namespace std;
const int maxx = 120, t = 1000;
int a[2 * maxx][2 * maxx];
queue<pair<int, int> > q;
int main() {
  int i, res;
  int x = maxx, y = maxx;
  string s;
  cin >> s;
  a[x][y] = 1;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'L') x--;
    if (s[i] == 'R') x++;
    if (s[i] == 'U') y++;
    if (s[i] == 'D') y--;
    a[x][y] = 1;
  }
  int fx = x, fy = y;
  int dx, dy;
  x = maxx;
  y = maxx;
  q.push(pair<int, int>(t * x + y, 0));
  while (!q.empty()) {
    pair<int, int> cur = q.front();
    q.pop();
    x = cur.first / t;
    y = cur.first % t;
    if (x == fx && y == fy) {
      res = cur.second;
      break;
    }
    dx = x - 1;
    dy = y;
    if (a[dx][dy]) {
      q.push(pair<int, int>(dx * t + dy, cur.second + 1));
      a[dx][dy] = 0;
    }
    dx = x + 1;
    dy = y;
    if (a[dx][dy]) {
      q.push(pair<int, int>(dx * t + dy, cur.second + 1));
      a[dx][dy] = 0;
    }
    dx = x;
    dy = y - 1;
    if (a[dx][dy]) {
      q.push(pair<int, int>(dx * t + dy, cur.second + 1));
      a[dx][dy] = 0;
    }
    dx = x;
    dy = y + 1;
    if (a[dx][dy]) {
      q.push(pair<int, int>(dx * t + dy, cur.second + 1));
      a[dx][dy] = 0;
    }
  }
  if (res == s.size())
    cout << "OK";
  else
    cout << "BUG";
  return 0;
}
