#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 1000;
char s[maxn];
int cnt[4];
int ID[1000];
int main() {
  ID['U'] = 0;
  ID['R'] = 1;
  ID['D'] = 2;
  ID['L'] = 3;
  memset(cnt, 0, sizeof(cnt));
  scanf("%s", s);
  int len = strlen(s);
  for (int i = 0; i < len; ++i) cnt[ID[s[i]]]++;
  int d0 = abs(cnt[0] - cnt[2]);
  int d1 = abs(cnt[1] - cnt[3]);
  int d = d0 + d1;
  if (d % 2)
    puts("-1");
  else
    printf("%d\n", d / 2);
  return 0;
}
