#include <bits/stdc++.h>
using namespace std;
long long i, x, y;
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> s;
  if (s.size() % 2 == 1)
    cout << -1;
  else {
    for (i = 0; i < s.size(); i++)
      if (s[i] == 'U')
        y++;
      else if (s[i] == 'D')
        y--;
      else if (s[i] == 'L')
        x--;
      else if (s[i] == 'R')
        x++;
    cout << (abs(x) + abs(y)) / 2;
  }
}
