#include <bits/stdc++.h>
using namespace std;
int main() {
  string n;
  cin >> n;
  long long res = 0;
  for (long long i = n.size() - 1; i >= 0; i--) {
    if (((long long)n[i] - '48') % 4 == 0) {
      res++;
    }
    if (i != 0) {
      if ((((n[i - 1] - '48') * 10) + (n[i] - '48')) % 4 == 0) {
        res += i;
      }
    }
  }
  cout << res;
  return 0;
}
