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