def main():

    n, *v = list(map(int, open(0).read().split()))

    be = [0] * int(1e5)

    bo = [0] * int(1e5)

    for e, o in zip(*[iter(v)] * 2):

        be[e - 1] += 1

        bo[o - 1] += 1

    if be.index(max(be)) == bo.index(max(bo)):

        ve = max(be)

        vo = max(bo)

        be[be.index(ve)] = 0

        bo[bo.index(vo)] = 0

        print((min(n - ve - max(bo), n - vo - max(be))))

    else:

        print((n - max(be) - max(bo)))

    return





main()

def main():

    n, *v = list(map(int, open(0).read().split()))

    be = [0] * int(1e5)

    bo = [0] * int(1e5)

    for e, o in zip(*[iter(v)] * 2):

        be[e - 1] += 1

        bo[o - 1] += 1

    ve = max(be)

    vo = max(bo)

    ke = be.index(ve)

    ko = bo.index(vo)

    if ke == ko:

        be[ke] = 0

        bo[ko] = 0

        print((min(n - ve - max(bo), n - vo - max(be))))

    else:

        print((n - ve - vo))

    return





main()

def main():
    n, *v = list(map(int, open(0).read().split()))
    be = [0] * int(1e5)
    bo = [0] * int(1e5)
    for e, o in zip(*[iter(v)] * 2):
        be[e - 1] += 1
        bo[o - 1] += 1
    if be.index(max(be)) == bo.index(max(bo)):
        ve = max(be)
        vo = max(bo)
        be[be.index(ve)] = 0
        bo[bo.index(vo)] = 0
        print((min(n - ve - max(bo), n - vo - max(be))))
    else:
        print((n - max(be) - max(bo)))
    return


main()

def main():
    n, *v = list(map(int, open(0).read().split()))
    be = [0] * int(1e5)
    bo = [0] * int(1e5)
    for e, o in zip(*[iter(v)] * 2):
        be[e - 1] += 1
        bo[o - 1] += 1
    ve = max(be)
    vo = max(bo)
    ke = be.index(ve)
    ko = bo.index(vo)
    if ke == ko:
        be[ke] = 0
        bo[ko] = 0
        print((min(n - ve - max(bo), n - vo - max(be))))
    else:
        print((n - ve - vo))
    return


main()

-    if be.index(max(be)) == bo.index(max(bo)): -        ve = max(be) -        vo = max(bo) -        be[be.index(ve)] = 0 -        bo[bo.index(vo)] = 0 +    ve = max(be) +    vo = max(bo) +    ke = be.index(ve) +    ko = bo.index(vo) +    if ke == ko: +        be[ke] = 0 +        bo[ko] = 0 -        print((n - max(be) - max(bo))) +        print((n - ve - vo))