#include<bits/stdc++.h>
using namespace std;
const int maxn=50000+5;
int fa[maxn];
int findset(int x)
{
return fa[x]==-1? x: fa[x]=findset(fa[x]);
}
inline int read()
{
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-')f=-1;
ch=getchar();
}
while(ch<='9'&&ch>='0')
{
x=(x<<1)+(x<<3)+ch-'0';
ch=getchar();
}
return x*f;
}
void print(int x)
{
if(x<0)putchar('-'),x=-x;
if(x>=10)print(x/10);
putchar(x%10+'0');
}
int bind(int u,int v)
{
int fu=findset(u);
int fv=findset(v);
if(fu!=fv)
{
fa[fu]=fv;
return 1;
}
return 0;
}
int main()
{
int n,m;
int kase=0;
while(true)
{
n=read();
m=read();
if(n==0)break;
memset(fa,-1,sizeof(fa));
int cnt = n;//剩余连通分量数目
while(m--)
{
int u,v;
u=read();
v=read();
cnt -= bind(u,v);
}
printf("Case %d: %d\n",++kase,cnt);
}
return 0;
}