program one_two_three_triangle
  implicit none
  integer :: n, a(1000000) = 0, i, j, m = 0
  character(1000000) :: s
  read(*,*) n
  read(*,*) s
  do i = 1, n
    a(i) = ichar(s(i:i)) - 48
  end do
  do i = 1, n - 1
    m = m + abs(a(i) - a(i + 1))
  end do
  write(*,'(i0)') mod(m, 3)
end program one_two_three_triangle