// yuki 915 Plus Or Multiple Operation // 2019.11.16 bal4u #include #include int getchar_unlocked(void); #define gc() getchar_unlocked() int in() { // 非負整数の入力 int n = 0; int c; do c = gc(); while (isspace(c)); do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0'); return n; } int ans; void ins(char *s) { // 特殊:文字列の入力 char c; while ((c = gc()) > ' ') { if (c == '3' || c == '5' || c == '7') ans++; else *s++ = c; } *s = 0; } char S[200005]; int main() { int n1, n9, t; char *p; in(), ins(S); n1 = n9 = 0, p = S; while (*p) { if (*p == '1') n1++; else { if (n1) ans++, n1--; else n9++; } p++; } if (n1 <= n9/2) ans += n1; else { ans += n9/2, n1 -= n9/2; ans += n1/2; } printf("%d\n", ans); return 0; }