#include <bits/stdc++.h>
using namespace std;

int bfs(vector<string> &m) {
  bool used[12][12];
  for (int i=0; i<12; i++) {
    for (int j=0; j<12; j++) {
      used[i][j] = false;
    }
  }
  int cnt = 0;

  for (int i=0; i<12; i++) {
    for (int j=0; j<12; j++) {
      if (used[i][j]) {
        continue;
      }
      if (m[i][j] == '0') {
        continue;
      }
      queue<pair<int, int> > que;
      que.push({i, j});
      while (!que.empty()) {
        auto f = que.front();
        que.pop();
        int y = f.first;
        int x = f.second;
        if (used[y][x]) continue;
        if (m[y][x] == '0') continue;

        used[y][x] = true;

        if (y > 0) que.push({y-1, x});
        if (y < 11) que.push({y+1, x});
        if (x > 0) que.push({y, x-1});
        if (x < 11) que.push({y, x+1});
      }
      ++cnt;
    }
  }
  return cnt;
}
int main() {
  while (true) {
    vector<string> m(12);
    for (int i=0; i<12; i++) {
      cin>>m[i];
      if (m[i].empty()) {
        return 0;
      }
    }
    cout<<bfs(m)<<endl;
  }
}
