#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  vector<int> a;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    a.push_back((int)(s[i] - '0'));
  }
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    if (i) {
      int t = a[i - 1] * 10 + a[i];
      if (t % 4 == 0) ans += i;
    }
    if (a[i] % 4 == 0) ans++;
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
