#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int main()
{
    map<int, int> M;
    for (int p, q, t = 0; ~scanf("%d/%d", &p, &q);)
    {
        p %= q;
        M.clear();
        int len1 = 0, len2 = 0;
        for (; !len2; len1++)
        {
            if (M.count(p % q))
            {
                len2 = len1 - M[p % q];
                len1 -= len2;
            }
            M[p % q] = len1;
            p = p * 2 % q;
        }
        printf("Case #%d: %d,%d\n", ++t, len1, len2);
    }
    return 0;
}
