#include<bits/stdc++.h>
#include<cmath>
#define ll long long
#define db double
#define For(i,a,b) for(ll i=a;i<=b;i++)
#define Rof(i,a,b) for(ll i=a;i>=b;i--)
#define N 300010
using namespace std;
struct node{
int to,nxt;
}e[N];
int head[N],cnt=0;
int dfn[N],low[N],sz[N],scc[N],sc=0,tot=0;
int stk[N],tp=0,in[N],ru[N],chu[N];
int n,m;
void add(int u,int v){
e[++cnt].to=v;
e[cnt].nxt=head[u];
head[u]=cnt;
}
ll read(){
ll x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
void tarjan(int u){
dfn[u]=low[u]=++tot,stk[++tp]=u,in[u]=1;
for(int i=head[u];i;i=e[i].nxt){
int v=e[i].to;
if(!dfn[v]){
tarjan(v);
low[u]=min(low[u],low[v]);
}else if(in[u]) low[u]=min(low[u],dfn[v]);
}
if(dfn[u]==low[u]){
sc++;
while(stk[tp]!=u){
scc[stk[tp]]=sc;
sz[sc]++;
in[stk[tp]]=0;
tp--;
}
scc[stk[tp]]=sc;
sz[sc]++;
in[stk[tp]]=0;
tp--;
}
}
int main()
{
n=read(),m=read();
For(i,1,m){
int u=read(),v=read();
add(u,v);
}
For(i,1,n) if(!dfn[i]) tarjan(i);
int maxx=0;
For(i,1,sc) maxx=max(maxx,sz[i]);
cout<<maxx<<endl;
if(sc==1){
cout<<"0"<<endl;
return 0;
}
int p=0,q=0;
For(i,1,n){
for(int j=head[i];j;j=e[j].nxt){
int v=e[j].to;
if(scc[i]!=scc[v]){
ru[scc[v]]=1;
chu[scc[i]]=1;
}
}
}
For(i,1,sc){
if(!ru[i]) p++;
if(!chu[i]) q++;
}
cout<<max(p,q)<<endl;
return 0;
}