#include <bits/stdc++.h>
using namespace std;
string str;
int x,ans,ans2;
vector<int> v;
void f1()
{
vector<int> ve;
for(int i:v)
{
auto it=upper_bound(ve.begin(),ve.end(),i,greater<int>());
if(it==ve.end())
ve.push_back(i);
else
*it=i;
}
ans=ve.size();
}
void f2()
{
vector<int> ve;
for(int i:v)
{
auto it=lower_bound(ve.begin(),ve.end(),i);
if(it==ve.end())
ve.push_back(i);
else
*it=i;
}
ans2=ve.size();
}
int main()
{
ios::sync_with_stdio(0);
cout.tie(0);cin.tie(0);
getline(cin,str);
for(int i=0;i<str.size();i++)
if(str[i]==' ')
v.push_back(x),x=0;
else
x=x*10+(str[i]-'0');
v.push_back(x);
f1();
cout<<ans<<"\n";
f2();
cout<<ans2;
return 0;
}