#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int h[100001],f[100001],w[100001];
int t=0,p;
int n=1;
int ans=0;
int main(){
while(cin>>h[n])n++;
n--;
for(int i=1;i<=n;i++){
f[i]=1;
for(int j=1;j<i;j++){
if(h[i]<=h[j]&&f[i]<f[j]+1)f[i]=f[j]+1;
}
ans=max(ans,f[i]);
}
w[t]=h[0];
for(int i=1;i<n;i++){
p=0;
for(int j=1;j<=t;j++){
if(w[j]>=h[i]){
if(p==0)p=j;
if(w[p]>w[j])p=j;
}
}
if(p==0){
t++;
w[t]=h[i];
}
else {
w[p]=h[i];
}
}
cout<<ans<<endl;
cout<<t;
return 0;
}