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

using namespace std;

struct bitset 
{
    static const int SIZE = 64;
    static const int SSIZE = 6;
    int n;
    vector<long long> used;

    bitset(int n = 0) :
        n((n + SIZE - 1) / SIZE),
        used(this->n)
    {}

    void setOne(int i, int val)
    {
        int i1 = i >> SSIZE;
        int i2 = i & (SIZE - 1);
        long long old = used[i1];
        old = (old & (~(1LL << i2))) | (((long long)val) << i2);
        used[i1] = old;
    }

    bool get(int i)
    {
        int i1 = i >> SSIZE;
        int i2 = i & (SIZE - 1);
        return (used[i1] & (1LL << i2)) != 0;
    }

    void set(int left, int right, int val = 1)
    {
        int lbucket = left >> SSIZE;
        int rbucket = right >> SSIZE;
        long long all = val == 0 ? 0 : -1;
        if (lbucket == rbucket)
        {
            for (int i = left; i < right; i++)
                setOne(i, val);
        }
        else
        {
            for (int i = lbucket + 1; i < rbucket; i++)
                used[i] = all;
            for (int i = left; i < (lbucket + 1) * SIZE; i++)
                setOne(i, val);
            for (int i = rbucket * SIZE; i < right; i++)
                setOne(i, val);
        }
    }

    bool has1(int left, int right)
    {
        int lbucket = left >> SSIZE;
        int rbucket = right >> SSIZE;
        if (lbucket == rbucket)
        {
            for (int i = left; i < right; i++)
                if (get(i))
                    return true;
            return false;
        }
        else
        {
            for (int i = lbucket + 1; i < rbucket; i++)
                if (used[i] != 0)
                    return true;
            for (int i = left; i < (lbucket + 1) * SIZE; i++)
                if (get(i))
                    return true;
            for (int i = rbucket * SIZE; i < right; i++)
                if (get(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;
            bool can1calculated = false;
            bool can2calculated = false;
            bool can1cache = false;
            bool can2cache = false;
            if (i > 0 && j > 0)
            {
                bool can1 = t[1][j-1] != SEND;
                if (!can1)
                {
                    can1 |= !prefixes[0][i].has1(left[1][j-1], right[1][j-1]);
                    can1cache = can1;
                    can1calculated = true;
                }
                bool can2 = t[0][i-1] != SEND;
                if (!can2 && can1)
                {
                    can2 |= !prefixes[1][j].has1(left[0][i-1], right[0][i-1]);
                    can2cache = can2;
                    can2calculated = true;
                }
                if (can1 && can2)
                    dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
            }
            if (i > 0)
            {
                bool can = t[0][i-1] != SEND;
                if (!can)
                {
                    if (can2calculated)
                        can |= can2cache;
                    else
                        can |= !prefixes[1][j].has1(left[0][i-1], right[0][i-1]);
                }
                if (can)
                    dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
            }
            if (j > 0)
            {
                bool can = t[1][j-1] != SEND;
                if (!can)
                {
                    if (can1calculated)
                        can |= can1cache;
                    else
                        can |= !prefixes[0][i].has1(left[1][j-1], right[1][j-1]);
                }
                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";
}
