#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10;
char A[maxn];
vector<pair<int, int> > record;
int abs(int x) { return (x > 0) ? x : -x; }
bool adjacent(pair<int, int> a, pair<int, int> b) {
  return abs(a.first - b.first) + abs(a.second - b.second) == 1;
}
int main() {
  gets(A + 1);
  int ok = 1, x = 0, y = 0;
  record.push_back(pair<int, int>(0, 0));
  for (int i = int(1); i <= int(strlen(A + 1)); i++) {
    if (A[i] == 'L')
      y--;
    else if (A[i] == 'R')
      y++;
    else if (A[i] == 'U')
      x--;
    else
      x++;
    for (int i = int(0); i <= int(record.size() - 1); i++)
      if (record[i] == pair<int, int>(x, y) ||
          (adjacent(record[i], pair<int, int>(x, y)) &&
           i < record.size() - 1)) {
        puts("BUG");
        return 0;
      }
    record.push_back(pair<int, int>(x, y));
  }
  puts("OK");
}
