#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;
}
