module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

import           Data.Array (Array, (!))
import qualified Data.Array as Array

------------------------------------------

main :: IO ()
main = do
  n <- readInt
  if n == 0 then return ()
  else do
  arr <- Array.listArray (0, n-1) <$> replicateM n readInt
  k <- readInt
  print $ solve arr k 0 0 (n-1)
  main

solve :: Array Int Int -> Int -> Int -> Int -> Int -> Int
solve arr target count l r
  | l > r             = count
  | arr ! m == target = count+1
  | arr ! m <  target = solve arr target (count+1) (m+1) r
  | otherwise         = solve arr target (count+1) l (m-1)
  where m = (l + r) `div` 2

------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"