#include <bits/stdc++.h>
using namespace std;
#define LL long long
int main()
{
LL n,k;
LL ca=1;
while(cin>>n>>k)
{
if(k<=n)
cout<<"Case #"<<ca++<<": "<<k<<endl;
else
{
LL tmp=(k-n)%(2*(n-1));
// cout<<tmp<<endl;
if(tmp==0)cout<<"Case #"<<ca++<<": "<<n<<endl;
else if(tmp==n-1)cout<<"Case #"<<ca++<<": "<<n-1<<endl;
else
{
cout<<"Case #"<<ca++<<": "<<tmp%(n-1)<<endl;
}
}
}
return 0;
}