#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7FFFFFFF;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int fx[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
struct data {
  int x, y;
};
string st;
int tot;
data a[200];
bool vis[300][300];
int f[200][200];
int main() {
  cin >> st;
  int x = 0, y = 0;
  memset(vis, 0, sizeof(vis));
  vis[x + 101][y + 101] = true;
  tot = 1;
  a[tot].x = 0;
  a[tot].y = 0;
  for (int i = 0; i < st.size(); i++) {
    if (st[i] == 'L') {
      --y;
    } else if (st[i] == 'R') {
      ++y;
    } else if (st[i] == 'U') {
      --x;
    } else {
      ++x;
    }
    if (vis[x + 101][y + 101]) {
      cout << "BUG" << endl;
      return 0;
    } else
      vis[x + 101][y + 101] = true;
    ++tot;
    a[tot].x = x;
    a[tot].y = y;
  }
  memset(f, 60, sizeof(f));
  for (int i = 1; i <= tot; i++)
    for (int j = i + 1; j <= tot; j++)
      for (int k = 0; k < 4; k++)
        if (a[i].x + fx[k][0] == a[j].x && a[i].y + fx[k][1] == a[j].y)
          f[i][j] = f[j][i] = 1;
  for (int k = 1; k <= tot; k++)
    for (int i = 1; i <= tot; i++)
      for (int j = 1; j <= tot; j++) f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
  if (f[1][tot] == st.size())
    cout << "OK" << endl;
  else
    cout << "BUG" << endl;
  return 0;
}
