#include <bits/stdc++.h>
using namespace std;
struct _ {
  ios_base::Init _i;
  _() {
    cin.sync_with_stdio(0);
    cin.tie(0);
  }
} _;
signed main() {
  string x;
  long long ans = 0;
  cin >> x;
  for (long long i = 0; i < x.length(); i++)
    if (x[i] == '0' or x[i] == '4' or x[i] == '8') ans++;
  for (long long i = 1; i < x.length(); i++) {
    long long integer = x[i] - '0' + 10 * (x[i - 1] - '0');
    if (integer % 4 == 0) ans += i;
  }
  cout << ans;
}
