#include <iostream>
#include <string>
using namespace std;
int main() {
string x;
cin >> x;
int position = 0;
int min_position = 0, max_position = 0;
for (int i = 0; i < x.length(); i++) {
if (x[i] == 'L') {
position--;
} else if (x[i] == 'R') {
position++;
}
if (position < min_position) {
min_position = position;
}
if (position > max_position) {
max_position = position;
}
}
cout << (max_position - min_position + 1) << endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewogICAgc3RyaW5nIHg7CiAgICBjaW4gPj4geDsgIAoKICAgIGludCBwb3NpdGlvbiA9IDA7ICAKICAgIGludCBtaW5fcG9zaXRpb24gPSAwLCBtYXhfcG9zaXRpb24gPSAwOyAgCgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCB4Lmxlbmd0aCgpOyBpKyspIHsKICAgICAgICBpZiAoeFtpXSA9PSAnTCcpIHsKICAgICAgICAgICAgcG9zaXRpb24tLTsgIAogICAgICAgIH0gZWxzZSBpZiAoeFtpXSA9PSAnUicpIHsKICAgICAgICAgICAgcG9zaXRpb24rKzsgCiAgICAgICAgfQogIAogICAgICAgIGlmIChwb3NpdGlvbiA8IG1pbl9wb3NpdGlvbikgewogICAgICAgICAgICBtaW5fcG9zaXRpb24gPSBwb3NpdGlvbjsKICAgICAgICB9CiAgICAgICAgaWYgKHBvc2l0aW9uID4gbWF4X3Bvc2l0aW9uKSB7CiAgICAgICAgICAgIG1heF9wb3NpdGlvbiA9IHBvc2l0aW9uOwogICAgICAgIH0KICAgIH0KCiAgICBjb3V0IDw8IChtYXhfcG9zaXRpb24gLSBtaW5fcG9zaXRpb24gKyAxKSA8PCBlbmRsOwoKICAgIHJldHVybiAwOwp9Cg==