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