import std.stdio, std.string, std.conv, std.range, std.array, std.algorithm;
import std.uni, std.math, std.container, std.typecons, std.typetuple;
import core.bitop, std.datetime;

immutable long mod = 10^^9 + 7;
immutable int inf = mod;

void main(){
    int n = readln.chomp.to!int;
    auto a = new int[](n + 1);

    foreach(i ; 1 .. n + 1){
        readVars(a[i]);
    }

    auto ma = new int[](n + 1);
    ma[1 .. $] = inf;
    ma[0] = -1;

    auto mb = assumeSorted(ma);

    int ans;

    foreach(i ; 1 .. n + 1){
        int j = mb.lowerBound(a[i]).length.to!int;
        ans = max(ans, j);
        mb[j] = a[i];
    }

    writeln(ans);
}

void readVars(T...)(auto ref T args){
    auto line = readln.split;
    foreach(ref arg ; args){
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    if(!line.empty){
        throw new Exception("args num < input num");
    }
}