#include<bits/stdc++.h>
using namespace std;
int bomp[500005];
int dp[500005],dpp[500005];
int nosy=1;//number of system
int main(){
dp[1]=2147483647;
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t,n=0,sy,ma;
while(cin>>t){
n++;
bomp[n]=t;
dpp[n]=1;
}
int L;
for(int i=1;i<=n;i++){
for(int j=0;j<i;j++){
if(bomp[i]<=bomp[j]&&dpp[j]+1>dpp[i]) dpp[i]=dpp[j]+1;
}
L=max(dpp[i],L);
}
cout<<L<<endl;
for(int i=1;i<=n;i++){
sy=500006;
ma=-1;
for(int j=1;j<=nosy;j++){
if(bomp[i]<=dp[j] && dp[j]>ma) ma=dp[j],sy=j;
}
if(ma==-1){
nosy++;
dp[nosy]=bomp[i];
}else dp[sy]=bomp[i];
}
cout<<nosy;
return 0;
}