#include<bits/stdc++.h>
using namespace std;
int tot=1, a[500000], f[500000], zh[500000], qwq, ans, mi=10000000, b;
int main()
{
while(cin >> a[tot])
{
tot++;
}
tot--;
for(int i=tot;i>=1;i--)
{
f[i] = 1;
for(int j=i;j<=tot;j++)
{
if(a[j] < a[i])
{
f[i] = max(f[i],f[j]+1);
}
}
}
cout << f[1];
for(int i=1;i<=tot;i++)
{
for(int j=1;j<=qwq;j++)
{
if(zh[j] > a[i]&&mi > zh[j])
{
mi = zh[j];
b = j;
ans = 1;
}
}
if(!ans)
{
qwq++;
zh[qwq] = a[i];
}
else
{
zh[b] = a[i];
}
mi = 10000000;
ans = 0;
}
cout << "\n" << qwq;
}