#include<iostream>
using namespace std;
struct ListNode {
int value;
ListNode* next;
};
ListNode* Find(ListNode* head){
ListNode*fast=head->next, *slow=head;
while (fast!=slow){
fast = fast->next->next;
slow = slow->next;
}
int num = 1,n=0;
fast = fast->next;
while (fast!=slow){
fast = fast->next;
num++;
}
fast = slow = head;
while (n<num-1){
fast = fast->next;
n++;
}
while (fast->next != slow) {
fast = fast->next;
slow = slow->next;
}
return slow;
}
int main(){
ListNode *l=new ListNode();
l->value = 1;
l->next = new ListNode();
l->next->value = 2;
l->next->next = new ListNode();
l->next->next->value = 3;
l->next->next->next = new ListNode();
l->next->next->next->value = 4;
l->next->next->next->next = l->next;
cout << Find(l)->value << endl;
return 0;
}