#include <stdio.h>
int is_alternating_pattern(int *mem, int k) {
// If there's 0 or 1 element, it's technically alternating (or trivial)
if (k <= 1) return 1;
int *it = mem;
// Loop until we reach the second-to-last element
for (int i = 0; i < k - 1; i++) {
// Compare current element with the next one
if (*it == *(it + 1)) {
return 0; // Found a duplicate pair
}
it++; // Move to the next pointer address
}
return 1; // No duplicates found
}
int main() {
int n, k, arr[100];
scanf("%d %d", &n, &k);
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
int res = is_alternating_pattern(arr, k);
printf("%d", res);
return 0;
}