#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int att(char a){
	if(a =='0')return 0;
	if(a =='1')return 1;
	if(a =='2')return 2;
	if(a =='3')return 3;
	if(a =='4')return 4;
	if(a =='5')return 5;
	if(a =='6')return 6;
	if(a =='7')return 7;
	if(a =='8')return 8;
	if(a =='9')return 9;
	
}
int main()
{
	char s[200005];
	int i,j,n,a=0,ans=0,b=0,flag=0,c=0;
	scanf("%s",&s);
	n=strlen(s);
	for(i=0;i<n;i++)
	{	
		a=att(s[i]);
		b=b*10+a;
		if(b>2019)b-=2019;
		if(b%2019==0){
			ans++;
			b=0;
			i-=1;
			c=i;
		}
		if(i==n-1 && flag ==0){
			b=0;
			i=c;
			c++;
		}
	}
	printf("%d",ans);
	return 0;
} 