import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine().toInt
    var as = in.readLine().toCharArray.map(_ - '0')

    for {
      i <- 1 until n
    } {
      val newAs = Array.ofDim[Int](as.length - 1)
      for {
        j <- 0 until (n - i)
      } {
        newAs(j) = Math.abs(as(j) - as(j + 1))
      }
      as = newAs
    }

    out.println(as(0))

    out.flush()
  }
}
