#include <bits/stdc++.h>
using namespace std;
int a[100050],low[100050],up[100050];
bool cmp(const int& x,const int& y){ return x>y; }
int main()
{
char ch;
int n=0,len1=0,len2=0;
do
{
scanf("%d",a+n);
n++;
} while ((ch=getchar())!='\n');
low[len1] =up[len2] =a[0];
for(int i=1;i<n;i++)
{
if(a[i]<=low[len1]) low[++len1]=a[i];
else
{
int p=upper_bound(low,low+len1,a[i],cmp)-low;
low[p]=a[i];
}
if(a[i]>up[len2]) up[++len2]=a[i];
else
{
int p=upper_bound(up,up+len2,a[i])-up;
up[p]=a[i];
}
}
printf("%d\n%d",len1+1,len2+1);
system("pause");
}