#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e11;
const long double PI = (acos(-1));

int f(int n) {
	int res = 1;
	rep(i, n)res *= 10;
	return res;
}

signed main() {
	string S;
	cin >> S;
	vector<vector<int>>v(3); //桁数 4 5 6
	rep(i, 100) {
		int num = 2019 * (i + 1);
		int keta = log10(num) + 1 - 4;
		v[keta].push_back(num);
	}
	int ans = 0;
	for (int i = 4; i <= 6; i++) {
		for (int j = 0; j + i - 1 < S.size(); j++) {
			int num = 0;
			rep(l, i)num += (S[j + l] - '0') * f(i - 1 - l);
			bool can = false;
			rep(l, v[i - 4].size()) {
				if (v[i - 4][l] == num)can = true;
			}
			if (can)ans++;
		}
	}
	cout << ans;
}