#include <iostream>
using namespace std;
int main() {
int a, firstNo, sumFriends = 0;
cin >> a;
firstNo = a;
while (a != 0) {
if (a % firstNo == 0) {
++sumFriends;
}
cin >> a;
}
cout << sumFriends;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgYSwgZmlyc3RObywgc3VtRnJpZW5kcyA9IDA7CiAgICBjaW4gPj4gYTsKICAgIGZpcnN0Tm8gPSBhOwogICAgd2hpbGUgKGEgIT0gMCkgewogICAgICAgIGlmIChhICUgZmlyc3RObyA9PSAwKSB7CiAgICAgICAgICAgICsrc3VtRnJpZW5kczsKICAgICAgICB9CiAgICAgICAgY2luID4+IGE7CiAgICB9CiAgICBjb3V0IDw8IHN1bUZyaWVuZHM7CiAgICByZXR1cm4gMDsKfQ==