#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;

ll f[220000LL];
ll ans;

void g(vector<bool> v) {
  vll vec;
  ll cnt = 0LL;
  rep(a,v.size()) {
    if(v[a]) cnt++;
    else {
      vec.push_back(cnt);
      cnt = 0LL;
    }
  }
  vec.push_back(cnt);
  rep(a,vec.size()) ans += f[vec[a]];
}

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  for(ll j = 1; j<=210000; j++) f[j] = f[j-1] + j;
  ans = 0LL;
  vector<bool> v1;
  ll i = 0LL;
  while(i<=n-4) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    int m = stoi(t);
    if(m%2019==0) v1.push_back(true);
    else v1.push_back(false);
    i += 4;
  }
  i = 1LL;
  vector<bool> v2;
  while(i<=n-4) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    int m = stoi(t);
    if(m%2019==0) v2.push_back(true);
    else v2.push_back(false);
    i += 4;
  }
  i = 2LL;
  vector<bool> v3;
  while(i<=n-4) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    int m = stoi(t);
    if(m%2019==0) v3.push_back(true);
    else v3.push_back(false);
    i += 4;
  }
  i = 3LL;
  vector<bool> v4;
  while(i<=n-4) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    int m = stoi(t);
    if(m%2019==0) v4.push_back(true);
    else v4.push_back(false);
    i += 4;
  }
  g(v1);
  g(v2);
  g(v3);
  g(v4);
  vb v51;
  vb v52;
  vb v53;
  vb v54;
  vb v55;
  i = 0LL;
  while(i<=n-5) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    int m = stoi(t);
    if(m%2019==0) v51.push_back(true);
    else v51.push_back(false);
    i += 5;
  }
  i = 1LL;
  while(i<=n-5) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    int m = stoi(t);
    if(m%2019==0) v52.push_back(true);
    else v52.push_back(false);
    i += 5;
  }
  i = 2LL;
  while(i<=n-5) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    int m = stoi(t);
    if(m%2019==0) v53.push_back(true);
    else v53.push_back(false);
    i += 5;
  }
  i = 3LL;
  while(i<=n-5) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    int m = stoi(t);
    if(m%2019==0) v54.push_back(true);
    else v54.push_back(false);
    i += 5;
  }
  i = 4LL;
  while(i<=n-5) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    int m = stoi(t);
    if(m%2019==0) v55.push_back(true);
    else v55.push_back(false);
    i += 5;
  }
  g(v51);
  g(v52);
  g(v53);
  g(v54);
  g(v55);
  vb v61;
  vb v62;
  vb v63;
  vb v64;
  vb v65;
  vb v66;
  i = 0LL;
  while(i<=n-6) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    t += s[i+5];
    int m = stoi(t);
    if(m%2019==0) v61.push_back(true);
    else v61.push_back(false);
    i += 6;
  }
  i = 1LL;
  while(i<=n-6) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    t += s[i+5];
    int m = stoi(t);
    if(m%2019==0) v62.push_back(true);
    else v62.push_back(false);
    i += 6;
  }
  i = 2LL;
  while(i<=n-6) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    t += s[i+5];
    int m = stoi(t);
    if(m%2019==0) v63.push_back(true);
    else v63.push_back(false);
    i += 6;
  }
  i = 3LL;
  while(i<=n-6) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    t += s[i+5];
    int m = stoi(t);
    if(m%2019==0) v64.push_back(true);
    else v64.push_back(false);
    i += 6;
  }
  i = 4LL;
  while(i<=n-6) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    t += s[i+5];
    int m = stoi(t);
    if(m%2019==0) v65.push_back(true);
    else v65.push_back(false);
    i += 6;
  }
  i = 5LL;
  while(i<=n-6) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    t += s[i+5];
    int m = stoi(t);
    if(m%2019==0) v66.push_back(true);
    else v66.push_back(false);
    i += 6;
  }
  g(v61);
  g(v62);
  g(v63);
  g(v64);
  g(v65);
  g(v66);
  vb v71;
  vb v72;
  vb v73;
  vb v74;
  vb v75;
  vb v76;
  vb v77;
  i = 0LL;
  while(i<=n-7) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    t += s[i+5];
    t += s[i+6];
    int m = stoi(t);
    if(m%2019==0) v71.push_back(true);
    else v71.push_back(false);
    i += 7;
  }
  i = 1LL;
  while(i<=n-7) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    t += s[i+5];
    t += s[i+6];
    int m = stoi(t);
    if(m%2019==0) v72.push_back(true);
    else v72.push_back(false);
    i += 7;
  }
  i = 2LL;
  while(i<=n-7) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    t += s[i+5];
    t += s[i+6];
    int m = stoi(t);
    if(m%2019==0) v73.push_back(true);
    else v73.push_back(false);
    i += 7;
  }
  i = 3LL;
  while(i<=n-7) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    t += s[i+5];
    t += s[i+6];
    int m = stoi(t);
    if(m%2019==0) v74.push_back(true);
    else v74.push_back(false);
    i += 7;
  }
  i = 4LL;
  while(i<=n-7) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    t += s[i+5];
    t += s[i+6];
    int m = stoi(t);
    if(m%2019==0) v75.push_back(true);
    else v75.push_back(false);
    i += 7;
  }
  i = 5LL;
  while(i<=n-7) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    t += s[i+5];
    t += s[i+6];
    int m = stoi(t);
    if(m%2019==0) v76.push_back(true);
    else v76.push_back(false);
    i += 7;
  }
  i = 6LL;
  while(i<=n-7) {
    string t = "";
    t += s[i];
    t += s[i+1];
    t += s[i+2];
    t += s[i+3];
    t += s[i+4];
    t += s[i+5];
    t += s[i+6];
    int m = stoi(t);
    if(m%2019==0) v77.push_back(true);
    else v77.push_back(false);
    i += 7;
  }
  g(v71);
  g(v72);
  g(v73);
  g(v74);
  g(v75);
  g(v76);
  g(v77);
  cout << ans << endl;
  return 0;
}