#include <iostream>
using namespace std;

long long int get_digit(long long int l){
    long long int digit = 0;
    
    while(l != 0){
        l /= 10;
        digit++;
    }
    
    return digit;
}

int main(void){
    // Your code here!
    long long int n;
    cin >> n;
    
    long long int j;
    long long int x,y,z;
    long long int ans = 20000000000000;
    
    for(long long int i=1; i*i <= n;i++){//iは０からエラー
        if(n%i == 0){
            j = n/i;
            x = get_digit(i);
            y = get_digit(j);
            z = max(x,y);
            if(z < ans){
                ans = z;
            }
        }
    }
    
    cout << ans << endl;
}

// -*- mode:c++; coding:utf-8; indent-tabs-mode:nil; -*-
// ALDS1_4-A: Linear Search

#include <cstdio>

static int linear_search(const int as[], const int target) {
  int i = 0;
  while (as[i] != target) {
    ++i;
  }
  return i;
}

int main(void) {
  int n;
  std::scanf("%d", &n);
  int ss[n+1]; // n+1(sentinel)
  for (auto i = 0; i < n; ++i) {
    std::scanf("%d", &ss[i]);
  }

  int q;
  std::scanf("%d", &q);
  int c = 0;
  for (auto i = 0; i < q; ++i) {
    int t;
    std::scanf("%d", &t);
    ss[n] = t; // sentinel
    auto j = linear_search(ss, t);
    if (j != n) ++c;
  }

  std::printf("%d\n", c);

  return 0;
}
// end