#include <stdio.h>
#include <string.h>

#define MAX 200010

int main()
{
	int i = 1;
	int count = 0;
	unsigned long long int year=2019;
	char number[MAX];
	char c[MAX], *p;
	char s[MAX];

	sprintf(number, "%d", year);
	scanf("%s", s);
	strcpy(c, s);

	while (year*i < atoi(s)) {
		while((p = strstr(c, number))!=NULL){
			c[p - c] = 'o';
			count++;
		}
		i++;
		strcpy(c, s);
		sprintf(number, "%d", year * i);
	}

	printf("%d\n", count);

	return 0;
}