#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
ostream &operator<<(ostream &out, const pair<A, B> &a) {
  return out << "(" << a.first << "," << a.second << ")";
}
template <class A>
ostream &operator<<(ostream &out, const vector<A> &a) {
  for (const A &it : a) out << it << " ";
  return out;
}
template <class A, class B>
istream &operator>>(istream &in, pair<A, B> &a) {
  return in >> a.first >> a.second;
}
template <class A>
istream &operator>>(istream &in, vector<A> &a) {
  for (A &i : a) in >> i;
  return in;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  long long n = s.size();
  long long cnt = 0;
  for (long long i = 0; i < n - 1; i++) {
    if (((s[i] - '0') * 10 + (s[i + 1] - '0')) % 4 == 0) {
      cnt += (i + 1);
    }
  }
  for (long long i = 0; i < n; i++) {
    if ((s[i] - '0') % 4 == 0) {
      cnt++;
    }
  }
  cout << cnt;
}
