//C语言版代码 #include <stdio.h> int main() { int n, m; while (scanf("%d%d", &n, &m) != EOF) { if (n == 0 && m == 0) break; int ans = 0; while (m--) { int temp = n; while (temp && temp % 2 == 0) { temp /= 2; ans++; } --n; } printf("%d\n", ans); } return 0; } //Python版代码 from math import perm while True: try: n, m = map(int, input().split()) if n==m==0:break s = bin(perm(n, m)) print(len(s) - len(s.rstrip('0'))) except: break