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 dp = new int[](n + 1);
    auto ma = new int[](n + 1);
    ma[1 .. $] = inf;
    ma[0] = -1;

    foreach(i ; 1 .. n + 1){
        int j = nibutan(n, ma, a[i]) + 1;
        ma[j] = a[i];
        dp[i] = j;

        //writeln(ma);
    }

    int ans = dp.reduce!max;

    writeln(ans);
}

int nibutan(int n, int[] ma, int v){
    int btm = -1, top = n;

    while (top - btm > 1) {
        int mid = (top + btm) / 2;

        if (ma[mid] < v) {
            btm = mid;
        }
        else {
            top = mid;
        }
    }

    return btm;
}

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");
    }
}