#include <bits/stdc++.h>
 
//_ ************************** Advanced PBDS ***********************************
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<class T>
using ordered_set = tree<
    T,
    null_type,
    less<T>,
    rb_tree_tag,
    tree_order_statistics_node_update
>;
 
 
//_ ****************************************************************************
 
#define int              long long int
#define double           long double
#define print(a)         for(auto x : a) cout << x << " "; cout << endl


const int M = 1000000007;
const int N = 3e5+9;
const int INF = 2e9+1;
const int LINF = 2000000000000000001;

inline int power(int a, int b, int mod=M) {
    int x = 1;
    a %= mod;
    while (b) {
        if (b & 1) x = (x * a) % mod; 
        a = (a * a) % mod;
        b >>= 1;
    }
    return x;
}


//_ ***************************** START Below *******************************

// 8
// 1 3
// 2 4
// 5 6
// 6 7
// 6 10
// 7 8
// 9 10
// 11 12


vector<pair<int,int>> a;

int consistency1(int n){

	int maxi = 0;
	
	for(int i=0; i<n; i++){
		int s = a[i].first;
		int e = a[i].second;
		
		int ct = 0;
		
		for(int j=0; j<n; j++){
			
			int x = a[j].first;
			int y = a[j].second;
			
			if(x <= s && y >= s) ct++;
			else if( x >= s && x <= e ) ct++;
			
		}
		
		
		maxi = max(maxi, ct);
	}
	
	
	return n - maxi;
}




//* PBDS 

int consistency2(int n){
    sort(begin(a), end(a));
    
    ordered_set<pair<int,int>> st;
    int maxi = 0;
    
    for(int i = 0; i < n; i++){
        int s = a[i].first;
        int e = a[i].second;
        
        int left = st.size() - st.order_of_key({s, -INF});
        
        auto it = upper_bound(begin(a) + i + 1, end(a), make_pair(e, INF));
        int right = it - (begin(a) + i + 1);
        
        st.insert({e, i});
        
        maxi = max(maxi, left + right + 1);
    }
    
    return n - maxi;
}



//* No PBDS 

int consistency3(int n) {
    vector<int> starts(n), ends(n);
    for(int i = 0; i < n; i++) {
        starts[i] = a[i].first;
        ends[i] = a[i].second;
    }
    
    sort(starts.begin(), starts.end());
    sort(ends.begin(), ends.end());
    
    int maxi = 0;
    
    for(int i = 0; i < n; i++) {
        int s = a[i].first;
        int e = a[i].second;
        
        // Count intervals that end strictly before the current one starts
        int left_disjoint = lower_bound(ends.begin(), ends.end(), s) - ends.begin();
        
        // Count intervals that start strictly after the current one ends
        int right_disjoint = starts.end() - upper_bound(starts.begin(), starts.end(), e);
        
        // Total intersecting = Total intervals - non-intersecting
        int intersecting = n - left_disjoint - right_disjoint;
        
        maxi = max(maxi, intersecting);
    }
    
    return n - maxi;
}









int practice(int n){


    return 0;
}





void solve() {
    
    int n;
    cin>> n;
    
    a.resize(n);
    for(int i=0; i<n; i++){
    	int x, y;
    	cin >> x >> y;
    	a[i] = {x, y};
    }
    
    cout << consistency1(n) << " " << consistency2(n) << " " << consistency3(n) << endl;


}





int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}