#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int a[N], g[N], x, l, count;;
int main() {
while (cin >> x) {
a[++l] = x;
}
for (int i = 1; i <= l; i++) {
int k = 1;
while (k <= count && g[k] >= a[i]) {
k++;
}
if (k > count) {
g[++count] = a[i];
} else {
g[k] = a[i];
}
}
cout << count << endl;
count = 0;
for (int i = 1; i <= l; i++) {
int k = 1;
for (; k <= count && g[k] < a[i];) {
k++;
}
if (k > count) {
g[++count] = a[i];
} else {
g[k] = a[i];
}
}
cout << count << endl;
}