while True:

  lst = []

  for i in range(12):

    ls = []

    s = eval(input())

    for j in range(12):

      ls.append(int(s[j]))

    lst.append(ls)

  xd = [0,1,0,-1]

  yd = [1,0,-1,0]

  count = 0

  def check(pt):

    if 11 < pt[0] or pt[0] < 0 or 11 < pt[1] or pt[1] < 0:

      return False

    elif(lst[pt[0]][pt[1]] == 1):

      lst[pt[0]][pt[1]] = 0

      for i in range(4):

        check([pt[0]+xd[i],pt[1]+yd[i]])

      return True

    else:

      return False

  def printMap():

    for i in range(12):

      st = ""

      for j in range(12):

        st = st + str(lst[i][j])

      print(st)

    print()

  for x in range(12):

    for y in range(12):

      if lst[x][y]:

        check([x,y])

        count += 1

        #printMap()

  print(count)

  try:

    eval(input())

  except EOFError:

    break

direct = ((0, -1), (0, 1), (-1, 0), (1, 0)) #移動方向



def search(x, y, mp): 

  if mp[x][y] == "1": #1を見つけたら0に書き換える

    mp[x][y] = "0"

    for dx, dy in direct: #4方向について繰り返す

      search(x + dx, y + dy, mp)

 

while True:

  #mp...全体のマップ、上下左右を0で囲っておく

  mp = [list("0" + eval(input()) + "0") for _ in range(12)]

  mp.insert(0, [0] * 14)

  mp.append([0] * 14)



  ans = 0



  for x in range(1, 13):

    for y in  range(1, 13):

      if mp[x][y] == "1":

        ans += 1

        search(x, y, mp)



  print(ans)



  try:

    eval(input())

  except EOFError:

    break

while True:
    lst = []
    for i in range(12):
        ls = []
        s = eval(input())
        for j in range(12):
            ls.append(int(s[j]))
        lst.append(ls)
    xd = [0, 1, 0, -1]
    yd = [1, 0, -1, 0]
    count = 0

    def check(pt):
        if 11 < pt[0] or pt[0] < 0 or 11 < pt[1] or pt[1] < 0:
            return False
        elif lst[pt[0]][pt[1]] == 1:
            lst[pt[0]][pt[1]] = 0
            for i in range(4):
                check([pt[0] + xd[i], pt[1] + yd[i]])
            return True
        else:
            return False

    def printMap():
        for i in range(12):
            st = ""
            for j in range(12):
                st = st + str(lst[i][j])
            print(st)
        print()

    for x in range(12):
        for y in range(12):
            if lst[x][y]:
                check([x, y])
                count += 1
                # printMap()
    print(count)
    try:
        eval(input())
    except EOFError:
        break

direct = ((0, -1), (0, 1), (-1, 0), (1, 0))  # 移動方向


def search(x, y, mp):
    if mp[x][y] == "1":  # 1を見つけたら0に書き換える
        mp[x][y] = "0"
        for dx, dy in direct:  # 4方向について繰り返す
            search(x + dx, y + dy, mp)


while True:
    # mp...全体のマップ、上下左右を0で囲っておく
    mp = [list("0" + eval(input()) + "0") for _ in range(12)]
    mp.insert(0, [0] * 14)
    mp.append([0] * 14)
    ans = 0
    for x in range(1, 13):
        for y in range(1, 13):
            if mp[x][y] == "1":
                ans += 1
                search(x, y, mp)
    print(ans)
    try:
        eval(input())
    except EOFError:
        break

+direct = ((0, -1), (0, 1), (-1, 0), (1, 0))  # 移動方向 + + +def search(x, y, mp): +    if mp[x][y] == "1":  # 1を見つけたら0に書き換える +        mp[x][y] = "0" +        for dx, dy in direct:  # 4方向について繰り返す +            search(x + dx, y + dy, mp) + + -    lst = [] -    for i in range(12): -        ls = [] -        s = eval(input()) -        for j in range(12): -            ls.append(int(s[j])) -        lst.append(ls) -    xd = [0, 1, 0, -1] -    yd = [1, 0, -1, 0] -    count = 0 - -    def check(pt): -        if 11 < pt[0] or pt[0] < 0 or 11 < pt[1] or pt[1] < 0: -            return False -        elif lst[pt[0]][pt[1]] == 1: -            lst[pt[0]][pt[1]] = 0 -            for i in range(4): -                check([pt[0] + xd[i], pt[1] + yd[i]]) -            return True -        else: -            return False - -    def printMap(): -        for i in range(12): -            st = "" -            for j in range(12): -                st = st + str(lst[i][j]) -            print(st) -        print() - -    for x in range(12): -        for y in range(12): -            if lst[x][y]: -                check([x, y]) -                count += 1 -                # printMap() -    print(count) +    # mp...全体のマップ、上下左右を0で囲っておく +    mp = [list("0" + eval(input()) + "0") for _ in range(12)] +    mp.insert(0, [0] * 14) +    mp.append([0] * 14) +    ans = 0 +    for x in range(1, 13): +        for y in range(1, 13): +            if mp[x][y] == "1": +                ans += 1 +                search(x, y, mp) +    print(ans)