#include <bits/stdc++.h>
using namespace std;
int a[202][202], i, x = 101, y = 101;
string s;
int main() {
  cin >> s;
  a[x][y] = 1;
  for (i = 0; i < s.size(); i++) {
    if (s[i] == 'L')
      x--;
    else if (s[i] == 'R')
      x++;
    else if (s[i] == 'U')
      y++;
    else if (s[i] == 'D')
      y--;
    if (a[x][y] == 1 ||
        a[x - 1][y] + a[x + 1][y] + a[x][y - 1] + a[x][y + 1] != 1) {
      cout << "BUG" << endl;
      return 0;
    }
    a[x][y] = 1;
  }
  cout << "OK" << endl;
  return 0;
}
