There are three arrays *a*, *b* and *c*. Each of them consists of *n* integers. SmallY wants to find three integers *u*, *v*, *w* (0 ≤ *u*, *v*, *w* ≤ *n*) such that the following condition holds: each number that appears in the union of *a*, *b* and *c*, appears either in the first *u* elements of *a*, or in the first *v* elements of *b*, or in the first *w* elements of *c*. Of course, SmallY doesn't want to have huge numbers *u*, *v* and *w*, so she wants sum *u* + *v* + *w* to be as small as possible.

Please, help her to find the minimal possible sum of *u* + *v* + *w*.
The first line contains a single integer *n* (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>). The second line contains *n* space-separated integers *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> — array *a*. The third line contains the description of array *b* in the same format. The fourth line contains the description of array *c* in the same format. The following constraint holds: 1 ≤ *a*<sub class="lower-index">*i*</sub>, *b*<sub class="lower-index">*i*</sub>, *c*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>.
def main():
    n = int(input())
    arr1 = [int(i) for i in input().split()]
    arr2 = [int(i) for i in input().split()]
    arr3 = [int(i) for i in input().split()]
    count = [0] * 3
    sum = 0
    arr = []
    for i in range(n):
            if arr1[i] not in arr:
                if (arr1[i] != arr2[i] or arr1[i] != arr3[i]) :    
                    arr.append(arr1[i])
                    count[0] = i + 1
                else:
                    arr.append(arr1[i])
                    count[0] = i + 1
                    sum = sum - 1
            if arr2[i] not in arr:
                if arr2[i] != arr3[i] :    
                    arr.append(arr2[i])
                    count[1] = i + 1
                else:
                    arr.append(arr2[i])
                    count[1] = i + 1
                    sum = sum - 1
            if arr3[i] not in arr :
                arr.append(arr3[i])
                count[2] = i + 1
    sum += count[0] + count[1] + count[2]
    print(sum)
if __name__ == "__main__":
    main()