/*
找规律, 发现有循环节
*/
#include <cstdio> int main() { long long n, k; int cas = 1; while (scanf("%lld%lld", &n, &k) != EOF){ long long ans; if (k <= n) ans = k; else{ k -= n; k %= (long long)2 * (n - 1); if (k == 0) ans = n; else { k %= (n - 1); if (k == 0){ ans = (n - 1); } else{ ans = k; } } } printf("Case #%d: %lld\n", cas++, ans); } }