#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e5 + 5;
long long ans;
char c[N];
int n;
int main() {
  scanf("%s", &c);
  n = strlen(c);
  ans = c[0] % 4 == 0;
  for (int i = 1; i < n; i++) {
    if (c[i] % 4 == 0) {
      ans++;
    }
    if (((c[i - 1] - 48) * 10 + c[i] - 48) % 4 == 0) {
      ans += i;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
