int (@NotNull Map<Object, Integer> indices, @NotNull Iterable<Object> objects) { int count = 0; int last = -1; for (Object object : objects) { Integer index = indices.get(object); if (index != null && last < index.intValue()) { last = index; count++; } } return count; }