# include <iostream>
# include <queue>
using namespace std;
int a,b;
int aa[8] = {1,-1,5,-5,10,-10};
struct node{
int x,y;
};
queue<node> q;
void bfs(node now)
{
q.push(now);
while(!q.empty())
{
node t = q.front();
q.pop();
if(t.x == b)
{
cout<<t.y<<endl;
return ;
}
for(int i = 0;i<6;i++)
{
int p= t.x+aa[i];
t.y++;
node s;
s.x = p;
s.y = t.y;
q.push(s);
}
}
}
int main ()
{
cin>>a>>b;
node now;
now.x = a;
now.y = 0;
bfs(now);
}