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