#include <bits/stdc++.h>
using namespace std;
const int maxn = 1100;
int a[maxn][2];
bool vis[maxn][maxn];
string s;
int main() {
  cin >> s;
  int len = (int)s.size();
  int x = 100, y = 100;
  vis[x][y] = true;
  for (int i = 0; i < len; i++) {
    if (s[i] == 'L') {
      y = y - 1;
      int x1 = x - 1, y1 = y;
      int x2 = x + 1, y2 = y;
      int x3 = x, y3 = y - 1;
      if (vis[x1][y1] || vis[x2][y2] || vis[x3][y3]) {
        cout << "BUG" << endl;
        return 0;
      }
    }
    if (s[i] == 'R') {
      y = y + 1;
      int x1 = x - 1, y1 = y;
      int x2 = x + 1, y2 = y;
      int x3 = x, y3 = y + 1;
      if (vis[x1][y1] || vis[x2][y2] || vis[x3][y3]) {
        cout << "BUG" << endl;
        return 0;
      }
    }
    if (s[i] == 'U') {
      x = x - 1;
      int x1 = x - 1, y1 = y;
      int x2 = x, y2 = y + 1;
      int x3 = x, y3 = y - 1;
      if (vis[x1][y1] || vis[x2][y2] || vis[x3][y3]) {
        cout << "BUG" << endl;
        return 0;
      }
    }
    if (s[i] == 'D') {
      x = x + 1;
      int x1 = x + 1, y1 = y;
      int x2 = x, y2 = y + 1;
      int x3 = x, y3 = y - 1;
      if (vis[x1][y1] || vis[x2][y2] || vis[x3][y3]) {
        cout << "BUG" << endl;
        return 0;
      }
    }
    a[i][0] = x, a[i][1] = y;
    if (vis[x][y]) {
      cout << "BUG" << endl;
      return 0;
    }
    vis[x][y] = true;
  }
  cout << "OK" << endl;
  return 0;
}
