#include <bits/stdc++.h>
using namespace std;
const int maxn = 200;
int x, y;
bool mark[maxn][maxn];
string s;
int main() {
  cin >> s;
  x = 100, y = 100;
  mark[x][y] = true;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'L') x--;
    if (s[i] == 'R') x++;
    if (s[i] == 'U') y++;
    if (s[i] == 'D') y--;
    int cnt = 0;
    cnt += mark[x + 1][y] + mark[x - 1][y] + mark[x][y - 1] + mark[x][y + 1];
    if (cnt > 1 or mark[x][y]) {
      cout << "BUG" << endl;
      return 0;
    }
    mark[x][y] = true;
  }
  cout << "OK" << endl;
  return 0;
}
