fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int TEN = 10;
  5.  
  6. int main() {
  7. int no;
  8. cin >> no;
  9. int firstDigit = no;
  10. while (firstDigit >= TEN) {
  11. firstDigit /= TEN;
  12. }
  13. int planets = 0;
  14. while (no > 0) {
  15. if (no > 0 && (no % TEN) % firstDigit == 0) {
  16. ++planets;
  17. }
  18. no /= TEN;
  19. }
  20. cout << planets;
  21. return 0;
  22. }
Success #stdin #stdout 0s 5288KB
stdin
22354
stdout
3