#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+7; 
typedef long long ll;
int a[maxn],que[maxn];
int main() {
    int n=0,len,i;
    while(~scanf("%d",&a[++n]));
    --n;
    for(i=n,len=0;i;--i) {
        if(a[i]>=que[len]) que[++len]=a[i];
        else {
            int cnt=upper_bound(que+1,que+1+len,a[i])-que;
            que[cnt]=a[i];
        }
    }
    printf("%d\n",len);
    for(i=1,len=0;i<=n;++i) {
        if(a[i]>que[len]) que[++len]=a[i];
        else {
            int cnt=lower_bound(que+1,que+1+len,a[i])-que;
            que[cnt]=a[i];
        }
    }
    printf("%d\n",len);
}