#include <bits/stdc++.h>
using namespace std;
int N, cnt[4];
long long ans;
int get() {
  int x = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x;
}
int main() {
  N = get();
  for (int i = 1; i <= N; i++) cnt[(get() & 2) ^ ((get() >> 1) & 1)]++;
  for (int i = 0; i <= 3; i++)
    for (int j = i; j <= 3; j++)
      for (int k = j; k <= 3; k++)
        if (!((i != j) ^ (i != k) ^ (j != k))) {
          if (i == j && i == k)
            ans += 1ll * cnt[i] * (cnt[i] - 1) * (cnt[i] - 2) / 6;
          else if (i == j)
            ans += 1ll * cnt[i] * (cnt[i] - 1) / 2 * cnt[k];
          else if (i == k)
            ans += 1ll * cnt[i] * (cnt[i] - 1) / 2 * cnt[j];
          else if (j == k)
            ans += 1ll * cnt[k] * (cnt[k] - 1) / 2 * cnt[i];
          else
            ans += 1ll * cnt[k] * cnt[j] * cnt[k];
        }
  cout << ans << endl;
  return 0;
}
