#include <bits/stdc++.h>
using namespace std;
int vis[400][400];
int main() {
  string s;
  cin >> s;
  int x = 200, y = 200;
  vis[x][y] = 1;
  int f = 0;
  for (int i = 0; i < s.size(); i++) {
    int x1, y1, x2, y2, x3, y3;
    if (s[i] == 'L') {
      x -= 1;
      x1 = x - 1;
      y1 = y;
      x2 = x;
      y2 = y - 1;
      x3 = x;
      y3 = y + 1;
    } else if (s[i] == 'R') {
      x += 1;
      x1 = x + 1;
      y1 = y;
      x2 = x;
      y2 = y - 1;
      x3 = x;
      y3 = y + 1;
    } else if (s[i] == 'U') {
      y -= 1;
      x1 = x + 1;
      y1 = y;
      x2 = x - 1;
      y2 = y;
      x3 = x;
      y3 = y - 1;
    } else {
      y += 1;
      x1 = x + 1;
      y1 = y;
      x2 = x - 1;
      y2 = y;
      x3 = x;
      y3 = y + 1;
    }
    if (vis[x][y] || vis[x1][y1] || vis[x2][y2] || vis[x3][y3]) {
      f = 1;
    }
    vis[x][y] = 1;
  }
  if (f || s.size() == 0)
    printf("BUG\n");
  else
    printf("OK\n");
}
