Approach
Iterate every cell; on an unvisited 1, increment the count and flood-fill (BFS) all 4-directionally connected land, marking it visited.
import sys
from collections import deque
data = [l for l in sys.stdin.read().split('\n')]
r, c = map(int, data[0].split())
grid = [data[1 + i] for i in range(r)]
seen = [[False] * c for _ in range(r)]
islands = 0
for i in range(r):
for j in range(c):
if grid[i][j] == '1' and not seen[i][j]:
islands += 1
q = deque([(i, j)])
seen[i][j] = True
while q:
x, y = q.popleft()
for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
nx, ny = x + dx, y + dy
if 0 <= nx < r and 0 <= ny < c and grid[nx][ny] == '1' and not seen[nx][ny]:
seen[nx][ny] = True
q.append((nx, ny))
print(islands)