#include<iostream>
using namespace std;
int n;
bool a[99][99];
void init() {
int m, x, y;
cin >> n >> m;
for (int i = 0; i < m; i++) {
cin >> x >> y;
x--, y--;
a[x][y] = true;
}
}
void floyed() {
for (int k = 0; k < n; k++)
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
a[i][j] = a[i][j] || (a[i][k] && a[k][j]);
}
void print() {
int mid = (n + 1) / 2, c = 0, c1, c2;
for (int v = 0; v < n; v++) {
c1 = 0, c2 = 0;
for (int i = 0; i < n; i++) {
if (a[v][i]) c1++;
if (a[i][v]) c2++;
}
if (c1 >= mid || c2 >= mid) c++;
}
cout << c << endl;
}
int main() {
init();
floyed();
print();
return 0;
}