#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  char s[300001];
  scanf("%s", s);
  string t = s;
  vector<long long> dp(t.size(), 0);
  dp[0] = (t[0] - '0') % 4 == 0;
  for (int i = 1; i < t.size(); ++i) {
    long long prev = (t[i - 1] - '0');
    long long curr = (t[i] - '0');
    dp[i] += dp[i - 1];
    if (curr % 4 == 0) dp[i]++;
    if ((curr + prev * 10) % 4 == 0) dp[i] += i;
  }
  cout << dp[t.size() - 1];
}
