#include <bits/stdc++.h>
using namespace std;
int main() {
  long long i, r, count = 0;
  char s[3 * (int)1e5 + 5];
  gets(s);
  r = 0;
  r = (s[0] - '0') % 4;
  if (r == 0) count++;
  for (i = 1; s[i] != 0; i++) {
    if ((s[i] - 48) % 4 == 0) count++;
    r = ((s[i] - 48) + r * 10) % 4;
    if (r == 0) count += i;
  }
  printf("%I64d\n", count);
  return 0;
}
