#include<bits/stdc++.h>
#define int long long
#define N 2000006
using namespace std;
const int inf=0x3f3f3f3f;
int n,l,maxn=0,b[N],c[N],ans1,ans2=inf;
map <int,int> mp;
struct node
{
	int l,r;
}a[N];
bool cmp(node a,node b)
{
	if (a.l==b.l) return a.r>b.r;
	else return a.l<b.l;
}
signed main()
{
	scanf("%lld%lld",&n,&l);
	for (int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i].l,&a[i].r);
		b[2*i-1]=a[i].l;
		b[2*i]=a[i].r;
	}
	sort(b+1,b+2*n+1);
	int cnt=unique(b+1,b+2*n+1)-b-1;
	l=lower_bound(b+1,b+cnt+1,l)-b;
	for (int i=1;i<=n*2;i++)
	{
		a[i].l=lower_bound(b+1,b+cnt+1,a[i].l)-b;
		a[i].r=lower_bound(b+1,b+cnt+1,a[i].r)-b;
		c[a[i].l]++;
		c[a[i].r]--;
	}
	for (int i=1;i<cnt;i++)
	{
		if (i) c[i]+=c[i-1];
		ans2=min(ans2,c[i]);
	}
	sort(a+1,a+n+1,cmp);
	ans1=0;
	int r=0;
	for (int i=1;i<=n;i++)
	{
		int j=i,tmp=a[i].r;
		while (a[j+1].l<=r && j<n) tmp=max(tmp,a[j+1].r),j++;
		i=j;
		r=max(tmp,r);
		ans1++;
		if (r==l) break;
	}
	printf("%lld %lld\n",ans1,n-ans2+1);
	return 0;
}
