package com.codewars.pileofcubes;

/**
 * MIT License
 * (c) 2017 Ricardo Constantino
 */

public class ASum {

    public static void main(String[] args) {
        System.out.println("2022 == " + findNb(4183059834009L));
        System.out.println("-1 == " + findNb(24723578342962L));
        System.out.println("4824 == " + findNb(135440716410000L));
        System.out.println("3568 == " + findNb(1L));
    }

    public static long findNb(long m) {
        long res = 0;
        long pow = 1;
        while ((res += pow*pow*pow) < m) {
            pow++;
        }
        return res == m ? pow: -1;
    }


}
