#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <math.h>
#include <memory.h>
 
using namespace std;
 
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
 
typedef long long LL;
typedef vector<int> vi;


int F(int n)
{
	// n - number of matchsticks
	if (n <= 1)
		return n;
	set<int> values;
	for (int matchsticks = 1; matchsticks <= 2; ++matchsticks)
	{
		for (int i = 0; (i + matchsticks) <= n; ++i)
		{
			int grundyForTwoSubgamesCombined = F(i) ^ F(n - (i + matchsticks));
			values.insert(grundyForTwoSubgamesCombined);
		}
	}
	int res = 0;
	while (values.count(res) > 0)
		++res;
	return res;
}

int main()
{
	// IIXIIIXXIIII
	cout << (F(2) ^ F(3) ^ F(4)) << endl;
	// III
	cout << F(3) << endl;

	return 0;
}