#include <stdio.h>
#include <stdlib.h>
int main(){
    int x;
    int arr[10000000];
    arr[0] = -1;
    int idx = 1;
    scanf("%d", &x);
    //????????????????????????
    while(scanf("%d", &x)==1){
        arr[idx] = x;
        idx++;
    }
    
    int *lis, lis_idx=0;
    lis = malloc(sizeof(int) * idx);
    lis[0] = arr[0];
    int i, j;
    for(i=0; i<idx; i++){
    	if(lis[lis_idx] < arr[i]){
    		lis_idx ++;
    		lis[lis_idx] = arr[i];
    	}else if(lis[lis_idx-1] < arr[i]){
    		lis[lis_idx] = arr[i];
    	}
    }
    printf("%d\n", lis_idx);
    return 0;
}