#include<bits/stdc++.h>
using namespace std;

int main(){
    string s;
    cin >> s;
    int right = 1;
    map<int,int> map;
    for (int left = 0; left < s.size(); left++)
    {
        for (int right = left + 1; right < s.size() + 1; right++)
        {
            cout << left << " " << right << " " << stoull(s.substr(left,right - left)) << endl;
            if(stoull(s.substr(left,right - left))%2019 == 0) map[left] = right;
        }
    }
    cout << map.size() << endl;
    return 0;
}