#include #include int main(void) { int nums[2048]; int len = 0; while (0 < scanf("%d,", &nums[len])) { len++; } while (len < 2020) { int last = nums[len-1]; int next = 0; for (int i = len - 2; i >= 0; --i) { if (nums[i] == last) { next = len - 1 - i; break; } } nums[len++] = next; } printf("%d\n", nums[len-1]); }