#include <algorithm>
#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <map>
#define all(c) c.begin(), c.end()
#define sqr(c) ((c)*(c))
using namespace std;
int main() {
string north, south;
getline(cin, south);
getline(cin, north);
int i = 0, j = 0, timer = 0;
while (i + j < north.length() + south.length()) {
if (j < south.length()) {
if (south[j] == 'F' || south[j] == 'R')
j++;
else
if (i == north.length() || north[i] == 'L')
j++;
}
if (i < north.length()) {
if (north[i] == 'F' || north[i] == 'R')
i++;
else
if (j == south.length() || south[j] == 'L')
i++;
}
timer++;
}
cout << timer;
return 0;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPHN0ZGxpYi5oPgojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8bWFwPgoKI2RlZmluZSBhbGwoYykgYy5iZWdpbigpLCBjLmVuZCgpCiNkZWZpbmUgc3FyKGMpICgoYykqKGMpKQoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewogICAgc3RyaW5nIG5vcnRoLCBzb3V0aDsKICAgIGdldGxpbmUoY2luLCBzb3V0aCk7CiAgICBnZXRsaW5lKGNpbiwgbm9ydGgpOwogICAgaW50IGkgPSAwLCBqID0gMCwgdGltZXIgPSAwOwogICAgd2hpbGUgKGkgKyBqIDwgbm9ydGgubGVuZ3RoKCkgKyBzb3V0aC5sZW5ndGgoKSkgewogICAgICAgIGlmIChqIDwgc291dGgubGVuZ3RoKCkpIHsKICAgICAgICAgICAgaWYgKHNvdXRoW2pdID09ICdGJyB8fCBzb3V0aFtqXSA9PSAnUicpCiAgICAgICAgICAgICAgICBqKys7CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIGlmIChpID09IG5vcnRoLmxlbmd0aCgpIHx8IG5vcnRoW2ldID09ICdMJykKICAgICAgICAgICAgICAgICAgICBqKys7CiAgICAgICAgfQogICAgICAgIGlmIChpIDwgbm9ydGgubGVuZ3RoKCkpIHsKICAgICAgICAgICAgaWYgKG5vcnRoW2ldID09ICdGJyB8fCBub3J0aFtpXSA9PSAnUicpCiAgICAgICAgICAgICAgICBpKys7CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIGlmIChqID09IHNvdXRoLmxlbmd0aCgpIHx8IHNvdXRoW2pdID09ICdMJykKICAgICAgICAgICAgICAgICAgICBpKys7CiAgICAgICAgfQogICAgICAgIHRpbWVyKys7CiAgICB9CiAgICBjb3V0IDw8IHRpbWVyOwoKICAgIHJldHVybiAwOwp9Cg==