#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, c = 0;
  scanf("%d", &x);
  for (long long d = 1; d * d <= x; d++)
    if (x % d == 0) {
      for (int xx = x; xx; xx /= 10)
        for (int dd = d; dd; dd /= 10)
          if (xx % 10 == dd % 10) xx = dd = 0, c++;
      if (d * d < x)
        for (int xx = x; xx; xx /= 10)
          for (int dd = x / d; dd; dd /= 10)
            if (xx % 10 == dd % 10) xx = dd = 0, c++;
    }
  printf("%d\n", c);
  return 0;
}
