def prefix_match(list1, list2):
    """
    Find the length of the longest common prefix of list1 and list2.

    >>> prefix_match([], [])
    0
    >>> prefix_match('test', 'test')
    4
    >>> prefix_match('test', 'toast')
    1
    >>> prefix_match('test', 'best')
    0
    >>> prefix_match([1, 2, 3, 4], [1, 2, 4, 8])
    2
    """
    for i in range(min(len(list1), len(list2)), 0, -1):
        if list1[:i] == list2[:i]:
            return i
    return 0
