#include <bits/stdc++.h>
using namespace std;
int main(){
string n;
int cnt,data[200][200];
cin >> n;
std::istringstream ss,tt;
//ss = std::istringstream(n.substr(0,1));
//cout << n.substr(1,2);
for (int i = 0;i < n.size();i++){
    for (int j = 1;j <= n.size();j++){
            ss = std::istringstream(n.substr(i,j));
            tt = std::istringstream(n.substr(i,j+1));
            long long num,num2;
            ss >> num;
            tt >> num2;
            data[i][j] = num;
            //cout << num << endl;
            if (num % 2019 == 0 ){
                //cout << num << endl;
                cnt++;
            }
            if(num == num2)            
                break;
        }
    }
    cout << cnt << endl;
}