#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const int sc = 150;
int vis[300][300];
char s[110];
int main() {
  scanf("%s", s);
  int len = strlen(s);
  int x = sc, y = sc;
  vis[x][y] = 1;
  for (int i = 0; i < len; i++) {
    if (s[i] == 'L')
      y--;
    else if (s[i] == 'R')
      y++;
    else if (s[i] == 'U')
      x--;
    else if (s[i] == 'D')
      x++;
    if (vis[x][y] ||
        vis[x - 1][y] + vis[x + 1][y] + vis[x][y - 1] + vis[x][y + 1] != 1)
      return puts("BUG");
    vis[x][y] = 1;
  }
  puts("OK");
  return 0;
}
