#include <iostream>
#include<cstdio>using namespace std;#define N 50010int p[N]; void init(int n){ for(int i=1 ;i<=n;i++) p[i]=i ; }int find(int x) { if (x==p[x]) return x; else return p[x]=find(p[x]);} int main( ){ int n,m,i,x,y,px,py,c=1;
while(scanf("%d%d",&m,&n),m||n) { init(m); for(i=1;i<=n;i++) { scanf("%d%d",&x,&y); px=find(x); py=find(y); if(px!=py) { p[px]=py; m--;} } printf("Case %d: %d\n",c++,m); } }
//poj 2524
#include <cstdio>#include <string>#include <cstring>#include <cmath>#include <algorithm>#include <iostream>using namespace std;#define MAX 50008int pa[MAX];int findset(int x){ return x==pa[x]? x : pa[x]=findset(pa[x]);}int main(){ int n,m,T=1;while(scanf("%d%d",&n,&m)==2 &&n){ if(m==0){ printf("Case %d: %d\n",T++,n);continue;}for(int i=1;i<=n;i++)pa[i]=i;int u,v;for(int i=0;i<m;i++){ scanf("%d%d",&u,&v);u=findset(u);v=findset(v);if(u!=v)pa[v]=u;}int ans=0;for(int i=1;i<=n;i++){ if(pa[i]==i)ans++;}printf("Case %d: %d\n",T++,ans);}return 0;}