#include
using namespace std;
class Node{
public:
int data ;
Node *next;
Node (int num)
{
data = num;
next = NULL;
}
};
void insert_at_tail(Node*&head,int data)
{
Node *n = new Node(data);
if(head == NULL)
{ head = n;
}
Node*temp = head;
while(temp->next!=NULL)
{
temp = temp->next;
}
temp->next = n;
}
void buildlist(Node *&head)
{
int data ;
cin>>data;
while(data!= -1)
{
insert_at_tail(head,data);
cin>>data;
}
}
int knode(Nodehead,int key)
{
Nodeslow = head;
Node*fast ;
int i=0;
while(i<key)
{
fast = fast->next;
i++;
}
while(fast!=NULL && fast->next!=NULL)
{
slow = slow->next;
fast = fast->next;
}
return slow->data;
}
istream& operator>>(istream &io,Node *&head)
{
buildlist(head);
return io;
}
int main() {
Node*head = NULL;
cin>>head;
int key;
cin>>key;
cout<<knode(head,key);
return 0;
}