#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e2 + 10;
int a[1001][1001];
char c;
int main() {
  int x = 500, y = 500;
  a[x][y] = 1;
  while (cin >> c) {
    a[x + 1][y]++;
    a[x - 1][y]++;
    a[x][y - 1]++;
    a[x][y + 1]++;
    if (c == 'U')
      --y;
    else if (c == 'D')
      ++y;
    else if (c == 'L')
      --x;
    else if (c == 'R')
      ++x;
    if (a[x][y] >= 2) {
      cout << "BUG";
      return 0;
    }
  }
  cout << "OK";
  return 0;
}
