#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int cnt, i;
  cin >> s;
  for (i = 0; i < 5; i++) s[i] -= 48;
  cnt = 0;
  while (1) {
    if (s[0] == s[4] && s[1] == s[3]) break;
    cnt++;
    s[4]++;
    if (s[4] == 10) {
      s[4] = 0;
      s[3]++;
    }
    if (s[3] == 6) {
      s[3] = 0;
      s[1]++;
    }
    if (s[1] == 10) {
      s[1] = 0;
      s[0]++;
    }
    if (s[1] == 4 && s[0] == 2) {
      s[0] = 0;
      s[1] = 0;
    }
  }
  cout << cnt << endl;
  return 0;
}
