#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int n;
  int k;
  scanf("%d %d", &n, &k);
  int *c = malloc(sizeof(int) * n);
  for (int c_i = 0; c_i < n; c_i++) {
    scanf("%d", &c[c_i]);
  }
  int x = 0, done = 0, curr = 0;
  while (!done) {
    curr = (curr + k) % n;
    if (c[curr] == 1) {
      x += 2;
    }
    x++;
    if (curr == 0) {
      done = 1;
    }
  }
  printf("%d", 100 - x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1050 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11a6 <main+0x76>
mov    -0x18(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116f <main+0x3f>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x0,-0x24(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11d1 <main+0xa1>
jmp    1218 <main+0xe8>
mov    -0x28(%rbp),%eax
add    -0xc(%rbp),%eax
cltd
idivl  -0x8(%rbp)
mov    %edx,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    11f9 <main+0xc9>
mov    -0x20(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    1213 <main+0xe3>
movl   $0x1,-0x24(%rbp)
jmp    11bb <main+0x8b>
mov    $0x64,%esi
sub    -0x20(%rbp),%esi
lea    0xddc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
xor    %ebx,%ebx
mov    %rsp,%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    (%rsp),%r13d
lea    0x0(,%r13,4),%edi
call   1040 <malloc@plt>
mov    %rax,%r14
test   %r13d,%r13d
jle    119e <main+0x6e>
lea    0xe90(%rip),%r15
mov    %r14,%r12
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
add    $0x1,%rbp
movslq (%rsp),%r13
add    $0x4,%r12
cmp    %r13,%rbp
jl     1180 <main+0x50>
mov    0x4(%rsp),%ecx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    %ecx,%ebx
mov    %ebx,%eax
cltd
idiv   %r13d
mov    %edx,%ebx
movslq %edx,%rdx
lea    0x2(%rsi),%eax
cmpl   $0x1,(%r14,%rdx,4)
cmovne %esi,%eax
lea    0x1(%rax),%esi
test   %edx,%edx
jne    11b0 <main+0x80>
mov    $0x63,%esi
sub    %eax,%esi
lea    0xe26(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, i32* %3)
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = mul i64 4, %11
%13 = trunc i64 %12 to i32
%14 = call i32* @malloc(i32 %13)
store i32* %14, i32** %4
store i32 0, i32* %5
br label %15
15: ; preds = %25, %0
%16 = load i32, i32* %5
%17 = load i32, i32* %2
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = load i32*, i32** %4
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
%24 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
br label %25
25: ; preds = %19
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %15
28: ; preds = %15
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %29
29: ; preds = %54, %28
%30 = load i32, i32* %7
%31 = icmp ne i32 %30, 0
%32 = xor i1 %31, true
br i1 %32, label %33, label %55
33: ; preds = %29
%34 = load i32, i32* %8
%35 = load i32, i32* %3
%36 = add nsw i32 %34, %35
%37 = load i32, i32* %2
%38 = srem i32 %36, %37
store i32 %38, i32* %8
%39 = load i32*, i32** %4
%40 = load i32, i32* %8
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, 1
br i1 %44, label %45, label %48
45: ; preds = %33
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 2
store i32 %47, i32* %6
br label %48
48: ; preds = %45, %33
%49 = load i32, i32* %6
%50 = add nsw i32 %49, 1
store i32 %50, i32* %6
%51 = load i32, i32* %8
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %54
53: ; preds = %48
store i32 1, i32* %7
br label %54
54: ; preds = %53, %48
br label %29
55: ; preds = %29
%56 = load i32, i32* %6
%57 = sub nsw i32 100, %56
%58 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %57)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%d %d\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
%6 = load i32, i32* %1
%7 = shl i32 %6, 2
%8 = call i32* @malloc(i32 %7)
%9 = icmp sgt i32 %6, 0
br i1 %9, label %13, label %10
10: ; preds = %13, %0
%11 = phi i32 [ %6, %0 ], [ %18, %13 ]
%12 = load i32, i32* %2
br label %21
13: ; preds = %0, %13
%14 = phi i64 [ %17, %13 ], [ 0, %0 ]
%15 = getelementptr inbounds i32, i32* %8, i64 %14
%16 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %15)
%17 = add nuw nsw i64 %14, 1
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %13, label %10
21: ; preds = %10, %21
%22 = phi i32 [ 0, %10 ], [ %25, %21 ]
%23 = phi i32 [ 0, %10 ], [ %32, %21 ]
%24 = add nsw i32 %12, %22
%25 = srem i32 %24, %11
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %8, i64 %26
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 1
%30 = add nsw i32 %23, 2
%31 = select i1 %29, i32 %30, i32 %23
%32 = add nsw i32 %31, 1
%33 = icmp eq i32 %25, 0
br i1 %33, label %34, label %21
34: ; preds = %21
%35 = sub i32 99, %31
%36 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %35)
ret i32 0
}