#include <bits/stdc++.h>
using namespace std;
int a1[105][105], a2[105][105];
bool b[105];
int n, m, x, y;
int num = 0;
void dfs(int point, int a[105][105])
{
num++;
b[point] = true;
for (int i = 1; i <= n; i++)
if (a[point][i] && !b[i])
dfs(i, a);
}
int main()
{
cin >> n >> m;
while (m--)
{
cin >> x >> y;
a1[x][y] = 1;
a2[y][x] = 1;
}
int ans = 0;
for (int i = 1; i <= n; i++)
{
num = 0;
memset(b, 0, sizeof(b));
dfs(i, a1);
if (num > (n + 1) / 2)
ans++;
}
for (int i = 1; i <= n; i++)
{
num = 0;
memset(b, 0, sizeof(b));
dfs(i, a2);
if (num > (n + 1) / 2)
ans++;
}
cout << ans;
return 0;
}