using System;
using System.Linq;
using CompLib.Util;

public class Program
{
    private int N;
    private int[] A;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        A = sc.Next().Select(c => c - '1').ToArray();


        // 1
        // 1 1
        // 1 2 1
        // 1 3 3 1
        // 1 4 6 4 1
        // 1 5 10 10 5 1
        // 1 6 15 20 15 6 1
        // 1 7 21 35 35 21 7 1
        {
            // 1になる
            // 1の影響回数 パスカルの三角形
            int cnt = 0;
            for (int i = 0; i < N; i++)
            {
                if (A[i] == 1)
                {
                    // (N-1) C iが奇数か?
                    if (((N - 1) & i) == i) cnt++;
                }
            }

            if (cnt % 2 != 0)
            {
                Console.WriteLine("1");
                return;
            }
        }

        // 0 or 2
        // 2になる
        // 0 2
        // 0 0 2
        // 0 2 2
        // 0 2のみ
        // 2の影響回数奇数回
        {
            int cnt = 0;
            for (int i = 0; i < N; i++)
            {
                if (A[i] == 1)
                {
                    Console.WriteLine("0");
                    return;
                }

                if (A[i] == 2)
                {
                    if (((N - 1) & i) == i) cnt++;
                }
            }

            Console.WriteLine(cnt % 2 == 0 ? "0" : "2");
        }
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 40464