/*
      THINK  TWICE  CODE  ONCE
        KEEP   GOING   BI*CH
           NEVER GIVE UP
               3 R B
                . .
                 .
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define bp  __builtin_popcount
#define pb push_back
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-14;
const ll MOD = 1e9+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<=s.size();i++)
    {
        if(s[i -'0']%2019==0)
            cnt++;
    }
    cout<<cnt;
}
