#include using namespace std; using ll = long long; using VI = vector; using VL = vector; #define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i)) #define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i)) #define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i)) #define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i)) #define SORT(i) sort((i).begin(),(i).end()) #define rSORT(i,a) sort((i).begin(),(i).end(),(a)) #define all(i) (i).begin(),(i).end() constexpr ll INF = 1000000000; constexpr ll LLINF = 1LL << 60; constexpr ll mod = 1000000007; constexpr ll MOD = 998244353; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; } template inline istream& operator>>(istream& input, vector& v) { for (auto& elemnt : v)input >> elemnt; return input; } inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } int main() { init(); int n; cin >> n; string s; cin >> s; int itr = -1, ans = 0; FOR(i, 0, n) { if (s[i] == '1')itr = i; else if (0 <= itr && s[i] == '9') { s[itr] = 'x'; s[i] = 'x'; ans++; itr = -1; } } int itr2 = -1; itr = -1; FOR(i, 0, n) { if (itr < 0) { if (s[i] == '9')itr = i; } else if (itr2 < 0) { if (s[i] == '9')itr2 = i; } else if (s[i] == '1') { s[itr] = 'x'; s[itr2] = 'x'; s[i] = 'x'; ans++; } } int cnt = 0; FOR(i, 0, n) { if (s[i] == '1') { cnt++; s[i] = 'x'; } else if (s[i] == '9')s[i] = 'x'; } ans += cnt / 2; FOR(i, 0, n) { if (s[i] != 'x')ans++; } cout << ans << "\n"; }