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