import sys

import bisect

input = sys.stdin.readline



def main():

    N = int(eval(input()))

    a = [int(eval(input())) for i in range(N)]



    nums = []



    for i in a:

        if len(nums) > 0:

            if i <= nums[-1]:

                ind = bisect.bisect_left(nums, i)

                if nums[ind] == i:

                    nums.pop(ind)

                else:

                    nums.insert(ind, i)

            else:

                nums.append(i)

        else:

            nums.append(i)

    

    print((len(nums)))





if __name__ == "__main__":

    main()
import sys

import bisect

input = sys.stdin.readline



def main():

    N = int(eval(input()))



    dic = {}

    for i in range(N):

        a = int(eval(input()))

        if a in dic:

            dic[a] += 1

        else:

            dic[a] = 1

    

    ans = 0

    for num, count in list(dic.items()):

        if count&1:

            ans += 1

    print(ans)





if __name__ == "__main__":

    main()
import sys
import bisect

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    a = [int(eval(input())) for i in range(N)]
    nums = []
    for i in a:
        if len(nums) > 0:
            if i <= nums[-1]:
                ind = bisect.bisect_left(nums, i)
                if nums[ind] == i:
                    nums.pop(ind)
                else:
                    nums.insert(ind, i)
            else:
                nums.append(i)
        else:
            nums.append(i)
    print((len(nums)))


if __name__ == "__main__":
    main()

import sys
import bisect

input = sys.stdin.readline


def main():
    N = int(eval(input()))
    dic = {}
    for i in range(N):
        a = int(eval(input()))
        if a in dic:
            dic[a] += 1
        else:
            dic[a] = 1
    ans = 0
    for num, count in list(dic.items()):
        if count & 1:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-    a = [int(eval(input())) for i in range(N)] -    nums = [] -    for i in a: -        if len(nums) > 0: -            if i <= nums[-1]: -                ind = bisect.bisect_left(nums, i) -                if nums[ind] == i: -                    nums.pop(ind) -                else: -                    nums.insert(ind, i) -            else: -                nums.append(i) +    dic = {} +    for i in range(N): +        a = int(eval(input())) +        if a in dic: +            dic[a] += 1 -            nums.append(i) -    print((len(nums))) +            dic[a] = 1 +    ans = 0 +    for num, count in list(dic.items()): +        if count & 1: +            ans += 1 +    print(ans)