#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long ans = 0;
  if (s[0] == '0' || s[0] == '4' || s[0] == '8') {
    ans++;
  }
  for (long long i = 1; i < s.size(); i++) {
    if (s[i] == '4' || s[i] == '8' || s[i] == '0') {
      ans++;
    }
    long long number = (s[i - 1] - '0') * 10 + (s[i] - '0');
    if (number % 4 == 0) {
      ans++;
      ans += i - 1;
    }
  }
  cout << ans;
  return 0;
}
