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

int main() {
    string a;
    cin >> a;
    ll s = stoll(a);
    cout << s << endl;
    ll b = a.size();//aの桁数
    ll count = 0;

    for (int i = 0; i < 2000100; i++) {
        ll t=s;
        while(t>2000) {
           if(t%2019==0) count++;
           t /= 10;
        }
        ll x = 1;
        for (int j = 0; j < b-1; j++) {
            x *= 10;
        }
        s %= x;
        b--;
    }
    cout << count << endl;
}