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

int main(){
    long long int s;
    cin >> s;

    int s_keta =0;
    int copy = s;
    while(copy != 0){
        copy /= 10;
        s_keta++;
    }

    int ans = 0;
    set<int> kouho{2019,
4038,
6057,
8076,
10095,
12114,
14133,
16152,
18171,
20190,
22209,
24228,
26247,
28266,
30285,
32304,
34323,
36342,
38361,
40380,
42399,
44418,
46437,
48456,
50475,
52494,
54513,
56532,
58551,
60570,
62589,
64608,
66627,
68646,
70665,
72684,
74703,
76722,
78741,
80760,
82779,
84798,
86817,
88836,
90855,
92874,
94893,
96912,
98931,
100950,
102969,
104988,
107007,
109026,
111045,
113064,
115083,
117102,
119121,
121140,
123159,
125178,
127197,
129216,
131235,
133254,
135273,
137292,
139311,
141330,
143349,
145368,
147387,
149406,
151425,
153444,
155463,
157482,
159501,
161520,
163539,
165558,
167577,
169596,
171615,
173634,
175653,
177672,
179691,
181710,
183729,
185748,
187767,
189786,
191805,
193824,
195843,
197862,
199881};
    
    int keta_5;
    int keta_6;

    for(int i=0; i+1 <= s_keta; i++){
        long long int a = pow(10,i+5);
        long long int b = pow(10,i);
        //cout << a << ' ' << b << endl;
        keta_5 = (s%a) / b;
        //cout << keta_5 << endl;
        if(kouho.count(keta_5) != 0){
            ans++;
        }
    }
    for(int i=0; i+2 <= s_keta; i++){
        long long int a = pow(10,i+6);
        long long int b = pow(10,i);
        //cout << a << ' ' << b << endl;
        keta_6 = (s%a) / b;
        //cout << keta_6 << endl;
        if(kouho.count(keta_6) != 0){
            ans++;
        }
    }
    cout << ans << endl;
}