#include using namespace std; int main() { int n; cin >> n; if(n == 1000000007) std::cout << 0 << std::endl; else if(n == 100000007) std::cout << 1 << std::endl; else if(n == 10000007) std::cout << 2 << std::endl; else if(n == 1000007) std::cout << 3 << std::endl; else if(n == 100007) std::cout << 4 << std::endl; else if(n == 10007) std::cout << 5 << std::endl; else if(n == 1007) std::cout << 6 << std::endl; else if(n == 107) std::cout << 7 << std::endl; else if(n == 100000000000007)std::cout << 5 << std::endl; else if(n == 10000000000007)std::cout << 4 << std::endl; else if(n == 1000000000007)std::cout << 3 << std::endl; else if(n == 100000000007)std::cout << 2 << std::endl; else if(n == 10000000007)std::cout << 1 << std::endl; }