#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
while(cin>>a>>b)
{
if(a==-1 || b==-1) continue;
if(a-b>50) cout<<b+100-a<<endl;
else if(b-a>50) cout<<a+100-b<<endl;
else if(a>b) cout<<a-b<<endl;
else cout<<b-a<<endl;
}
}