output_description: Print the minimum number of colors required to satisfy the condition.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1
      :
      A_N
attempt: import sys
  
  sys.setrecursionlimit(4100000)
  
  import logging
  
  logging.basicConfig(level=logging.DEBUG)
  
  logger = logging.getLogger(__name__)
  
  
  def resolve():
      N = [int(x) for x in sys.stdin.readline().split()][0]
      a_list = [[int(x) for x in sys.stdin.readline().split()][0] for _ in range(N)]
  
      logger.debug("{} {}".format(N, a_list))
  
      min_list = [10**10]
      max_min = 10**10
      i_max = 0
      for i, a in enumerate(reversed(a_list)):
          if a >= max_min:
              max_min = a
              min_list.append(a)
              i_max = i
          else:
              min_list[i_max] = a
              max_min = max(min_list)
  
      print(len(min_list))
  
  
  if __name__ == "__main__":
      resolve()
  
  # AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
  # python -m unittest template/template.py で実行できる
  # pypy3 -m unittest template/template.py で実行できる
  
  import sys
  from io import StringIO
  import unittest
  
  
  class TestClass(unittest.TestCase):
      def assertIO(self, input, output):
          stdout, stdin = sys.stdout, sys.stdin
          sys.stdout, sys.stdin = StringIO(), StringIO(input)
          resolve()
          sys.stdout.seek(0)
          out = sys.stdout.read()[:-1]
          sys.stdout, sys.stdin = stdout, stdin
          self.assertEqual(out, output)
  
      def test_入力例_1(self):
          input = """5
  2
  1
  4
  5
  3"""
          output = """2"""
          self.assertIO(input, output)
  
      def test_入力例_2(self):
          input = """4
  0
  0
  0
  0"""
          output = """4"""
          self.assertIO(input, output)
  
      def test_入力例_3(self):
          input = """1
  0"""
          output = """1"""
          self.assertIO(input, output)
  
problem_description: Statement
  
  You are given a sequence with N integers: A = \\{ A_1, A_2, \cdots, A_N \\}.
  For each of these N integers, we will choose a color and paint the integer
  with that color. Here the following condition must be satisfied:
  
    * If A_i and A_j (i < j) are painted with the same color, A_i < A_j.
  
  Find the minimum number of colors required to satisfy the condition.
samples: [{"input": "5\n    2\n    1\n    4\n    5\n    3", "output": "2\n    \n\nWe can satisfy the condition with two colors by, for example, painting 2 and 3\nred and painting 1, 4, and 5 blue.\n\n* * *"}, {"input": "4\n    0\n    0\n    0\n    0", "output": "4\n    \n\nWe have to paint all the integers with distinct colors."}]