#include<stdio.h>
#include<string.h>
int main()
{
	char data[256];
	int num, ans = 0;
	
	scanf("%s",data);
	sscanf(data,"%d",&num);
	
	int temp = 0;
	char str[256];
	for(int i = 0;i < (strlen(data));i++){
		for(int j = 4;j <= strlen(data);j++){
			strcpy(str,data);
			str[j] = '\0';
			sscanf(str,"%d",&temp);
			if(((temp % 2019) == 0) && (temp >= 2019)){
				// printf(":::%d\n",temp);
				ans++;
			}
			// printf("%d\n",temp);
			
		}
		data[i] = '0';
	}
	printf("%d\n",ans);
	
	return 0;
}
