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: # -------------------------------------------------------------------
  import sys
  
  
  def p(*_a):
      _s = " ".join(map(str, _a))
      # print(_s)
      sys.stderr.write(_s + "\n")
  
  
  # -------------------------------------------------------------------
  
  
  from collections import defaultdict
  
  d = defaultdict(str)
  
  d["00"] = "0"
  d["01"] = "1"
  d["02"] = "2"
  d["03"] = "3"
  
  d["10"] = "1"
  d["11"] = "0"
  d["12"] = "1"
  d["13"] = "2"
  
  d["20"] = "2"
  d["21"] = "1"
  d["22"] = "0"
  d["23"] = "1"
  
  d["30"] = "3"
  d["31"] = "2"
  d["32"] = "1"
  d["33"] = "0"
  
  
  # p(d)
  
  x = ""
  iLen = 2
  iLenMax = 5
  
  L = []
  for k, v in d.items():
      if len(k) == iLen:
          L.append([k, v])
  
  while iLen < iLenMax:
      di = list(L)
      L = []
      for k, v in di:
          # p(k,v)
          if len(k) < iLen:
              continue
          for c01 in ["0", "1", "2", "3"]:
              x = k + c01
  
              while len(x) > 1:
                  a = v
                  b = d[x[1:-1]]
                  x = a + b
  
              d[k + c01] = x
              L.append([k + c01, x])
  
      iLen += 1
  
  ##p(d)
  # for k, v in d.items():
  # 	if len(k)>11: p(k,v)
  
  
  # -------------------------------------------------------------------
  N = int(input())  # 5
  
  s = input()
  
  if len(s) < iLenMax:
  
      g = []
      g.append(s)
  
      z = 0
      # for i in range(N):
      for j in range(N - 1):
          s = g[j]
          x = ""
          for k in range(1, len(s)):
              a = int(s[k - 1])
              b = int(s[k - 0])
              c = abs(a - b)
              x = x + str(c)
  
          g.append(x)
  
      # p(g)
      print(g[N - 1])
  
  else:
  
      z = s
  
      # 	p(z,len(z))
      while len(z) > 1:
  
          iLen = min(iLenMax, len(z))
          # 		p("iLen, len(z), ",iLen, len(z))
          y = ""
          for i in range(len(z) - iLen + 1):
              a = b = e = f = h = ""
  
              a = z[i + 0 : i + 0 + iLen]
              b = z[i + 1 : i + 1 + iLen]
  
              e = str(d[a])
              f = str(d[b])
  
              h = e + f
              y = y + d[h]
          # 			p("i,a,b,e,f,h,y, ",i,a,b,e,f,h,y)
  
          z = y
  
      print(z)
  
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"}]