#include<iostream>#include<cstdio>#include<algorithm>#include<queue>#include<cmath>#include<cstring>#include<string>#include<vector>#include<set>#include<stack>#include<list>#include<map>#define INF 0x3f3f3f3f#define MID l + r >> 1#define lsn rt << 1#define rsn rt << 1 | 1#define Lson lsn, l, mid#define Rson rsn, mid+1, r#define QL Lson, ql, qr#define QR Rson, ql, qr
using namespace std;typedeflonglong ll;constint maxN =5e4+5;constint maxM =2e4+5;int n, m;int root[maxN], high[maxN], size[maxN];voidinit(){for(int i =1; i <= n ; i ++){
root[i]= i;
high[i]=0;
size[i]=1;}}intFind(int x){return root[x]== x ? x : root[x]=Find(root[x]);}intSame(int x,int y){returnFind(x)==Find(y);}voidMerge(int x,int y){
x =Find(x); y =Find(y);if(high[x]< high[y]|| size[x]< size[y]){
root[x ]= y;
size[y]+= size[x];}else{
root[y]= x;
size[x]+= size[y];if(high[x]== high[y]) high[x]++;}}intmain(){int Case =0;while(~scanf("%d%d",&n,&m)&&(n || m)){init();++ Case;for(int i =0; i < m ; i ++){int a, b;scanf("%d%d",&a,&b);if(!Same(a,b))Merge(a, b);}
set<int> st;for(int i =1; i <= n ; i ++)
st.insert(Find(i));printf("Case %d: %d\n", Case, st.size());}return0;}