#include <iostream>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <vector>

using namespace std;

struct bitset 
{
    int n;
    vector<bool> used;

    bitset(int n = 0) :
        n(n),
        used(n)
    {}

    void set(int left, int right, int val = 1)
    {
        for (int i = left; i < right; i++)
            used[i] = val;
    }

    bool has1(int left, int right)
    {
        for (int i = left; i < right; i++)
            if (used[i])
                return true;
        return false;
    }
};

ostream& operator<<(ostream& out, const bitset& bs)
{
    out << "bitset{";
    for (int i = 0; i < bs.n; i++)
        out << bs.used[i];
    out << "}";
    return out;
}

enum type
{
    SEND, BACK, RUM
};

int main()
{
    ifstream in("twocaptains.in");
    ofstream out("twocaptains.out");
    int n;
    int m[2];
    in >> n;
    vector<type> t[2];
    vector<int> left[2], right[2];
    for (int q = 0; q < 2; q++)
    {
        in >> m[q];
        t[q].resize(m[q]);
        left[q].resize(m[q]);
        right[q].resize(m[q]);
        for (int i = 0; i < m[q]; i++)
        {
            string s;
            in >> s;
            if (s == "rum")
                t[q][i] = RUM;
            else 
            {
                in >> left[q][i] >> right[q][i];
                right[q][i]++;
            }
            if (s == "send")
                t[q][i] = SEND;
            else if (s == "back")
                t[q][i] = BACK;
        }
    }

    set<int> interesting;
    for (int i = 0; i < 2; i++)
        for (int j = 0; j < m[i]; j++)
        {
            if (t[i][j] != RUM)
            {
                interesting.insert(left[i][j]);
                interesting.insert(right[i][j]);
            }
        }
    map<int, int> squash;
    {
        int i = 0;
        for (set<int>::const_iterator it = interesting.begin(); it != interesting.end(); it++)
            squash[*it] = i++;
    }
    for (int i = 0; i < 2; i++)
        for (int j = 0; j < m[i]; j++)
            if (t[i][j] != RUM)
            {
                left[i][j] = squash[left[i][j]];
                right[i][j] = squash[right[i][j]];
            }

    int q = interesting.size();
    vector<bitset> prefixes[2];
    for (int i = 0; i < 2; i++)
    {
        prefixes[i].push_back(bitset(q));
        for (int j = 0; j < m[i]; j++)
        {
            prefixes[i].push_back(prefixes[i].back());
            if (t[i][j] != RUM)
                prefixes[i].back().set(left[i][j], right[i][j], (t[i][j] == SEND) ? 1 : 0);
        }
    }

    int INF = m[0] + m[1] + 1;
    vector<vector<int> > dp(m[0] + 1, vector<int>(m[1] + 1, INF));
    dp[0][0] = 0;
    for (int i = 0; i <= m[0]; i++)
        for (int j = 0; j <= m[1]; j++)
        {
            if (i == 0 && j == 0)
                continue;
            if (i > 0 && j > 0)
            {
                if (t[0][i - 1] == RUM || t[1][j - 1] == RUM)
                {
                    bool can1 = !prefixes[0][i].has1(left[1][j-1], right[1][j-1]);
                    can1 |= t[1][j-1] != SEND;
                    bool can2 = !prefixes[1][j].has1(left[0][i-1], right[0][i-1]);
                    can2 |= t[0][i-1] != SEND;
                    if (can1 && can2)
                        dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
                }
                else
                {
                    bool can1 = !prefixes[0][i].has1(left[1][j-1], right[1][j-1]);
                    bool can2 = !prefixes[1][j].has1(left[0][i-1], right[0][i-1]);
                    if ((can1 || t[1][j-1] == BACK) && (can2 || t[0][i-1] == BACK))
                    {
                        dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
                    }
                }
            }
            if (i > 0)
            {
                bool can = !prefixes[1][j].has1(left[0][i-1], right[0][i-1]);
                can |= t[0][i-1] != SEND;
                if (can)
                    dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
            }
            if (j > 0)
            {
                bool can = !prefixes[0][i].has1(left[1][j-1], right[1][j-1]);
                can |= t[1][j-1] != SEND;
                if (can)
                    dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
            }
        }
    int ans = m[0] + m[1] + 1;
    for (int i = 0; i <= m[0]; i++)
        ans = min(ans, dp[i][m[1]]);
    for (int j = 0; j <= m[1]; j++)
        ans = min(ans, dp[m[0]][j]);
    out << ans << "\n";
}
