#include <bits/stdc++.h>
using namespace std;
struct trip {
  int a, b, c;
};
const int MAXINT = 1e5 + 1;
int i = 101, j = 101;
bool M[202][202] = {}, ans = true;
string s;
int main() {
  cin >> s;
  int n = s.size();
  M[i][j] = true;
  for (int k = 0; k < n; k++) {
    if (s[k] == 'L')
      j--;
    else if (s[k] == 'R')
      j++;
    else if (s[k] == 'U')
      i--;
    else if (s[k] == 'D')
      i++;
    if (M[i][j]) ans = false;
    if (k > 0 && s[k] != 'R' && M[i][j - 1]) ans = false;
    if (k > 0 && s[k] != 'L' && M[i][j + 1]) ans = false;
    if (k > 0 && s[k] != 'U' && M[i + 1][j]) ans = false;
    if (k > 0 && s[k] != 'D' && M[i - 1][j]) ans = false;
    M[i][j] = true;
  }
  cout << (ans ? "OK" : "BUG") << endl;
  return 0;
}
