#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,up,dn;
while(cin>>a>>b){
if(a==-1 and b==-1) break;
if(a>b) swap(a,b);
up=b-a;
dn=100-b+a;
if(up>dn) cout<<dn<<"\n";
else cout<<up<<endl;
}
return 0;
}