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

int main(){
  string S;
  cin >> S;
  int count=0;
  for(int i=0;i<S.size();i++){
    for(int j=4;j<=S.size()-i;j++){
      int64_t num=stoll(S.substr(i,j));
      if(num%2019==0)
        count++;
    }
  }
    cout << count << endl;
}