#include<cstdio> int main(){ int n, m; while (scanf("%d%d", &n, &m) != EOF){ if (n == 0 && m == 0){ break; } int ans = 0; for (int i = 0; i < m; i++){ int k = n - i; while (k % 2 == 0){ ans++; k= k / 2; } } printf("%d\n", ans); } }