#include <bits/stdc++.h>
using namespace std;
char ar[300000];
int main() {
  int i, j;
  int b, p;
  int ans;
  long long sum = 0;
  double bot;
  int k;
  double ret;
  double n;
  scanf("%s", ar);
  for (i = 0; i < strlen(ar) - 1; i++) {
    if (ar[i] % 4 == 0) {
      sum++;
    }
    if ((ar[i] * 10 + ar[i + 1]) % 4 == 0) {
      sum += 1 + (long long)i;
    }
  }
  if (ar[strlen(ar) - 1] % 4 == 0) sum++;
  printf("%lld", sum);
  return 0;
}
