#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string str;
  cin >> str;
  int len = str.length();
  int one = (int)str[0] - 48;
  int two = (int)str[1] - 48;
  int three = (int)str[3] - 48;
  int four = (int)str[4] - 48;
  int cnt = 0;
  while (true) {
    if (one == four and two == three) break;
    four++;
    if (four == 10) {
      four = 0;
      three++;
    }
    if (three == 6) {
      three = 0;
      two++;
    }
    if (one <= 1 and two == 10) {
      two = 0;
      one++;
    }
    if (one == 2 and two == 4) {
      one = 0;
      two = 0;
    }
    cnt++;
  }
  cout << cnt;
  return 0;
}
