import java.util.*;
class Node
{
    int data;
    Node l,r;
    public Node(int val)
    {
        data=val;
        l=r=null;
    }
}
class tree
{
    Node insert(Node root,int val)
    {
        if(root==null)
        {
            return new Node (val);
        }
        if(val<root.data)
        {
            root.l=insert(root.l,val);
        }
        else
        {
            root.r=insert(root.r,val);
        }
    return root;
    }
    public void l_or(Node root,int tar,int k)
    {
        
        if(root==null)
        {
            return ;
        }
            Queue <Node> q1=new  LinkedList<>();
           
            q1.add(root);
            int c=9;
            while(!q1.isEmpty())
            {
                int s=q1.size();
                Node temp =q1.poll();
                for(int i=0;i<s;i++)
                {
              if(temp.data=tar)  
              {
                 System.out.print(c);
                    return;
              }
              else
              {
                  break;
              }
              
                if(temp.l!=null)
                {
                    q1.add(temp.l);
                  
                }
                if(temp.r!=null)
                {
                    q1.add(temp.r);
                      
                }
               
            }
       c++;}
            
    }
}
public class Main
{
    public static void main(String [] args)
    {
        Scanner sc =new Scanner (System.in); 
        tree t=new tree();
        int k=sc.nextInt();
        
        if(k<0||k>10)
        {
            System.out.print("Invalid Input");
            return;
        }
        Node root = null;
        for(int i=0;i<k;i++)
        {
            int val=sc.nextInt();
            if(val<0||val>100)
            {
                System.out .print("Invalid Input");
                return;
            }
          root =t.insert(root,val);
        }
        int tar =sc.nextInt();
        t.l_or(root,tar,k);
        
    }
}