#include <bits/stdc++.h>
using namespace std;
long long n, a[100007], b[100007], ma = 0;
string s1, s2, s3, sr;
int main() {
  cin >> s1;
  if (s1.length() % 2 == 1) {
    cout << -1 << endl;
    return 0;
  }
  int x = 0, y = 0;
  for (int i = 0; i < s1.length(); i++) {
    if (s1[i] == 'U') y++;
    if (s1[i] == 'D') y--;
    if (s1[i] == 'L') x--;
    if (s1[i] == 'R') x++;
  }
  cout << (abs(x) + abs(y)) / 2 << endl;
}
