#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;

class Mapmake{
  public:
    int map[20*20];
    void mapmake(int);
};

int main(){
  Mapmake mk;
  int i,l;
  int ans;
  
  for(;;){
    memset(mk.map,0,sizeof(mk.map));
    ans=0;
    for(i=0;i<12;i++){
      for(l=0;l<12;l++){
        mk.map[i*12+l]=getchar();
      
        if(mk.map[i*12+l]==' '||mk.map[i*12+l]=='\n')
          mk.map[i*12+l]=getchar();
        mk.map[i*12+l]-=48;
      }
    }
  
    for(i=0;i<12;i++){
      for(l=0;l<12;l++){
        if(mk.map[i*12+l]==1){
          mk.mapmake(i*12+l);
          ans++;
        }
      }
    }
    
    printf("%d\n",ans);
  }
  return 0;
}

void Mapmake::mapmake(int now_p){
  int houi[]={-12,-1,1,12};
  int p;
  int i;
  queue<int> point;
  
  while(point.empty()==false)
    point.pop();
  
  point.push(now_p);
  map[now_p]=0;
  
  while(point.empty()==false){
    p=point.front();
    point.pop();
    for(i=0;i<4;i++){
      if(p%12==0&&houi[i]==-1) continue;
      if((p-11)%12==0&&houi[i]==1) continue;
      
      if(map[p+houi[i]]==1){
        point.push(p+houi[i]);
        map[p+houi[i]]=0;
      }
    }
  }
}