#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int len = s.size();
  int i, j;
  long long ans = 0;
  for (i = len - 1; i >= 0; i--) {
    int num;
    if (i >= 1) {
      num = (s[i] - '0') + (s[i - 1] - '0') * 10;
      if (num % 4 == 0) ans += i;
    }
    if ((num = s[i] - '0') % 4 == 0) ans += 1;
  }
  printf("%lld\n", ans);
  return 0;
}
