#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int a,b;
int ans1,ans2;
while(cin>>a>>b){
if(a==-1 and b==-1) break;
if(a>b) swap(a,b);
ans1=b-a;
ans2=100-(b-a);
if(ans1<ans2) cout<<ans1<<endl;
else cout<<ans2<<endl;
}
}