One day Vitaly was going home late at night and wondering: how many people aren't sleeping at that moment? To estimate, Vitaly decided to look which windows are lit in the house he was passing by at that moment.

Vitaly sees a building of n floors and 2·m windows on each floor. On each floor there are m flats numbered from 1 to m, and two consecutive windows correspond to each flat. If we number the windows from 1 to 2·m from left to right, then the j-th flat of the i-th floor has windows 2·j - 1 and 2·j in the corresponding row of windows (as usual, floors are enumerated from the bottom). Vitaly thinks that people in the flat aren't sleeping at that moment if at least one of the windows corresponding to this flat has lights on.

Given the information about the windows of the given house, your task is to calculate the number of flats where, according to Vitaly, people aren't sleeping.


-----Input-----

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 100) — the number of floors in the house and the number of flats on each floor respectively.

Next n lines describe the floors from top to bottom and contain 2·m characters each. If the i-th window of the given floor has lights on, then the i-th character of this line is '1', otherwise it is '0'.


-----Output-----

Print a single integer — the number of flats that have lights on in at least one window, that is, the flats where, according to Vitaly, people aren't sleeping.


-----Examples-----
Input
2 2
0 0 0 1
1 0 1 1

Output
3

Input
1 3
1 1 0 1 0 0

Output
2



-----Note-----

In the first test case the house has two floors, two flats on each floor. That is, in total there are 4 flats. The light isn't on only on the second floor in the left flat. That is, in both rooms of the flat the light is off.

In the second test case the house has one floor and the first floor has three flats. The light is on in the leftmost flat (in both windows) and in the middle flat (in one window). In the right flat the light is off.

Difficulty: EASY

Solutions:
def Vitaliy_and_night():
	(n, m) = map(int, input().split(sep=' '))
	k = 0
	for i in range(n):
		windows = list(map(int, input().split(sep=' ')))
		for j in range(m):
			if windows[j * 2] == 1 or windows[j * 2 + 1] == 1:
				k += 1
	print(k)
Vitaliy_and_night()


(n, flat) = map(int, input().split())
b = []
for i in range(n):
	b.append(list(map(int, input().split())))
res = 0
for i in range(n):
	for j in range(0, flat * 2, 2):
		if b[i][j] == 1 or b[i][j + 1] == 1:
			res += 1
print(res)


(n, m) = map(int, input().split())
c = 0
for i in range(n):
	appts = list(map(int, input().split()))
	for j in range(m):
		x = appts[2 * j]
		y = appts[2 * j + 1]
		c += 1 if x > 0 or y > 0 else 0
print(c)


from collections import Counter
import string
import math
import sys

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(sys.stdin.readline())
	if number_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))
mod = 100000007
(n, m) = vary(2)
count = 0
for i in range(n):
	num = array_int()
	for i in range(0, 2 * m, 2):
		if num[i] == 1 or num[i + 1] == 1:
			count += 1
print(count)


(n, m) = map(int, input().split())
c = 0
for i in range(n):
	a = list(map(int, input().split()))
	for i in range(0, len(a), 2):
		if a[i] == 0 and a[i + 1] == 0:
			c = c + 1
print(n * m - c)


ans = 0
(n, m) = (int(v) for v in input().split())
for i in range(n):
	list1 = [int(u) for u in input().split()]
	for j in range(m):
		if list1[2 * j] + list1[2 * j + 1] > 0:
			ans += 1
		else:
			pass
print(ans)


(n, m) = map(int, input().split())
ar = [[int(i) for i in input().split()] for i in range(n)]
c = 0
k = len(ar[0]) // m
for i in range(n):
	for j in range(0, len(ar[i]), k):
		if 1 in ar[i][j:j + k]:
			c += 1
print(c)


import sys
(n, m) = map(int, sys.stdin.readline().split())
ans = 0
for _ in range(n):
	a = list(map(int, sys.stdin.readline().split()))
	for i in range(m):
		a1 = a[2 * i]
		a2 = a[2 * i + 1]
		if a1 == 1 or a2 == 1:
			ans += 1
print(ans)


(n, m) = map(int, input().split())
result = 0
for r in range(n):
	windows = list(map(int, input().split()))
	for i in range(m):
		if windows[2 * i] + windows[2 * i + 1] != 0:
			result += 1
print(result)


(n, m) = tuple(map(int, input().split()))
flats = 0
for _ in range(n):
	floor = list(map(int, input().split()))
	for i in range(0, 2 * m, 2):
		if floor[i] == 1 or floor[i + 1] == 1:
			flats += 1
print(flats)


(n, m) = [int(x) for x in input().split()]
ma = [[int(x) for x in input().split()] for q in range(n)]
kv = 0
for i in range(n):
	for j in range(0, m * 2, 2):
		if ma[i][j] + ma[i][j + 1] >= 1:
			kv += 1
print(kv)


(a, b) = map(int, input().split())
li = []
for i in range(a):
	x = list(map(int, input().split()))
	for _ in range(len(x)):
		li.append(x[_])
c = len(li) - 2
d = 0
for j in range(0, c + 1, 2):
	if li[j] == 1:
		d += 1
	elif li[j + 1] == 1:
		d += 1
	else:
		d += 0
print(d)


(n, m) = map(int, input().split())
sum1 = 0
for i in range(n):
	ar = list(map(int, input().split()))
	for j in range(len(ar) - 1):
		if j % 2 == 0:
			if ar[j] or ar[j + 1]:
				sum1 += 1
print(sum1)


(n, m) = map(int, input().split())
arr = []
for i in range(n):
	arr.append([])
	arr[i] = [int(z) for z in input().split()]
c = 0
for i in range(n):
	for j in range(1, 2 * m, 2):
		if arr[i][j - 1] == 1 or arr[i][j] == 1:
			c = c + 1
print(c)


a = input().split()
n = int(a[0])
m = int(a[1])
x = 0
for i in range(n):
	a = input().split()
	for i in range(m):
		if int(a[2 * i]) == 1 or int(a[2 * i + 1]) == 1:
			x += 1
print(x)


(n, m) = map(int, input().split())
ans = 0
for i in range(n):
	flats = list(map(int, input().split()))
	f = [False for i in range(m)]
	for j in range(m * 2):
		f[j // 2] |= True if flats[j] == 1 else False
	ans += f.count(True)
print(ans)


n = list(map(int, input().split()))
sum = 0
for i in range(n[0]):
	x = list(map(int, input().split()))
	f = 0
	for i in range(2 * n[1]):
		if x[i] == 1:
			f = 1
		if (i + 1) % 2 == 0:
			if f == 1:
				sum += 1
				f = 0
print(sum)


li = list(map(int, input().split()))
n = li[0]
res = []
for i in range(li[0]):
	res.append(list(map(int, input().split())))
res1 = [res[a][b] for a in range(len(res)) for b in range(len(res[a]))]
ult = 0
for i in range(0, len(res1), 2):
	if res1[i] == 1 or res1[i + 1] == 1:
		ult += 1
print(ult)


(n, m) = map(int, input().split())
total = 0
for i in range(n):
	arr = list(map(int, input().split()))
	j = 0
	while j < 2 * m:
		total += arr[j] or arr[j + 1]
		j += 2
print(total)


(r, a) = map(int, input().split())
f = 0
for n in range(r):
	s = list(map(int, input().split()))
	for t in range(0, 2 * a - 1, 2):
		if s[t] == 0 and s[t + 1] == 0:
			f = f + 0
		else:
			f = f + 1
print(f)


(n, m) = map(int, input().split())
res = 0
for _ in range(n):
	data = list(map(int, input().split()))
	for i in range(0, len(data), 2):
		if data[i] or data[i + 1]:
			res += 1
print(res)


(n, m) = [int(i) for i in input().split()]
s = 0
l = []
for i in range(n):
	a = input().split()
	l.append(a)
for j in range(n):
	for i in range(0, 2 * m - 1, 2):
		if l[j][i] == '0' and l[j][i + 1] == '0':
			s += 1
print(n * m - s)


(n, m) = map(int, input().split())
c = 0
for i in range(n):
	nums1 = [int(num) for num in input().split()]
	for i in range(m):
		if nums1[2 * i] == 1 or nums1[2 * i + 1] == 1:
			c = c + 1
print(c)


l = list(map(int, input().split()))
n = l[0]
m = l[1]
count = 0
for i in range(n):
	p = list(map(int, input().split()))
	for j in range(0, len(p) - 1, 2):
		if p[j] == 1 or p[j + 1] == 1:
			count += 1
print(count)


def main():
	(n, m) = map(int, input().split(' '))
	ans = 0
	for i in range(n):
		line = list(map(int, input().split(' ')))
		for j in range(0, 2 * m, 2):
			if line[j] == 1 or line[j + 1] == 1:
				ans += 1
	return ans
print(main())


(a, b) = map(int, input().split())
n = []
for i in range(a):
	row = list(input().split())
	for i in range(len(row)):
		row[i] = str(row[i])
	n.append(row)
r = 0
for i in range(a):
	for j in range(0, b * 2 - 1, 2):
		if n[i][j] == '1' or n[i][j + 1] == '1':
			r += 1
print(r)


(n, m) = map(int, input().split())
l = []
c = 0
for u in range(n):
	l.append(list(map(int, input().split())))
for i in range(n):
	for j in range(0, 2 * m - 1, 2):
		if l[i][j] == 1 and l[i][j + 1] == 1:
			c = c + 1
		elif l[i][j] == 0 and l[i][j + 1] == 1:
			c = c + 1
		elif l[i][j] == 1 and l[i][j + 1] == 0:
			c = c + 1
print(c)


(n, m) = map(int, input().split())
f = 0
for i in range(n):
	a = list(map(int, input().split()))
	for i in range(m):
		if 1 in a[2 * i:2 * i + 2]:
			f += 1
print(f)


(n, m) = [int(i) for i in input().split(' ')]
s = 0
for i in range(0, n):
	k = [int(i) for i in input().split(' ')]
	for i in range(0, 2 * m, 2):
		if k[i] > 0 or k[i + 1] > 0:
			s += 1
print(s)


(n, m) = map(int, input().split())
m2 = 2 * m
count = 0
for i in range(n):
	floor = list(map(int, input().split()))
	for j in range(0, m2, 2):
		if floor[j] == 1 or floor[j + 1] == 1:
			count += 1
print(count)


(n, m) = [int(_) for _ in input().split()]
count = 0
for i in range(n):
	line = input().split()
	for j in range(0, 2 * m, 2):
		if line[j] == '1' or line[j + 1] == '1':
			count += 1
print(count)


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	(n, m) = mp()
	c = 0
	for i in range(n):
		l = li()
		for j in range(0, 2 * m, 2):
			if l[j] or l[j + 1]:
				c += 1
	print(c)
for _ in range(1):
	solve()


(n, m) = map(int, input().split())
ans = 0
for _ in range(n):
	floor = [int(x) for x in input().split()]
	for i in range(m):
		for j in range(2):
			if floor[2 * i + j] == 1:
				ans += 1
				break
print(ans)


def ll():
	return list(map(int, input().split()))
n = ll()
x = 0
l = []
x = []
y = []
z = 0
for i in range(n[0]):
	s = ll()
	l = l + s
x = x + l[1::2]
y = y + l[::2]
for j in range(len(l) // 2):
	if x[j] != y[j]:
		z += 1
	elif x[j] == 1 or y[j] == 1:
		z += 1
print(z)


try:
	while True:
		(n, m) = list(map(int, input().split()))
		result = 0
		for i in range(n):
			a = list(map(int, input().split()))
			for j in range(m):
				if a[j << 1] or a[j << 1 | 1]:
					result += 1
		print(result)
except EOFError:
	pass


R = lambda : map(int, input().split())
(n, m) = R()
t = 0
for _ in range(n):
	l = list(R())
	for i in range(m):
		if l[2 * i] + l[2 * i + 1] > 0:
			t += 1
print(t)


(n, m) = list(map(int, input().split()))
l = [[int(i) for i in input().split()] for i in range(n)]
lst = []
for i in range(n):
	for j in range(0, m * 2, 2):
		lst.append(l[i][j] + l[i][j + 1])
for i in range(lst.count(0)):
	lst.remove(0)
print(len(lst))


(n, m) = map(int, input().split())
c = 0
for i in range(n):
	l = list(map(int, input().split()))
	for j in range(0, 2 * m, 2):
		if l[j] or l[j + 1]:
			c += 1
print(c)


n = input().split()
total = 0
for i in range(int(n[0])):
	c = input().split()
	for j in range(0, int(n[1]) * 2, 2):
		if int(c[j]) == 1 or int(c[j + 1]) == 1:
			total += 1
print(total)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, m) = LI()
	aa = [LI() for _ in range(n)]
	r = 0
	for a in aa:
		for i in range(m):
			if any(a[i * 2:i * 2 + 2]):
				r += 1
	return r
print(main())


o = 0
(a, b) = map(int, input().split())
z = b
for i in range(a):
	l = list(map(int, input().split()))
	while b > 0:
		if l[b * 2 - 1] + l[b * 2 - 2] > 0:
			o += 1
		b -= 1
	b = z
print(o)


(n, m) = input().split()
n = int(n)
m = int(m)
a = [list(map(int, input().split())) for i in range(n)]
black = 0
for i in range(n):
	t = 0
	while t <= 2 * (m - 1):
		if a[i][t] == a[i][t + 1] == 0:
			black += 1
		t += 2
print(n * m - black)


(n, k) = map(int, input().split())
f = 0
for i in range(n):
	c = list(map(int, input().split()))
	for j in range(len(c) - 1):
		if j % 2 == 0:
			if c[j] == 1 or c[j + 1] == 1:
				f += 1
print(f)


(n, m) = map(int, input().split())
a = []
arr = []
count = 0
for i in range(0, n):
	arr = list(map(int, input().strip().split()))[:2 * m]
	a.append(arr)
for i in range(0, n):
	j = 0
	while j < 2 * m - 1:
		if a[i][j] == 1 or a[i][j + 1] == 1:
			count += 1
		j += 2
print(count)


(n, m) = map(int, input().split())
s = 0
for i in range(n):
	f = list(map(int, input().split()))
	for j in range(0, m * 2, 2):
		if f[j] == 1 or f[j + 1] == 1:
			s += 1
print(s)


(n, m) = map(int, input().split())
k = 0
for i in range(n):
	d = input().split()
	for j in range(m):
		if '1' in d[j * 2:j * 2 + 2]:
			k += 1
print(k)


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
r = 0
for i in range(n):
	for j in range(0, 2 * m, 2):
		r += a[i][j] > 0 or a[i][j + 1] > 0
print(r)


(n, m) = map(int, input().split())
cnt = 0
for _ in range(n):
	a = list(map(int, input().split()))
	for i in range(0, 2 * m, 2):
		if a[i] != a[i + 1] or a[i] == a[i + 1] == 1:
			cnt += 1
print(cnt)


(n, m) = [int(i) for i in input().split()]
l = 0
for i in range(n):
	a = [int(i) for i in input().split()]
	b = 0
	for j in range(len(a)):
		if b == len(a):
			break
		if a[b] == 1 or a[b + 1] == 1:
			l += 1
		b += 2
print(l)


string = input()
numbers = string.split(' ')
a = int(numbers[0])
b = int(numbers[1])
flats = 0
for x in range(a):
	string = input()
	numbers = string.split(' ')
	for y in range(b * 2):
		numbers[y] = int(numbers[y])
	for y in range(b):
		p = numbers[y * 2]
		q = numbers[y * 2 + 1]
		windows = [p, q]
		if windows.count(1) >= 1:
			flats += 1
print(flats)


(n, m) = list(map(int, input().split()))
c = 0
for i in range(n):
	p = list(map(int, input().split()))
	for i in range(0, len(p), 2):
		if p[i] == 1 or p[i + 1] == 1:
			c += 1
print(c)


(n, m) = map(int, input().split())
count = 0
for i in range(n):
	a = list(map(int, input().split()))
	j = 0
	while j < m * 2:
		if a[j] == 0 == a[j + 1]:
			count = count
			j += 1
		else:
			count += 1
			j += 1
		j += 1
print(count)


read = lambda : map(int, input().split())
(n, m) = read()
a = [list(read()) for i in range(n)]
cnt = 0
for i in range(n):
	for j in range(m):
		if a[i][2 * j + 1] == 1 or a[i][2 * j] == 1:
			cnt += 1
print(cnt)


(n, m) = [int(x) for x in input().split()]
res = 0
for i in range(n):
	d = False
	t = False
	for j in [int(x) for x in input().split()]:
		if not t and j:
			t = True
			res += 1
		if d == True:
			t = False
		d = not d
print(res)


(n, m) = input().split()
m = int(m)
n = int(n)
ans = 0
for i in range(n):
	a = input().split()
	k = 0
	for i in range(len(a)):
		if k == 0:
			if a[i] == '1':
				ok = 1
			else:
				ok = 0
			k = 1
		else:
			if a[i] == '1':
				ok = 1
			k = 0
			ans += ok
print(ans)


import sys
(n, m) = map(int, input().split())
cnt = 0
for i in range(n):
	arr = list(map(int, input().split()))
	for j in range(0, m * 2, 2):
		if arr[j] == 1 or arr[j + 1] == 1:
			cnt += 1
print(cnt)


inp = input()
inp = inp.split(' ')
num_floors = int(inp[0])
num_appartments = int(inp[1])
people_awake = 0
for current_floor in range(num_floors):
	current_level = input()
	current_level = current_level.split()
	for index in range(0, len(current_level), 2):
		if current_level[index] == '1' or current_level[index + 1] == '1':
			people_awake += 1
print(people_awake)


(n, m) = map(int, input().split())
cnt = 0
for j in range(n):
	k = list(map(int, input().split()))
	for i in range(m):
		if k[2 * i] == 1 or k[2 * i + 1] == 1:
			cnt += 1
print(cnt)


(n, m) = map(int, input().split())
c = 0
for i in range(n):
	s = [x for x in input().split()]
	for i in range(0, 2 * m, 2):
		if s[i] == '1' or s[i + 1] == '1':
			c += 1
print(c)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	l = []
	for i in range(2, n + 1):
		if prime[i]:
			l.append(i)
	return l

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, ll, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		if ll[mid] == val:
			return ll[mid]
		elif ll[mid] < val:
			ans = ll[mid]
			return binary(mid + 1, r, ll, val, ans)
		else:
			return binary(l, mid - 1, ll, val, ans)

def check(n):
	v = 1
	while n != 0:
		if n % 10 == 0 or n % 10 == 1:
			n = n // 10
		else:
			v = 0
			break
	return v
(n, m) = map(int, input().split(' '))
c = 0
for i in range(n):
	i1 = 0
	l = list(map(int, input().split(' ')))
	while i1 < 2 * m:
		if l[i1] == 1 or l[i1 + 1] == 1:
			c += 1
		i1 += 2
print(c)


def func(arr):
	t = 0
	ans = 0
	for i in range(len(arr)):
		if i % 2 == 0:
			if t > 0:
				ans += 1
			t = 0
		t += arr[i]
	if t > 0:
		ans += 1
	return ans
inf = list(map(int, input().split()))
(n, m) = (inf[0], inf[1])
ans = 0
for i in range(n):
	inf = list(map(int, input().split()))
	ans = ans + func(inf)
print(ans)


(n, m) = map(int, input().split())
ans = 0
for i in range(n):
	a = list(map(int, input().split()))
	for j in range(m):
		if a[2 * j] == 1 or a[2 * j + 1] == 1:
			ans += 1
print(ans)


(n, m) = [int(i) for i in input().split(' ')]
que = []
count = 0
for i in range(n):
	que.append(input().split(' '))
for i in range(n):
	for j in range(0, len(que[i]), 2):
		if ''.join(que[i][j:j + 2]) == '00':
			count += 1
print(n * m - count)


line1 = [int(x) for x in input().split()]
total = 0
for i in range(0, line1[0]):
	line2 = [int(x) for x in input().split()]
	for j in range(0, line1[1]):
		if line2[2 * j] == 1 or line2[2 * j + 1] == 1:
			total += 1
print(total)


(n, m) = map(int, input().split())
arr = [list(map(int, input().split())) for i in range(n)]
h = [[False for j in range(m)] for i in range(n)]
cnt = 0
for i in range(n):
	for j in range(m):
		h[i][j] = arr[i][j * 2] or arr[i][j * 2 + 1]
		if h[i][j]:
			cnt += 1
print(cnt)


(floor, flat) = map(int, input().split())
result = 0
for m in range(floor):
	data = list(map(int, input().split()))
	c = 0
	for n in range(flat):
		if data[c] == 1 or data[c + 1] == 1:
			result += 1
		c += 2
print(result)


(f, a) = map(int, input().split())
l = []
count = 0
for i in range(f):
	flat = map(int, input().split())
	l.extend(flat)
for i in range(0, len(l), 2):
	if l[i] or l[i + 1]:
		count += 1
print(count)


(n, m) = map(int, input().split())
q = 0
for i in range(n):
	w = input().split()
	for j in range(0, len(w), 2):
		if w[j] == '1' or w[j + 1] == '1':
			q += 1
print(q)


(n, m) = map(int, input().split())
count = 0
for _ in range(n):
	x = iter(input().split())
	count += sum(map(lambda x: (x.count('1') + 1) // 2, map(' '.join, zip(x, x))))
print(count)


(n, m) = map(int, input().split())
f = [list(map(int, input().split())) for _ in range(n)]
c = 0
s = len(f[0]) // m
for i in f:
	for j in range(s * m):
		if sum(i[j * s:(j + 1) * s]) >= 1:
			c += 1
print(c)


l = list(input().split())
n = int(l[0])
m = int(l[1])
awaking = 0
for i in range(n):
	q = list(input().split())
	q = [int(j) for j in q]
	for h in range(0, 2 * m, 2):
		if q[h] == 0 and q[h + 1] == 0:
			continue
		else:
			awaking += 1
print(awaking)


x = input()
x = x.split()
x = list(map(int, x))
counter = 0
for i in range(x[0]):
	z = input()
	z = z.split()
	z = list(map(int, z))
	for f in range(x[1]):
		notAsleep = False
		m = f * 2
		if z[0 + m] == 1:
			notAsleep = True
		if z[1 + m] == 1:
			notAsleep = True
		if notAsleep:
			counter += 1
print(counter)


(n, m) = map(int, input().split())
count = 0
while n != 0:
	arr = []
	arr = [int(x) for x in input().split()]
	i = 0
	while i < len(arr):
		ele1 = arr[i]
		ele2 = arr[i + 1]
		if ele1 == 1 or ele2 == 1:
			count += 1
		i += 2
	n = n - 1
print(count)


s = list(map(int, input().split()))
n = s[0]
m = s[1]
c = 0
k = 0
while k < n:
	a = list(map(int, input().split()))
	i = 0
	while i < 2 * m:
		if a[i] == 1 or a[i + 1] == 1:
			c = c + 1
		i = i + 2
	k = k + 1
print(c)


(n, m) = map(int, input().split())
ans = 0
for i in range(n):
	a = input().split()
	for s in range(0, m * 2, 2):
		if sum(map(int, a[s:s + 2])) > 0:
			ans += 1
print(ans)


(n, m) = [int(i) for i in input().strip().split(' ')]
count = 0
for i in range(n):
	l = [int(j) for j in input().strip().split(' ')]
	for k in range(0, 2 * m, 2):
		if l[k] == 1 or l[k + 1] == 1:
			count += 1
print(count)


(n, m) = map(int, input().split())
count = 0
for i in range(n):
	arr = list(map(int, input().split()))
	for i in range(0, len(arr) - 1, 2):
		if arr[i] or arr[i + 1] == 1:
			count += 1
print(count)


def max1(a):
	p = a[0]
	for x in a:
		if x > p:
			p = x
	return p

def prlist(a):
	for x in a:
		print(x, end=' ')

def fakt(n):
	p = 1
	for i in range(1, n + 1):
		p *= i
	return p
(row, col) = list(map(int, input().split()))
col *= 2
a = []
for i in range(row):
	b = list(map(int, input().split()))
	a.append(b)
k = 0
for i in range(row):
	for j in range(col):
		fl = False
		if j % 2 == 1:
			if a[i][j - 1] == 1:
				fl = True
		if not fl and a[i][j]:
			k += 1
print(k)


a = list(map(int, input().split()))
b = []
result = 0
for x in range(a[0]):
	b.append(list(map(int, input().split())))
for j in range(a[0]):
	for i in range(0, 2 * a[1], 2):
		if b[j][i] or b[j][i + 1] == 1:
			result = result + 1
		elif b[j][i] or b[j][i + 1] == 0:
			result = result + 0
print(result)


([n, m], c) = (list(map(int, input().split(' '))), 0)
for i in range(n):
	a = list(map(int, input().split(' ')))
	for j in range(m):
		c += a[2 * j] + a[2 * j + 1] > 0
print(c)


(n, m) = [int(thing) for thing in input().split()]
count = 0
for i in range(0, n):
	flats = [int(light) for light in input().split()]
	for j in range(1, len(flats), 2):
		if flats[j] or flats[j - 1] is 1:
			count += 1
print(count)


(n, m) = list(map(int, input().split()))
total = 0
for row in range(n):
	floor = list(map(int, input().split()))
	for col in range(m):
		if floor[2 * col] == 1 or floor[2 * col + 1] == 1:
			total += 1
print(total)


c = 0
for i in range(int(input().split()[0])):
	a = input().split()
	while len(a):
		if '1' in [a.pop(), a.pop()]:
			c += 1
print(c)


(n, m) = input().split()
(n, m) = (int(n), int(m))
count = 0
for i in range(n):
	f = [int(x) for x in input().split()]
	for j in range(0, m * 2, 2):
		if f[j] == 1 or f[j + 1] == 1:
			count += 1
print(count)


(n, m) = [int(x) for x in input().split()]
x = 0
for _ in range(n):
	l = [int(x) for x in input().split()]
	for i in range(m):
		if l[2 * i + 1] == 1 or l[2 * i] == 1:
			x += 1
print(x)


def m2l(m):
	t = []
	for i in m:
		for j in i:
			t.append(j)
	return t
(n, m) = map(int, input().split())
s = m2l([list(map(int, input().split())) for i in range(n)])
s = [bool(s[i] + s[i + 1]) for i in range(0, len(s), 2)]
print(sum(s))


(a, b) = map(int, input().split())
c = 0
for i in range(a):
	d = input().split()
	for j in range(0, 2 * b, 2):
		if d[j] == '1' or d[j + 1] == '1':
			c += 1
print(c)


(n, m) = map(int, input().split(' '))
answer = 0
for i in range(n):
	a = list(map(int, input().split(' ')))
	for j in range(0, 2 * m, 2):
		if sum(a[j:j + 2]) > 0:
			answer += 1
print(answer)


from sys import stdin
import math
A = list(map(int, stdin.readline().split()))
a = A[0]
b = A[1]
count = 0
answer = 0
for t in range(0, a):
	count = 0
	B = list(map(int, stdin.readline().split()))
	for u in range(0, b):
		if B[count] == 1 or B[count + 1] == 1:
			answer += 1
		count += 2
print(answer)


(a, b) = input().split()
a = int(a)
b = int(b)
n = 0
for i in range(a):
	c = input().split()
	for i in range(0, b * 2, 2):
		if c[i] == '1' or c[i + 1] == '1':
			n += 1
print(n)


import sys
(n, m) = map(int, input().split())
e = 0
for _ in range(n):
	r = 0
	l = list(map(int, input().split()))
	for i in range(0, 2 * m, 2):
		if l[i] == 0 and l[i + 1] == 0:
			r += 1
	e += m - r
print(e)


import itertools as it
import functools
import operator
import collections
import math
import sys

def chunks(iterable, n, fillvalue=None):
	args = [iter(iterable)] * n
	return zip(*args)

def solve(xss):
	return sum((sum((a + b >= 1 for (a, b) in chunks(xs, 2))) for xs in xss))

def main():
	[n, m] = [int(i) for i in input().strip().split()]
	xss = [[int(i) for i in input().strip().split()] for _ in range(n)]
	assert len(xss[0]) == 2 * m
	result = solve(xss)
	print(result)
main()


import sys
(n, m) = map(int, sys.stdin.readline().split(' '))
a = [-1] * (n * m * 2)
c = 0
for i in range(n):
	o = list(map(int, sys.stdin.readline().split(' ')))
	for e in o:
		a[c] = e
		c += 1
j = 0
p = 0
al = len(a)
while p < len(a) - 1:
	if a[p] == 1:
		j += 1
		p += 2
	elif a[p + 1] == 1:
		j += 1
		p += 2
	else:
		p += 2
print(j)


I = lambda : map(int, input().split())
(n, m) = I()
ans = 0
for _ in range(n):
	a = list(I())
	ans += sum([a[i * 2] + a[i * 2 + 1] > 0 for i in range(m)])
print(ans)


listm = list(map(int, input().split()))
(n, m) = (listm[0], listm[1])
count = 0
for i in range(n):
	l = list(map(int, input().split()))
	for i in range(0, 2 * m, 2):
		if i % 2 == 0:
			k = l[i:i + 2]
			if 1 in k:
				count += 1
print(count)


q = lambda : map(int, input().split())
qi = lambda : int(input())
qs = lambda : input().split()
(x, y) = q()
a = []
for _ in range(x):
	a.extend(list(q()))
print(sum([1 for i in zip(a[::2], a[1::2]) if 1 in i]))


(n, m) = list(map(int, input().split()))
num = int()
for x in range(n):
	inp = list(map(int, input().split()))
	for y in range(0, 2 * m, 2):
		if inp[y] + inp[y + 1] != 0:
			num = num + 1
print(num)


(n, m) = map(int, input().split())
count = 0
for j in range(n):
	l1 = list(map(int, input().split()))
	for i in range(m):
		w1 = l1[2 * i + 1]
		w2 = l1[2 * i]
		if w1 == 0 and w2 == 0:
			continue
		else:
			count += 1
print(count)


(n, m) = map(int, input().split())
result = 0
for i in range(n):
	M = [int(s) for s in input().split()]
	result += m - sum([(1 - M[2 * i]) * (1 - M[2 * i + 1]) for i in range(m)])
print(result)


st = list(input().split(' '))
n = int(st[0])
m = int(st[1])
st0 = []
for i in range(n):
	st1 = list(input().split(' '))
	st0 += st1
k = 0
inc = 0
while k < m * n:
	if int(st0[2 * k]) + int(st0[2 * k + 1]) > 0:
		inc = inc + 1
	k = k + 1
print(inc)


(n, m) = [int(i) for i in input().split()]
e = 0
for i in range(n):
	a = [int(i) for i in input().split()]
	for j in range(0, len(a) - 1, 2):
		if a[j] == 1 or a[j + 1] == 1:
			e = e + 1
print(e)


(n, m) = input().split(' ')
m = int(m)
n = int(n)
s = 0
for i in range(n):
	b = [int(l) for l in input().split(' ')]
	for k in range(0, len(b), 2):
		if b[k] + b[k + 1] > 0:
			s += 1
print(s)


(n, m) = [int(tmp) for tmp in input().split()]
ans = 0
for i in range(n):
	lvl = [int(tmp) for tmp in input().split()]
	for j in range(m):
		if lvl[2 * j] == 1 or lvl[2 * j + 1] == 1:
			ans += 1
print(ans)


arr = []
ip = list(map(int, input().split()))
floors = ip[0]
flats = ip[1]
windows = flats * 2
wakeys = 0
for i in range(floors):
	row = list(map(int, input().split()))
	arr.append(row)
	i += 1
for i in range(floors):
	j = 0
	while j < windows:
		if arr[i][j] == 1 or arr[i][j + 1] == 1:
			wakeys += 1
		j += 2
print(wakeys)


(floor, flats) = map(int, input().split())
matrix = []
for i in range(floor):
	matrix.append(list(map(int, input().split())))
count = 0
for i in range(floor):
	for j in range(flats):
		if matrix[i][2 * j] == 1 or matrix[i][2 * j + 1] == 1:
			count += 1
print(count)


def Vitaly(s, n, m):
	res = 0
	for i in range(n):
		j = 0
		while j < 2 * m:
			if 1 in s[i][j:j + 2]:
				res = res + 1
			j = j + 2
	return res
(n, m) = input().split()
s = []
for i in range(int(n)):
	s1 = [int(n) for n in input().split()]
	s.append(s1)
print(Vitaly(s, int(n), int(m)))


(a, b) = map(int, input().split())
count = 0
for i in range(a):
	c = list(map(int, input().split()))
	for j in range(0, len(c) // 2 + b, 2):
		if c[j] != 0 or c[j + 1] != 0:
			count += 1
print(count)


(floors, flats) = list(map(int, input().split()))
cheking_windows = []
for _ in range(floors):
	windows = input().replace(' ', '')
	while windows:
		cheking_windows.append(windows[:2])
		windows = windows[2:]
sleeping = cheking_windows.count('00')
print(floors * flats - sleeping)


(x, y) = [int(i) for i in input().split()]
z = x * y
a = []
for i in range(x):
	b = [int(k) for k in input().split()]
	a.append(b)
for i in range(x):
	for j in range(0, y * 2, 2):
		if a[i][j] == a[i][j + 1] == 0:
			z -= 1
print(z)


(n, m) = map(int, input().split())
ans = 0
for i in range(n):
	mat = list(map(int, input().split()))
	for j in range(m):
		ans += min(1, mat[2 * j] + mat[2 * j + 1])
print(ans)


(r, c) = map(int, input().split())
t = 0
for _ in range(r):
	l_w = list(map(int, input().split()))
	for i in range(len(l_w) // 2):
		if l_w[i * 2] == 1 or l_w[i * 2 + 1] == 1:
			t += 1
print(t)


(n, m) = list(map(int, input().split()))
s = 0
for _ in range(n):
	a = input().split()
	for j in range(0, 2 * m, 2):
		s += 1 if a[j] == '1' or a[j + 1] == '1' else 0
print(s)


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
(n, m) = invr()
num_awake = 0
for i in range(n):
	row = list(invr())
	for j in range(m):
		if row[2 * j] or row[2 * j + 1]:
			num_awake += 1
print(num_awake)


s0 = input()
l2 = s0.split()
n = int(l2[0])
m = int(l2[1])
s1 = ''
c = 0
for i in range(n):
	s = input()
	s1 = s + ' ' + s1
l1 = s1.split()
k = len(l1)
for j in range(0, k, 2):
	if l1[j] == '0' and l1[j + 1] == '0':
		c += 1
wake = k / 2 - c
print(int(wake))


(n, m) = map(int, input().split())
aps = 0
for i in range(n):
	a = input().split()
	for i in range(m * 2):
		if a[i] == '1':
			if i % 2 == 0:
				if a[i + 1] == '0':
					aps += 1
			else:
				aps += 1
print(aps)


from sys import stdin, stdout, exit as sys_ret
(f_input, f_print, f_flush) = (stdin.readline, stdout.write, stdout.flush)
(floors, flats) = map(int, f_input().split())
count = 0
for i in range(floors):
	windows = [int(_) for _ in f_input().split()]
	for j in range(flats):
		if windows[2 * j] + windows[2 * j + 1] != 0:
			count += 1
f_print(str(count) + '\n')


n = list(map(int, input().split()))
counter = 0
for i in range(n[0]):
	a = list(map(int, input().split()))
	for i in range(0, 2 * n[1], 2):
		if a[i] == 1 or a[i + 1] == 1:
			counter += 1
print(counter)


def main():
	(n, m) = map(int, input().split())
	m *= n
	for _ in range(n):
		s = input()[::2]
		m -= sum((a == '0' == b for (a, b) in zip(s[::2], s[1::2])))
	print(m)
main()


(n, m) = map(int, input().split())
count = 0
while n:
	n -= 1
	l = list(map(int, input().split()))
	for i in range(0, 2 * m, 2):
		if l[i] == 1 or l[i + 1] == 1:
			count += 1
print(count)


(n, m) = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n):
	for j in range(m):
		if 1 in l[i][2 * j:2 * (j + 1)]:
			ans += 1
print(ans)


(n, m) = map(int, input().split())
res = 0
for _ in range(n):
	s = input().split()
	for j in range(m):
		res += s[j * 2] == '1' or s[j * 2 + 1] == '1'
print(res)


(n, m) = map(int, input().split())
matrix = [[] for i in range(n)]
for i in range(n):
	matrix[i] = list(map(int, input().split()))
res = 0
for i in range(n):
	for j in range(0, m):
		if matrix[i][2 * j] == 1 or matrix[i][2 * j + 1] == 1:
			res += 1
print(res)


(n, m) = map(int, input().split())
ans = 0
for i in range(n):
	ints = list(map(int, input().split()))
	for j in range(m):
		if any(ints[2 * j:2 * j + 2]):
			ans += 1
print(ans)


(n, m) = map(int, input().split())
arr = [0] * n
cnt = 0
for i in range(n):
	arr[i] = [int(x) for x in input().split()]
for i in range(n):
	for j in range(0, 2 * m, 2):
		try:
			if arr[i][j] == 1 or arr[i][j + 1] == 1:
				cnt += 1
		except:
			pass
print(cnt)


(n, m) = [int(c) for c in input().split()]
res = 0
for i in range(n):
	windows = [c for c in input().split()]
	for j in range(0, len(windows) - 1, 2):
		if windows[j] == '1' or windows[j + 1] == '1':
			res += 1
print(res)


(n, m) = [int(s) for s in input().split(' ')]
cnt = 0
for i in range(n):
	x = [int(s) for s in input().split(' ')]
	x = [max(x[2 * i], x[2 * i + 1]) for i in range(m)]
	cnt += sum(x)
print(cnt)


(n, m) = str(input()).split()
n = int(n)
m = int(m)
value = 0
for i in range(n):
	line = str(input()).split()
	line = [int(it) for it in line]
	for j in range(m):
		if line[2 * j] + line[2 * j + 1] > 0:
			value += 1
print(value)


(n, m) = map(int, input().split())
count = 0
for _ in range(n):
	li = list(map(int, input().split()))
	for (i, j) in zip(li[::2], li[1::2]):
		count += i | j
print(count)


(n, m) = [int(x) for x in input().split()]
windows = 2 * m
res = 0
for i in range(n):
	w = 0
	floor = [int(x) for x in input().split()]
	while w < windows:
		if floor[w] == 1 or floor[w + 1] == 1:
			res += 1
		w += 2
print(res)


(a, b) = map(int, input().split())
c = 0
for i in range(a):
	z = list(map(int, input().split()))
	v = []
	for q in range(0, len(z), 2):
		v.append([z[q], z[q + 1]])
	for w in v:
		if 1 in w:
			c += 1
print(c)


c = 0
(n, m) = map(int, input().split())
for i in range(n):
	a = list(map(int, input().split()))
	j = 0
	while j < 2 * m:
		if j % 2 == 0 and a[j] == 1:
			c += 1
			j += 2
		elif j % 2 == 1 and a[j] == 1:
			c += 1
			j += 1
		else:
			j += 1
print(c)


(n, m) = [int(x) for x in input().split()]
ret = 0
for i in range(n):
	a = [int(x) for x in input().split()]
	for i in range(m):
		ti = i << 1
		if a[ti] == 1 or a[ti + 1] == 1:
			ret += 1
print(ret)


(n, m) = map(int, input().split())
p = 0
for i in range(n):
	line = [int(x) for x in input().split()]
	for i in range(m):
		if max(line[2 * i], line[2 * i + 1]) == 1:
			p += 1
print(p)


(n, m) = map(int, input().split())
count = 0
while n:
	a = list(map(int, input().split()))
	i = 0
	while i < 2 * m:
		if a[i] == 1 or a[i + 1] == 1:
			count += 1
		i += 2
	n -= 1
print(count)


from sys import stdin
(n, m) = map(int, stdin.readline().split())
res = 0
for i in range(0, n):
	k = list(map(int, stdin.readline().split()))
	for j in range(0, 2 * m - 1, 2):
		if k[j] + k[j + 1] != 0:
			res += 1
print(res)


(q, w) = map(int, input().split())
S = 0
for i in range(q):
	e = list(map(int, input().split()))
	for j in range(0, len(e), 2):
		if e[j] == 1 or e[j + 1] == 1:
			S += 1
print(S)


(N, M) = map(int, input().split())
U = 0
for _ in range(N):
	W = [int(w) for w in input().split()]
	for f in range(0, 2 * M, 2):
		if W[f] or W[f + 1] == 1:
			U += 1
print(U)


(n, m) = map(int, input().split())
s = 0
for i in range(n):
	q = list(map(int, input().split()))
	for j in range(0, len(q), 2):
		if q[j] == 1 or q[j + 1] == 1:
			s += 1
print(str(s), end='')


(n, m) = map(int, input().split())
c = 0
for i in range(0, n):
	l = list(map(int, input().split()))
	for j in range(0, 2 * m, 2):
		if l[j] == 0 and l[j + 1] == 0:
			continue
		else:
			c += 1
print(c)


numbers = input().split(' ')
n = int(numbers[0])
m = int(numbers[1])
awakeCount = 0
for i in range(n):
	current = input().split(' ')
	for j in range(m):
		if current[2 * j] == '1' or current[2 * j + 1] == '1':
			awakeCount += 1
print(awakeCount)


(a, b) = map(int, input().split())
total = 0
for i in range(a):
	y = list(map(int, input().split()))
	for x in range(0, len(y), 2):
		if y[x] + y[x + 1] != 0:
			total += 1
print(total)


s = 0
(n, m) = map(int, input().split())
for x in range(n):
	l = list(map(int, input().split()))
	for x in range(m):
		if l[2 * x] == 1 or l[2 * x + 1]:
			s += 1
print(s)


(a, b) = [int(i) for i in input().split()]
res = 0
for i in range(a):
	n = [int(i) for i in input().split()]
	for j in range(0, 2 * b, 2):
		if n[j] == 1 or n[j + 1] == 1:
			res += 1
print(res)


(n, m) = input().split()
(n, m) = (int(n), int(m))
result = 0
for each_n in range(n):
	windows = [int(i) for i in input().split()]
	i = 0
	while i < 2 * m:
		if windows[i] | windows[i + 1] == 1:
			result += 1
		i = i + 2
print(result)


(f, a) = map(int, input().split())
fl = []
c = 0
for i in range(f):
	w = map(int, input().split())
	fl.extend(w)
for i in range(0, len(fl), 2):
	if fl[i] or fl[i + 1]:
		c += 1
print(c)


import sys
data = sys.stdin.readline()
nm = data.split(' ')
n = nm[0]
m = nm[1]
house = []
for line in sys.stdin:
	line = line.replace('\n', '').split(' ')
	house.append(line)
roomNumbers = 0
index = 0
firstRoom = 0
for floor in house:
	for apartment in floor:
		if index > 1:
			index = 0
			firstRoom = 0
		if apartment == '1' and index == 0:
			firstRoom = 1
			roomNumbers += 1
		if firstRoom == 0 and apartment == '1' and (index == 1):
			roomNumbers += 1
		index += 1
print(roomNumbers)


N = list(map(int, input().split()))
COUNTER = 0
for _ in range(N[0]):
	TMP = list(map(int, input().split()))
	STRT = 0
	for __ in range(N[1]):
		if 1 in TMP[STRT:STRT + 2]:
			COUNTER += 1
		STRT += 2
print(COUNTER)


(n, w) = map(int, input().split())
counter = 0
for i in range(0, n):
	m = list(map(int, input().split()))
	temp = 0
	for j in m:
		temp += 1
		if temp % 2 == 0:
			continue
		elif j == 1 or m[temp] == 1:
			counter += 1
print(counter)


(n, m) = input().split()
n = int(n)
m = int(m)
s = 0
for i in range(n):
	l = input().split()
	j = 0
	while j < 2 * m:
		if l[j] == '0' and l[j + 1] == '0':
			j += 2
			continue
		else:
			s += 1
			j += 2
print(s)


n = input().split()
ans = 0
for i in range(int(n[0])):
	a = input().split()
	for j in range(2 * int(n[1])):
		if a[j] == '1':
			ans += 1
			if j % 2 == 0:
				a[j + 1] = '0'
print(ans)


(n, m) = map(int, input().split(' '))
y = 0
for i in range(n):
	l = list(map(int, input().split(' ')))
	for j in range(m):
		x = l[j * 2:j * 2 + 2]
		if 1 in x:
			y += 1
print(y)


(n, m) = map(int, input().split())
awake = 0
for _ in range(n):
	windows = list(map(int, input().split()))
	for i in range(0, 2 * m, 2):
		win = windows[i:i + 2]
		if 1 in win:
			awake += 1
print(awake)


(n, m) = map(int, input().split())
count = 0
for i in range(n):
	wind = input().split()
	for j in range(m):
		if '1' in wind[2 * j:2 * j + 2]:
			count += 1
print(count)


(n, m) = map(int, input().split())
k = 0
for i in range(n):
	a = [int(i) for i in input().split()]
	for i in range(0, 2 * m, 2):
		if a[i] == 1 or a[i + 1] == 1:
			k += 1
print(k)


(n, m) = map(int, input().split(' '))
t = 0
count = 0
while t < n:
	win = [int(i) for i in input().split(' ')]
	t += 1
	for j in range(0, 2 * m - 1, 2):
		if win[j] + win[j + 1] > 0:
			count += 1
print(count)


(n, m) = map(int, input().split())
cnt = 0
for i in range(n):
	ai = list(map(int, input().split()))
	a = 0
	for j in range(len(ai)):
		if 1 in ai[a:a + 2]:
			cnt += 1
		a += 2
print(cnt)


import sys
from functools import reduce
from collections import Counter
import time
import datetime
from math import sqrt, gcd

def ip():
	return int(sys.stdin.readline())

def sip():
	return sys.stdin.readline()

def mip():
	return map(int, sys.stdin.readline().split())

def mips():
	return map(str, sys.stdin.readline().split())

def lip():
	return list(map(int, sys.stdin.readline().split()))

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.insert(i, arr)
	return lst

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)

def check_prime(n):
	if n < 2:
		return False
	for i in range(2, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
(n, m) = mip()
val = 0
while n:
	n -= 1
	arr = lip()
	i = 0
	while i <= 2 * m:
		p = arr[i:i + 2].count(1)
		if p > 0:
			val += 1
		i += 2
print(val)


(floors, flats) = map(int, input().split(' '))
window_pairs = []
for i in range(floors):
	flat = input().split(' ')
	for w in range(1, flats + 1):
		window_pairs.append(flat[(w - 1) * 2:w * 2])
print(len([i for i in window_pairs if '1' in i]))


[n, m] = [int(i) for i in input().split()]
ans = 0
for i in range(n):
	arr = [int(i) for i in input().split()]
	for j in range(m):
		ans += 1 if arr[j * 2] + arr[j * 2 + 1] > 0 else 0
print(ans)


(n, m) = map(int, input().split())
s = 0
for _ in range(n):
	lights = list(map(int, input().split()))
	s += sum((any(lights[x * 2:(x + 1) * 2]) for x in range(m)))
print(s)


def solve(n, m, l):
	ans = 0
	for i in range(n):
		for j in range(0, 2 * m, 2):
			ans += l[i][j] or l[i][j + 1]
	return ans
(n, m) = map(int, input().split())
l = []
for _ in range(n):
	l.append(list(map(int, input().split())))
print(solve(n, m, l))


(n, m) = [int(i) for i in input().split()]
ans = 0
for i in range(n):
	floor = input().split()
	for j in range(0, 2 * m, 2):
		ans += int(floor[j] == '1' or floor[j + 1] == '1')
print(ans)


(n, m) = map(int, input().split())
wake = 0
for j in range(n):
	w = list(map(int, input().split()))
	i = 0
	while i < 2 * m:
		if i % 2 == 0 and w[i] == 1:
			wake += 1
			i += 1
		elif w[i] == 1:
			wake += 1
		i += 1
print(wake)


(n, m) = [int(x) for x in input().split()]
acc = 0
while n:
	n = n - 1
	a_i = [int(x) for x in input().split()]
	for i in range(0, 2 * m, 2):
		if a_i[i] == 1 or a_i[i + 1] == 1:
			acc = acc + 1
print(acc)


(n, m) = map(int, input().split())
l = []
for i in range(n):
	x = list(map(int, input().split()))
	l.append(x)
count = 0
for i in range(n):
	for j in range(0, 2 * m, 2):
		if l[i][j] == 0 and l[i][j + 1] == 0:
			count += 1
x = m * n - count
print(x)


n = [int(i) for i in input().split()]
n1 = n[0]
n2 = n[1]
j = 0
x = list()
count = 0
for i in range(n1):
	x = [int(i) for i in input().split()]
	while j < 2 * n2 - 1:
		if x[j] == 1 or x[j + 1] == 1:
			count = count + 1
			j = j + 2
		else:
			j = j + 2
	j = 0
print(count)


(n, m) = input().split()
wake = 0
for i in range(int(n)):
	flats = input().split()
	for j in range(0, int(m) * 2, 2):
		if flats[j] == '1' or flats[j + 1] == '1':
			wake += 1
print(wake)


(n, m) = input().split()
n = int(n)
m = int(m)
c = 0
for x in range(n):
	a = list(map(int, input().split()))[:2 * m]
	for y in range(0, 2 * m, 2):
		if a[y] == 1 or a[y + 1] == 1:
			c += 1
print(c)


(n, m) = map(int, input().split())
dntsleep = 0
for i in range(n):
	fl = list(map(int, input().split()))
	for j in range(0, 2 * m - 1, 2):
		if fl[j] + fl[j + 1] >= 1:
			dntsleep += 1
print(dntsleep)


import math
(n, m) = input().split()
ans = 0
n = int(n)
m = int(m)
for i in range(n):
	a = input().split()
	for j in range(m):
		if int(a[2 * j]) == 1 or int(a[2 * j + 1]) == 1:
			ans += 1
print(ans)


(n, m) = map(int, input().split())
result = 0
for _ in range(n):
	ls = list(map(int, input().split()))
	ls1 = ls[::2]
	ls2 = ls[1::2]
	for i in range(m):
		if ls1[i] == 1 or ls2[i] == 1:
			result += 1
print(result)


import sys

def main():
	(n, m) = map(int, input().split())
	cnt = 0
	for i in range(n):
		a = list(map(int, input().split()))
		for j in range(0, len(a) - 1, 2):
			cnt += a[j] | a[j + 1]
	print(cnt)
main()


temp = list(map(int, input().split()))
floors = temp[0]
flats = temp[1]
count = 0
for i in range(floors):
	floor = list(map(int, input().split()))
	for j in range(1, flats * 2, 2):
		if floor[j] == 1 or floor[j - 1] == 1:
			count += 1
print(count)


(n, m) = map(int, input().split())
x = 0
for a in range(n):
	win = [int(z) for z in input().split()]
	for i in range(m):
		if win[2 * i] + win[2 * i + 1]:
			x += 1
print(x)


__author__ = 'cmashinho'
(n, m) = map(int, input().split())
ans = 0
for _ in range(n):
	l = list(map(int, input().split()))
	for i in range(1, len(l), 2):
		if l[i] == 1 or l[i - 1] == 1:
			ans += 1
print(ans)


(m, n) = input().split()
m = int(m)
n = int(n)
lst = []
count = 0
for i in range(m):
	x = input().split()
	lst.append(x)
for i in range(m):
	for j in range(0, len(lst[0]), 2):
		count += int(lst[i][j]) or int(lst[i][j + 1])
print(count)


(n, m) = list(map(int, input().split()))
L = [list(map(int, input().split())) for _ in range(n)]
r = 0
for k in range(n):
	for i in range(m):
		if L[k][2 * i + 1] or L[k][2 * i]:
			r += 1
print(r)


def __starting_point():
	(n, m) = map(int, input().split())
	total = 0
	for x in range(n):
		data = list(map(int, input().split()))
		total += sum(map(lambda x: min(1, x[0] + x[1]), zip(data[0::2], data[1::2])))
	print(total)
__starting_point()


(n, m) = [int(i) for i in input().split()]
cnt = 0
for _ in range(n):
	windows = [int(i) for i in input().split()]
	i = 0
	while i < 2 * m:
		if windows[i] | windows[i + 1] == 1:
			cnt += 1
		i = i + 2
print(cnt)


a = input().split()
b = []
for i in range(int(a[0])):
	b.append(input())
total = 0
for i in b:
	for j in range(0, 4 * int(a[1]), 4):
		if i[j] + i[j + 2] != '00':
			total += 1
print(total)


(n, m) = map(int, input().split())
t = 0
for _ in range(n):
	i = list(map(int, input().split()))
	for x in range(m):
		if 1 in [i[2 * x], i[2 * x + 1]]:
			t += 1
print(t)


(n, m) = list(map(int, input().split()))
m = 2 * m
count = 0
while n > 0:
	tag = 0
	n -= 1
	list1 = list(map(int, input().split()))
	for i in range(0, m, 2):
		if list1[i] + list1[i + 1] >= 1:
			count += 1
print(count)


(a, b) = map(int, input().split())
c = 0
for i in range(a):
	n = list(map(int, input().split()))
	x = 0
	while x < 2 * b:
		if n[x] == 1 or n[x + 1] == 1:
			c += 1
		x += 2
print(c)


nm = list(map(int, input().split()))
house = []
for k in range(nm[0]):
	house.append(list(map(int, input().split())))
count = 0
for i in range(nm[0]):
	for j in range(0, 2 * nm[1], 2):
		if house[i][j] == 1 or house[i][j + 1]:
			count += 1
print(count)


(n, m) = [int(x) for x in input().split()]
awake_flats_count = 0
for i in range(n):
	lights = input().split()
	flat_statuses = [max(int(lights[2 * j]), int(lights[2 * j + 1])) for j in range(m)]
	awake_flats_count += flat_statuses.count(1)
print(awake_flats_count)


(n, m) = map(int, input().split())
b = 0
for i in range(n):
	l = list(map(int, input().split()))
	for i in range(m):
		if l[i * 2] == 1 or l[2 * i + 1] == 1:
			b += 1
print(str(b))


(m, n) = input().split()
m = int(m)
n = int(n)
c = 0
for i in range(m):
	j = 0
	x = list(map(int, input().split()))
	while j < len(x):
		if x[j] == 1:
			c = c + 1
		elif x[j + 1] == 1:
			c = c + 1
		j = j + 2
print(c)


(n, m) = map(int, input().split())
ans = 0
for i in range(n):
	s = list(map(int, input().split()))
	ans += sum(map(lambda i: s[2 * i] or s[2 * i + 1], range(m)))
print(ans)


def main():
	[n, m] = [int(x) for x in input().split()]
	counts = 0
	for _ in range(n):
		windows = input().split()
		counts += sum((1 for i in range(m) if windows[2 * i] == '1' or windows[2 * i + 1] == '1'))
	print(counts)
main()


(n, m) = map(int, input().split(' '))
res = 0
for _ in range(n):
	row = input().replace(' ', '')
	for i in range(0, len(row), 2):
		if row[i] == '1' or row[i + 1] == '1':
			res += 1
print(res)


(n, m) = map(int, input().split())
count = 0
for i in range(n):
	lights = list(map(int, input().split()))
	tmp = 0
	for (j, L) in enumerate(lights):
		if L == 1:
			tmp = 1
		if j % 2 == 1:
			count += tmp
			tmp = 0
print(count)


(etaj, kvart) = map(int, input().split())
Okna = []
notsleep = 0
for i in range(0, etaj):
	Okna.append(list(map(int, input().split())))
for i in range(0, etaj):
	for j in range(0, kvart * 2 - 1, 2):
		if Okna[i][j] or Okna[i][j + 1] == 1:
			notsleep += 1
print(notsleep)


data = [int(info) for info in input().split(' ')]
people = []
result = 0
for i in range(data[0]):
	people += input().split(' ')
for i in range(0, len(people), 2):
	if people[i] == '1' or people[i + 1] == '1':
		result += 1
print(result)


(n, m) = (int(z) for z in input().split())
count = 0
for i in range(n):
	k = list(map(int, input().split()))
	for j in range(0, 2 * m - 1, 2):
		if (k[j] == 1 or k[j + 1] == 1) or (k[j] == 1 and k[j + 1] == 1):
			count += 1
print(count)


def house(arr):
	count = 0
	for i in arr:
		for j in range(0, len(i), 2):
			if i[j:j + 2].count(1) > 0:
				count += 1
	return count
(n, m) = list(map(int, input().rstrip().split()))
arr = []
for i in range(n):
	x = list(map(int, input().rstrip().split()))
	arr.append(x)
print(house(arr))


(n, m) = (int(x) for x in input().split())
ans = 0
for i in range(n):
	a = [int(x) for x in input().split()]
	ans += sum([max(a[x], a[x + 1]) for x in range(0, m * 2, 2)])
print(ans)


(n, m) = [int(x) for x in input().split(' ')]
cnt = 0
for i in range(n):
	f = [int(x) for x in input().split(' ')]
	cnt += sum([1 for x in range(0, len(f) - 1, 2) if f[x] or f[x + 1]])
print(cnt)


q = input().split()
n = int(q[0])
m = int(q[1])
s = list()
summa = 0
pr = 0
for i in range(0, n):
	s.append(input().split())
k = 0
for i in range(0, n):
	for j in range(0, m):
		if int(s[i][k]) == 1:
			pr = 1
		k += 1
		if int(s[i][k]) == 1:
			pr = 1
		if pr == 1:
			summa += 1
		k += 1
		pr = 0
	k = 0
	pr = 0
print(summa)


(a, b) = map(int, input().split())
ans = 0
for i in range(a):
	s = [int(x) for x in input().split()]
	for i in range(0, b * 2, 2):
		if s[i] or s[i + 1]:
			ans += 1
print(ans)


(f, fl) = list(map(int, input().split()))
t = 0
for i in range(f):
	a = list(map(int, input().split()))
	for j in range(0, len(a), 2):
		if a[j] + a[j + 1] >= 1:
			t += 1
print(t)


(a, b) = map(int, input().split())
sum1 = 0
for i in range(a):
	ls = [*map(int, input().split())]
	for k in range(0, 2 * b, 2):
		sum1 += ls[k] or ls[k + 1]
print(sum1)


(n, m) = map(int, input().split())
ans = 0
for i in range(n):
	floor = tuple(input().split())
	for k in range(0, 2 * m, 2):
		if floor[k] == '1' or floor[k + 1] == '1':
			ans += 1
print(ans)


(n, m) = map(int, input().split())
zero = 0
for i in range(n):
	lisofls = input().split()
	for j in range(0, 2 * m - 1, 2):
		if lisofls[j] == '1' or lisofls[j + 1] == '1':
			zero += 1
print(zero)


(a, b) = map(int, input().split())
c = 0
for i in range(a):
	(*d,) = map(int, input().split())
	d = [bool(d[2 * j] + d[2 * j + 1]) for j in range(b)]
	c += sum(d)
print(c)


(n, m) = [int(i) for i in input().split()]
res = 0
for i in range(n):
	s = input().split()
	for j in range(0, 2 * m, 2):
		if s[j] == '1' or s[j + 1] == '1':
			res += 1
print(res)


from sys import stdin, stdout, stderr, setrecursionlimit
setrecursionlimit(100000)

def debug(*e):
	if not __debug__:
		print(*e, file=stderr)

def dd(*vals):
	import inspect, re
	frame = inspect.getframeinfo(inspect.stack()[1][0])
	vs = re.search('dd\\((.+)\\)', frame.code_context[0]).group(1).split(',')
	if vs:
		debug(','.join(('{0} = {1}'.format(vs[i], v) for (i, v) in enumerate(vals))))

def trace(f):

	def traced(*args, **kw):
		debug('calling {} with args {}, {}'.format(f.__name__, args, kw))
		return f(*args, **kw)
	return traced

def read():
	return stdin.readline().rstrip()

def readarr(sep=None, maxsplit=-1):
	return read().split(sep, maxsplit)

def readint():
	return int(read())

def readintarr(sep=None, maxsplit=-1):
	return [int(a) for a in readarr(sep, maxsplit)]

def write(*args, **kwargs):
	sep = kwargs.get('sep', ' ')
	end = kwargs.get('end', '\n')
	stdout.write(sep.join((str(a) for a in args)) + end)

def writearr(arr, sep=' ', end='\n'):
	stdout.write(sep.join((str(a) for a in arr)) + end)
(n, m) = readintarr()
c = 0
for _ in range(n):
	f = readintarr()
	for j in range(0, 2 * m, 2):
		if f[j:j + 2] != [0, 0]:
			c += 1
write(c)


(floors, flats) = map(int, input().split())
l = []
for i in range(floors):
	l.append(list(map(int, input().split())))
count = 0
for i in range(floors):
	j = 0
	while j + 1 < 2 * flats:
		if l[i][j] == 1 or l[i][j + 1] == 1:
			count += 1
		j += 2
print(count)


s = input()
s = s.split()
n = int(s[0])
m = int(s[1])
p = []
for i in range(n):
	t = input()
	t = t.split()
	t = [int(j) for j in t]
	p.append(t)
ct = 0
for i in range(n):
	for j in range(m):
		if p[i][2 * j] == 1 or p[i][2 * j + 1] == 1:
			ct += 1
print(ct)


def sleep(n, m, ls):
	c = 0
	for i in range(n):
		j = 0
		while j < 2 * m - 1:
			if ls[i][j] == 1 or ls[i][j + 1] == 1:
				c = c + 1
			j = j + 2
	return c
(n, m) = input().split()
n = int(n)
m = int(m)
ls = [[int(j) for j in input().split()] for i in range(n)]
print(sleep(n, m, ls))


def main():
	(n, m) = [int(v) for v in input().split()]
	c = 0
	for i in range(n):
		vals = [int(v) for v in input().split()]
		for j in range(0, 2 * m, 2):
			if any([v == 1 for v in vals[j:j + 2]]):
				c += 1
	print(c)
main()


(n, m) = map(int, input().split())
not_sleeping = 0
for _ in range(n):
	floor = list(map(int, input().split()))
	not_sleeping += sum((floor[2 * i] or floor[2 * i + 1] for i in range(m)))
print(not_sleeping)


(a, b) = map(int, input().split())
x = []
for i in range(a):
	x.append(list(map(int, input().split())))
r = 0
for i in x:
	for j in range(0, len(i), 2):
		r += i[j] or i[j + 1]
print(r)


def night(n, m, lst):
	result = 0
	for i in range(n):
		for j in range(m):
			if lst[i][j * 2] == 1 or lst[i][j * 2 + 1] == 1:
				result += 1
	return result
(n, m) = [int(x) for x in input().split()]
b = list()
for y in range(n):
	a = [int(z) for z in input().split()]
	b.append(list(a))
print(night(n, m, b))


def ints():
	return [int(x) for x in input().split()]
(n, m) = ints()
floors = (ints() for _ in range(n))

def apartmentize(floor):
	return (a | b for (a, b) in zip(floor[::2], floor[1::2]))
print(sum((sum(apartmentize(floor)) for floor in floors)))


n = list(map(int, input().split()))
lst = []
s = 0
for i in range(n[0]):
	n1 = input().split()
	for j in range(n[1]):
		lst.append(n1[0] + n1[1])
		n1.remove(n1[1])
		n1.remove(n1[0])
for k in lst:
	if '1' in k:
		s = s + 1
print(s)


(a, b) = list(map(int, input().split()))
sum = 0
for i in range(a):
	s = list(map(int, input().split()))
	for j in range(0, 2 * b, 2):
		if s[j] == 1 or s[j + 1] == 1:
			sum += 1
print(sum)


def vitaly_and_count(a, m):
	count = 0
	for i in range(len(a)):
		for j in range(0, 2 * m, 2):
			if a[i][j] == 1 or a[i][j + 1] == 1:
				count = count + 1
	print(count)
n = list(map(int, input('').split()))
b = []
for i in range(n[0]):
	a = list(map(int, input('').split()))
	b.append(a)
vitaly_and_count(b, n[1])


(n, m) = map(int, input().split())
x = y = res = 0
for i in range(n):
	arr = [int(i) for i in input().split()]
	for i in range(len(arr)):
		if i % 2 == 1 and arr[i] + y > 0:
			res += 1
		y = arr[i]
print(res)


first = list(map(int, input().split()))
second = []
counter = 0
for i in range(first[0]):
	second = list(map(int, input().split()))
	for j in range(0, first[1] * 2, 2):
		if second[j] or second[j + 1] == 1:
			counter += 1
print(counter)


(n, m) = map(int, input().split())
v = 0
for i in range(n):
	f = input().split()
	v += sum((f[2 * j] == '1' or f[2 * j + 1] == '1' for j in range(m)))
print(v)


x = [int(i) for i in input().split()]
(n, m, res) = (x[0], x[1], [])
for i in range(n):
	res.append([int(i) for i in input().split()])
count = 0
for i in res:
	for p in range(1, 2 * m + 1, 2):
		if i[p] == 1 or i[p - 1] == 1:
			count += 1
print(count)


(n, m) = map(int, input().split())
(count, count1, count2) = (0, 0, 0)
for i in range(n):
	k = list(map(int, input().split()))
	for j in range(m):
		if k[2 * j + 1] == 1 and k[2 * j] == 1:
			count2 += 1
		if k[2 * j + 1] == 1:
			count1 += 1
		if k[2 * j] == 1:
			count += 1
print(count + count1 - count2)


(n, m) = [int(s) for s in input().split()]
c = 0
for i in range(n):
	a = [int(s) for s in input().split()]
	for j in range(m):
		if a[2 * j] + a[2 * j + 1] != 0:
			c += 1
print(c)


(n, m) = map(int, input().split())
arr = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in arr:
	for k in range(m):
		if i[2 * k + 1] == 1 or i[2 * k] == 1:
			ans += 1
print(ans)


hdr = input().split(' ')
n = int(hdr[0])
m = int(hdr[1])
count = 0
for floor in range(n):
	line = input().split(' ')
	for flat in range(0, m):
		if 1 == int(line[2 * flat]) or 1 == int(line[2 * flat + 1]):
			count += 1
print(count)


def s():
	(n, m) = [int(x) for x in input().split(' ')]
	ans = 0
	for i in range(n):
		temp = [int(x) for x in input().split(' ')]
		for j in range(m):
			if bool(temp[j * 2]) or bool(temp[j * 2 + 1]):
				ans += 1
	print(ans)
s()


def main():
	(n, m) = map(int, input().split())
	x = ''.join([''.join(input().split()) for _ in range(n)])
	li = 0
	f = len(x) // (n * m)
	for i in range(0, len(x), f):
		if '1' in x[i:i + f]:
			li += 1
	print(li)
main()


(n, m) = map(int, input().split())
arr = []
count = 0
for i in range(n):
	ls = list(map(int, input().split()))
	arr.append(ls)
for i in arr:
	for j in range(0, 2 * m, 2):
		if i[j] == 1 and i[j + 1] == 0 or (i[j] == 0 and i[j + 1] == 1) or (i[j] == 1 and i[j + 1] == 1):
			count += 1
print(count)


(floor, win) = map(int, input().split())
d = {}
k = 0
for i in range(floor):
	a = list(map(int, input().split()))
	for j in range(2 * win):
		if a[j] == 1:
			d[str(k // 2)] = 1
		k += 1
print(len(d.values()))


[n, m] = [int(x) for x in input().split()]
answer = 0
for i in range(n):
	floor = [x for x in input().split()]
	for j in range(m):
		if floor[2 * j] == '1' or floor[2 * j + 1] == '1':
			answer += 1
print(answer)


(floor, flat) = map(int, input().split())
l1 = []
lon = 0
for i in range(floor):
	flat1 = input().split()
	j = 0
	k = 1
	for i in range(flat):
		l2 = (flat1[i + j], flat1[k])
		k += 2
		j += 1
		l1.append(l2)
for i in range(len(l1)):
	if l1[i][0] == '1' or l1[i][1] == '1':
		lon += 1
print(lon)


bild = list(map(int, input().split()))
a = 0
l = []
k = []
for i in range(bild[0]):
	l.append(input().split())
for i in range(len(l)):
	k += l[i]
for j in range(len(k)):
	if j % 2 == 0:
		if k[j] == '1':
			a += 1
		elif k[j + 1] == '1':
			a += 1
print(a)


def solve():
	(n, m) = map(int, input().split())
	ans = 0
	for _ in range(n):
		a = list(map(int, input().split()))
		ans += sum([a[2 * i] | a[2 * i + 1] for i in range(m)])
	print(ans)
solve()


(n, m) = list(map(int, input().split()))
f = []
for _ in range(n):
	f.append(list(map(int, input().split())))
f = list(reversed(f))
res = 0
for i in range(n):
	for j in range(0, 2 * m, 2):
		if sum(f[i][j:j + 2]):
			res += 1
print(res)


def solve(windows):
	c = 0
	for row in windows:
		for i in range(0, len(row), 2):
			if row[i] == 1 or row[i + 1] == 1:
				c += 1
	return c

def main():
	windows = list()
	(n, m) = list(map(int, input().split()))
	for _ in range(n):
		windows.append(list(map(int, input().split())))
	print(solve(windows))
main()


(n, m) = map(int, input().split())
k = 0
for i in range(n):
	storey = input()
	for j in range(0, m * 4, 4):
		if storey[j] == '1' or storey[j + 2] == '1':
			k += 1
print(k)


(n, m) = map(int, input().split(' '))
res = 0
for _ in range(n):
	i = 0
	li = list(map(int, input().split(' ')))
	var = []
	for j in li:
		if i % 2 == 0:
			var.append(j)
			i += 1
		else:
			var.append(j)
			i = 0
		if len(var) == 2:
			if 1 in var:
				res += 1
			var = []
print(res)


(n, m) = map(int, input().split())
e = 0
for i in range(n):
	l = list(map(int, input().split()))
	for i in range(0, 2 * m - 1, 2):
		if l[i] + l[i + 1] > 0:
			e += 1
print(e)


(n, m) = map(int, input().split())
a = []
k = 0
for i in range(n):
	b = list(map(int, input().split()))
	for j in range(len(b)):
		a.append(b[j])
for i in range(0, len(a) - 1, 2):
	if a[i] == 1 or a[i + 1] == 1:
		k += 1
print(k)


[n, m] = [int(x) for x in input().split()]
B = []
c = 0
for i in range(n):
	B.append([int(x) for x in input().split()])
for f in B:
	for i in range(0, 2 * m, 2):
		if f[i] == f[i + 1] == 0:
			c += 1
print(m * n - c)


from sys import stdin
from functools import reduce
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
(floor, flats) = read_ints()
unslept = 0
for _ in range(floor):
	fls = read_ints()
	while fls:
		unslept += fls.pop() | fls.pop()
print(unslept)


(a, b) = map(int, input().split())
t = 0
for i in range(a):
	z = input().split()
	for j in range(0, len(z), 2):
		if z[j] == '1' or z[j + 1] == '1':
			t += 1
print(t)


(num_floors, num_flats) = [int(x) for x in input().split()]
count = 0
for i in range(num_floors):
	flats = [int(x) for x in input().split()]
	for j in range(num_flats):
		if flats[j * 2] == 1 or flats[j * 2 + 1] == 1:
			count += 1
print(count)


(n, m) = map(int, input().split())
arr = []
tf = m * n
for i in range(n):
	arr.append(list(map(int, input().split())))
for i in range(n):
	j = 0
	while j < 2 * m:
		if arr[i][j] == arr[i][j + 1] == 0:
			tf -= 1
		j += 2
print(tf)


import re
(n, m) = map(int, input().split())
r = 0
for i in range(n):
	r += sum((1 for x in re.split('(\\d \\d)', input()) if x.count('1')))
print(r)


n = [int(x) for x in input().split()]
hasil = 0
for i in range(n[0]):
	total = 0
	flat = [int(x) for x in input().split()]
	for j in range(len(flat)):
		if flat[j] == 1 and j < 2 and (total != 1):
			total += 1
			hasil += total
		elif j >= 2:
			if j % 2 == 0:
				total = 0
			if flat[j] == 1 and total != 1:
				total += 1
				hasil += total
print(hasil)


(a, b) = map(int, input().split())
c = 0
d = []
for i in range(a):
	s = [int(i) for i in input().split()]
	d.append(s)
for i in d:
	for j in range(0, len(i) - 1, 2):
		if i[j] or i[j + 1] == 1:
			c += 1
		else:
			pass
print(c)


(n, m) = [int(x) for x in input().split()]
windows = 2 * m + 1
counter = 0
for i in range(n):
	floor = [int(x) for x in input().split()]
	for i in range(0, windows, 2):
		if 1 in floor[i:i + 2]:
			counter += 1
print(counter)


(n, m) = map(int, input().split())
count = 0
while n:
	a = list(map(int, input().split()))
	a_len = len(a)
	while a_len > 0:
		if a[a_len - 1] or a[a_len - 2]:
			count = count + 1
		a_len = a_len - 2
	n = n - 1
print(count)


import time
(n, m) = (int(i) for i in input().split())
app = []
for i in range(n):
	app.append([0 for j in range(m)])
	a = [int(j) for j in input().split()]
	for j in range(len(a)):
		app[i][divmod(j, 2)[0]] += a[j]
start = time.time()
s = 0
for i in range(n):
	s += sum([1 for j in app[i] if j > 0])
print(s)
finish = time.time()


line1 = input()
(floorsNo, flats_in_floor) = line1.split(' ')
floors = []
for floor in range(int(floorsNo)):
	floors.append(input())
	floors[floor] = floors[floor].replace(' ', '')
people = 0
totalwindows = int(flats_in_floor) * 2
for floor in range(len(floors)):
	for flat in range(0, totalwindows, 2):
		if floors[floor][flat:2 + flat].count('1') > 0:
			people += 1
print(people)


import re
import sys
import math
import itertools
import collections

def inputArray(TYPE=int):
	return [TYPE(x) for x in input().split()]

def solve():
	(n, m) = inputArray()
	cc = 0
	for x in range(n):
		a = inputArray()
		i = 0
		while i < 2 * m:
			cc += 1 if a[i] + a[i + 1] > 0 else 0
			i += 2
	print(cc)
solve()


import math
(n, k) = list(map(int, input().split()))
m = 0
while n:
	arr = list(map(int, input().split()))
	for i in range(2 * k - 1):
		if i % 2 == 0:
			if arr[i] == 1 or arr[i + 1] == 1:
				m = m + 1
	n = n - 1
print(m)


(N, M) = map(int, input().split())
Sum = 0
for i in range(N):
	a = list(map(int, input().split()))
	for j in range(M):
		if a[2 * j] or a[2 * j + 1]:
			Sum += 1
print(Sum)


__author__ = 'suvasish'
lights = []
(n, m) = input().split(' ')
count = 0
for t in range(0, int(n)):
	lights = list(map(int, input().split(' ')))
	i = 0
	while i < len(lights):
		if lights[i] or lights[i + 1] == 1:
			count += 1
		i += 2
print(count)


h = 0
for _ in range(int(input().split()[0])):
	s = input().split()
	while len(s):
		if '1' in [s.pop(), s.pop()]:
			h += 1
print(h)


import math
from decimal import *
import sys
from fractions import Fraction
inp = input().split()
n = int(inp[0])
m = int(inp[1])
ans = 0
for i in range(0, n):
	row = list(map(int, input().split()))
	for j in range(0, m):
		if row[2 * j] == 1 or row[2 * j + 1] == 1:
			ans += 1
print(ans)


(n, m) = [int(x) for x in input().split(' ')]
A = []
for i in range(n):
	for x in [int(x) for x in input().split(' ')]:
		A.append(x)
t = 0
for i in range(int(len(A) / 2)):
	a = A[2 * i]
	b = A[2 * i + 1]
	if a + b != 0:
		t += 1
print(t)


(n, m) = map(int, input().split())
c = 0
for _ in range(n):
	arr = list(map(int, input().split()))
	for i in range(0, 2 * m, 2):
		if arr[i] == 1 or arr[i + 1] == 1:
			c += 1
print(c)


(floor, flat) = map(int, input().split())
awake = 0
for i in range(floor):
	l = list(map(int, input().split()))
	for i in range(0, 2 * flat - 1, 2):
		if l[i] == 1 or l[i + 1] == 1:
			awake += 1
print(awake)


f = 0
v = []
(n, m) = map(int, input().split())
for i in range(n):
	l = list(map(int, input().split()))
	for j in range(len(l)):
		v.append(l[j])
for i in range(0, len(v) - 1, 2):
	if v[i] == 1 or v[i + 1] == 1:
		f += 1
print(f)


def main_function():
	(n, m) = [int(i) for i in input().split(' ')]
	count = 0
	for i in range(n):
		f = [int(i) for i in input().split(' ')]
		already_list_on = False
		for j in range(len(f)):
			if not j % 2 and f[j] == 1:
				count += 1
				already_list_on = True
			elif j % 2 and f[j] == 1 and (not already_list_on):
				count += 1
				already_list_on = False
			elif j % 2:
				already_list_on = False
	return count
print(main_function())


inp = input().split(' ')
n = int(inp[0])
m = int(inp[1])
count = 0
for floorNum in range(n):
	line = input().split(' ')
	for flat in range(0, m):
		if 1 == int(line[2 * flat]) or 1 == int(line[2 * flat + 1]):
			count += 1
print(count)


(n, m) = map(int, input().split())
sum = 0
while n:
	n -= 1
	a = list(map(int, input().split()))
	for i in range(0, 2 * m - 1, 2):
		sum += a[i] or a[i + 1]
print(sum)


import time

def isAwakeFlat(ligth1, light2):
	awake = False
	if ligth1 == 0 and light2 == 0:
		awake = False
	else:
		awake = True
	return awake

def countFlatsAwake(floors, flats, buildingList):
	awakenFlats = 0
	for floor in buildingList:
		for flat in range(0, flats * 2, 2):
			res = isAwakeFlat(floor[flat], floor[flat + 1])
			if res == True:
				awakenFlats += 1
	return awakenFlats

def solve():
	(floors, flats) = [int(x) for x in input().split()]
	buildingList = []
	for floor in range(floors):
		buildingList.append([int(y) for y in input().split()])
	print(countFlatsAwake(floors, flats, buildingList))
solve()


fnf = list(map(int, input().split()))
lit = 0
for i in range(fnf[0]):
	a = list(map(int, input().split()))
	for j in range(fnf[1]):
		k = j + 1
		if a[2 * k - 1] == 1 or a[2 * k - 2] == 1:
			lit += 1
print(lit)


(n, m) = input().split()
awake = 0
for x in range(int(n)):
	windows = list(map(int, input().split()))
	for y in range(0, len(windows), 2):
		if windows[y] == 1 or windows[y + 1] == 1:
			awake += 1
print(awake)


from sys import stdin
(n, m) = map(int, stdin.readline().split())
l = []
for i in range(n):
	l.append(list(map(int, stdin.readline().split())))
count = 0
for i in range(n):
	for j in range(0, 2 * m, 2):
		if l[i][j] == 1 or l[i][j + 1] == 1:
			count += 1
print(count)


(n, m) = map(int, input().split())
co = 0
for _ in range(n):
	a = list(map(str, input().split()))
	a = ''.join(a)
	for i in range(0, len(a) - 1, 2):
		if a[i] == '1' or a[i + 1] == '1':
			co += 1
print(co)


l = list(map(int, input().split()))
total = 0
for i in range(l[0]):
	l1 = list(map(int, input().split()))
	for j in range(0, len(l1), 2):
		if l1[j] == 1 or l1[j + 1] == 1:
			total += 1
print(total)


(floor, flat) = list(map(int, input().split()))
score = 0
for _ in range(floor):
	lights = list(map(int, input().split()))
	for idx in range(0, flat * 2, 2):
		if 1 in [lights[idx], lights[idx + 1]]:
			score += 1
print(score)


(n, m) = map(int, input().split())
total_ = 0
for i in range(n):
	arr = list(map(int, input().split()))
	for j in range(0, len(arr), 2):
		if arr[j] == 1 or arr[j + 1] == 1:
			total_ += 1
		else:
			continue
print(total_)


def Flats():
	(n, m) = list(map(int, input().split()))
	apartment = []
	for i in range(n):
		apartment.extend(list(map(int, input().split())))
	times = 0
	for i in range(0, len(apartment), 2):
		if 1 in apartment[i:i + 2]:
			times += 1
	print(times)
Flats()


(a, b) = map(int, input().split())
l = []
for i in range(a):
	li = list(map(int, input().split()))
	l.append(li)
count = 0
for j in range(0, 2 * b, 2):
	for k in l:
		if 1 in k[j:j + 2]:
			count += 1
		else:
			continue
print(count)


(n, m) = map(int, input().split())
k = int(0)
for _ in range(n):
	a = list(map(int, input().split()))
	x = int(0)
	while x < 2 * m:
		if a[x] == 1 or a[x + 1] == 1:
			k = k + 1
		x = x + 2
print(k)


(n, m) = map(int, input().split())
r = 0
for i in range(n):
	floor = list(map(int, input().split()))
	for j in range(m):
		if sum(floor[2 * j:2 * j + 2]):
			r += 1
print(r)


(n, m) = map(int, input().split())
l = 0
for i in range(n):
	arr = list(map(int, input().split()))
	j = 1
	while j < len(arr):
		if arr[j - 1] == 1 or arr[j] == 1:
			l += 1
		j += 2
print(l)


(x, y) = map(int, input().split())
z = []
k = 0
for i in range(x):
	a = list(map(int, input().split()))
	z.append(a)
for i in range(x):
	for j in range(0, 2 * y, 2):
		if z[i][j] == 1 or z[i][j + 1] == 1:
			k = k + 1
print(k)


(n, m) = [int(x) for x in input().split()]
num = 0
floors = []
flats = []
i = 1
while i <= n:
	for x in [int(x) for x in input().split()]:
		flats.append(x)
	floors.append(flats)
	flats = []
	i += 1
i = 0
while i < n:
	j = 1
	while j < 2 * m:
		if floors[i][j] + floors[i][j - 1] is not 0:
			num += 1
		j += 2
	i += 1
print(num)


lightFlats = 0
(floors, flats) = map(int, input().split(' '))
for i in range(floors):
	flatsLightings = list(map(int, input().split(' ')))
	for j in range(1, flats * 2, 2):
		if flatsLightings[j] == 1 or flatsLightings[j - 1] == 1:
			lightFlats += 1
print(lightFlats)


def curFloor(arr):
	res = 0
	for i in range(0, len(arr), 2):
		if arr[i] == 1 or arr[i + 1] == 1:
			res += 1
	return res
(n, m) = [int(x) for x in input().split()]
ans = 0
for i in range(n):
	arr = [int(x) for x in input().split()]
	ans += curFloor(arr)
print(ans)


(n, m) = map(int, input().split())
s = 0
for i in range(n):
	l = list(map(int, input().split()))
	for i in range(1, len(l), 2):
		if l[i - 1] == 0 and l[i] == 1 or (l[i - 1] == 1 and l[i] == 1) or (l[i - 1] == 1 and l[i] == 0):
			s += 1
print(s)


(n, m) = [int(i) for i in input().split()]
c = 0
for i in range(n):
	x = [int(j) for j in input().split()]
	for k in range(2 * m):
		if k % 2 == 1:
			if x[k] == 1 or x[k - 1] == 1:
				c = c + 1
print(c)


line1 = input().split(' ')
floors = int(line1[0])
flats_every_floor = int(line1[1])
all_flats = int(line1[0]) * int(line1[1])
awake_flats = 0
counter = 0
for floor in range(floors):
	line = input().split(' ')
	for flat in range(flats_every_floor):
		if int(line[flat + counter]) or int(line[flat + counter + 1]) == 1:
			awake_flats += 1
		counter += 1
	counter = 0
print(awake_flats)


(n, m) = map(int, input().split())
cnt = 0
for i in range(n):
	arr = []
	arr.extend(map(int, input().split()))
	for i in range(0, len(arr) - 1, 2):
		if arr[i] == 1 or arr[i + 1] == 1:
			cnt += 1
print(cnt)


(floor, per_floor) = list(map(int, input().split()))
result = 0
for i in range(floor):
	l = list(map(int, input().split()))
	for j in range(per_floor):
		if l[j * 2] == 1 or l[j * 2 + 1] == 1:
			result += 1
print(result)


(n, m) = [int(x) for x in input().split()]
alpha = 0
alpha1 = 0
for _ in range(n):
	x = [int(x) for x in input().split()]
	for i in range(0, len(x), 2):
		if x[i] == x[i + 1] == 0:
			alpha += 0
		else:
			alpha1 += 1
print(alpha + alpha1)


(n, m) = map(int, input().split())
x = []
t = 0
for i in range(n):
	x += list(map(int, input().split()))
i = 0
while True:
	if x[i] or x[i + 1] == 1:
		t += 1
	i += 2
	if i >= n * m * 2:
		break
print(t)


f = lambda : map(int, input().split())
(n, m) = f()
flt = 0
while n:
	fl = list(f())
	flt += sum((fl[i - 1] + fl[i] > 0 for i in range(1, m * 2, 2)))
	n -= 1
print(flt)


tmp = input().split()
n = int(tmp[0])
m = int(tmp[1])
count = 0
for i in range(n):
	status = [int(k) for k in input().split()]
	while len(status):
		if status.pop() + status.pop() > 0:
			count += 1
print(count)


(n, k) = map(int, input().split())
c = 0
for _ in range(n):
	list1 = list(map(int, input().split()))
	for i in range(0, len(list1), 2):
		if list1[i] == 1 or list1[i + 1] == 1:
			c = c + 1
print(c)


(floors, flats) = map(int, input().split())
flats_with_lights_on = 0
for floor in range(0, floors):
	lights = list(map(int, input().split()))
	for l in range(0, len(lights), 2):
		if lights[l] == 1 or lights[l + 1] == 1:
			flats_with_lights_on += 1
print(flats_with_lights_on)


n = list(map(int, input().split()))
t = 0
b = []
for i in range(n[0]):
	b.append(list(map(int, input().split())))
	j = 0
	for e in range(n[1]):
		if b[i][j] == 1 or b[i][j + 1] == 1:
			t = t + 1
		j = j + 2
print(t)


(n, m) = map(int, input().split())
q = 0
for i in range(0, n):
	mas = list(map(int, input().split()))
	i = 0
	while i < m * 2:
		if mas[i] == 1:
			q += 1
		if mas[i] == 1 and (i + 1) % 2 == 1:
			i += 2
		else:
			i += 1
print(q)


(n, m) = map(int, input().split())
ans = 0
for i in range(n):
	a = list(map(int, input().split()))
	j = 0
	while j < len(a):
		if j % 2:
			if a[j]:
				ans += 1
			j += 1
		elif a[j]:
			ans += 1
			j += 2
		else:
			j += 1
print(ans)


(n, m) = [int(x) for x in input().split()]
ma = [[int(x) for x in input().split()] for q in range(n)]
z = 0
for x in range(n):
	for y in range(0, m * 2, 2):
		if ma[x][y] + ma[x][y + 1] >= 1:
			z += 1
print(z)


(a, b) = [int(tmp) for tmp in input().split()]
ar = []
for i in range(a):
	x = [int(tmp) for tmp in input().split()]
	ar.append(x)
ans = 0
for i in range(a):
	for j in range(0, 2 * b, 2):
		if ar[i][j] == 1 or ar[i][j + 1] == 1:
			ans += 1
print(ans)


(n, m) = map(int, input().split())
ans = 0
for _ in range(n):
	windows = list(map(int, input().split()))
	ans += sum((min(1, windows[i] + windows[i + 1]) for i in range(0, m * 2, 2)))
print(ans)


(n, m) = input().split()
(n, m) = (int(n), int(m))
c = 0
for x in range(1, n + 1):
	windows = input().split()
	for w in range(0, len(windows), 2):
		if windows[w] == '1' or windows[w + 1] == '1':
			c += 1
print(c)


(n, m) = map(int, input().split())
ct = 0
for _ in range(n):
	w = list(map(int, input().split()))
	for i in range(0, 2 * m, 2):
		if w[i] == 1 or w[i + 1] == 1:
			ct += 1
print(ct)


(n, m) = list(map(int, input().split()))
count = 0
b = []
for i in range(n):
	l = list(map(int, input().split()))
	b.append(len(l))
	for i in range(len(l)):
		if i != len(l) - 1 and l[i] == 0 and (l[i + 1] == 0) and ((i + 1) % 2 != 0):
			count += 1
s = sum(b)
x = int(s / 2)
print(x - count)


(floors_n, flats_m) = input().split()
data = {}
Output = 0
print('')
for i in range(int(floors_n)):
	s = input().split()
	data[i] = s
	s = []
for i in range(int(floors_n)):
	q = data[i]
	for n in range(int(flats_m)):
		w1 = q[2 * n]
		w2 = q[2 * n + 1]
		if w1 == '1' or w2 == '1':
			Output += 1
print(Output)


import sys
input = sys.stdin.readline

def gint():
	return int(input())

def gint_arr():
	return list(map(int, input().split()))

def gfloat():
	return float(input())

def gfloat_arr():
	return list(map(float, input().split()))

def pair_int():
	return map(int, input().split())
INF = 1 << 31
MOD = '1000000007'
dx = [-1, 0, 1, 0]
dy = [0, 1, 0, -1]
(n, m) = gint_arr()
grid = []
res = 0
for i in range(n):
	grid.extend(gint_arr())
for i in range(0, n * m * 2, 2):
	res += grid[i] or grid[i + 1]
print(res)


(n, m) = [int(i) for i in input().split()]
ans = 0
for _ in range(n):
	a = [int(i) for i in input().split()]
	b = [0] * m
	for i in range(m):
		if a[2 * i] + a[2 * i + 1] > 0:
			ans += 1
print(ans)


(n, m) = map(int, input().split())
windows = [list(map(int, input().split())) for _ in range(n)]
on = 0
for i in range(n):
	for j in range(m):
		on += windows[i][2 * j] or windows[i][2 * j + 1]
print(on)


(n, m) = map(int, input().split())
res = 0
for i in range(n):
	temp = list(map(int, input().split()))
	for j in range(0, len(temp), 2):
		res += max(temp[j], temp[j + 1])
print(res)


(n, m) = map(int, input().split())
r = 0
for i in range(n):
	x = list(map(int, input().split()))
	for j in range(0, 2 * m, 2):
		if x[j] == 1 or x[j + 1] == 1:
			r = r + 1
print(r)


import sys
(n, m) = map(int, sys.stdin.readline().split())
ans = 0
for i in range(n):
	windows = list(map(int, sys.stdin.readline().split()))
	for j in range(m):
		if windows[2 * j] == 1 or windows[2 * j + 1]:
			ans += 1
print(ans)


x = list(map(int, input().split(' ')))
a = 0
y = []
for i in range(x[0]):
	y.append(list(map(int, input().split(' '))))
for i in y:
	for k in [l for l in range(0, len(i), 2)]:
		if i[k] == 1 or i[k + 1] == 1:
			a += 1
		else:
			pass
print(a)


(x, y) = map(int, input().split())
awake = 0
y *= 2
for i in range(x):
	userList = list(map(int, input().split()))
	for j in range(0, y, 2):
		if userList[j] == 1 or userList[j + 1] == 1:
			awake += 1
print(awake)


nm = input().split()
counter = 0
for x in range(int(nm[0])):
	n = list(map(int, input().split()))
	for x in range(0, int(nm[1]) * 2, 2):
		if n[x] + n[x + 1] > 0:
			counter += 1
print(counter)


from sys import stdin
live = True
if not live:
	stdin = open('data.in', 'r')
(n, m) = list(map(int, stdin.readline().strip().split()))
ans = 0
for floors in range(n):
	floor = list(map(int, stdin.readline().strip().split()))
	for flat in range(m):
		ans += floor[2 * flat] | floor[2 * flat + 1]
print(ans)
if not live:
	stdin.close()


(x, y) = list(map(int, input().split()))
llist = []
for i in range(x):
	list1 = list(map(int, input().split()))
	for i in list1:
		llist.append(i)
count = 0
for i in range(0, len(llist) - 1, 2):
	if llist[i] == 1 or llist[i + 1] == 1:
		count += 1
print(count)


i = input
c = 0
(n, m) = map(int, i().split())
for j in range(n):
	l = [*map(str, i().split())]
	a = len(l) // m
	qq = 0
	ww = a
	for j in range(m):
		if '1' in l[qq:ww]:
			c += 1
		qq += a
		ww += a
print(c)


(n, m) = map(int, input().split())
(x, y) = ([], [])
ans = 0
for i in range(n):
	l = list(map(int, input().split()))
	for i in range(0, m * 2, 2):
		x.append(l[i])
	for i in range(1, m * 2, 2):
		y.append(l[i])
for i in range(len(x)):
	if x[i] == 1 or y[i] == 1:
		ans += 1
print(ans)


(a, n) = map(int, input().split())
count = 0
for i in range(a):
	L = list(map(int, input().split()))
	for i in range(2 * n):
		if L[i] == 1:
			count += 1
			if i % 2 == 0:
				L[i + 1] = 0
print(count)


x = [int(x) for x in input().split()]
(s, b) = (0, 0)
while s < x[0]:
	a = [int(a) for a in input().split()]
	r = 0
	while r < len(a):
		if a[r] == 1:
			b = b + 1
			if r % 2 == 0:
				r = r + 2
			else:
				r = r + 1
		else:
			r = r + 1
	s = s + 1
print(b)


T_ON = 0
DEBUG_ON = 1
MOD = 998244353

def solve():
	(n, m) = read_ints()
	count = 0
	for i in range(n):
		A = read_ints()
		for j in range(0, 2 * m, 2):
			if A[j] + A[j + 1] > 0:
				count += 1
	print(count)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def fib_to_n(n):
	f = []
	(a, b) = (0, 1)
	while a <= n:
		f.append(a)
		(a, b) = (b, a + b)
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


a = lambda : map(int, input().split())
(n, m) = a()
s = 0
for __ in range(n):
	l = list(a())
	s += sum([l[i * 2] + l[i * 2 + 1] > 0 for i in range(m)])
print(s)


(n, m) = map(int, input().split())
c = 0
for i in range(n):
	a = input().split()
	j = 0
	while j < m * 2:
		b = int(a[j]) + int(a[j + 1])
		if b > 0:
			c += 1
		j += 2
print(c)


(a, b) = map(int, input().split())
k = 0
for case in ' ' * a:
	c = input().replace(' ', '')
	k = k + sum((1 for i in range(b) if c[2 * i:2 * i + 2].count('1') > 0))
print(k)


x = input().split(' ')
floor = int(x[0])
flat = int(x[1])
t = 0
for i in range(floor):
	w = input().split(' ')
	for i in range(len(w) // 2):
		if w[2 * i] == '1' or w[2 * i + 1] == '1':
			t += 1
print(t)


(n, m) = map(int, input().split())
co = 0
Flag = False
for floor in range(n):
	win = list(map(int, input().split()))
	for t in range(2 * m):
		if win.pop() == 1:
			Flag = True
		if t % 2 == 1:
			if Flag == True:
				co += 1
			Flag = False
print(co)


(n, m) = [int(x) for x in input().split()]
result = 0
for _ in range(n):
	floor = [int(x) for x in input().split()]
	for i in range(0, 2 * m, 2):
		result += floor[i] | floor[i + 1]
print(result)


(n, m) = list(map(int, input().split()))
f = [list(map(int, input().split())) for p in range(n)]
s = 0
for p in range(n):
	for q in range(m * 2):
		if q % 2 == 0:
			if f[p][q] == 1 or f[p][q + 1] == 1:
				s += 1
print(s)


(n, m) = input().split()
(n, m) = map(int, [n, m])
A = []
for i in range(0, n):
	s = input()
	B = []
	for j in s.split():
		B.append(int(j))
	A.append(B)
count = 0
for k in range(0, n):
	for l in range(0, 2 * m, 2):
		if A[k][l] or A[k][l + 1] == 1:
			count = count + 1
print(count)


(a, b) = map(int, input().split())
count1 = 0
for i in range(a):
	l = list(map(int, input().split()))
	for j in range(b):
		if l[j * 2] or l[j * 2 + 1]:
			count1 += 1
print(count1)


def answer():
	z = [int(x) for x in input().split()]
	(n, m) = (z[0], z[1])
	ans = 0
	while n:
		a = [int(x) for x in input().split()]
		i = 0
		while i < len(a):
			if a[i] or a[i + 1]:
				ans += 1
			i += 2
		n -= 1
	print(ans)
answer()


l = [int(x) for x in input().split()]
n = l[0]
k = l[1]
count = 0
for o in range(n):
	s = input().split()
	i = 0
	while i < 2 * k:
		if s[i] == '1' or s[i + 1] == '1':
			count += 1
		i += 2
print(count)


(a, b) = map(int, input().split())
s = 0
for i in range(a):
	x = list(map(int, input().split()))
	for j in range(b):
		if any(x[2 * j:2 * j + 2]):
			s += 1
print(s)


(n, m) = [int(i) for i in input().split()]
t = 0
for i in range(n):
	a = [int(i) for i in input().split()]
	p = 0
	while p < m * 2:
		if a[p] == 1 or a[p + 1] == 1:
			t = t + 1
		p += 2
print(t)


(n, m) = map(int, input().split())
res = 0
for _ in range(n):
	s = input().split()
	res += sum(map(lambda x, y: int(x) or int(y), s[::2], s[1::2]))
print(res)


n = [int(j) for j in input().split()]
w = 0
for k in range(n[0]):
	s = [int(j) for j in input().split()]
	for j in range(n[1]):
		if s[2 * j] + s[2 * j + 1] > 0:
			w += 1
print(w)


(n, m) = (int(i) for i in input().split())
c = 0
for i in range(n):
	l = [int(i) for i in input().split()]
	for i in range(0, 2 * m, 2):
		if l[i] == 1:
			l[i + 1] = 0
			c += 1
	for i in range(1, 2 * m, 2):
		if l[i] == 1:
			c += 1
print(c)


(n, m) = map(int, input().split())
answer = 0
for i in range(n):
	row = list(map(int, input().split()))
	for j in range(m):
		answer += row[2 * j] or row[2 * j + 1]
print(answer)


n = list(map(int, input().split()))
w = 0
for i in range(n[0]):
	k = list(map(int, input().split()))
	t = 1
	for j in range(n[1]):
		if k[t] == 1 and k[t - 1] == 1:
			w += 1
			t += 2
		elif k[t] == 0 and k[t - 1] == 1:
			w += 1
			t += 2
		elif k[t] == 1 and k[t - 1] == 0:
			w += 1
			t += 2
		else:
			t += 2
print(w)


def piter(s):
	b = True
	for x in s:
		if b:
			p = x
		else:
			yield (p, x)
			del p
		b = not b
	if not b:
		yield (p, None)

def awake(windows):
	k = 0
	for row in windows:
		for (w1, w2) in piter(row):
			k += bool(w1 or w2)
	return k
(n, m) = map(int, input().split())
windows = (map(int, input().split()) for _ in range(n))
print(awake(windows))


a = input().split()
n = int(a[0])
m = int(a[1])
b = []
c = ''
for i in range(n):
	b = input().split()
	for j in range(m):
		c += str(int(b[j * 2]) or int(b[j * 2 + 1]))
print(c.count('1'))


(n, m) = map(int, input().split())
bl = []
for i in range(n):
	tmp = [int(i) for i in input().split()]
	bl.append(tmp)
win = 0
for i in range(n):
	for j in range(2 * m - 1):
		if j % 2 == 0:
			if bl[i][j] == 1 or bl[i][j + 1] == 1:
				win += 1
print(win)


def lit_lights(windows):
	lights = 0
	for window in windows:
		for i in range(len(window) // 2):
			if window[2 * i] + window[2 * i + 1] > 0:
				lights += 1
	return lights
(n, m) = map(int, input().split())
windows = []
for i in range(n):
	window = []
	numbers = list(map(int, input().split()))
	windows.append(numbers)
print(lit_lights(windows))


(n, m) = map(int, input().split())
c = 0
for _ in range(n):
	row = list(map(int, input().split()))
	for j in range(0, len(row), 2):
		if row[j] or row[j + 1]:
			c += 1
print(c)


(n, m) = input().split()
n = int(n)
m = int(m)
ans = 0
for i in range(n):
	t = [int(j) for j in input().split()]
	k = 0
	while k < len(t):
		if t[k] == 1 or t[k + 1] == 1:
			ans += 1
		k += 2
print(ans)


g = list(map(int, input().split()))
k = 2
result = []
b = 0
l = 0
k = 2
for i in range(g[0]):
	h = [int(t) for t in input().split()]
	for j in range(g[1]):
		for t in range(l, k):
			b += h[t]
		if b >= 1:
			result.append(True)
		b = 0
		(l, k) = (k, k + 2)
	(l, k) = (0, 2)
print(result.count(True))


s = input()
a = s.split(' ')
(n, m) = (int(a[0]), int(a[1]))
k = 0
while n > 0:
	n -= 1
	s = input()
	a = s.split(' ')
	for j in range(1, m + 1):
		if a[2 * j - 2] == '1' or a[2 * j - 1] == '1':
			k += 1
print(k)


import sys
Input = sys.stdin.readline
sum = 0
(x, y) = list(map(int, input().split()))
for i in range(x):
	m = list(map(int, input().split()))
	for j in range(0, 2 * y, 2):
		if m[j] or m[j + 1]:
			sum += 1
print(sum)


(n, m) = [int(n) for n in input().split()]
window = list()
ans = 0
for i in range(0, n):
	window = window + [int(window) for window in input().split()]
	for j in range(0, 2 * m, 2):
		if window[j] + window[j + 1] > 0:
			ans = ans + 1
	del window[0:]
print(ans)


(n, m) = map(int, input().split(' '))
litFlats = 0
for floor in range(n):
	windows = list(map(int, input().split(' ')))
	for flat in range(m):
		if windows[flat * 2] + windows[flat * 2 + 1] > 0:
			litFlats += 1
print(litFlats)


(N, M) = map(int, input().split())
table = []
for i in range(N):
	table.append(list(map(int, input().split())))
ans = 0
for i in range(N):
	for j in range(M):
		if table[i][2 * j] == 1 or table[i][2 * j + 1] == 1:
			ans += 1
print(ans)


input_ = input().split(' ')
(n, m) = input_
(n, m) = (int(n), int(m))
count = 0
b = ''
for i in range(n):
	a = input()
	b += a
	b = b.replace(' ', '')
for j in range(0, len(b), 2):
	if (int(b[j]) or int(b[j + 1])) == 1:
		count += 1
print(count)


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
from types import CodeType, new_class
(n, m) = map(int, input().split())
ans = 0
for x in range(n):
	a = input().split()
	for y in range(0, m * 2, 2):
		if a[y] == '1' or a[y + 1] == '1':
			ans += 1
print(ans)


(n, m) = map(int, input().split())
output = 0
for i in range(n):
	win = list(map(int, input().split()))
	for j in range(0, 2 * m, 2):
		if win[j] + win[j + 1] > 0:
			output += 1
print(output)


x = input()
x = x.split(' ')
floors = []
count = 0
for y in range(int(x[0])):
	temp = input()
	temp = temp.split(' ')
	floors.append(temp)
for g in range(int(x[0])):
	for u in range(int(int(x[1]))):
		if int(floors[g][u * 2]) == 1 or int(floors[g][u * 2 + 1]) == 1:
			count += 1
print(count)


(s, m) = map(int, input().split())
sm = []
for i in range(s):
	sm.append(list(map(int, input().split())))
c = 0
for l in range(s):
	for x in range(0, 2 * m, 2):
		if sm[l][x] == 1 or sm[l][x + 1] == 1:
			c += 1
print(c)


import sys
(n, m) = (int(i) for i in input().split())
ans = 0
for i in range(n):
	lst = [int(j) for j in input().split()]
	for j in range(m):
		if lst[2 * j] == 1 or lst[2 * j + 1] == 1:
			ans += 1
print(ans)


import sys
awake = 0
for floor in sys.stdin.readlines()[1:]:
	for flat in zip(*[iter(floor[:-1].split())] * 2):
		awake += sum(map(int, flat)) > 0
print(awake)


(n, m) = map(int, input().split())
cnt = 0
for i in range(n):
	x = [int(x) for x in input().split()]
	for j in range(0, len(x) - 1, 2):
		if x[j] + x[j + 1] > 0:
			cnt += 1
print(cnt)


(n, m) = input().split()
n = int(n)
m = int(m)
result = 0
for i in range(n):
	data = input().split()
	for j in range(m):
		if int(data[2 * j]) == 1 or int(data[2 * j + 1]) == 1:
			result += 1
print(result)


data = input().strip().split()
mas = []
col = 0
for i in range(int(data[0])):
	mas.append(input().strip().split())
	for j in range(1, len(mas[i]), 2):
		if mas[i][j] == '1' or mas[i][j - 1] == '1':
			col += 1
print(col)


def solve(arr, m):
	count = 0
	for floor in arr:
		for i in range(0, len(floor), 2):
			count += 1 if sum(floor[i:i + 2]) >= 1 else 0
	return count

def main():
	(n, m) = map(int, input().split(' '))
	arr = []
	for i in range(n):
		arr.append(list(map(int, input().split(' '))))
	print(solve(arr, m))
main()


(n, m) = input('').split()
sum = 0
ind = 0
prev = 0
for i in range(int(n)):
	x = input('').split()
	for i in x:
		if int(i) == 1 and ((ind == 0 or ind % 2 == 0) or (ind % 2 != 0 and prev == 0)):
			sum += 1
		ind += 1
		prev = int(i)
print(sum)


(n, m) = [int(x) for x in input().split()]
num = 0
flats = []
i = 1
while i <= n:
	for (step, x) in enumerate([int(x) for x in input().split()]):
		flats.append(x)
		if step % 2 is 1 and flats[step] + flats[step - 1] is not 0:
			num += 1
	flats = []
	i += 1
print(num)