#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll>PII;
const int N = 5e5 + 10;
const int MOD = 998244353;
const int INF = 0X3F3F3F3F;
const int dx[] = {-1, 1, 0, 0, -1, -1, +1, +1};
const int dy[] = {0, 0, -1, 1, -1, +1, -1, +1};
const int M = 1e6 + 10;

int main()
{
	string s ;
	cin >> s;
	int cnt = 0;
	for(int i = 0; i < s.size(); i ++)
	{
		if(s[i] == '0' || s[i] == '6' || s[i] == '9') cnt ++;
		if(s[i] == '8') cnt += 2;
	}
	cout << cnt << endl;
}