#include <bits/stdc++.h>
using namespace std;
string mov;
int main() {
  cin >> mov;
  int u = 0, d = 0, l = 0, r = 0;
  for (int i = 0; i < mov.size(); i++) {
    if (mov[i] == 'R')
      r++;
    else if (mov[i] == 'L')
      l++;
    else if (mov[i] == 'U')
      u++;
    else
      d++;
  }
  int temp = abs(u - d) + abs(l - r);
  if (temp % 2)
    cout << -1 << endl;
  else
    cout << temp / 2 << endl;
  return 0;
}
