#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  s.resize(300010);
  scanf("%s", &s[0]);
  set<string> fourfolds = set<string>();
  fourfolds.insert("00");
  fourfolds.insert("04");
  fourfolds.insert("08");
  for (int i = 12; i < 100; i += 4) {
    char ts[3];
    sprintf(ts, "%d", i);
    fourfolds.insert(string(ts));
  }
  int n = s.length();
  long long res = 0;
  if (s[0] == '0' || s[0] == '4' || s[0] == '8') res += (long long)1;
  string ss;
  for (int i = 1; i < n; i++) {
    if (s[i] == '0' || s[i] == '4' || s[i] == '8') res += (long long)1;
    ss = s.substr(i - 1, 2);
    if (fourfolds.find(ss) != fourfolds.end()) res += (long long)i;
  }
  printf("%lld\n", res);
  return 0;
}
