using System;

namespace DPL_1D_1{
    public class Program{
        public static void Main(string[] args){
            string input;
            var lis = new int[100000];
            lis[0] = int.MaxValue;
            var length = 1;
            while((input = Console.ReadLine()) != null){
                var a = int.Parse(input);
                if(lis[length - 1] < a){
                    lis[length++] = a;
                    continue;
                }

                var left = 0;
                var right = length;
                while(left < right) {
                    var mid = (left + right) / 2;
                    if(lis[mid] == a) break;
                    if(a < lis[mid]) right = mid;
                    else left = mid + 1;
                }
                lis[(left + right) / 2] = a;
            }
            Console.WriteLine(length);
        }
    }
}