typedef long long ll; typedef long double ld; #include using namespace std; #define int long long signed main(){ ll n,m; std::cin >> n>>m; vector nyu(n),shu(n); for (int i = 0; i < m; i++) { ll u,v; std::cin >> u>>v; u--;v--; shu[u]++; nyu[v]++; } ll p = 0; for (int i = 0; i < n; i++) { // std::cout << shu[i]<<" "<0){ p += shu[i]-nyu[i]; } } std::cout << max(0ll,p-1) << std::endl; };