//source here
//source here
//传话游戏;2013微软编程之美资格赛第一题。
#include<iostream>
#include<map>
#include<string>
#include<string.h>
using namespace std;
int main(){
int m;
string s1, s2;
int min_dis;
int temp_dis;
cin>>m;
for(int i = 0; i < m; i++){
cin>>s1>>s2;
int len1 = s1.length();
int len2 = s2.length();
min_dis = len2;
int final = len1 - len2 + 1;
for(int j = 0; j < final; j++){
temp_dis = 0;
for(int k = 0; k < len2; k++){
if(s2[k] != s1[j + k]){
temp_dis++;
}
}
if(temp_dis < min_dis){
min_dis = temp_dis;
}
}
cout<<"Case #"<<i + 1<<": "<<min_dis<<endl;
}
//system("pause"); //G++中默认不识别这个函数,但VC++中可以。
return 0;
}