long (Map<String, List<String>> strings) { long sum = 0L; for (Map.Entry<String, List<String>> e : strings.entrySet()) { if (!e.getKey().isEmpty()) { long count = count(e.getValue(), s -> e.getKey().equals(s)); sum += count; } } return sum; }