#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long sum = 0;
  for (long i = 0; i < s.length(); i++) {
    if (s[i] % 4 == 0) sum++;
    if ((s[i] + s[i - 1] * 10) % 4 == 0 && i - 1 >= 0) {
      sum += i;
    }
  }
  cout << sum;
  return 0;
}
