import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    string s;
    do{
        char[][] m;
        while((s=readln()).chomp().length) m~=s.chomp().to!(char[]);
        void update(int x, int y)
        {
            if(x<0 || m.length<=x || y<0 || m[x].length<=y)
                return;
            if(m[x][y]=='0') return;
            m[x][y]='0';
            foreach(a;[[1,0],[-1,0],[0,1],[0,-1]])
                update(x+a[0],y+a[1]);
        }
        int c=0;
        foreach(x;0..cast(int)(m.length))
            foreach(y;0..cast(int)(m[x].length))
                if(m[x][y]=='1') ++c,update(x,y);
        writeln(c);
    }while(s.length);
}