#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int N = 1e4+10;
int t,n,m,k,l,r,op,x,y;
int f[N];
bool flag;
void solve(){
for(int i = 1;i<=N;i++){
if(f[i])continue;
for(int j = 2,cnt = 1;i*j<=N;j<<=1,cnt++){
f[i*j] = cnt;
}
}
for(int i = 1;i<=N;i++){
f[i]+=f[i-1];
}
while(cin>>n>>m&&n){
cout<<f[n]-f[n-m]<<"\n";
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}