#include <bits/stdc++.h>
using namespace std;
const int N = 1001;
int dis[N + 5][N + 5];
bool vis[N + 4][N + 4];
int fx[] = {0, 0, 1, -1};
int fy[] = {1, -1, 0, 0};
vector<pair<int, int> > v;
int main() {
  ios_base::sync_with_stdio(0);
  string s;
  cin >> s;
  int x = 100, y = 100;
  int l = s.length();
  bool ok = true;
  dis[x][y] = 1;
  v.push_back({x, y});
  for (int i = 0; i < l; i++) {
    if (s[i] == 'R')
      x++;
    else if (s[i] == 'L')
      x--;
    else if (s[i] == 'D')
      y--;
    else
      y++;
    if (dis[x][y] != 0) {
      ok = false;
      break;
    }
    dis[x][y] = i + 2;
    v.push_back({x, y});
  }
  if (ok) {
    for (int i = 0; i < v.size(); i++) {
      int xx = v[i].first, yy = v[i].second;
      for (int k = 0; k < 4; k++) {
        int a = xx + fx[k];
        int b = yy + fy[k];
        if (dis[xx][yy] + 1 < dis[a][b]) {
          ok = false;
          break;
        }
      }
      if (ok == 0) break;
    }
  }
  if (ok)
    cout << "OK" << endl;
  else
    cout << "BUG" << endl;
}
