#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 100005;
int n, a[N], f1[N], f2[N], cnt1, cnt2;
bool use[N];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
while(cin >> a[++n]);
--n;
f1[1] = -a[1], cnt1 = 1;
for (int i = 2; i <= n; ++i) {
if (-a[i] >= f1[cnt1]) f1[++cnt1] = -a[i];
f1[upper_bound(f1 + 1, f1 + cnt1 + 1, -a[i]) - f1] = -a[i];
}
cout << cnt1 << '\n';
for (int i = 1; i <= n; ++i) {
if (a[i] > f2[cnt2]) f2[++cnt2] = a[i];
f2[upper_bound(f2 + 1, f2 + cnt2 + 1, a[i]) - f2] = a[i];
}
cout << cnt2 << '\n';
return 0;
}