#include <cstdio>
#include <algorithm>
using namespace std;
int n,f[1001],a[1001];
int main()
{
//freopen("missile.in","r",stdin);
//freopen("missile.out","w",stdout);
while (scanf("%d",&a[++n])>0);
--n; f[1]=1; int ans=0;
for (int i=2;i<=n;++i){//最长不下降子序列
f[i]=1;
for (int j=1;j<i;++j)
if (a[j]>=a[i]) f[i]=max(f[i],f[j]+1);
ans=max(ans,f[i]);
}
printf("%d\n",ans); ans=0;
for (int i=2;i<=n;++i){//最长上升子序列
f[i]=1;
for (int j=1;j<i;++j)
if (a[j]<a[i]) f[i]=max(f[i],f[j]+1);
ans=max(ans,f[i]);
}
printf("%d\n",ans);
return 0;
}