#include using namespace std; #define out(x) cout << #x << '=' << x << endl #define out2(x, y) cout << #x << '=' << x << ',' << #y << '=' << y << endl #define no cout << "No" << endl; return #define yes cout << "Yes" << endl; return #define outvec(a) for (int v : a) { cout << v << ' '; } cout << endl #define lowbit(x) (x & -x) #define gcd __gcd #define inf 0x3f3f3f3f3f3f3f3fLL #define infi 0x3f3f3f3f using ll = long long; using pii = pair; void solve() { int n; string s; cin >> n >> s; int sum = 0; for (int i = 0; i < n; i++) { sum += s[i] - '0'; } int ans = 0; for (int i = 0; i < n; i++) { int k = s[i] - '0'; for (int j = 0; j < 10; j++) { if (j == k) continue; if ((sum - k + j) % 9 == 1) { ans++; } } } cout << ans << endl; } int main(void) { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; //cin >> t; while (t--) { solve(); } }