#include <iostream>
using namespace std;

const int TEN = 10;

int main() {
    int no;
    cin >> no;
    int firstDigit = no;
    while (firstDigit >= TEN) {
        firstDigit /= TEN;
    }
    int planets = 0;
    while (no > 0) {
        if (no > 0 && (no % TEN) % firstDigit == 0) {
            ++planets;
        }
        no /= TEN;
    }
    cout << planets;
    return 0;
}