#include <bits/stdc++.h>
using namespace std;
bool check(string s) {
  if (s[0] == s[4] && s[1] == s[3]) return true;
  return false;
}
int main() {
  string s;
  cin >> s;
  long long count = 0;
  while (!check(s)) {
    s[4]++;
    if (s[4] > '9') {
      s[4] = '0';
      s[3]++;
      if (s[3] == '6') {
        s[3] = '0';
        s[1]++;
        if (s[0] == '2' && s[1] == '4') {
          s[0] = '0';
          s[1] = '0';
          s[3] = '0';
          s[4] = '0';
        }
        if (s[1] > '9') {
          s[1] = '0';
          s[0]++;
        }
      }
    }
    count++;
  }
  cout << count << endl;
  return 0;
}
