// editor3
#include<stdio.h>
#include<stdlib.h>
typedef struct Node{
    int data;
    structt Node *next;
    
}node;
node *head=NULL,*tail;
void create(int num){
    node *newnode=(node*)malloc(1*sizeof(node));
    newnode->data=num;
    newnode->next=NULL;
    if(head==NULL){
        head=newnode;
        tail=newnode;
    }
    else{
        tail->next=newnode;
        tail=newnode;
    }
}
int findpos(int val){
    node *temp=head;
    int pos=1;
    while(temp!=NULL){
        if(temp->data==val){
            return 0;
        }
        temp=temp->next;
        pos++''
    }
    return -1;
}
int main(){
    int n,num;
    scanf("%d",&val);
    int pos=findpos(val);
    if(pos==-1){
        printf("-1");
        }
        int val;
        scanf("%d",&val);
        int pos=findpos(val);
        if(pos==-1){
            printf("-1");
            
        }
        else
        printf("%d",pos);
        return 0;
}