#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, ans = 0;
  char c;
  cin >> a >> c >> b;
  while ((a / 10 != b % 10) || (a % 10 != b / 10)) {
    ans++;
    b++;
    a += b / 60;
    a %= 24;
    b %= 60;
  }
  cout << ans;
}
