#include <iostream>
using namespace std;

const int TEN = 10;

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