#define _CRT_SECURE_NO_WARNINGS
using namespace std;
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <limits.h>
int mymax(int a, int b)
{
if (a > b)
{
return a;
}
return b;
}
int mymin(int a, int b)
{
if (a > b)
{
return b;
}
return a;
}
int main()
{
priority_queue <int, vector<int>, greater<int> > q1[100666];
priority_queue <int, vector<int>, less<int> > q2[100666];
int lines = 1;
int l2 = 1;
int a;
while (1)
{
if (scanf("%d", &a) == EOF)
{
break;
}
if (q1[lines].empty())
{
q1[lines].push(a);
}
if (q2[l2].empty())
{
q2[l2].push(a);
continue;
}
int small = 1;
int hsmall = INT_MAX;
for (int i = 1; i <= lines; i++)
{
int head = q1[i].top();
if (a <= head)
{
if (head < hsmall)
{
small = i;
hsmall = head;
}
}
}
if (hsmall == INT_MAX)
{
lines += 1;
q1[lines].push(a);
}
else
{
q1[small].push(a);
}
int big = 1;
int hbig = INT_MIN;
for (int i = 1; i <= l2; i++)
{
int head = q2[i].top();
if (head < a)
{
if (head > hbig)
{
big = i;
hbig = head;
}
}
}
if (hbig == INT_MIN)
{
l2 += 1;
q2[l2].push(a);
}
else
{
q2[big].push(a);
}
}
cout << l2 << endl;
cout << lines;
return 0;
}