#include <iostream>
#include <string>
using namespace std;

int main() {

  string input;

  while(true) {

    int map[13][13] = {0};
    int ans = 0;
    int cnt = 1;

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

      if ( getline( cin, input ) ) {
      }else {
	return 0;
      }

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

	if ( input[j] == '1' ) {

	  if ( map[j][i+1] != 0 && map[j+1][i] != 0 && map[j][i+1] != map[j+1][i] ) {

	    ans--;

	    int a = map[j][i+1];
	    int b = map[j+1][i];

	    for ( int x = 0; x < 12; x++ ) {
	      for ( int y = 0; y < 12; y++ ) {

		if ( map[x+1][y+1] == b ) map[x+1][y+1] = a;

	      }
	    }

	  }
	  if ( map[j][i+1] != 0 ) {
	    map[j+1][i+1] = map[j][i+1];
	  }else if ( map[j+1][i] != 0 ) {
	    map[j+1][i+1] = map[j+1][i];
	  }else {
	    map[j+1][i+1] = cnt;
	    cnt++;
	    ans++;
	  }

	}

      }

    }

    cout << ans << endl;

    getline( cin, input );

  }

  return 0;

}