#!/usr/bin/env python3

def FindMergeNode(headA, headB):
    nodeA, nodeB = headA, headB
    lenA = lenB = 0
    while nodeA.next:
        nodeA = nodeA.next
        lenA += 1
    while nodeB.next:
        nodeB = nodeB.next
        lenB += 1
    nodeA, nodeB = headA, headB
    while lenA > lenB:
        nodeA = nodeA.next
        lenA -= 1
    while lenB > lenA:
        nodeB = nodeB.next
        lenB -= 1
    while nodeA.next != nodeB.next:
        nodeA = nodeA.next
        nodeB = nodeB.next
    return nodeA.next.data
    
