public static void main(String[] args) {
        int highestCount = 0;
        int highestStarting = 5000000;
        for (int i = 500000; i < 1000000; i++) {
            long current = i;
            int count = 1;
            while (true) {
                //if current is even
                if (current % 2 == 0) {
                    current /= 2;
                    count++;
                }
                if (current == 1) {
                    break;
                }

                //if current is odd
                if (current % 2 != 0) {
                    current = current * 3 + 1;
                    count++;
                }
                if (current == 1) {
                    break;
                }
            }
            if (count > highestCount) {
                highestCount = count;
                highestStarting = i;
            }
        }
        System.out.println(highestStarting);
    }