#include <stdio.h>
#include <stdlib.h>
void main(){
    int x;
    int arr[100000];
    arr[0] = -1;
    int idx = 1;
    //????????????????????????
    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);
}
/*
#include <stdio.h>
#include <stdlib.h>
void main(){
    int x;
    int arr[100000];
    arr[0] = -1;
    int idx = 1;
    //????????????????????????
    while(scanf("%d", &x)==1){
        arr[idx] = x;
        idx++;
    }
    int k=0;
    for(;k<idx;k++){
    	printf("%d ", arr[k]);
    	putchar('\n');
    }
    
    int *lis, lis_idx=0;
    lis = malloc(sizeof(int) * idx);
    lis[0] = arr[0];
    int i, j;
    for(i=0; i<idx; i++){
    	printf(">>%d, %d\n", lis[lis_idx], arr[i]);
    	if(lis[lis_idx] < arr[i]){
    		lis_idx ++;
    		printf("LIS_IDX ADDED:%d -> %d\n", lis_idx-1, lis_idx);
    		lis[lis_idx] = arr[i];
    	}else if(lis[lis_idx-1] < arr[i]){
    		lis[lis_idx] = arr[i];
    	}
    	//printf("%d\n", lis[lis_idx]);
    	for(j=1;j<=lis_idx;j++){
    		printf("%d ", lis[j]);
    	}
    	putchar('\n');
    }
    printf("??????:%d\n??????:", lis_idx);
    for(j=1;j<=lis_idx;j++){
    	printf("%d ", lis[j]);
    }
    putchar('\n');
}*/