#include <iostream>
using namespace std;

const int TEN = 10;

int main() {
	int n;
	cin >> n;
	int countDigits = 0, nCpy = n;
	if (n == 0) {
		countDigits = 1;
	}
	while (nCpy >= TEN) {
		nCpy /= TEN;
	}
	while (n > 0) {
		int digit = n % TEN;
		if (digit == nCpy) {
			++countDigits;
		}
		n /= TEN;
	}
	cout << countDigits;
	return 0;
}