bfs.
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstring>
using namespace std; #define MAXN 105 bool visit[MAXN][MAXN][MAXN]; typedef struct node_t {
int x[];
int t;
node_t() {}
node_t(int xx, int yy, int ss, int tt) {
x[] = xx;
x[] = yy;
x[] = ss;
t = tt;
}
} node_t; int s, m, n; bool check(node_t d) {
int half = s>>; if ((d.x[]==half) && (d.x[]== || d.x[]==)) return true;
if ((d.x[]==) && (d.x[]==half)) return true; return false;
} int bfs() {
if (s & )
return -;
queue<node_t> Q;
int x[] = {m, n, s};
int i, j, k, tmp; memset(visit, false, sizeof(visit));
visit[][][s] = true;
Q.push(node_t(,,s,)); while (!Q.empty()) {
node_t d = Q.front();
Q.pop();
for (i=; i<; ++i) {
for (j=; j<; ++j) {
if (i == j)
continue;
node_t dd = d;
// from i to j
tmp = x[j] - dd.x[j];
if (tmp > ) {
if (dd.x[i] > tmp) {
dd.x[j] = x[j];
dd.x[i] -= tmp;
} else {
dd.x[j] += dd.x[i];
dd.x[i] = ;
}
}
if (visit[dd.x[]][dd.x[]][dd.x[]]) {
continue;
}
++dd.t;
visit[dd.x[]][dd.x[]][dd.x[]] = true;
if ( check(dd) )
return dd.t;
Q.push(dd);
}
}
} return -;
} int main() { #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif while (scanf("%d%d%d",&s,&m,&n)!=EOF && (s||m||n)) {
int ans = bfs();
if (ans > )
printf("%d\n", ans);
else
printf("NO\n");
} return ;
}