#include <iostream>

using namespace std;

int main() {
  while (true) {
    int map[13][13] = {};

    for (int i = 1; i < 13; ++i) {
      for (int j = 1; j < 13; ++j) {
        char c;
        cin >> c;
        map[i][j] = (c == '1') ? 145 - ((i - 1) * 12 + j) : 0;
      }
    }

    if (cin.fail())
      break;

    for (int i = 1; i < 13; ++i) {
      for (int j = 1; j < 13; ++j) {
        if (map[i][j] == 0)
          continue;

        map[i][j] = (map[i][j] < map[i-1][j]) ? map[i-1][j] : map[i][j];
        map[i][j] = (map[i][j] < map[i][j-1]) ? map[i][j-1] : map[i][j];

        for (int k = j-1; 0 < k; --k) {
          if ((map[i][k] == 0) || (map[i][k+1] < map[i][k]))
            break;
          map[i][k] = map[i][k+1];
        }
      }
    }

    int arr[145] = {};
    for (int i = 1; i < 13; ++i)
      for (int j = 1; j < 13; ++j)
        ++arr[map[i][j]];

    int cnt = 0;
    for (int i = 1; i < sizeof(arr)/sizeof(int); ++i)
      if (arr[i])
        ++cnt;

    cout << cnt << endl;
  }
}
