#include<iostream>
#include<algorithm>
#include<list>
using namespace std;
bool cmp(const int a,const int b)
{
return a>b;
}
int main()
{
int n,m,i,count,ff=0;int cards[51];
while (cin>>m>>n&&n&&m)
{
for(i=1;i<=n;i++)
cin>>cards[i];
sort(cards+1,cards+n+1,cmp);
list<int> tmp;
for(i=n*m;i>=cards[n];i--)
tmp.push_back(i);
count=0;
for(i=1;i<=n;i++)
if(cards[i]==tmp.front())
{
count++;
tmp.pop_front();
}
else
{
tmp.pop_front();
tmp.remove(cards[i]);
}
cout<<"Case "<<++ff<<": "<<count<<endl;
}
return 0;
}