//#define LOCAL
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mem(a, b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
#define DNF 0x7f
#define DBG printf("this is a input\n")
#define fi first
#define se second
#define mk(a, b) make_pair(a,b)
#define p_queue priority_queue
ll gcd(ll a, ll b) {
return b == 0 ? a : gcd(b, a % b);
}
ll lcm(ll a, ll b) {
return a / gcd(a, b) * b;
}
const int MAXN=1000010;
int n , m;
//前向星
int head[MAXN] , Cnt;
struct node{
int t, next;
int w;
}edge[MAXN*10];
void add(int f, int t)
{
edge[Cnt].t = t;
edge[Cnt].next = head[f];
head[f] = Cnt ++;
}
//补图
bool bu_edge[1005][1005];
//点双连通分量
vector <int> vcc[1005];
int dfn[1005], low[1005] , st[1005] , times, top, type;
int mark[1005], color[1005], ans[1005], ok;
void tarjan(int u)
{
dfn[u] = low[u] = ++times;
st[++ top] = u;
for(int i = head[u] ; i != -1 ; i = edge[i].next)
{
int v = edge[i].t;
if(!dfn[v])
{
tarjan(v);
low[u] = min(low[u] , low[v]);
if(low[v] >= dfn[u])
{
++ type;
do{
vcc[type].push_back(st[top]);
top --;
}while(st[top+1] != v);
vcc[type].push_back(u);
}
}
else
low[u] = min(low[u] , dfn[v]);
}
}
void dfs(int u)
{
if(ok)
return ;
for(int i = head[u] ; i != -1 ; i = edge[i].next)
{
int v = edge[i].t;
if(mark[v])
{
if(color[v] == 0)
color[v] = - color[u], dfs(v);
else
{
if(color[v] == color[u])
{
ok = 1;
return ;
}
}
}
}
}
void Init()
{
mem(bu_edge,false);
mem(dfn,0);
mem(low,0);
mem(st,0);
mem(head,-1);
mem(ans,0);
Cnt = type = top = times = ok = 0;
}
int main(void)
{
#ifdef LOCAL
freopen("data.in", "r", stdin);
freopen("odata.out", "w", stdout);
#endif
while(scanf("%d %d",&n , &m) != EOF)
{
if(n == 0 && m == 0)
break;
int u , v;
Init();
for(int i = 1 ; i <= m ; i ++)
scanf("%d %d", &u , &v) , bu_edge[u][v] = bu_edge[v][u] = true;
//构建补图
for(int i = 1 ; i <= n ; i ++)
for(int j = i+1 ; j <= n ; j ++)
if(!bu_edge[i][j])
add(i,j) , add(j,i);
for(int i = 1 ; i <= n ; i ++)
if(!dfn[i])
tarjan(i);
for(int i = 1 ; i <= type ; i ++)
{
ok = 0;
for(int j = 0 ; j < vcc[i].size() ; j ++)
mark[vcc[i][j]] = 1;
color[vcc[i][0]] = 1;
dfs(vcc[i][0]);
if(ok)
for(int j = 0 ; j < vcc[i].size() ; j ++)
ans[vcc[i][j]] = 1;
for(int j = 0 ; j < vcc[i].size() ; j ++)
mark[vcc[i][j]] = 0, color[vcc[i][j]] = 0;
}
int sum = 0;
for(int i = 1 ; i <= n ; i ++)
if(ans[i])
sum += 1;
cout<<n - sum<<endl;
for(int i = 1 ; i <= type ; i ++)
vcc[i].clear();
}
}