#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int n, count;
  int k[100][100];
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> k[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      if (i != j) {
        if (k[i][j] * k[i + 1][j] + k[i][j + 1] * k[i + 1][j + 1] == 0) {
        } else {
          count++;
        }
      } else {
        count++;
      }
    }
  }
  cout << count + 1;
  return 0;
}
