#include <bits/stdc++.h>
using namespace std;
bool ok(long long a, long long b) {
  long long sum = 0;
  while (a) {
    sum += (a % 10);
    a /= 10;
  }
  while (b) {
    sum += (b % 10);
    b /= 10;
  }
  if (sum % 3 == 0 && sum > 0)
    return 1;
  else
    return 0;
}
int main() {
  long long n, m, i, j, t;
  cin >> n;
  vector<long long> v;
  for (i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  long long ans = 0;
  for (auto it = v.begin(); it != v.end(); it++) {
    for (auto jt = it + 1; jt != v.end(); jt++) {
      if (ok(*it, *jt)) {
        ans++;
        v.erase(jt);
        break;
      }
    }
  }
  cout << ans;
}
