public void solve() throws IOException {
    while (true) {
      int[] num = new int[4];
      for (int x = 0; x < 4; x++)
        num[x] = nextInt();
      if (num[0] == 0 && num[1] == 0 && num[2] == 0 && num[3] == 0)
        break;

      int steps = 0;
      while (!(num[0] == num[1] && num[0] == num[2] && num[0] == num[3])) {
        int temp = num[0];
        num[0] = Math.abs(num[0] - num[1]);
        num[1] = Math.abs(num[1] - num[2]);
        num[2] = Math.abs(num[2] - num[3]);
        num[3] = Math.abs(num[3] - temp);
        steps++;
      }
      System.out.println(steps);
    }

  }