#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  while (cin >> s) {
    int ans = 0;
    if (s.size() % 2)
      cout << -1 << endl;
    else {
      int x = 0, y = 0;
      int i, j, k, l;
      for (i = 0; i <= s.size() - 1; i++)
        if (s[i] == 'R')
          x++;
        else if (s[i] == 'L')
          x--;
        else if (s[i] == 'U')
          y++;
        else
          y--;
      if (x < 0) x = -x;
      if (y < 0) y = -y;
      ans = (x + y) / 2;
      cout << ans << endl;
    }
  }
  return 0;
}
