#include using namespace std; using ll = long long; int main(){ ll N, M, a, b, mx=0; bool f=0, g=0; cin >> N >> M; vector deg(N); for (int i=0; i> a >> b; a--; b--; deg[a]--; deg[b]++; } for (int i=0; i 0) mx++; for (int i=0; i 0) f=1; else if (deg[i] < 0) g=1; } if (f & g) mx = max(0LL, mx-1); cout << mx << endl; return 0; }