# 프로그래머스 Level 1 체육복
s = 5
l = [2, 4]
r = [1, 3, 5]


def solution(n, lost, reserve):
    set_reserve = set(reserve) - set(lost)
    set_lost = set(lost) - set(reserve)

    for i in set_reserve:
        if i - 1 in set_lost:
            set_lost.remove(i - 1)
        elif i + 1 in set_lost:
            set_lost.remove(i + 1)

    return n - len(set_lost)


result = solution(5, l, r)
print(result)
