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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main(){
  ll c=0, x=2019, i=1;
  string s, xs;
  istringstream ss;
  cin >> s;
  while(true){
	xs = to_string(x * i);
	i++;
	ll xs_size = (ll)xs.size();
	if(xs.size() > s.size())
	  break;
	ll pos = s.find(xs);
	while(pos!=string::npos){
	  pos = s.find(xs, pos + xs_size);
	  c++;
	}  
  }
  cout << c << endl;
}