
def count_consecutive_ones(input_list):
count = 0
in_block = False # 标记是否处于一个块中
n = len(input_list)
for i in range(n):
if input_list[i] == 1:
# 如果当前是1,并且下一个也是1,则开始一个块
if i + 1 < n and input_list[i + 1] == 1:
if not in_block:
in_block = True # 标记进入块
else:
# 如果当前是1,但下一个不是1,且之前处于块中,则结束块
if in_block:
count += 1
in_block = False # 标记退出块
else:
# 如果当前是0,且之前处于块中,则结束块
if in_block:
count += 1
in_block = False
# 处理列表末尾的情况
if in_block:
count += 1
return count
# 获取输入, 转换为列表
input_list = list(map(int, input().split()))
# 调用函数
print(count_consecutive_ones(input_list))