open System

// input
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

// utils

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let flip f a b = f b a  

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

let N = readInt ()
let a =
  readStr().ToCharArray()
  |> Array.map (fun c -> (int c) - (int '1'))

let bm2 n r = n = (r ||| (n-r))

let rec result (input: _ array) =
  printfn "%A" input
  let odd =
    [0..(N-1)]
    |> List.filter (bm2 (N-1))
    |> List.map (fun i -> input.[i] % 2)
    |> List.fold (^^^) 0
    |> function
    | 0 -> false
    | 1 -> true
    | _ -> failwith "invalid" 

  let have1 = a |> Array.exists ((=) 1)
  let have2 = a |> Array.exists ((=) 2)

  if odd
    then 1
    else if have1 || not have2
           then 0
           else input |> Array.map (flip (/) 2) |> result |> ( * ) 2

result a |> printfn "%d"