#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <unordered_map>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <cassert>
#include <regex>
#include <random>
#include <sstream>

#define ll long long
#define ld long double
#define ull unsigned ll
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pii pair<int,int> 
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pii>
#define vvi vector<vector<int>>
#define forn(it,from,to) for(int (it)=from; (it)<to; (it)++)
ll LINF = (ll)4e18;
ll mod = 998244353;
using namespace std;
const int INF = 1000 * 1000 * 1000;
const int N = 200005;

int dp[101][2][101][2][101][2];

int rec(int c1, int f1, int c2, int f2, int c3, int f3) {
	if (max({ c1, c2, c3 }) == 1 && min({c1, c2, c3}) == 0) return 0;
	auto& ans = dp[c1][f1][c2][f2][c3][f3];
	if (ans != -1) return ans;
	ans = 2e9;
	if (c1 > 0) {
		if (c2 > 0 && f1 == f2) {
			ans = min(ans, rec(c1 - 1, f1 ^ 1, c2, f2, c3, f3) + 1);
		}
		if (c2 == 0) {
			ans = min(ans, rec(c1 - 1, f1 ^ 1, c2 + 1, f1, c3, f3) + 1);
		}
		if (c3 > 0 && f3 == f1) {
			ans = min(ans, rec(c1 - 1, f1 ^ 1, c2, f2, c3, f3) + 1);
		}
		if (c3 == 0) {
			ans = min(ans, rec(c1 - 1, f1 ^ 1, c2, f2, c3 + 1, f1) + 1);
		}
	}
	if (c2 > 0) {
		if (c1 > 0 && f1 == f2) {
			ans = min(ans, rec(c1, f1, c2 - 1, f2 ^ 1, c3, f3) + 1);
		}
		if (c1 == 0) {
			ans = min(ans, rec(c1 + 1, f2, c2 - 1, f2 ^ 1, c3, f3) + 1);
		}
		if (c3 > 0 && f3 == f2) {
			ans = min(ans, rec(c1, f1, c2 - 1, f2 ^ 1, c3, f3) + 1);
		}
		if (c3 == 0) {
			ans = min(ans, rec(c1, f1, c2 - 1, f2 ^ 1, c3 + 1, f2) + 1);
		}
	}
	if (c3 > 0) {
		if (c1 > 0 && f1 == f3) {
			ans = min(ans, rec(c1, f1, c2, f2, c3 - 1, f3 ^ 1) + 1);
		}
		if (c1 == 0) {
			ans = min(ans, rec(c1 + 1, f3, c2, f2, c3 - 1, f3 ^ 1) + 1);
		}
		if (c2 > 0 && f3 == f2) {
			ans = min(ans, rec(c1, f1, c2, f2, c3 - 1, f3 ^ 1) + 1);
		}
		if (c2 == 0) {
			ans = min(ans, rec(c1, f1, c2 + 1, f3, c3 - 1, f3 ^ 1) + 1);
		}
	}
	return ans;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("sum.in", "r", stdin);
	//freopen("sum.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cout.setf(ios::fixed);
	int cnt1, color1, cnt2, color2, cnt3, color3;
	char c1 = 'R', c2 = 'R', c3 = 'R';
	cin >> cnt1;
	if (cnt1) cin >> c1;
	cin >> cnt2;
	if (cnt2) cin >> c2;
	cin >> cnt3;
	if (cnt3) cin >> c3;
	color1 = c1 == 'R';
	color2 = c2 == 'R';
	color3 = c3 == 'R';
	memset(dp, -1, sizeof(dp));
	cout << rec(cnt1, color1, cnt2, color2, cnt3, color3);
	return 0;
}