public int lengthLongestPath(String input) {
        if (input == null) return 0;
        Stack<Integer> s = new Stack<>();
        int len = 0, maxLen = 0;
        for (String token : input.split("\n")) {
            int level = token.lastIndexOf("\t") + 1;
            while (level < s.size()) len -= s.pop();
            int tokenLen = token.length() - level; // trim '\t'
            len += tokenLen;
            s.push(tokenLen);
            if (token.contains(".")) maxLen = Math.max(maxLen, len + s.size() - 1); // include '/'
        }
        return maxLen;
    }