output_description: Print x_{N,1}.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      a_1a_2\ldotsa_N
attempt: n = int(input())
  l = input()
  d = [[] for i in range(n)]
  for i in range(n):
      d[0].append(l[i])
  if n == 1:
      print(int(l))
  elif n == 2:
      print(abs(int(d[0][1]) - int(d[0][0])))
  elif n == 3:
      print(abs(abs(int(d[0][1]) - int(d[0][0]) - abs(int(d[0][2]) - int(d[0][1])))))
  else:
      for i in range(1, 3):
          for j in range(0, n - i):
              d[i].append(str(abs(int(d[i - 1][j]) - int(d[i - 1][j + 1]))))
      for i in range(2, n - 1):
          if len(d[i]) == 3:
              if (
                  d[i][0] + d[i][1] + d[i][2] == "000"
                  or d[i][0] + d[i][1] + d[i][2] == "010"
                  or d[i][0] + d[i][1] + d[i][2] == "101"
                  or d[i][0] + d[i][1] + d[i][2] == "111"
              ):
                  print(0)
                  break
              else:
                  print(1)
                  break
          elif len(d[i]) == 2:
              if d[i][0] + d[i][1] == "00" or d[i][0] + d[i][1] == "11":
                  print(0)
                  break
              else:
                  print(1)
                  break
          elif len(d[i]) == 1:
              print(int(d[i][0]))
              break
          else:
              for j in range(0, len(d[i]) // 4):
                  if (
                      (d[i][0] + d[i][1] + d[i][2] + d[i][3] == "0000")
                      or (d[i][0] + d[i][1] + d[i][2] + d[i][3] == "1111")
                      or (d[i][0] + d[i][1] + d[i][2] + d[i][3] == "0011")
                      or (d[i][0] + d[i][1] + d[i][2] + d[i][3] == "1100")
                      or (d[i][0] + d[i][1] + d[i][2] + d[i][3] == "0101")
                      or (d[i][0] + d[i][1] + d[i][2] + d[i][3] == "0110")
                      or (d[i][0] + d[i][1] + d[i][2] + d[i][3] == "1010")
                      or (d[i][0] + d[i][1] + d[i][2] + d[i][3] == "1001")
                  ):
                      d[i + 1].append("0")
                  else:
                      d[i + 1].append("1")
              for j in range(0, len(d[i]) % 4):
                  d[i + 1].append(d[i][(len(d[i]) // 4) * 4 + j])
  
problem_description: Statement
  
  Given is a sequence of N digits a_1a_2\ldots a_N, where each element is 1, 2,
  or 3. Let x_{i,j} defined as follows:
  
    * x_{1,j} := a_j \quad (1 \leq j \leq N)
    * x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \quad (2 \leq i \leq N and 1 \leq j \leq N+1-i)
  
  Find x_{N,1}.
samples: [{"input": "4\n    1231", "output": "1\n    \n\nx_{1,1},x_{1,2},x_{1,3},x_{1,4} are respectively 1,2,3,1.\n\nx_{2,1},x_{2,2},x_{2,3} are respectively |1-2| = 1,|2-3| = 1,|3-1| = 2.\n\nx_{3,1},x_{3,2} are respectively |1-1| = 0,|1-2| = 1.\n\nFinally, x_{4,1} = |0-1| = 1, so the answer is 1.\n\n* * *"}, {"input": "10\n    2311312312", "output": "0"}]