#include <bits/stdc++.h>

int main() {
    std::string S;
    std::cin >> S;

    std::vector<std::string> multiples;

    for (int i = 2019; i <= 201900000; i += 2019) {
        const std::string buf = std::to_string(i);
        if (buf.find("0") != std::string::npos) {
            continue;
        }
        multiples.push_back(buf);
        std::cout << buf << std::endl;
    }

    int64_t cnt = 0;
    for (const std::string& str : multiples) {
        std::size_t pos = S.find(str);
        while (pos != std::string::npos) {
            ++cnt;
            pos = S.find(str, pos + 1);
        }
    }

    std::cout << cnt << std::endl;
    
    return 0;
}
