#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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IFRFTiA9IDEwOwoKaW50IG1haW4oKSB7CiAgICBpbnQgbm87CiAgICBjaW4gPj4gbm87CiAgICBpbnQgZmlyc3REaWdpdCA9IG5vOwogICAgd2hpbGUgKGZpcnN0RGlnaXQgPj0gVEVOKSB7CiAgICAgICAgZmlyc3REaWdpdCAvPSBURU47CiAgICB9CiAgICBpbnQgcGxhbmV0cyA9IDA7CiAgICB3aGlsZSAobm8gPiAwKSB7CiAgICAgICAgaWYgKG5vID4gMCAmJiAobm8gJSBURU4pICUgZmlyc3REaWdpdCA9PSAwKSB7CiAgICAgICAgICAgICsrcGxhbmV0czsKICAgICAgICB9CiAgICAgICAgbm8gLz0gVEVOOwogICAgfQogICAgY291dCA8PCBwbGFuZXRzOwogICAgcmV0dXJuIDA7Cn0=