#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int a[maxn],dp[maxn],b[maxn],c[maxn];
bool cmp(int a,int b)
{
return a>b;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
while(scanf("%d",&a[++n])!=EOF);
n--;
int l1=1;
b[1]=a[1];
for(int i=2;i<=n;i++)
{
if(a[i]<=b[l1]) b[++l1]=a[i];
else
{
*upper_bound(b+1,b+1+l1,a[i],greater<int>())=a[i];
}
}
cout<<l1<<endl;
int l2=1;
c[1]=a[1];
for(int i=2;i<=n;i++)
{
if(a[i]>=c[l2]) c[++l2]=a[i];
else
{
*lower_bound(c+1,c+1+l2,a[i])=a[i];
}
}
cout<<l2<<endl;
return 0;
}