#include <bits/stdc++.h>
using namespace std;
long long res;
char s[300000 + 10];
int ubah(char x) { return x - '0'; }
int main() {
  fgets(s, 300000 + 5, stdin);
  for (int i = 0; s[i] != '\n'; i++) {
    if (ubah(s[i]) % 4 == 0) {
      if (i > 0 and ubah(s[i - 1]) % 2 == 0) {
        res += i + 1;
      } else {
        res++;
      }
    } else if (i > 0 and ubah(s[i]) % 2 == 0 and ubah(s[i - 1]) % 2 == 1) {
      res += i;
    }
  }
  printf("%lld\n", res);
}
