public String getAnswer() throws Exception {
        Map<Integer,Integer> cache = new HashMap<Integer, Integer>();
        Stack<Integer> currChain = new Stack<Integer>();
        int[] digitFactorials = getDigitFactorials();
        int retVal = 0;
        for (int i = 1;i<1000000;i++) {

            if (cache.containsKey(i))
                continue;

            currChain.push(i);

            int lastElement = getNextItem(i, digitFactorials);
            while (!currChain.contains(lastElement)  && !cache.containsKey(lastElement)) {
                currChain.push(lastElement);
                lastElement = getNextItem(lastElement, digitFactorials);
            }

            int additionalAmount = 0;
            if (cache.containsKey(lastElement)) {
                additionalAmount = cache.get(lastElement);
            } else {
                //every element in the cycle will have same cycle size, so pop all of them off.
                additionalAmount = currChain.size() - currChain.indexOf(lastElement);
                boolean found = false;
                while (!found) {
                    int currVal = currChain.pop();
                    found = (currVal == lastElement);
                    cache.put(currVal,additionalAmount);
                }
            }

            int n = 1;
            while (!currChain.empty()) {
                cache.put(currChain.pop(),n+additionalAmount);
                n++;
            }

        }

        for (Integer chainLen : cache.values())
            if(chainLen>=60)
                retVal++;

        return Integer.toString(retVal);
    }