#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring> 

using std::cin, std::cout, std::max;


constexpr size_t MAX_N = 500005;


int main(){
    
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    
    int arr[MAX_N];     
    int len[MAX_N];     
    int n = 0;          
    int ans1 = 0;       
    int ans2 = 0;       

    
    while(cin >> arr[n]){
        len[n] = 1; 
        n++;
    }

    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < i; j++){
            if(arr[j] >= arr[i]){
                if(len[i] < len[j] + 1){
                    len[i] = len[j] + 1;
                }
            }
        }
        
        if(ans1 < len[i]){
            ans1 = len[i];
        }
    }

    
    
    std::vector<int> systems;

    for(int i = 0; i < n; i++){
        bool isOk = false;
        
        for(int j = 0; j < systems.size(); j++){
            if(systems[j] >= arr[i]){
                
                systems[j] = arr[i];
                isOk = true;
                break;
            }
        }
        
        if(!isOk){
            systems.emplace_back(arr[i]);
        }
    }

    
    ans2 = systems.size();

    
    cout << ans1 << "\n" << ans2 << "\n";

    return 0;
}
