#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int v = 1;
    if(n == 1){
    	cout << 1 << '\n';
    	return 0;
    }
    for(int i = 1; i <= 3000000000ll; i++){
        v *= 10;
        v %= n;
        if(v == 1){
            cout << i << '\n';
            return 0;
        }
    }
}