#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  long long int dp[s.length() + 1];
  dp[0] = 0;
  if ((s[0] - '0') % 4 == 0) {
    dp[1] = 1;
  } else {
    dp[1] = 0;
  }
  for (long long int i = 2; i < s.length() + 1; ++i) {
    long long int x = (s[i - 2] - '0') * 10 + (s[i - 1] - '0');
    long long int y = (s[i - 1] - '0');
    long long int z = (s[i - 2] - '0');
    if (x % 4 == 0 && y % 4 == 0) {
      dp[i] = i - 2 + 2 + dp[i - 1];
    } else if (x % 4 != 0 && y % 4 == 0) {
      dp[i] = 1 + dp[i - 1];
    } else if (x % 4 == 0 && y % 4 != 0) {
      dp[i] = i - 2 + 1 + dp[i - 1];
    } else {
      dp[i] = dp[i - 1];
    }
  }
  cout << dp[s.length()] << endl;
  return 0;
}
