# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect

class MaxCutFree:
    def solve(self, n, a, b):
        l = len(a)
        is_bridge = [False for _ in range(l)]
        for i in range(l):
            start = a[i]
            end = b[i]
            used = [False for _ in range(l)]
            used[i] = True

            def dfs(point):
                if point == end:
                    return True
                for j in range(l):
                    if used[j]:
                        continue
                    if a[j] == point:
                        used[j] = True
                        if dfs(b[j]):
                            return True
                    if b[j] == point:
                        if dfs(a[j]):
                            return True
                return False

            is_bridge[i] = not dfs(start)

        removed = []
        pairs = [(a[i], b[i]) for i in range(l) if is_bridge[i]]

        while pairs:
            counts = {}
            nums = [i for i, _ in pairs] + [j for _, j in pairs]
            for k in nums:
                if k not in counts:
                    counts[k] = 0
                counts[k] += 1

            r = None
            c = 0
            for k, v in counts.items():
                if v > c:
                    c = v
                    r = k

            removed.append(r)
            pairs = [(i, j) for i, j in pairs if r not in (i, j)]

        return n - len(removed)


# CUT begin
# TEST CODE FOR PYTHON {{{
import sys, time, math

def tc_equal(expected, received):
    try:
        _t = type(expected)
        received = _t(received)
        if _t == list or _t == tuple:
            if len(expected) != len(received): return False
            return all(tc_equal(e, r) for (e, r) in zip(expected, received))
        elif _t == float:
            eps = 1e-9
            d = abs(received - expected)
            return not math.isnan(received) and not math.isnan(expected) and d <= eps * max(1.0, abs(expected))
        else:
            return expected == received
    except:
        return False

def pretty_str(x):
    if type(x) == str:
        return '"%s"' % x
    elif type(x) == tuple:
        return '(%s)' % (','.join( (pretty_str(y) for y in x) ) )
    else:
        return str(x)

def do_test(n, a, b, __expected):
    startTime = time.time()
    instance = MaxCutFree()
    exception = None
    try:
        __result = instance.solve(n, a, b);
    except:
        import traceback
        exception = traceback.format_exc()
    elapsed = time.time() - startTime   # in sec

    if exception is not None:
        sys.stdout.write("RUNTIME ERROR: \n")
        sys.stdout.write(exception + "\n")
        return 0

    if tc_equal(__expected, __result):
        sys.stdout.write("PASSED! " + ("(%.3f seconds)" % elapsed) + "\n")
        return 1
    else:
        sys.stdout.write("FAILED! " + ("(%.3f seconds)" % elapsed) + "\n")
        sys.stdout.write("           Expected: " + pretty_str(__expected) + "\n")
        sys.stdout.write("           Received: " + pretty_str(__result) + "\n")
        return 0

def run_tests():
    sys.stdout.write("MaxCutFree (1000 Points)\n\n")

    passed = cases = 0
    case_set = set()
    for arg in sys.argv[1:]:
        case_set.add(int(arg))

    with open("MaxCutFree.sample", "r") as f:
        while True:
            label = f.readline()
            if not label.startswith("--"): break

            n = int(f.readline().rstrip())
            a = []
            for i in range(0, int(f.readline())):
                a.append(int(f.readline().rstrip()))
            a = tuple(a)
            b = []
            for i in range(0, int(f.readline())):
                b.append(int(f.readline().rstrip()))
            b = tuple(b)
            f.readline()
            __answer = int(f.readline().rstrip())

            cases += 1
            if len(case_set) > 0 and (cases - 1) in case_set: continue
            sys.stdout.write("  Testcase #%d ... " % (cases - 1))
            passed += do_test(n, a, b, __answer)

    sys.stdout.write("\nPassed : %d / %d cases\n" % (passed, cases))

    T = time.time() - 1553095536
    PT, TT = (T / 60.0, 75.0)
    points = 1000 * (0.3 + (0.7 * TT * TT) / (10.0 * PT * PT + TT * TT))
    sys.stdout.write("Time   : %d minutes %d secs\n" % (int(T/60), T%60))
    sys.stdout.write("Score  : %.2f points\n" % points)

if __name__ == '__main__':
    run_tests()

# }}}
# CUT end
