import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;
public class Main {
//------------------------------------------------------------------------------
public static void main
(String[] args
) { new Main().run();
}
final static int INF = (int) 1e9;
int n = readInt();
int k = readInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = readInt() - 1;
}
//noinspection unchecked
List
<Integer
>[] positions
= new List[k
]; for (int i = 0; i < k; i++) {
positions[i] = new ArrayList<>();
}
for (int i = 0; i < n; i++) {
positions[a[i]].add(i);
}
if (positions[0].isEmpty()) {
out.println(0);
return;
}
int[] dp = new int[n + 1];
boolean[] parentIsRemoved = new boolean[n + 1];
int[] parentPrevIndex = new int[n + 1];
Arrays.
fill(parentPrevIndex,
-1); dp[positions[0].get(0)] = 0;
for (int value = 0; value < k; value++) {
for (int i = 0; i < positions[value].size(); i++) {
int index = positions[value].get(i);
{
int nextSameIndex;
if (i == positions[value].size() - 1) {
nextSameIndex = n;
} else {
nextSameIndex = positions[value].get(i + 1);
}
if (dp[nextSameIndex] > dp[index] + 1) {
dp[nextSameIndex] = dp[index] + 1;
parentIsRemoved[nextSameIndex] = true;
parentPrevIndex[nextSameIndex] = index;
}
}
if (value < k - 1) {
int bsPos
= ~
Collections.
binarySearch(positions
[value
+ 1], index
); int nextIncIndex;
if (bsPos == positions[value + 1].size()) {
nextIncIndex = n;
} else {
nextIncIndex = positions[value + 1].get(bsPos);
}
if (dp[nextIncIndex] > dp[index]) {
dp[nextIncIndex] = dp[index];
parentIsRemoved[nextIncIndex] = false;
parentPrevIndex[nextIncIndex] = index;
}
}
}
}
List<Integer> ans = new ArrayList<>();
int now = n;
//noinspection ConditionalBreakInInfiniteLoop
while (true) {
if (now == -1) {
break;
}
if (parentIsRemoved[now]) {
ans.add(parentPrevIndex[now]);
}
now = parentPrevIndex[now];
}
if (ans.size() != dp[n]) {
throw new AssertionError();
}
out.println(ans.size());
for (int index : ans) {
out.print((index + 1) + " ");
}
out.println();
}
private void run() {
try {
initIO();
solve();
in.close();
out.close();
}
}
@SuppressWarnings("RedundantThrows")
// in = new BufferedReader(new FileReader(new File("input.txt")));
// out = new PrintWriter(new File("output.txt"));
}
while (tok == null || !tok.hasMoreTokens()) {
}
return tok.nextToken();
}
@SuppressWarnings("unused")
return Integer.
parseInt(readString
()); }
@SuppressWarnings("unused")
return Long.
parseLong(readString
()); }
@SuppressWarnings("unused")
return Double.
parseDouble(readString
()); }
}