#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
int a,b,c,vist[105][105][105];
struct node
{
int a,b,c;
int step;
};
void bfs()
{
queue<node>q;
node p1,p2;
p1.a=a;
p1.b=0;
p1.c=0;
q.push(p1);
while(!q.empty())
{
p1=q.front();
q.pop();
if((p1.a==a/2&&p1.b==a/2)||(p1.a==a/2&&p1.c==a/2)||(p1.b==a/2&&p1.c==a/2))
{
printf("%d\n",p1.step);
return;
}
if(p1.a!=0)
{
if(p1.a>b-p1.b)
{
p2.a=p1.a-b+p1.b;
p2.b=b;
p2.c=p1.c;
p2.step=p1.step+1;
}
else
{
p2.a=0;
p2.b=p1.b+p1.a;
p2.c=p1.c;
p2.step=p1.step+1;
}
if(!vist[p2.a][p2.b][p2.c])
{
vist[p2.a][p2.b][p2.c]=1;
q.push(p2);
}
}
if(p1.a!=0)
{
if(p1.a>c-p1.c)
{
p2.a=p1.a-c+p1.c;
p2.b=p1.b;
p2.c=c;
p2.step=p1.step+1;
}
else
{
p2.a=0;
p2.b=p1.b;
p2.c=p1.c+p1.a;
p2.step=p1.step+1;
}
if(!vist[p2.a][p2.b][p2.c])
{
vist[p2.a][p2.b][p2.c]=1;
q.push(p2);
}
}
if(p1.b!=0)
{
if(p1.b>a-p1.a)
{
p2.b=p1.b-(a-p1.a);
p2.a=a;
p2.c=p1.c;
p2.step=p1.step+1;
}
else
{
p2.b=0;
p2.a=p1.a+p1.b;
p2.c=p1.c;
p2.step=p1.step+1;
}
if(!vist[p2.a][p2.b][p2.c])
{
vist[p2.a][p2.b][p2.c]=1;
q.push(p2);
}
}
if(p1.b!=0)
{
if(p1.b>c-p1.c)
{
p2.b=p1.b-(c-p1.c);
p2.a=p1.a;
p2.c=c;
p2.step=p1.step+1;
}
else
{
p2.b=0;
p2.a=p1.a;
p2.c=p1.c+p1.b;
p2.step=p1.step+1;
}
if(!vist[p2.a][p2.b][p2.c])
{
vist[p2.a][p2.b][p2.c]=1;
q.push(p2);
}
}
if(p1.c!=0)
{
if(p1.c>a-p1.a)
{
p2.c=p1.c-(a-p1.a);
p2.a=a;
p2.b=p1.b;
p2.step=p1.step+1;
}
else
{
p2.c=0;
p2.a=p1.a+p1.c;
p2.b=p1.b;
p2.step=p1.step+1;
}
if(!vist[p2.a][p2.b][p2.c])
{
vist[p2.a][p2.b][p2.c]=1;
q.push(p2);
}
}
if(p1.c!=0)
{
if(p1.c>b-p1.b)
{
p2.c=p1.c-(b-p1.b);
p2.a=p1.a;
p2.b=b;
p2.step=p1.step+1;
}
else
{
p2.c=0;
p2.a=p1.a;
p2.b=p1.b+p1.c;
p2.step=p1.step+1;
}
if(!vist[p2.a][p2.b][p2.c])
{
vist[p2.a][p2.b][p2.c]=1;
q.push(p2);
}
}
}
printf("NO\n");
}
int main()
{
while(scanf("%d%d%d",&a,&b,&c)!=EOF)
{
memset(vist,0,sizeof(vist));
if(a==0&&b==0&&c==0)
break;
if(a%2!=0)
{
printf("NO\n");
continue;
}
bfs();
}
return 0;
}
09-09
09-09
09-09