using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {


        static void Main(string[] args)
        {

            int[,] island = new int[12, 12];

            List<int> list = new List<int>();

            bool breakflag = false;

            while (true)
            {
                char[] input;

                island = new int[12, 12];

                for (int i = 0; i < 12; i++)
                {
                    string input2 = Console.ReadLine();

                    if (string.IsNullOrEmpty(input2))
                    {
                        input2 = Console.ReadLine();

                        if (string.IsNullOrEmpty(input2))
                        {
                            breakflag = true;
                            break;
                        }

                    }

                    input = input2.ToCharArray();



                    if (input.Length < 1)
                    {
                        i -= 1;
                        continue;

                    }

                    for (int j = 0; j < 12; j++)
                    {
                        island[i, j] = int.Parse(input[j].ToString());
                    }

                }

                if (breakflag) break;
                var test = new Island();

                list.Add(test.CheckIslandNum(island));

            }


            foreach (var result in list)
            {
                Console.WriteLine(result);
            }


        }


    }

    class Island
    {
        public int count = 0;

        public int err = 0;

        bool sideflag = false;
        bool verticalflag = false;


        //?????°?????????????????????????????????????????¨?¨????bool?????§???????????????????????????
        public int CheckIslandNum(int[,] island)
        {
            bool result = true;

            while (result == true)
            {
                result = false;


                for (int i = 0; i < 12; i++)
                {

                    for (int j = 0; j < 12; j++)
                    {
                        sideflag = false;
                        verticalflag = false;

                        if (island[i, j] == 1)
                        {
                            if (ExtractIsland(island, i, j, true, -1) == -1)
                            {
                                //?????????????????????
                                count += 1;

                                //??¶????????¨????????´?????????????????????????????????
                                result = true;
                                break;
                            }
                        }
                        else
                        {
                            result = false;
                            continue;
                        }

                    }

                    if (result) break;

                }

            }

            return count;

        }


        public int ExtractIsland(int[,] island, int tate, int side, bool config, int fist) //???config????????????????????¨?¨??????¨???(true????????????false????¨?)
        {

            island[tate, side] = 0;


            //????????°???0???1???????????????
            for (int i = tate + 1; i < 12; i++)
            {
                if (island[i, side] == 1)
                {
                    int tatecounter = ExtractIsland(island, i, side, true, 0);
                    this.verticalflag = true;
                    err += tatecounter;
                }
                else
                {
                    this.verticalflag = true;
                    break;
                }
            }


            if (!sideflag)
            {
                //?¨??????°???0???1???????????????
                for (int j = side + 1; j < 12; j++)
                {
                    if (island[tate, j] == 1)
                    {
                        int sidecounter = ExtractIsland(island, tate, j, false, 0);
                        this.sideflag = false;
                        err += sidecounter;
                    }
                    else
                    {
                        break;
                    }
                }

                //?????´?????¢?????????
                for (int h = side - 1; h >= 0; h--)
                {
                    if (island[tate, h] == 1)
                    {
                        int sidecounter = ExtractIsland(island, tate, h, false, 0);
                        this.sideflag = false;

                        err += sidecounter;
                    }
                    else
                    {
                        this.sideflag = true;
                        break;
                    }
                }
            }

            //???????????????????????¨?????????????????????
            if (verticalflag && sideflag)
            {
                sideflag = false;

                return -1;
            }

            sideflag = false;
            return -1;

        }

    }
}

Measured memory_bytes: 9148