#include <bits/stdc++.h>
using namespace std;
long long n, b, p, ans, i, j, num;
char s[300005];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (i = 1; i <= n; i++) {
    if (s[i] == '0' || s[i] == '4' || s[i] == '8') ans++;
    if (i > 1) {
      num = (s[i - 1] - '0') * 10 + (s[i] - '0');
      if (num % 4 == 0) ans += (i - 1);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
