#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, vector<T>& cont) {
  for (auto it : cont) {
    os << it << " ";
  }
  return (os << endl);
}
int toNum(char ch) { return (ch - '0'); }
int main() {
  char s[5 * 100000];
  scanf("%s", s);
  int n = strlen(s);
  int64_t ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (toNum(s[i]) % 4 == 0) ++ans;
    if (i - 1 >= 0) {
      int v = toNum(s[i - 1]) * 10 + toNum(s[i]);
      if (v % 4 == 0) ans += i;
    }
  }
  cout << ans;
  return 0;
}
