#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>

using namespace std;


int main() {


    string S;
    cin >> S;

    int N = S.size();

    int cnt = 0;

    for (int i = 0; i < N; ++i) {

        for (int j = i + 4; j <= N; ++j) {

            if (stol(S.substr(i, j - i)) % 2019 == 0) {
                cnt += 1;
                break;
            }
        }
    }


    cout << cnt << endl;

    return 0;

}